diff --git a/README.md b/README.md index cd448037..4b8efec0 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,22 @@ # prostgles-server - - Isomorphic PostgreSQL client for [node](http://nodejs.org) + +Isomorphic PostgreSQL client for [node](http://nodejs.org) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/prostgles/prostgles-server-js/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/prostgles-server.svg?style=flat)](https://www.npmjs.com/package/prostgles-server) ![Tests](https://github.com/prostgles/prostgles-server-js/actions/workflows/main.yml/badge.svg) -### New: JSONB schema runtime validation and TS types - +### New: JSONB schema runtime validation and TS types + + ## Features - - * CRUD operations - * Subscriptions to data changes - * Fine grained access control - * Optimistic data replication - * Generated TypeScript Definition for Database schema + +- CRUD operations with end-to-end type safety +- Auto-Generated TypeScript Definition for Database schema +- Subscriptions to data and schema changes +- Fine grained access control +- Optimistic data replication ## Installation @@ -25,101 +26,96 @@ $ npm install prostgles-server ## Quick start -```js -let prostgles = require('prostgles-server'); +```typescript +import prostgles from "prostgles-server"; +import prostgles from "prostgles-server"; prostgles({ dbConnection: { host: "localhost", port: "5432", user: process.env.PG_USER, - password: process.env.PG_PASS + password: process.env.PG_PASS, }, + tsGeneratedTypesDir: __dirname, onReady: async ({ dbo }) => { - const posts = await dbo.posts.find( - { title: { $ilike: "%car%" } }, - { - orderBy: { created: -1 }, - limit: 10 + { title: { $ilike: "%car%" } }, + { + orderBy: { created: -1 }, + limit: 10, } ); - - } + }, }); ``` ## Server-Client usage server.js + ```js -const express = require('express'); +const express = require("express"); const app = express(); -const path = require('path'); -var http = require('http').createServer(app); -var io = require('socket.io')(http); +const path = require("path"); +var http = require("http").createServer(app); +var io = require("socket.io")(http); http.listen(3000); -let prostgles = require('prostgles-server'); +let prostgles = require("prostgles-server"); prostgles({ dbConnection: { host: "localhost", port: "5432", user: process.env.PRGL_USER, - password: process.env.PRGL_PWD + password: process.env.PRGL_PWD, }, io, publish: "*", // Unrestricted INSERT/SELECT/UPDATE/DELETE access to the tables in the database - onReady: async (dbo) => { - - } + onReady: async (dbo) => {}, }); ``` react.tsx -```js +```js const App = () => { const { isLoading, dbo } = useProstglesClient(); - if(isLoading) return null; - return <> - Database tables: {Object.keys(dbo)} - -} - + if (isLoading) return null; + return <>Database tables: {Object.keys(dbo)}; +}; ``` ./public/index.html + ```html - - Prostgles - - - - + Prostgles + + + + - - ``` - ## License - [MIT](LICENSE) +[MIT](LICENSE) diff --git a/documentation/CLIENT.md b/documentation/CLIENT.md deleted file mode 100644 index 90ec55fb..00000000 --- a/documentation/CLIENT.md +++ /dev/null @@ -1,542 +0,0 @@ -## getInfo() -Retrieves the table/view info -```typescript - getInfo: (lang?: string): Promise - ``` -#### Arguments - - - **lang**: `string` - Language code for i18n data. ```typescript. "en". ```. -#### Return type -`TableInfo` - - **oid**: `number` - OID from the postgres database. Useful in handling renamed tables. - - **comment**: `string` - Comment from the postgres database. - - **isFileTable**: `{ allowedNestedInserts?: { table: string; column: string; }[] | undefined; }` - Defined if this is the fileTable. - - **allowedNestedInserts**: `{ table: string; column: string; }` - - **table**: `string` - - **column**: `string` - - **hasFiles**: `false` - True if fileTable is enabled and this table references the fileTable. - - **isView**: `false` - - **fileTableName**: `string` - Name of the fileTable (if enabled). - - **dynamicRules**: `{ update?: boolean | undefined; }` - See dynamicFields from Update rules. - - **update**: `false` - - **info**: `{ label?: string | undefined; }` - Additional table info provided through TableConfig. - - **label**: `string` - - **uniqueColumnGroups**: `string[][] | undefined` - - -## getColumns() -Retrieves columns metadata of the table/view -```typescript - getColumns: (lang?: string, params?: GetColumnsParams): Promise - ``` -#### Arguments - - - **lang**: `string` - - **params**: `GetColumnsParams` - Dynamic/filter based rules allow limit what columns can be updated based on the request data/filter. This allows parameter allows identifying the columns that can be updated based on the request data. - - **rule**: `"update"` - - **data**: `AnyObject` - - - **filter**: `AnyObject` - -#### Return type -`ValidatedColumnInfo` - - **name**: `string` - - **label**: `string` - Column display name. Will be first non empty value from i18n data, comment, name. - - **comment**: `string` - Column description (if provided). - - **ordinal_position**: `number` - Ordinal position of the column within the table (count starts at 1). - - **is_nullable**: `boolean` - - - **is_updatable**: `boolean` - - **is_generated**: `boolean` - If the column is a generated column (converted to boolean from ALWAYS and NEVER). - - **data_type**: `string` - Simplified data type. - - **udt_name**: `PG_COLUMN_UDT_DATA_TYPE` - Postgres raw data types. values starting with underscore means it's an array of that data type. - - **element_type**: `string` - Element data type. - - **element_udt_name**: `string` - Element raw data type. - - **is_pkey**: `boolean` - PRIMARY KEY constraint on column. A table can have more then one PK. - - **references**: `{ ftable: string; fcols: string[]; cols: string[]; }` - - **ftable**: `string` - - **fcols**: `string` - - **cols**: `string` - - **has_default**: `boolean` - true if column has a default value. Used for excluding pkey from insert. - - **column_default**: `any` - Column default value. - - **min**: `string | number | undefined` - Extracted from tableConfig. Used in SmartForm. - - **max**: `string | number | undefined` - - **hint**: `string` - - **jsonbSchema**: `JSONBSchema` - - **nullable**: `any` - False by default. - - **description**: `any` - - **title**: `any` - - **type**: `any` - - **allowedValues**: `any` - - **oneOf**: `any` - - **oneOfType**: `any` - - **arrayOf**: `any` - - **arrayOfType**: `any` - - **enum**: `any` - - **record**: `any` - - **lookup**: `any` - - **defaultValue**: `any` - - **file**: `FileColumnConfig | undefined` - If degined then this column is referencing the file table. Extracted from FileTable config. Used in SmartForm. - - **tsDataType**: `"string" | "number" | "boolean" | "any" | "number[]" | "boolean[]" | "string[]" | "any[]"` - TypeScript data type. - - **select**: `boolean` - Can be viewed/selected. - - **orderBy**: `boolean` - Can be ordered by. - - **filter**: `boolean` - Can be filtered by. - - **insert**: `boolean` - Can be inserted. - - **update**: `boolean` - Can be updated. - - **delete**: `boolean` - Can be used in the delete filter. - -## find() -Retrieves a list of matching records from the view/table -```typescript - find: (filter?: FullFilter | undefined, selectParams?: SelectParams): Promise> - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetSelectReturnType` - -## findOne() -Retrieves a record from the view/table -```typescript - findOne: (filter?: FullFilter | undefined, selectParams?: SelectParams): Promise | undefined> - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetSelectReturnType | undefined` - -## subscribe() -Retrieves a list of matching records from the view/table and subscribes to changes -```typescript - subscribe: (filter: FullFilter, params: SelectParams, onData: (items: GetSelectReturnType) => any, onError?: OnError): Promise - ``` -#### Arguments - - - **filter**: `FullFilter` - Group or simple filter. - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). - - **onData**: `(items: GetSelectReturnType) => any` - - **onError**: `OnError` -#### Return type -`SubscriptionHandler` - - **unsubscribe**: `() => Promise` - - **filter**: `{} | FullFilter` - -## subscribeOne() -Retrieves first matching record from the view/table and subscribes to changes -```typescript - subscribeOne: (filter: FullFilter, params: SelectParams, onData: (item: GetSelectReturnType | undefined) => any, onError?: OnError): Promise - ``` -#### Arguments - - - **filter**: `FullFilter` - Group or simple filter. - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). - - **onData**: `(item: GetSelectReturnType | undefined) => any` - - **onError**: `OnError` -#### Return type -`SubscriptionHandler` - - **unsubscribe**: `() => Promise` - - **filter**: `{} | FullFilter` - -## count() -Returns the number of rows that match the filter -```typescript - count: (filter?: FullFilter | undefined, selectParams?: SelectParams): Promise - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`number` - -## size() -Returns result size in bits -```typescript - size: (filter?: FullFilter | undefined, selectParams?: SelectParams): Promise - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`string` - -## getJoinedTables() - -```typescript - getJoinedTables: (): string[] - ``` -#### Arguments - -#### Return type -`string` - - - - - -## sync() - -```typescript - sync: (basicFilter: EqualityFilter, options: SyncOptions, onChange: (data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any, onError?: (error: any) => void): Promise<{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }> - ``` -#### Arguments - - - **basicFilter**: `EqualityFilter` - Equality filter used for sync. Multiple columns are combined with AND. - - - **options**: `SyncOptions` - - **onChange**: `(data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any` - - **onError**: `(error: any) => void` -#### Return type -`{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }` - - **$unsync**: `() => void` - - **$upsert**: `(newData: T[]) => any` - - **getItems**: `() => T[]` - -## useSync() -Retrieves rows matching the filter and keeps them in sync -- use { handlesOnData: true } to get optimistic updates method: $update -- any changes to the row using the $update method will be reflected instantly - to all sync subscribers that were initiated with the same syncOptions -```typescript - useSync: (basicFilter: EqualityFilter, syncOptions: SyncOptions): { data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **basicFilter**: `EqualityFilter` - Equality filter used for sync. Multiple columns are combined with AND. - - - **syncOptions**: `SyncOptions` -#### Return type -`{ data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }` - - **data**: `SyncDataItem>[] | undefined` - - **isLoading**: `boolean` - - **error**: `any` - -## syncOne() - -```typescript - syncOne: (basicFilter: Partial, options: SyncOneOptions, onChange: (data: SyncDataItem, false>, delta?: Partial | undefined) => any, onError?: (error: any) => void): Promise> - ``` -#### Arguments - - - **basicFilter**: `Partial` - Make all properties in T optional. - - - **options**: `SyncOneOptions` - - **onChange**: `(data: SyncDataItem, false>, delta?: Partial | undefined) => any` - - **onError**: `(error: any) => void` -#### Return type -`SingleSyncHandles` - CRUD handles added if initialised with handlesOnData = true. - - **$get**: `() => T | undefined` - - **$find**: `(idObj: Partial) => T | undefined` - - **$unsync**: `() => any` - - **$delete**: `() => void` - - **$update**: `(newData: OPTS extends { deepMerge: true; } ? DeepPartial : Partial, opts?: OPTS | undefined) => any` - - **$cloneSync**: `CloneSync` - - **$cloneMultiSync**: `CloneMultiSync` - -## useSyncOne() -Retrieves the first row matching the filter and keeps it in sync -- use { handlesOnData: true } to get optimistic updates method: $update -- any changes to the row using the $update method will be reflected instantly - to all sync subscribers that were initiated with the same syncOptions -```typescript - useSyncOne: (basicFilter: EqualityFilter, syncOptions: SyncOneOptions): { data: SyncDataItem> | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **basicFilter**: `EqualityFilter` - Equality filter used for sync. Multiple columns are combined with AND. - - - **syncOptions**: `SyncOneOptions` -#### Return type -`{ data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }` - - **data**: `SyncDataItem> | undefined` - - **isLoading**: `boolean` - - **error**: `any` - - - -## useSubscribe() -Retrieves a list of matching records from the view/table and subscribes to changes -```typescript - useSubscribe: (filter?: FullFilter | undefined, options?: SubscribeParams): { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **options**: `SubscribeParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). - - **throttle**: `number` - If true then the subscription will be throttled to the provided number of milliseconds. - - **throttleOpts**: `{ skipFirst?: boolean | undefined; }` - - **skipFirst**: `false` - If true then the first value will be emitted at the end of the interval. Instant otherwise. -#### Return type -`{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }` - - **data**: `GetSelectReturnType | undefined` - - **error**: `any` - - **isLoading**: `boolean` - -## useSubscribeOne() -Retrieves a matching record from the view/table and subscribes to changes -```typescript - useSubscribeOne: (filter?: FullFilter | undefined, options?: SubscribeParams): { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **options**: `SubscribeParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). - - **throttle**: `number` - If true then the subscription will be throttled to the provided number of milliseconds. - - **throttleOpts**: `{ skipFirst?: boolean | undefined; }` - - **skipFirst**: `false` - If true then the first value will be emitted at the end of the interval. Instant otherwise. -#### Return type -`{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }` - - **data**: `GetSelectReturnType | undefined` - - **error**: `any` - - **isLoading**: `boolean` - -## useFind() -Retrieves a list of matching records from the view/table -```typescript - useFind: (filter?: FullFilter | undefined, selectParams?: SelectParams): { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }` - - **data**: `GetSelectReturnType | undefined` - - **isLoading**: `boolean` - - **error**: `any` - -## useFindOne() -Retrieves first matching record from the view/table -```typescript - useFindOne: (filter?: FullFilter | undefined, selectParams?: SelectParams): { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }` - - **data**: `GetSelectReturnType | undefined` - - **isLoading**: `boolean` - - **error**: `any` - -## useCount() -Returns the total number of rows matching the filter -```typescript - useCount: (filter?: FullFilter | undefined, selectParams?: SelectParams): { data: number | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`{ data: number | undefined; isLoading: boolean; error?: any; }` - - **data**: `number | undefined` - - **isLoading**: `boolean` - - **error**: `any` - -## useSize() -Returns result size in bits matching the filter and selectParams -```typescript - useSize: (filter?: FullFilter | undefined, selectParams?: SelectParams): { data: string | undefined; isLoading: boolean; error?: any; } - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **selectParams**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`{ data: string | undefined; isLoading: boolean; error?: any; }` - - **data**: `string | undefined` - - **isLoading**: `boolean` - - **error**: `any` - -## update() -Updates a record in the table based on the specified filter criteria -- Use { multi: false } to ensure no more than one row is updated -```typescript - update: (filter: FullFilter, newData: Partial, params?: SelectParams): Promise | undefined> - ``` -#### Arguments - - - **filter**: `FullFilter` - Group or simple filter. - - **newData**: `Partial` - Make all properties in T optional. - - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetUpdateReturnType | undefined` - -## updateBatch() -Updates multiple records in the table in a batch operation. -- Each item in the `data` array contains a filter and the corresponding data to update. -```typescript - updateBatch: (data: [FullFilter, Partial>][], params?: SelectParams): Promise> - ``` -#### Arguments - - - **data**: `[FullFilter, Partial>][]` - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`void | GetUpdateReturnType` - -## insert() -Inserts a new record into the table. -```typescript - insert: (data: UpsertDataToPGCast | UpsertDataToPGCast[], params?: SelectParams): Promise> - ``` -#### Arguments - - - **data**: `InsertData` - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetInsertReturnType` - -## upsert() -Inserts or updates a record in the table. -- If a record matching the `filter` exists, it updates the record. -- If no matching record exists, it inserts a new record. -```typescript - upsert: (filter: FullFilter, newData: Partial, params?: SelectParams): Promise | undefined> - ``` -#### Arguments - - - **filter**: `FullFilter` - Group or simple filter. - - **newData**: `Partial` - Make all properties in T optional. - - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetUpdateReturnType | undefined` - -## delete() -Deletes records from the table based on the specified filter criteria. -- If no filter is provided, all records may be deleted (use with caution). -```typescript - delete: (filter?: FullFilter | undefined, params?: SelectParams): Promise | undefined> - ``` -#### Arguments - - - **filter**: `FullFilter | undefined` - - **params**: `SelectParams` - - **limit**: `number | null | undefined` - Max number of rows to return. - If undefined then 1000 will be applied as the default. - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present). - - **offset**: `number` - Number of rows to skip. - - **groupBy**: `false` - Will group by all non aggregated fields specified in select (or all fields by default). - - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` - Result data structure/type:. - row: the first row as an object. - value: the first value from of first field. - values: array of values from the selected field. - statement: sql statement. - statement-no-rls: sql statement without row level security. - statement-where: sql statement where condition. - - **select**: `Select` - Fields/expressions/linked data to select. - If empty then all fields will be selected. - If "*" then all fields will be selected. - If { field: 0 } then all fields except the specified field will be selected. - If { field: 1 } then only the specified field will be selected. - If { field: { funcName: [args] } } then the field will be selected with the specified function applied. - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields. - - **orderBy**: `OrderBy` - Order by options. - If array then the order will be maintained. - - **having**: `FullFilter | undefined` - Filter applied after any aggregations (group by). -#### Return type -`GetUpdateReturnType | undefined` \ No newline at end of file diff --git a/documentation/METHODS.md b/documentation/METHODS.md new file mode 100644 index 00000000..aebc3509 --- /dev/null +++ b/documentation/METHODS.md @@ -0,0 +1,1467 @@ +# Isomorphic Methods + +The following methods are available on the client and server. + +## getInfo(lang?: string): Promise<TableInfo> +Retrieves the table/view info +```typescript +getInfo: (): +``` +#### Parameters + + - **lang**: `string` + + Language code for i18n data. "en" by default +#### `TableInfo` + + + - **oid**: `number` + + OID from the postgres database + Useful in handling renamed tables + - **comment**: `string` + + Comment from the postgres database + - **isFileTable**: `FileTableConfig` + + Defined if this is the fileTable + - **allowedNestedInserts**: `{ table: string; column: string; }` + + + - **table**: `string` + + + - **column**: `string` + + + - **hasFiles**: `false` + + True if fileTable is enabled and this table references the fileTable + Used in UI + - **isView**: `false` + + True if this is a view. + Table methods (insert, update, delete) are undefined for views + - **fileTableName**: `string` + + Name of the fileTable (if enabled) + Used in UI + - **dynamicRules**: `{ update?: boolean | undefined; }` + + Used for getColumns in cases where the columns are dynamic based on the request. + See dynamicFields from Update rules + - **update**: `false` + + + - **info**: `{ label?: string | undefined; }` + + Additional table info provided through TableConfig + - **label**: `string` + + + - **uniqueColumnGroups**: `string[][] | undefined` + + List of unique column indexes/constraints. + Column groups where at least a column is not allowed to be viewed (selected) are omitted. + +## getColumns(lang?: string, params?: GetColumnsParams): Promise<ValidatedColumnInfo[]> +Retrieves columns metadata of the table/view +```typescript +getColumns: (): +``` +#### Parameters + + - **lang**: `string` + + + - **params**: `GetColumnsParams` + + Dynamic/filter based rules allow limit what columns can be updated based on the request data/filter + This allows parameter allows identifying the columns that can be updated based on the request data + - **rule**: `"update"` + + + - **data**: `AnyObject` + + + + - **filter**: `FullFilter` + + Data filter + - `{ status: 'live' }` + - `{ $or: [{ id: 1 }, { status: 'live' }] }` + - `{ $existsJoined: { referencedTable: { id: 1 } } }` + - `{ + $filter: [ + { $age: ["created_at"] }, + "<", + '1 year' + ] + }` +#### `ValidatedColumnInfo` + + + - **name**: `string` + + + - **label**: `string` + + Column display name. Will be first non empty value from i18n data, comment, name + - **comment**: `string | undefined` + + Column description (if provided) + - **ordinal_position**: `number` + + Ordinal position of the column within the table (count starts at 1) + - **is_nullable**: `boolean` + + True if column is nullable + - **is_updatable**: `boolean` + + + - **is_generated**: `boolean` + + If the column is a generated column (converted to boolean from ALWAYS and NEVER) + - **data_type**: `string` + + Simplified data type + - **udt_name**: `PG_COLUMN_UDT_DATA_TYPE` + + Postgres data type name. + Array types start with an underscore + - **element_type**: `string | undefined` + + Element data type + - **element_udt_name**: `string | undefined` + + Element data type name + - **is_pkey**: `boolean` + + PRIMARY KEY constraint on column. + A table can have a multi column primary key + - **references**: `ReferenceTable` + + + - **ftable**: `string` + + + - **fcols**: `string` + + + - **cols**: `string` + + + - **has_default**: `boolean` + + true if column has a default value + Used for excluding pkey from insert + - **column_default**: `any` + + Column default value + - **min**: `string | number | undefined` + + Extracted from tableConfig + Used in SmartForm + - **max**: `string | number | undefined` + + + - **hint**: `string` + + + - **jsonbSchema**: `JSONBSchema` + + JSONB schema (a simplified version of json schema) for the column (if defined in the tableConfig) + A check constraint will use this schema for runtime data validation and apropriate TS types will be generated + - **nullable**: `any` + + False by default + - **description**: `any` + + + - **title**: `any` + + + - **type**: `any` + + + - **allowedValues**: `any` + + + - **oneOf**: `any` + + + - **oneOfType**: `any` + + + - **arrayOf**: `any` + + + - **arrayOfType**: `any` + + + - **enum**: `any` + + + - **record**: `any` + + + - **lookup**: `any` + + + - **defaultValue**: `any` + + + - **file**: `FileColumnConfig | undefined` + + If degined then this column is referencing the file table + Extracted from FileTable config + Used in SmartForm + - **tsDataType**: `"string" | "number" | "boolean" | "any" | "number[]" | "boolean[]" | "string[]" | "any[]"` + + TypeScript data type + - **select**: `boolean` + + Can be viewed/selected + Based on access rules and postgres policies + - **orderBy**: `boolean` + + Can be ordered by + Based on access rules + - **filter**: `boolean` + + Can be filtered by + Based on access rules + - **insert**: `boolean` + + Can be inserted + Based on access rules and postgres policies + - **update**: `boolean` + + Can be updated + Based on access rules and postgres policies + - **delete**: `boolean` + + Can be used in the delete filter + Based on access rules + +## find(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<GetSelectReturnType<S, P, T, true>> +Retrieves a list of matching records from the view/table +```typescript +find: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + Filter to apply. Undefined will return all records + - { "field": "value" } + - { "field": { $in: ["value", "value2"] } } + - { $or: [ + { "field1": "value" }, + { "field2": "value" } + ] + } + - { $existsJoined: { linkedTable: { "linkedTableField": "value" } } } + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetSelectReturnType` + + + +## findOne(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<GetSelectReturnType<S, P, T, false> | undefined> +Retrieves a record from the view/table +```typescript +findOne: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetSelectReturnType | undefined` + + + +## subscribe(filter: ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, params: SelectParams, onData: SubscribeCallback, onError?: SubscribeOnError): Promise<SubscriptionHandler> +Retrieves a list of matching records from the view/table and subscribes to changes +```typescript +subscribe: (): +``` +#### Parameters + + - **filter**: `FullFilter` + + Data filter + - `{ status: 'live' }` + - `{ $or: [{ id: 1 }, { status: 'live' }] }` + - `{ $existsJoined: { referencedTable: { id: 1 } } }` + - `{ + $filter: [ + { $age: ["created_at"] }, + "<", + '1 year' + ] + }` + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) + - **onData**: `SubscribeCallback` + + Callback fired once after subscribing and then every time the data matching the filter changes + - **onError**: `SubscribeOnError` + + Error handler that may fire due to schema changes or other post subscribe issues + Column or filter issues are thrown during the subscribe call +#### `SubscriptionHandler` + + + - **unsubscribe**: `() => Promise` + + + - **filter**: `{} | FullFilter` + + + +## subscribeOne(filter: ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, params: SelectParams, onData: SubscribeOneCallback, onError?: SubscribeOnError): Promise<SubscriptionHandler> +Retrieves first matching record from the view/table and subscribes to changes +```typescript +subscribeOne: (): +``` +#### Parameters + + - **filter**: `FullFilter` + + Data filter + - `{ status: 'live' }` + - `{ $or: [{ id: 1 }, { status: 'live' }] }` + - `{ $existsJoined: { referencedTable: { id: 1 } } }` + - `{ + $filter: [ + { $age: ["created_at"] }, + "<", + '1 year' + ] + }` + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) + - **onData**: `SubscribeOneCallback` + + Callback fired once after subscribing and then every time the data matching the filter changes + - **onError**: `SubscribeOnError` + + Error handler that may fire due to schema changes or other post subscribe issues + Column or filter issues are thrown during the subscribe call +#### `SubscriptionHandler` + + + - **unsubscribe**: `() => Promise` + + + - **filter**: `{} | FullFilter` + + + +## count(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<number> +Returns the number of rows that match the filter +```typescript +count: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `number` + + + +## size(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): Promise<string> +Returns result size in bits +```typescript +size: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `string` + + + +## update(filter: ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, newData: Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined> +Updates a record in the table based on the specified filter criteria +- Use { multi: false } to ensure no more than one row is updated +```typescript +update: (): +``` +#### Parameters + + - **filter**: `FullFilter` + + Data filter + - `{ status: 'live' }` + - `{ $or: [{ id: 1 }, { status: 'live' }] }` + - `{ $existsJoined: { referencedTable: { id: 1 } } }` + - `{ + $filter: [ + { $age: ["created_at"] }, + "<", + '1 year' + ] + }` + - **newData**: `Partial` + + Make all properties in T optional + + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetUpdateReturnType | undefined` + + + +## updateBatch(data: [FullFilter, Partial>][], params?: SelectParams): Promise<void | GetUpdateReturnType<P, T, S>> +Updates multiple records in the table in a batch operation. +- Each item in the `data` array contains a filter and the corresponding data to update. +```typescript +updateBatch: (): +``` +#### Parameters + + - **data**: `[FullFilter, Partial>][]` + + + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `void | GetUpdateReturnType` + + + +## insert(data: UpsertDataToPGCast | UpsertDataToPGCast[], params?: SelectParams): Promise<GetInsertReturnType<D, P, T, S>> +Inserts a new record into the table. +```typescript +insert: (): +``` +#### Parameters + + - **data**: `InsertData` + + + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetInsertReturnType` + + + +## upsert(filter: ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, newData: Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined> +Inserts or updates a record in the table. +- If a record matching the `filter` exists, it updates the record. +- If no matching record exists, it inserts a new record. +```typescript +upsert: (): +``` +#### Parameters + + - **filter**: `FullFilter` + + Data filter + - `{ status: 'live' }` + - `{ $or: [{ id: 1 }, { status: 'live' }] }` + - `{ $existsJoined: { referencedTable: { id: 1 } } }` + - `{ + $filter: [ + { $age: ["created_at"] }, + "<", + '1 year' + ] + }` + - **newData**: `Partial` + + Make all properties in T optional + + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetUpdateReturnType | undefined` + + + +## delete(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, params?: SelectParams): Promise<GetUpdateReturnType<P, T, S> | undefined> +Deletes records from the table based on the specified filter criteria. +- If no filter is provided, all records may be deleted (use with caution). +```typescript +delete: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **params**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `GetUpdateReturnType | undefined` + + +# Client Methods + +The following methods are available on the client. + +## getJoinedTables(): string[] + +```typescript +getJoinedTables: (): +``` +#### Parameters + +#### `string` + + + + + + + +## sync(basicFilter: EqualityFilter, options: SyncOptions, onChange: (data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any, onError?: (error: any) => void): Promise<{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }> + +```typescript +sync: (): +``` +#### Parameters + + - **basicFilter**: `EqualityFilter` + + Equality filter used for sync + Multiple columns are combined with AND + + - **options**: `SyncOptions` + + + - **onChange**: `(data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any` + + + - **onError**: `(error: any) => void` + + +#### `{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }` + + + - **$unsync**: `() => void` + + + - **$upsert**: `(newData: T[]) => any` + + + - **getItems**: `() => T[]` + + + +## useSync(basicFilter: EqualityFilter, syncOptions: SyncOptions): { data: SyncDataItem<Required<T>>[] | undefined; isLoading: boolean; error?: any; } +Retrieves rows matching the filter and keeps them in sync +- use { handlesOnData: true } to get optimistic updates method: $update +- any changes to the row using the $update method will be reflected instantly + to all sync subscribers that were initiated with the same syncOptions +```typescript +useSync: (): +``` +#### Parameters + + - **basicFilter**: `EqualityFilter` + + Equality filter used for sync + Multiple columns are combined with AND + + - **syncOptions**: `SyncOptions` + + +#### `{ data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `SyncDataItem>[] | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + + + +## syncOne(basicFilter: Partial, options: SyncOneOptions, onChange: (data: SyncDataItem, false>, delta?: Partial | undefined) => any, onError?: (error: any) => void): Promise<SingleSyncHandles<T, false>> + +```typescript +syncOne: (): +``` +#### Parameters + + - **basicFilter**: `Partial` + + Make all properties in T optional + + - **options**: `SyncOneOptions` + + + - **onChange**: `(data: SyncDataItem, false>, delta?: Partial | undefined) => any` + + + - **onError**: `(error: any) => void` + + +#### `SingleSyncHandles` + + CRUD handles added if initialised with handlesOnData = true + - **$get**: `() => T | undefined` + + + - **$find**: `(idObj: Partial) => T | undefined` + + + - **$unsync**: `() => any` + + + - **$delete**: `() => void` + + + - **$update**: `(newData: OPTS extends { deepMerge: true; } ? DeepPartial : Partial, opts?: OPTS | undefined) => any` + + + - **$cloneSync**: `CloneSync` + + + - **$cloneMultiSync**: `CloneMultiSync` + + + +## useSyncOne(basicFilter: EqualityFilter, syncOptions: SyncOneOptions): { data: SyncDataItem<Required<T>> | undefined; isLoading: boolean; error?: any; } +Retrieves the first row matching the filter and keeps it in sync +- use { handlesOnData: true } to get optimistic updates method: $update +- any changes to the row using the $update method will be reflected instantly + to all sync subscribers that were initiated with the same syncOptions +```typescript +useSyncOne: (): +``` +#### Parameters + + - **basicFilter**: `EqualityFilter` + + Equality filter used for sync + Multiple columns are combined with AND + + - **syncOptions**: `SyncOneOptions` + + +#### `{ data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `SyncDataItem> | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + + + + + +## useSubscribe(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, options?: SubscribeParams): { data: GetSelectReturnType<S, SubParams, T, true> | undefined; error?: any; isLoading: boolean; } +Retrieves a list of matching records from the view/table and subscribes to changes +```typescript +useSubscribe: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **options**: `SubscribeParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) + - **throttle**: `number` + + If true then the subscription will be throttled to the provided number of milliseconds + - **throttleOpts**: `{ skipFirst?: boolean | undefined; }` + + + - **skipFirst**: `false` + + False by default. + If true then the first value will be emitted at the end of the interval. Instant otherwise +#### `{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }` + + + - **data**: `GetSelectReturnType | undefined` + + + - **error**: `any` + + + - **isLoading**: `boolean` + + + +## useSubscribeOne(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, options?: SubscribeParams): { data: GetSelectReturnType<S, SubParams, T, false> | undefined; error?: any; isLoading: boolean; } +Retrieves a matching record from the view/table and subscribes to changes +```typescript +useSubscribeOne: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **options**: `SubscribeParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) + - **throttle**: `number` + + If true then the subscription will be throttled to the provided number of milliseconds + - **throttleOpts**: `{ skipFirst?: boolean | undefined; }` + + + - **skipFirst**: `false` + + False by default. + If true then the first value will be emitted at the end of the interval. Instant otherwise +#### `{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }` + + + - **data**: `GetSelectReturnType | undefined` + + + - **error**: `any` + + + - **isLoading**: `boolean` + + + +## useFind(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: GetSelectReturnType<S, P, T, true> | undefined; isLoading: boolean; error?: any; } +Retrieves a list of matching records from the view/table +```typescript +useFind: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `GetSelectReturnType | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + + + +## useFindOne(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: GetSelectReturnType<S, P, T, false> | undefined; isLoading: boolean; error?: any; } +Retrieves first matching record from the view/table +```typescript +useFindOne: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `GetSelectReturnType | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + + + +## useCount(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: number | undefined; isLoading: boolean; error?: any; } +Returns the total number of rows matching the filter +```typescript +useCount: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `{ data: number | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `number | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + + + +## useSize(filter?: undefined | ComplexFilter | { $and: FullFilter[]; } | { $or: FullFilter[]; } | NormalFilter | ShorthandFilter | Partial, selectParams?: SelectParams): { data: string | undefined; isLoading: boolean; error?: any; } +Returns result size in bits matching the filter and selectParams +```typescript +useSize: (): +``` +#### Parameters + + - **filter**: `FullFilter | undefined` + + + - **selectParams**: `SelectParams` + + + - **limit**: `number | null | undefined` + + Max number of rows to return. Defaults to 1000 + - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present) + - **offset**: `number` + + Number of rows to skip + - **groupBy**: `false` + + Will group by all non aggregated fields specified in select (or all fields by default) + - **returnType**: `"row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where" | undefined` + + Result data structure/type: + - **row**: the first row as an object + - **value**: the first value from of first field + - **values**: array of values from the selected field + - **statement**: sql statement + - **statement-no-rls**: sql statement without row level security + - **statement-where**: sql statement where condition + - **select**: `Select` + + Fields/expressions/linked data to select + - `"*"` or empty will return all fields + - `{ field: 0 }` - all fields except the specified field will be selected + - `{ field: 1 }` - only the specified field will be selected + - `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied + - `{ field: 1, referencedTable: "*" }` - field together with all fields from referencedTable will be selected + - `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable + - **orderBy**: `OrderBy` + + Order by options + - Order is maintained in arrays + - `[{ key: "field", asc: true, nulls: "last" }]` + - **having**: `FullFilter | undefined` + + Filter applied after any aggregations (group by) +#### `{ data: string | undefined; isLoading: boolean; error?: any; }` + + + - **data**: `string | undefined` + + + - **isLoading**: `boolean` + + + - **error**: `any` + diff --git a/documentation/SERVER.md b/documentation/SERVER.md index 7cf16244..dd123e66 100644 --- a/documentation/SERVER.md +++ b/documentation/SERVER.md @@ -11,8 +11,8 @@ To get started, you need to provide a configuration object to the server. Basic example: ```typescript import prostgles from "prostgles-server"; -import { DBSchemaGenerated } from "./DBSchemaGenerated"; -prostgles({ +import { DBGeneratedSchema } from "./DBGeneratedSchema"; +prostgles({ dbConnection: { host: "localhost", port: 5432, @@ -37,10 +37,9 @@ prostgles({ - onReady `OnReadyCallback` Called when the prostgles server is ready to accept connections. It waits for auth, tableConfig and other async configurations to complete before executing - - dbOptions `IDefaults` - tsGeneratedTypesDir `string | undefined` - If defined then a `DBSchemaGenerated.d.ts` file will be created in the provided directory. -This file exports a `DBSchemaGenerated` type which contains types for the database tables and + If defined then a `DBGeneratedSchema.d.ts` file will be created in the provided directory. +This file exports a `DBGeneratedSchema` type which contains types for the database tables and can be used as a generic type input for the prostgles instances to ensure type safety - disableRealtime `boolean | undefined` If true then schema watch, subscriptions and syncs will be disabled. @@ -83,11 +82,11 @@ Supports email and OAuth strategies Useful for logging or debugging - watchSchemaType `"DDL_trigger" | "prostgles_queries" | undefined` - watchSchema `boolean | EventTriggerTagFilter | "hotReloadMode" | OnSchemaChangeCallback | undefined` - If truthy then DBSchemaGenerated.d.ts will be updated + If truthy then DBGeneratedSchema.d.ts will be updated and "onReady" will be called with new schema on both client and server - keywords `Keywords` - onNotice `(notice: AnyObject, message?: string | undefined) => void` - - fileTable `FileTableConfig` + - fileTable `FileTableConfig | undefined` Enables file storage and serving. Currently supports saving files locally or to AWS S3 - restApi `RestApiConfig` diff --git a/documentation/utils/clientTypes.ts b/documentation/utils/clientTypes.ts index 8bf3da06..1983dcd1 100644 --- a/documentation/utils/clientTypes.ts +++ b/documentation/utils/clientTypes.ts @@ -15,7 +15,7 @@ export const definitions = [ "type": "primitive", "alias": "string", "subType": "string", - "comments": "Language code for i18n data\n```typescript\n \"en\"\n```" + "comments": "Language code for i18n data. \"en\" by default" } ], "returnType": { @@ -44,7 +44,8 @@ export const definitions = [ }, "isFileTable": { "type": "object", - "alias": "{ allowedNestedInserts?: { table: string; column: string; }[] | undefined; }", + "alias": "FileTableConfig", + "aliasSymbolescapedName": "FileTableConfig", "comments": "Defined if this is the fileTable", "properties": { "allowedNestedInserts": { @@ -79,20 +80,21 @@ export const definitions = [ "alias": "false", "subType": "boolean", "optional": true, - "comments": "True if fileTable is enabled and this table references the fileTable" + "comments": "True if fileTable is enabled and this table references the fileTable\nUsed in UI" }, "isView": { "type": "primitive", "alias": "false", "subType": "boolean", - "optional": true + "optional": true, + "comments": "True if this is a view.\nTable methods (insert, update, delete) are undefined for views" }, "fileTableName": { "type": "primitive", "alias": "string", "subType": "string", "optional": true, - "comments": "Name of the fileTable (if enabled)" + "comments": "Name of the fileTable (if enabled)\nUsed in UI" }, "dynamicRules": { "type": "object", @@ -152,7 +154,8 @@ export const definitions = [ } }, "optional": false, - "comments": "Retrieves the table/view info" + "comments": "Retrieves the table/view info", + "intersectionParent": "ViewHandler" }, "getColumns": { "type": "function", @@ -189,10 +192,145 @@ export const definitions = [ "optional": false }, "filter": { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "properties": {}, + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.$ilike`]: any; [x: `${string}.$like`]: any; [x: `${string}.$nilike`]: any; [x: `${string}.$nlike`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ $exists: any; $notExists: any; $existsJoined: any; $notExistsJoined: any; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], "optional": false } } @@ -214,28 +352,43 @@ export const definitions = [ "type": "primitive", "alias": "string", "subType": "string", - "optional": false + "optional": false, + "intersectionParent": "ColumnInfo" }, "label": { "type": "primitive", "alias": "string", "subType": "string", "optional": false, - "comments": "Column display name. Will be first non empty value from i18n data, comment, name" + "comments": "Column display name. Will be first non empty value from i18n data, comment, name", + "intersectionParent": "ColumnInfo" }, "comment": { - "type": "primitive", - "alias": "string", - "subType": "string", + "type": "union", + "alias": "string | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "string", + "subType": "string" + } + ], "optional": false, - "comments": "Column description (if provided)" + "comments": "Column description (if provided)", + "intersectionParent": "ColumnInfo" }, "ordinal_position": { "type": "primitive", "alias": "number", "subType": "number", "optional": false, - "comments": "Ordinal position of the column within the table (count starts at 1)" + "comments": "Ordinal position of the column within the table (count starts at 1)", + "intersectionParent": "ColumnInfo" }, "is_nullable": { "type": "union", @@ -248,7 +401,8 @@ export const definitions = [ } ], "optional": false, - "comments": "True if column is nullable. A not-null constraint is one way a column can be known not nullable, but there may be others." + "comments": "True if column is nullable", + "intersectionParent": "ColumnInfo" }, "is_updatable": { "type": "union", @@ -260,7 +414,8 @@ export const definitions = [ "subType": "boolean" } ], - "optional": false + "optional": false, + "intersectionParent": "ColumnInfo" }, "is_generated": { "type": "union", @@ -273,35 +428,62 @@ export const definitions = [ } ], "optional": false, - "comments": "If the column is a generated column (converted to boolean from ALWAYS and NEVER)" + "comments": "If the column is a generated column (converted to boolean from ALWAYS and NEVER)", + "intersectionParent": "ColumnInfo" }, "data_type": { "type": "primitive", "alias": "string", "subType": "string", "optional": false, - "comments": "Simplified data type" + "comments": "Simplified data type", + "intersectionParent": "ColumnInfo" }, "udt_name": { "type": "reference", "alias": "PG_COLUMN_UDT_DATA_TYPE", "aliasSymbolescapedName": "PG_COLUMN_UDT_DATA_TYPE", - "comments": "Postgres raw data types. values starting with underscore means it's an array of that data type", - "optional": false + "comments": "Postgres data type name.\nArray types start with an underscore", + "optional": false, + "intersectionParent": "ColumnInfo" }, "element_type": { - "type": "primitive", - "alias": "string", - "subType": "string", + "type": "union", + "alias": "string | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "string", + "subType": "string" + } + ], "optional": false, - "comments": "Element data type" + "comments": "Element data type", + "intersectionParent": "ColumnInfo" }, "element_udt_name": { - "type": "primitive", - "alias": "string", - "subType": "string", + "type": "union", + "alias": "string | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "string", + "subType": "string" + } + ], "optional": false, - "comments": "Element raw data type" + "comments": "Element data type name", + "intersectionParent": "ColumnInfo" }, "is_pkey": { "type": "union", @@ -314,14 +496,17 @@ export const definitions = [ } ], "optional": false, - "comments": "PRIMARY KEY constraint on column. A table can have more then one PK" + "comments": "PRIMARY KEY constraint on column.\nA table can have a multi column primary key", + "intersectionParent": "ColumnInfo" }, "references": { "type": "array", - "alias": "{ ftable: string; fcols: string[]; cols: string[]; }[]", + "alias": "ReferenceTable[]", "itemType": { "type": "object", - "alias": "{ ftable: string; fcols: string[]; cols: string[]; }", + "alias": "ReferenceTable", + "aliasSymbolescapedName": "ReferenceTable", + "comments": "", "properties": { "ftable": { "type": "primitive", @@ -352,7 +537,8 @@ export const definitions = [ } }, "optional": true, - "comments": "Foreign key constraint\nA column can reference multiple tables" + "comments": "Foreign key constraint\nA column can reference multiple tables", + "intersectionParent": "ColumnInfo" }, "has_default": { "type": "union", @@ -365,14 +551,16 @@ export const definitions = [ } ], "optional": false, - "comments": "true if column has a default value\nUsed for excluding pkey from insert" + "comments": "true if column has a default value\nUsed for excluding pkey from insert", + "intersectionParent": "ColumnInfo" }, "column_default": { "type": "primitive", "alias": "any", "subType": "any", "optional": true, - "comments": "Column default value" + "comments": "Column default value", + "intersectionParent": "ColumnInfo" }, "min": { "type": "union", @@ -395,7 +583,8 @@ export const definitions = [ } ], "optional": true, - "comments": "Extracted from tableConfig\nUsed in SmartForm" + "comments": "Extracted from tableConfig\nUsed in SmartForm", + "intersectionParent": "ColumnInfo" }, "max": { "type": "union", @@ -417,13 +606,15 @@ export const definitions = [ "subType": "number" } ], - "optional": true + "optional": true, + "intersectionParent": "ColumnInfo" }, "hint": { "type": "primitive", "alias": "string", "subType": "string", - "optional": true + "optional": true, + "intersectionParent": "ColumnInfo" }, "jsonbSchema": { "type": "object", @@ -435,73 +626,85 @@ export const definitions = [ "alias": "any", "subType": "any", "optional": true, - "comments": "False by default" + "comments": "False by default", + "intersectionParent": "Omit" }, "description": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "title": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "type": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "allowedValues": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "oneOf": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "oneOfType": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "arrayOf": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "arrayOfType": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "enum": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "record": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "lookup": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Omit" }, "defaultValue": { "type": "primitive", @@ -510,7 +713,9 @@ export const definitions = [ "optional": true } }, - "optional": true + "optional": true, + "comments": "JSONB schema (a simplified version of json schema) for the column (if defined in the tableConfig)\nA check constraint will use this schema for runtime data validation and apropriate TS types will be generated", + "intersectionParent": "ColumnInfo" }, "file": { "type": "union", @@ -3625,7 +3830,8 @@ export const definitions = [ } ], "optional": true, - "comments": "If degined then this column is referencing the file table\nExtracted from FileTable config\nUsed in SmartForm" + "comments": "If degined then this column is referencing the file table\nExtracted from FileTable config\nUsed in SmartForm", + "intersectionParent": "ColumnInfo" }, "tsDataType": { "type": "union", @@ -3686,7 +3892,7 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be viewed/selected" + "comments": "Can be viewed/selected\nBased on access rules and postgres policies" }, "orderBy": { "type": "union", @@ -3699,7 +3905,7 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be ordered by" + "comments": "Can be ordered by\nBased on access rules" }, "filter": { "type": "union", @@ -3712,7 +3918,7 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be filtered by" + "comments": "Can be filtered by\nBased on access rules" }, "insert": { "type": "union", @@ -3725,7 +3931,7 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be inserted" + "comments": "Can be inserted\nBased on access rules and postgres policies" }, "update": { "type": "union", @@ -3738,7 +3944,7 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be updated" + "comments": "Can be updated\nBased on access rules and postgres policies" }, "delete": { "type": "union", @@ -3751,14 +3957,15 @@ export const definitions = [ } ], "optional": false, - "comments": "Can be used in the delete filter" + "comments": "Can be used in the delete filter\nBased on access rules" } } } } }, "optional": false, - "comments": "Retrieves columns metadata of the table/view" + "comments": "Retrieves columns metadata of the table/view", + "intersectionParent": "ViewHandler" }, "find": { "type": "function", @@ -3767,147 +3974,197 @@ export const definitions = [ { "name": "filter", "optional": true, - "type": "reference", + "type": "union", "alias": "FullFilter | undefined", - "comments": "" - }, - { - "name": "selectParams", - "optional": true, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { - "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { "type": "primitive", - "alias": "number", - "subType": "number" + "alias": "any", + "subType": "any", + "optional": false } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + } }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } }, - "groupBy": { + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, - "returnType": { - "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", - "types": [ - { + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "literal", - "alias": "\"row\"", - "value": "row" - }, - { - "type": "literal", - "alias": "\"value\"", - "value": "value" - }, - { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true } - ], - "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + } } - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" - } - }, - "optional": false, - "comments": "Retrieves a list of matching records from the view/table" - }, - "findOne": { - "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise | undefined>", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" + ], + "comments": "Filter to apply. Undefined will return all records\n- { \"field\": \"value\" }\n- { \"field\": { $in: [\"value\", \"value2\"] } }\n- { $or: [\n { \"field1\": \"value\" },\n { \"field2\": \"value\" }\n ]\n }\n- { $existsJoined: { linkedTable: { \"linkedTableField\": \"value\" } } }" }, { "name": "selectParams", @@ -3937,21 +4194,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -3994,13 +4254,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -4010,254 +4271,22 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise | undefined>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "union", - "alias": "GetSelectReturnType | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" - } - ] - } - }, - "optional": false, - "comments": "Retrieves a record from the view/table" - }, - "subscribe": { - "type": "function", - "alias": "

>(filter: FullFilter, params: P, onData: (items: GetSelectReturnType) => any, onError?: OnError | undefined) => Promise<...>", - "arguments": [ - { - "name": "filter", - "optional": false, - "type": "reference", - "alias": "FullFilter", - "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" - }, - { - "name": "params", - "optional": false, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { "type": "union", - "alias": "number | null | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", "alias": "undefined", "subType": "undefined" }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" - }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" - }, - "groupBy": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" - }, - "returnType": { - "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "literal", - "alias": "\"row\"", - "value": "row" - }, - { - "type": "literal", - "alias": "\"value\"", - "value": "value" - }, - { - "type": "literal", - "alias": "\"values\"", - "value": "values" - }, - { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" - }, - { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" - }, - { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" - } - ], - "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - }, - { - "name": "onData", - "optional": false, - "type": "function", - "alias": "(items: GetSelectReturnType) => any", - "arguments": [ - { - "name": "items", - "optional": false, - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any", - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "comments": "" - }, - { - "name": "onError", - "optional": true, - "type": "function", - "alias": "OnError", - "aliasSymbolescapedName": "OnError", - "arguments": [ - { - "name": "err", - "optional": false, - "type": "primitive", - "alias": "any", - "subType": "any", - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "object", - "alias": "SubscriptionHandler", - "aliasSymbolescapedName": "SubscriptionHandler", - "comments": "", - "properties": { - "unsubscribe": { - "type": "function", - "alias": "() => Promise", - "arguments": [], - "returnType": { - "type": "promise", - "alias": "Promise", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "primitive", - "alias": "any", - "subType": "any" - } - }, - "optional": false - }, - "filter": { - "type": "union", - "alias": "{} | FullFilter", - "types": [ - { - "type": "object", - "alias": "{}", - "properties": {} - }, { "type": "object", "alias": "ComplexFilter", "aliasSymbolescapedName": "ComplexFilter", - "comments": "Complex filter that allows applying functions to columns", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", "properties": { "$filter": { "type": "primitive", @@ -4269,16 +4298,101 @@ export const definitions = [ }, { "type": "object", - "alias": "{ $and: FullFilter[]; }", + "alias": "{ $and: FullFilter[]; }", "properties": { "$and": { "type": "array", - "alias": "FullFilter[]", + "alias": "FullFilter[]", "itemType": { - "type": "reference", - "alias": "FullFilter", + "type": "union", + "alias": "FullFilter", "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] }, "optional": false } @@ -4286,18 +4400,18 @@ export const definitions = [ }, { "type": "object", - "alias": "{ $or: FullFilter[]; }", + "alias": "{ $or: FullFilter[]; }", "properties": { "$or": { "type": "reference", - "alias": "FullFilter[]", + "alias": "FullFilter[]", "optional": false } } }, { "type": "object", - "alias": "NormalFilter", + "alias": "NormalFilter>", "aliasSymbolescapedName": "NormalFilter", "comments": "Column filter with operators\nMultiple columns are combined with AND", "properties": { @@ -4305,52 +4419,21 @@ export const definitions = [ "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" } } }, { - "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }>", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {}, - "intersectionParent": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>" - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.$ilike`]: any; [x: `${string}.$like`]: any; [x: `${string}.$nilike`]: any; [x: `${string}.$nlike`]: any; }>", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ $exists: any; $notExists: any; $existsJoined: any; $notExistsJoined: any; }>", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", "aliasSymbolescapedName": "Partial", "comments": "Make all properties in T optional", "properties": { @@ -4381,29 +4464,230 @@ export const definitions = [ } } ], - "optional": false + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } - } + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" } }, "optional": false, - "comments": "Retrieves a list of matching records from the view/table and subscribes to changes" + "comments": "Retrieves a list of matching records from the view/table", + "intersectionParent": "ViewHandler" }, - "subscribeOne": { + "findOne": { "type": "function", - "alias": "

>(filter: FullFilter, params: P, onData: (item: GetSelectReturnType | undefined) => any, onError?: OnError | undefined) => Promise<...>", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise | undefined>", "arguments": [ { "name": "filter", - "optional": false, - "type": "reference", - "alias": "FullFilter", - "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" }, { - "name": "params", - "optional": false, + "name": "selectParams", + "optional": true, "type": "object", "alias": "SelectParams", "aliasSymbolescapedName": "SelectParams", @@ -4429,21 +4713,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -4486,13 +4773,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -4502,115 +4790,22 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - }, - { - "name": "onData", - "optional": false, - "type": "function", - "alias": "(item: GetSelectReturnType | undefined) => any", - "arguments": [ - { - "name": "item", - "optional": false, "type": "union", - "alias": "GetSelectReturnType | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", "alias": "undefined", "subType": "undefined" }, - { - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" - } - ], - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "comments": "" - }, - { - "name": "onError", - "optional": true, - "type": "function", - "alias": "OnError", - "aliasSymbolescapedName": "OnError", - "arguments": [ - { - "name": "err", - "optional": false, - "type": "primitive", - "alias": "any", - "subType": "any", - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "object", - "alias": "SubscriptionHandler", - "aliasSymbolescapedName": "SubscriptionHandler", - "comments": "", - "properties": { - "unsubscribe": { - "type": "function", - "alias": "() => Promise", - "arguments": [], - "returnType": { - "type": "promise", - "alias": "Promise", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "primitive", - "alias": "any", - "subType": "any" - } - }, - "optional": false - }, - "filter": { - "type": "union", - "alias": "{} | FullFilter", - "types": [ - { - "type": "object", - "alias": "{}", - "properties": {} - }, { "type": "object", "alias": "ComplexFilter", "aliasSymbolescapedName": "ComplexFilter", - "comments": "Complex filter that allows applying functions to columns", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", "properties": { "$filter": { "type": "primitive", @@ -4622,16 +4817,101 @@ export const definitions = [ }, { "type": "object", - "alias": "{ $and: FullFilter[]; }", + "alias": "{ $and: FullFilter[]; }", "properties": { "$and": { "type": "array", - "alias": "FullFilter[]", + "alias": "FullFilter[]", "itemType": { - "type": "reference", - "alias": "FullFilter", + "type": "union", + "alias": "FullFilter", "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] }, "optional": false } @@ -4639,18 +4919,18 @@ export const definitions = [ }, { "type": "object", - "alias": "{ $or: FullFilter[]; }", + "alias": "{ $or: FullFilter[]; }", "properties": { "$or": { "type": "reference", - "alias": "FullFilter[]", + "alias": "FullFilter[]", "optional": false } } }, { "type": "object", - "alias": "NormalFilter", + "alias": "NormalFilter>", "aliasSymbolescapedName": "NormalFilter", "comments": "Column filter with operators\nMultiple columns are combined with AND", "properties": { @@ -4658,52 +4938,21 @@ export const definitions = [ "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" } } }, { - "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }>", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {}, - "intersectionParent": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>" - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.$ilike`]: any; [x: `${string}.$like`]: any; [x: `${string}.$nilike`]: any; [x: `${string}.$nlike`]: any; }>", - "properties": {} - }, - { - "type": "object", - "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>", - "properties": {} + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { "type": "object", - "alias": "Partial<{ $exists: any; $notExists: any; $existsJoined: any; $notExistsJoined: any; }>", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", "aliasSymbolescapedName": "Partial", "comments": "Make all properties in T optional", "properties": { @@ -4734,28 +4983,139 @@ export const definitions = [ } } ], - "optional": false + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } - } + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise | undefined>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "union", + "alias": "GetSelectReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" + } + ] } }, "optional": false, - "comments": "Retrieves first matching record from the view/table and subscribes to changes" + "comments": "Retrieves a record from the view/table", + "intersectionParent": "ViewHandler" }, - "count": { + "subscribe": { "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise", + "alias": "

>(filter: FullFilter, params: P, onData: SubscribeCallback>, onError?: SubscribeOnError | undefined) => Promise<...>", "arguments": [ { "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" + "optional": false, + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] }, { - "name": "selectParams", - "optional": true, + "name": "params", + "optional": false, "type": "object", "alias": "SelectParams", "aliasSymbolescapedName": "SelectParams", @@ -4781,21 +5141,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -4838,13 +5201,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -4854,89 +5218,11 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "primitive", - "alias": "number", - "subType": "number" - } - }, - "optional": false, - "comments": "Returns the number of rows that match the filter" - }, - "size": { - "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" - }, - { - "name": "selectParams", - "optional": true, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" - }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" - }, - "groupBy": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" - }, - "returnType": { - "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", @@ -4944,383 +5230,4799 @@ export const definitions = [ "subType": "undefined" }, { - "type": "literal", - "alias": "\"row\"", - "value": "row" + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"value\"", - "value": "value" + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } }, { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } }, { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { + "comments": "Filter applied after any aggregations (group by)" + } + }, + "comments": "" + }, + { + "name": "onData", + "optional": false, + "type": "function", + "alias": "SubscribeCallback>", + "aliasSymbolescapedName": "SubscribeCallback", + "comments": "Callback fired once after subscribing and then every time the data matching the filter changes", + "arguments": [ + { + "name": "items", + "optional": false, "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", "subType": "any", - "optional": true - }, - "orderBy": { + "comments": "" + } + ], + "returnType": { + "type": "union", + "alias": "void | Promise", + "types": [ + { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "void", + "subType": "any" + } + } + ] + } + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "SubscribeOnError", + "aliasSymbolescapedName": "SubscribeOnError", + "comments": "Error handler that may fire due to schema changes or other post subscribe issues\nColumn or filter issues are thrown during the subscribe call", + "arguments": [ + { + "name": "err", + "optional": false, "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", + "alias": "any", "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "comments": "" } - }, - "comments": "" + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + } } ], "returnType": { "type": "promise", - "alias": "Promise", + "alias": "Promise", "comments": "Represents the completion of an asynchronous operation", "innerType": { - "type": "primitive", - "alias": "string", - "subType": "string" - } - }, - "optional": false, - "comments": "Returns result size in bits" - }, - "getJoinedTables": { - "type": "function", - "alias": "() => string[]", - "arguments": [], - "returnType": { - "type": "array", - "alias": "string[]", - "itemType": { - "type": "primitive", - "alias": "string", - "subType": "string" + "type": "object", + "alias": "SubscriptionHandler", + "aliasSymbolescapedName": "SubscriptionHandler", + "comments": "", + "properties": { + "unsubscribe": { + "type": "function", + "alias": "() => Promise", + "arguments": [], + "returnType": { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "any", + "subType": "any" + } + }, + "optional": false + }, + "filter": { + "type": "union", + "alias": "{} | FullFilter", + "types": [ + { + "type": "object", + "alias": "{}", + "properties": {} + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.$ilike`]: any; [x: `${string}.$like`]: any; [x: `${string}.$nilike`]: any; [x: `${string}.$nlike`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ $exists: any; $notExists: any; $existsJoined: any; $notExistsJoined: any; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": false + } + } } }, - "optional": false - }, - "_syncInfo": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "getSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + "optional": false, + "comments": "Retrieves a list of matching records from the view/table and subscribes to changes", + "intersectionParent": "ViewHandler" }, - "sync": { + "subscribeOne": { "type": "function", - "alias": "Sync", - "aliasSymbolescapedName": "Sync", + "alias": "

>(filter: FullFilter, params: P, onData: SubscribeOneCallback | undefined>, onError?: SubscribeOnError | undefined) => Promise<...>", "arguments": [ { - "name": "basicFilter", - "optional": false, - "type": "object", - "alias": "EqualityFilter", - "aliasSymbolescapedName": "EqualityFilter", - "comments": "Equality filter used for sync\nMultiple columns are combined with AND", - "properties": {} - }, - { - "name": "options", - "optional": false, - "type": "reference", - "alias": "SyncOptions", - "aliasSymbolescapedName": "SyncOptions", - "comments": "" - }, - { - "name": "onChange", + "name": "filter", "optional": false, - "type": "function", - "alias": "(data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any", - "arguments": [ + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ { - "name": "data", - "optional": false, - "type": "array", - "alias": "SyncDataItem, false>[]", - "itemType": { - "type": "object", - "alias": "SyncDataItem, false>", - "aliasSymbolescapedName": "SyncDataItem", - "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$unsync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$delete": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$update": { - "type": "primitive", - "alias": "any", + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + { + "name": "params", + "optional": false, + "type": "object", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" + }, + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" + } + ], + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" + }, + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" + } + }, + "comments": "" + }, + { + "name": "onData", + "optional": false, + "type": "function", + "alias": "SubscribeOneCallback | undefined>", + "aliasSymbolescapedName": "SubscribeOneCallback", + "comments": "Callback fired once after subscribing and then every time the data matching the filter changes", + "arguments": [ + { + "name": "item", + "optional": false, + "type": "union", + "alias": "GetSelectReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" + } + ], + "comments": "" + } + ], + "returnType": { + "type": "union", + "alias": "void | Promise", + "types": [ + { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "void", + "subType": "any" + } + } + ] + } + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "SubscribeOnError", + "aliasSymbolescapedName": "SubscribeOnError", + "comments": "Error handler that may fire due to schema changes or other post subscribe issues\nColumn or filter issues are thrown during the subscribe call", + "arguments": [ + { + "name": "err", + "optional": false, + "type": "primitive", + "alias": "any", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + } + } + ], + "returnType": { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "object", + "alias": "SubscriptionHandler", + "aliasSymbolescapedName": "SubscriptionHandler", + "comments": "", + "properties": { + "unsubscribe": { + "type": "function", + "alias": "() => Promise", + "arguments": [], + "returnType": { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "any", + "subType": "any" + } + }, + "optional": false + }, + "filter": { + "type": "union", + "alias": "{} | FullFilter", + "types": [ + { + "type": "object", + "alias": "{}", + "properties": {} + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "reference", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`" + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.=`]: any; [x: `${string}.$eq`]: any; [x: `${string}.<>`]: any; [x: `${string}.>`]: any; [x: `${string}.<`]: any; [x: `${string}.>=`]: any; [x: `${string}.<=`]: any; [x: `${string}.$ne`]: any; [x: `${string}.$gt`]: any; [x: `${string}.$gte`]: any; [x: `${string}.$lt`]: any; [x: `${string}.$lt...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.$ilike`]: any; [x: `${string}.$like`]: any; [x: `${string}.$nilike`]: any; [x: `${string}.$nlike`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ [x: `${string}.$in`]: any[]; [x: `${string}.$nin`]: any[]; }> & Partial<{ [x: `${string}.@@`]: any; [x: `${string}.@>`]: any; [x: `${string}.<@`]: any; [x: `${string}.$contains`]: any; [x: `${string}.$containedBy`]: any; }>", + "properties": {} + }, + { + "type": "object", + "alias": "Partial<{ $exists: any; $notExists: any; $existsJoined: any; $notExistsJoined: any; }>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": false + } + } + } + }, + "optional": false, + "comments": "Retrieves first matching record from the view/table and subscribes to changes", + "intersectionParent": "ViewHandler" + }, + "count": { + "type": "function", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" + }, + { + "name": "selectParams", + "optional": true, + "type": "object", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" + }, + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" + } + ], + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" + }, + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" + } + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "number", + "subType": "number" + } + }, + "optional": false, + "comments": "Returns the number of rows that match the filter", + "intersectionParent": "ViewHandler" + }, + "size": { + "type": "function", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => Promise", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" + }, + { + "name": "selectParams", + "optional": true, + "type": "object", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" + }, + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" + } + ], + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" + }, + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" + } + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "string", + "subType": "string" + } + }, + "optional": false, + "comments": "Returns result size in bits", + "intersectionParent": "ViewHandler" + }, + "getJoinedTables": { + "type": "function", + "alias": "() => string[]", + "arguments": [], + "returnType": { + "type": "array", + "alias": "string[]", + "itemType": { + "type": "primitive", + "alias": "string", + "subType": "string" + } + }, + "optional": false + }, + "_syncInfo": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "getSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "sync": { + "type": "function", + "alias": "Sync", + "aliasSymbolescapedName": "Sync", + "arguments": [ + { + "name": "basicFilter", + "optional": false, + "type": "object", + "alias": "EqualityFilter", + "aliasSymbolescapedName": "EqualityFilter", + "comments": "Equality filter used for sync\nMultiple columns are combined with AND", + "properties": {} + }, + { + "name": "options", + "optional": false, + "type": "reference", + "alias": "SyncOptions", + "aliasSymbolescapedName": "SyncOptions", + "comments": "" + }, + { + "name": "onChange", + "optional": false, + "type": "function", + "alias": "(data: SyncDataItem, false>[], delta?: Partial[] | undefined) => any", + "arguments": [ + { + "name": "data", + "optional": false, + "type": "array", + "alias": "SyncDataItem, false>[]", + "itemType": { + "type": "object", + "alias": "SyncDataItem, false>", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + "comments": "" + }, + { + "name": "delta", + "optional": true, + "type": "array", + "alias": "Partial[]", + "itemType": { + "type": "object", + "alias": "Partial", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "comments": "" + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "(error: any) => void", + "arguments": [ + { + "name": "error", + "optional": false, + "type": "primitive", + "alias": "any", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise<{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "object", + "alias": "{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }", + "properties": { + "$unsync": { + "type": "function", + "alias": "() => void", + "arguments": [], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "optional": false + }, + "$upsert": { + "type": "function", + "alias": "(newData: T[]) => any", + "arguments": [ + { + "name": "newData", + "optional": false, + "type": "array", + "alias": "T[]", + "itemType": { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {}, + "intersectionParent": "SyncDataItem" + }, + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "optional": false + }, + "getItems": { + "type": "function", + "alias": "() => T[]", + "arguments": [], + "returnType": { + "type": "array", + "alias": "T[]", + "itemType": { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {}, + "intersectionParent": "SyncDataItem" + } + }, + "optional": false + } + } + } + }, + "optional": true + }, + "useSync": { + "type": "function", + "alias": "(basicFilter: EqualityFilter, syncOptions: SyncOptions) => { data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }", + "arguments": [ + { + "name": "basicFilter", + "optional": false, + "type": "object", + "alias": "EqualityFilter", + "aliasSymbolescapedName": "EqualityFilter", + "comments": "Equality filter used for sync\nMultiple columns are combined with AND", + "properties": {} + }, + { + "name": "syncOptions", + "optional": false, + "type": "reference", + "alias": "SyncOptions", + "aliasSymbolescapedName": "SyncOptions", + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "{ data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }", + "properties": { + "data": { + "type": "union", + "alias": "SyncDataItem>[] | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "array", + "alias": "SyncDataItem>[]", + "itemType": { + "type": "object", + "alias": "SyncDataItem>", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + } + } + ], + "optional": false + }, + "isLoading": { + "type": "union", + "alias": "boolean", + "types": [ + { + "type": "primitive", + "alias": "false", + "subType": "boolean" + } + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + }, + "optional": true, + "comments": "Retrieves rows matching the filter and keeps them in sync\n- use { handlesOnData: true } to get optimistic updates method: $update\n- any changes to the row using the $update method will be reflected instantly\n to all sync subscribers that were initiated with the same syncOptions" + }, + "syncOne": { + "type": "function", + "alias": "SyncOne", + "aliasSymbolescapedName": "SyncOne", + "arguments": [ + { + "name": "basicFilter", + "optional": false, + "type": "object", + "alias": "Partial", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + }, + { + "name": "options", + "optional": false, + "type": "reference", + "alias": "SyncOneOptions", + "aliasSymbolescapedName": "SyncOneOptions", + "comments": "" + }, + { + "name": "onChange", + "optional": false, + "type": "function", + "alias": "(data: SyncDataItem, false>, delta?: Partial | undefined) => any", + "arguments": [ + { + "name": "data", + "optional": false, + "type": "object", + "alias": "SyncDataItem, false>", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + }, + "comments": "" + }, + { + "name": "delta", + "optional": true, + "type": "object", + "alias": "Partial", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "comments": "" + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "(error: any) => void", + "arguments": [ + { + "name": "error", + "optional": false, + "type": "primitive", + "alias": "any", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "comments": "" + } + ], + "returnType": { + "type": "promise", + "alias": "Promise>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "object", + "alias": "SingleSyncHandles", + "aliasSymbolescapedName": "SingleSyncHandles", + "comments": "CRUD handles added if initialised with handlesOnData = true", + "properties": { + "$get": { + "type": "function", + "alias": "() => T | undefined", + "arguments": [], + "returnType": { + "type": "union", + "alias": "T | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {}, + "intersectionParent": "SyncDataItem" + } + ] + }, + "optional": false + }, + "$find": { + "type": "function", + "alias": "(idObj: Partial) => T | undefined", + "arguments": [ + { + "name": "idObj", + "optional": false, + "type": "object", + "alias": "Partial", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + } + ], + "returnType": { + "type": "union", + "alias": "T | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {}, + "intersectionParent": "SyncDataItem" + } + ] + }, + "optional": false + }, + "$unsync": { + "type": "function", + "alias": "() => any", + "arguments": [], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "optional": false + }, + "$delete": { + "type": "function", + "alias": "() => void", + "arguments": [], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "optional": false + }, + "$update": { + "type": "function", + "alias": "(newData: OPTS extends { deepMerge: true; } ? DeepPartial : Partial, opts?: OPTS | undefined) => any", + "arguments": [ + { + "name": "newData", + "optional": false, + "type": "primitive", + "alias": "OPTS extends { deepMerge: true; } ? DeepPartial : Partial", + "subType": "any", + "comments": "" + }, + { + "name": "opts", + "optional": true, + "type": "object", + "alias": "$UpdateOpts", + "aliasSymbolescapedName": "$UpdateOpts", + "comments": "", + "properties": { + "deepMerge": { + "type": "union", + "alias": "boolean", + "types": [ + { + "type": "primitive", + "alias": "false", + "subType": "boolean" + } + ], + "optional": false + } + } + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "optional": false + }, + "$cloneSync": { + "type": "function", + "alias": "CloneSync", + "aliasSymbolescapedName": "CloneSync", + "arguments": [ + { + "name": "onChange", + "optional": false, + "type": "function", + "alias": "SingleChangeListener", + "aliasSymbolescapedName": "SingleChangeListener", + "arguments": [ + { + "name": "item", + "optional": false, + "type": "object", + "alias": "SyncDataItem", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + }, + "comments": "" + }, + { + "name": "delta", + "optional": true, + "type": "primitive", + "alias": "DeepPartial", + "aliasSymbolescapedName": "DeepPartial", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "comments": "" + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "(error: any) => void", + "arguments": [ + { + "name": "error", + "optional": false, + "type": "primitive", + "alias": "any", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "comments": "" + } + ], + "returnType": { + "type": "reference", + "alias": "SingleSyncHandles", + "aliasSymbolescapedName": "SingleSyncHandles", + "comments": "CRUD handles added if initialised with handlesOnData = true" + }, + "optional": false + }, + "$cloneMultiSync": { + "type": "function", + "alias": "CloneMultiSync", + "aliasSymbolescapedName": "CloneMultiSync", + "arguments": [ + { + "name": "onChange", + "optional": false, + "type": "function", + "alias": "MultiChangeListener", + "aliasSymbolescapedName": "MultiChangeListener", + "arguments": [ + { + "name": "items", + "optional": false, + "type": "array", + "alias": "SyncDataItem[]", + "itemType": { + "type": "object", + "alias": "SyncDataItem", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + "comments": "" + }, + { + "name": "delta", + "optional": false, + "type": "array", + "alias": "DeepPartial[]", + "itemType": { + "type": "primitive", + "alias": "DeepPartial", + "aliasSymbolescapedName": "DeepPartial", + "subType": "any" + }, + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "comments": "" + }, + { + "name": "onError", + "optional": true, + "type": "function", + "alias": "(error: any) => void", + "arguments": [ + { + "name": "error", + "optional": false, + "type": "primitive", + "alias": "any", + "subType": "any", + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "MultiSyncHandles", + "aliasSymbolescapedName": "MultiSyncHandles", + "comments": "", + "properties": { + "$unsync": { + "type": "function", + "alias": "() => void", + "arguments": [], + "returnType": { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + "optional": false + }, + "$upsert": { + "type": "function", + "alias": "(newData: T[]) => any", + "arguments": [ + { + "name": "newData", + "optional": false, + "type": "array", + "alias": "T[]", + "itemType": { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {}, + "intersectionParent": "SyncDataItem" + }, + "comments": "" + } + ], + "returnType": { + "type": "primitive", + "alias": "any", + "subType": "any" + }, + "optional": false + }, + "getItems": { + "type": "function", + "alias": "() => AnyObject[]", + "arguments": [], + "returnType": { + "type": "array", + "alias": "AnyObject[]", + "itemType": { + "type": "object", + "alias": "AnyObject", + "aliasSymbolescapedName": "AnyObject", + "comments": "", + "properties": {} + } + }, + "optional": false + } + } + }, + "optional": false + } + } + } + }, + "optional": true + }, + "useSyncOne": { + "type": "function", + "alias": "(basicFilter: EqualityFilter, syncOptions: SyncOneOptions) => { data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }", + "arguments": [ + { + "name": "basicFilter", + "optional": false, + "type": "object", + "alias": "EqualityFilter", + "aliasSymbolescapedName": "EqualityFilter", + "comments": "Equality filter used for sync\nMultiple columns are combined with AND", + "properties": {} + }, + { + "name": "syncOptions", + "optional": false, + "type": "reference", + "alias": "SyncOneOptions", + "aliasSymbolescapedName": "SyncOneOptions", + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "{ data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }", + "properties": { + "data": { + "type": "union", + "alias": "SyncDataItem> | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "SyncDataItem>", + "aliasSymbolescapedName": "SyncDataItem", + "properties": { + "$get": { + "type": "primitive", + "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" + }, + "$find": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$unsync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$delete": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + }, + "$update": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" }, "$cloneSync": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" + }, + "$cloneMultiSync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + } + ], + "optional": false + }, + "isLoading": { + "type": "union", + "alias": "boolean", + "types": [ + { + "type": "primitive", + "alias": "false", + "subType": "boolean" + } + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + }, + "optional": true, + "comments": "Retrieves the first row matching the filter and keeps it in sync\n- use { handlesOnData: true } to get optimistic updates method: $update\n- any changes to the row using the $update method will be reflected instantly\n to all sync subscribers that were initiated with the same syncOptions" + }, + "_sync": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "useSubscribe": { + "type": "function", + "alias": ">(filter?: FullFilter | undefined, options?: SubParams | undefined) => { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" + }, + { + "name": "options", + "optional": true, + "type": "object", + "alias": "SubscribeParams", + "aliasSymbolescapedName": "SubscribeParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" + }, + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" + } + ], + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" + }, + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" + }, + "throttle": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "If true then the subscription will be throttled to the provided number of milliseconds" + }, + "throttleOpts": { + "type": "object", + "alias": "{ skipFirst?: boolean | undefined; }", + "properties": { + "skipFirst": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "False by default.\nIf true then the first value will be emitted at the end of the interval. Instant otherwise" + } + }, + "optional": true + } + }, + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", + "properties": { + "data": { + "type": "union", + "alias": "GetSelectReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" + } + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "isLoading": { + "type": "union", + "alias": "boolean", + "types": [ + { + "type": "primitive", + "alias": "false", + "subType": "boolean" + } + ], + "optional": false + } + } + }, + "optional": false, + "comments": "Retrieves a list of matching records from the view/table and subscribes to changes" + }, + "useSubscribeOne": { + "type": "function", + "alias": ">(filter?: FullFilter | undefined, options?: SubParams | undefined) => { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] }, - "$cloneMultiSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" + }, + { + "name": "options", + "optional": true, + "type": "object", + "alias": "SubscribeParams", + "aliasSymbolescapedName": "SubscribeParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" + }, + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" + } + ], + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" + }, + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } } } - }, - "comments": "" + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" }, - { - "name": "delta", + "throttle": { + "type": "primitive", + "alias": "number", + "subType": "number", "optional": true, - "type": "array", - "alias": "Partial[]", - "itemType": { - "type": "object", - "alias": "Partial", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} + "comments": "If true then the subscription will be throttled to the provided number of milliseconds" + }, + "throttleOpts": { + "type": "object", + "alias": "{ skipFirst?: boolean | undefined; }", + "properties": { + "skipFirst": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "False by default.\nIf true then the first value will be emitted at the end of the interval. Instant otherwise" + } }, - "comments": "" + "optional": true } - ], - "returnType": { + }, + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", + "properties": { + "data": { + "type": "union", + "alias": "GetSelectReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" + } + ], + "optional": false + }, + "error": { "type": "primitive", "alias": "any", - "subType": "any" + "subType": "any", + "optional": true }, - "comments": "" - }, + "isLoading": { + "type": "union", + "alias": "boolean", + "types": [ + { + "type": "primitive", + "alias": "false", + "subType": "boolean" + } + ], + "optional": false + } + } + }, + "optional": false, + "comments": "Retrieves a matching record from the view/table and subscribes to changes" + }, + "useFind": { + "type": "function", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", + "arguments": [ { - "name": "onError", + "name": "filter", "optional": true, - "type": "function", - "alias": "(error: any) => void", - "arguments": [ + "type": "union", + "alias": "FullFilter | undefined", + "types": [ { - "name": "error", - "optional": false, "type": "primitive", - "alias": "any", - "subType": "any", - "comments": "" + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise<{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { + }, + { + "name": "selectParams", + "optional": true, "type": "object", - "alias": "{ $unsync: () => void; $upsert: (newData: T[]) => any; getItems: () => T[]; }", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", "properties": { - "$unsync": { - "type": "function", - "alias": "() => void", - "arguments": [], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "optional": false + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" + } + ], + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, - "$upsert": { - "type": "function", - "alias": "(newData: T[]) => any", - "arguments": [ + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" + }, + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" + }, + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, { - "name": "newData", - "optional": false, - "type": "array", - "alias": "T[]", - "itemType": { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {}, - "intersectionParent": "SyncDataItem" - }, - "comments": "" + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" } ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "optional": false + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, - "getItems": { - "type": "function", - "alias": "() => T[]", - "arguments": [], - "returnType": { - "type": "array", - "alias": "T[]", - "itemType": { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {}, - "intersectionParent": "SyncDataItem" - } - }, - "optional": false - } - } - } - }, - "optional": true - }, - "useSync": { - "type": "function", - "alias": "(basicFilter: EqualityFilter, syncOptions: SyncOptions) => { data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }", - "arguments": [ - { - "name": "basicFilter", - "optional": false, - "type": "object", - "alias": "EqualityFilter", - "aliasSymbolescapedName": "EqualityFilter", - "comments": "Equality filter used for sync\nMultiple columns are combined with AND", - "properties": {} - }, - { - "name": "syncOptions", - "optional": false, - "type": "reference", - "alias": "SyncOptions", - "aliasSymbolescapedName": "SyncOptions", - "comments": "" - } - ], - "returnType": { - "type": "object", - "alias": "{ data: SyncDataItem>[] | undefined; isLoading: boolean; error?: any; }", - "properties": { - "data": { - "type": "union", - "alias": "SyncDataItem>[] | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "array", - "alias": "SyncDataItem>[]", - "itemType": { + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { "type": "object", - "alias": "SyncDataItem>", - "aliasSymbolescapedName": "SyncDataItem", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true - }, - "$unsync": { + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true - }, - "$delete": { + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { "type": "primitive", "alias": "any", "subType": "any", "optional": true }, - "$update": { + "$notExists": { "type": "primitive", "alias": "any", "subType": "any", "optional": true }, - "$cloneSync": { + "$existsJoined": { "type": "primitive", "alias": "any", "subType": "any", "optional": true }, - "$cloneMultiSync": { + "$notExistsJoined": { "type": "primitive", "alias": "any", "subType": "any", @@ -5328,6 +10030,32 @@ export const definitions = [ } } } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" + } + }, + "comments": "" + } + ], + "returnType": { + "type": "object", + "alias": "{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", + "properties": { + "data": { + "type": "union", + "alias": "GetSelectReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" } ], "optional": false @@ -5352,586 +10080,520 @@ export const definitions = [ } } }, - "optional": true, - "comments": "Retrieves rows matching the filter and keeps them in sync\n- use { handlesOnData: true } to get optimistic updates method: $update\n- any changes to the row using the $update method will be reflected instantly\n to all sync subscribers that were initiated with the same syncOptions" + "optional": false, + "comments": "Retrieves a list of matching records from the view/table" }, - "syncOne": { + "useFindOne": { "type": "function", - "alias": "SyncOne", - "aliasSymbolescapedName": "SyncOne", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", "arguments": [ { - "name": "basicFilter", - "optional": false, - "type": "object", - "alias": "Partial", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - }, - { - "name": "options", - "optional": false, - "type": "reference", - "alias": "SyncOneOptions", - "aliasSymbolescapedName": "SyncOneOptions", - "comments": "" - }, - { - "name": "onChange", - "optional": false, - "type": "function", - "alias": "(data: SyncDataItem, false>, delta?: Partial | undefined) => any", - "arguments": [ + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, { - "name": "data", - "optional": false, "type": "object", - "alias": "SyncDataItem, false>", - "aliasSymbolescapedName": "SyncDataItem", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$unsync": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true - }, - "$delete": { + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true - }, - "$update": { + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { "type": "primitive", "alias": "any", "subType": "any", "optional": true }, - "$cloneSync": { + "$notExists": { "type": "primitive", "alias": "any", "subType": "any", "optional": true }, - "$cloneMultiSync": { + "$existsJoined": { "type": "primitive", "alias": "any", - "subType": "any", - "optional": true - } - }, - "comments": "" - }, - { - "name": "delta", - "optional": true, - "type": "object", - "alias": "Partial", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - } - ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "comments": "" - }, - { - "name": "onError", - "optional": true, - "type": "function", - "alias": "(error: any) => void", - "arguments": [ - { - "name": "error", - "optional": false, - "type": "primitive", - "alias": "any", - "subType": "any", - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "object", - "alias": "SingleSyncHandles", - "aliasSymbolescapedName": "SingleSyncHandles", - "comments": "CRUD handles added if initialised with handlesOnData = true", - "properties": { - "$get": { - "type": "function", - "alias": "() => T | undefined", - "arguments": [], - "returnType": { - "type": "union", - "alias": "T | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {}, - "intersectionParent": "SyncDataItem" - } - ] - }, - "optional": false - }, - "$find": { - "type": "function", - "alias": "(idObj: Partial) => T | undefined", - "arguments": [ + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "comments": "" + }, + { + "name": "selectParams", + "optional": true, + "type": "object", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", + "properties": { + "limit": { + "type": "union", + "alias": "number | null | undefined", + "types": [ { - "name": "idObj", - "optional": false, - "type": "object", - "alias": "Partial", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "null", + "subType": "null" + }, + { + "type": "primitive", + "alias": "number", + "subType": "number" } ], - "returnType": { - "type": "union", - "alias": "T | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {}, - "intersectionParent": "SyncDataItem" - } - ] - }, - "optional": false + "optional": true, + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, - "$unsync": { - "type": "function", - "alias": "() => any", - "arguments": [], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "optional": false + "offset": { + "type": "primitive", + "alias": "number", + "subType": "number", + "optional": true, + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, - "$delete": { - "type": "function", - "alias": "() => void", - "arguments": [], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "optional": false + "groupBy": { + "type": "primitive", + "alias": "false", + "subType": "boolean", + "optional": true, + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, - "$update": { - "type": "function", - "alias": "(newData: OPTS extends { deepMerge: true; } ? DeepPartial : Partial, opts?: OPTS | undefined) => any", - "arguments": [ + "returnType": { + "type": "union", + "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "types": [ { - "name": "newData", - "optional": false, "type": "primitive", - "alias": "OPTS extends { deepMerge: true; } ? DeepPartial : Partial", - "subType": "any", - "comments": "" + "alias": "undefined", + "subType": "undefined" }, { - "name": "opts", - "optional": true, - "type": "object", - "alias": "$UpdateOpts", - "aliasSymbolescapedName": "$UpdateOpts", - "comments": "", - "properties": { - "deepMerge": { - "type": "union", - "alias": "boolean", - "types": [ - { - "type": "primitive", - "alias": "false", - "subType": "boolean" - } - ], - "optional": false - } - } + "type": "literal", + "alias": "\"row\"", + "value": "row" + }, + { + "type": "literal", + "alias": "\"value\"", + "value": "value" + }, + { + "type": "literal", + "alias": "\"values\"", + "value": "values" + }, + { + "type": "literal", + "alias": "\"statement\"", + "value": "statement" + }, + { + "type": "literal", + "alias": "\"statement-no-rls\"", + "value": "statement-no-rls" + }, + { + "type": "literal", + "alias": "\"statement-where\"", + "value": "statement-where" } ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "optional": false + "optional": true, + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, - "$cloneSync": { - "type": "function", - "alias": "CloneSync", - "aliasSymbolescapedName": "CloneSync", - "arguments": [ - { - "name": "onChange", - "optional": false, - "type": "function", - "alias": "SingleChangeListener", - "aliasSymbolescapedName": "SingleChangeListener", - "arguments": [ - { - "name": "item", - "optional": false, - "type": "object", - "alias": "SyncDataItem", - "aliasSymbolescapedName": "SyncDataItem", - "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$unsync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$delete": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$update": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$cloneSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$cloneMultiSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - }, - "comments": "" - }, - { - "name": "delta", - "optional": true, - "type": "primitive", - "alias": "DeepPartial", - "aliasSymbolescapedName": "DeepPartial", - "subType": "any", - "comments": "" - } - ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "comments": "" + "select": { + "type": "primitive", + "alias": "Select", + "aliasSymbolescapedName": "Select", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", + "subType": "any", + "optional": true + }, + "orderBy": { + "type": "primitive", + "alias": "OrderBy", + "aliasSymbolescapedName": "OrderBy", + "subType": "any", + "optional": true, + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" }, { - "name": "onError", - "optional": true, - "type": "function", - "alias": "(error: any) => void", - "arguments": [ - { - "name": "error", - "optional": false, + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "comments": "" + "optional": false } - ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "comments": "" - } - ], - "returnType": { - "type": "reference", - "alias": "SingleSyncHandles", - "aliasSymbolescapedName": "SingleSyncHandles", - "comments": "CRUD handles added if initialised with handlesOnData = true" - }, - "optional": false - }, - "$cloneMultiSync": { - "type": "function", - "alias": "CloneMultiSync", - "aliasSymbolescapedName": "CloneMultiSync", - "arguments": [ + } + }, { - "name": "onChange", - "optional": false, - "type": "function", - "alias": "MultiChangeListener", - "aliasSymbolescapedName": "MultiChangeListener", - "arguments": [ - { - "name": "items", - "optional": false, + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { "type": "array", - "alias": "SyncDataItem[]", + "alias": "FullFilter[]", "itemType": { - "type": "object", - "alias": "SyncDataItem", - "aliasSymbolescapedName": "SyncDataItem", - "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } }, - "$unsync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" }, - "$delete": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, - "$update": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } }, - "$cloneSync": { + { "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, - "$cloneMultiSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } - } - }, - "comments": "" - }, - { - "name": "delta", - "optional": false, - "type": "array", - "alias": "DeepPartial[]", - "itemType": { - "type": "primitive", - "alias": "DeepPartial", - "aliasSymbolescapedName": "DeepPartial", - "subType": "any" + ] }, - "comments": "" + "optional": false } - ], - "returnType": { - "type": "primitive", - "alias": "any", - "subType": "any" - }, - "comments": "" + } }, { - "name": "onError", - "optional": true, - "type": "function", - "alias": "(error: any) => void", - "arguments": [ - { - "name": "error", - "optional": false, + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { "type": "primitive", "alias": "any", "subType": "any", - "comments": "" + "optional": true, + "intersectionParent": "Partial" } - ], - "returnType": { - "type": "primitive", - "alias": "void", - "subType": "any" - }, - "comments": "" - } - ], - "returnType": { - "type": "object", - "alias": "MultiSyncHandles", - "aliasSymbolescapedName": "MultiSyncHandles", - "comments": "", - "properties": { - "$unsync": { - "type": "function", - "alias": "() => void", - "arguments": [], - "returnType": { + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { "type": "primitive", - "alias": "void", - "subType": "any" - }, - "optional": false - }, - "$upsert": { - "type": "function", - "alias": "(newData: T[]) => any", - "arguments": [ - { - "name": "newData", - "optional": false, - "type": "array", - "alias": "T[]", - "itemType": { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {}, - "intersectionParent": "SyncDataItem" - }, - "comments": "" - } - ], - "returnType": { + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { "type": "primitive", "alias": "any", - "subType": "any" + "subType": "any", + "optional": true }, - "optional": false - }, - "getItems": { - "type": "function", - "alias": "() => AnyObject[]", - "arguments": [], - "returnType": { - "type": "array", - "alias": "AnyObject[]", - "itemType": { - "type": "object", - "alias": "AnyObject", - "aliasSymbolescapedName": "AnyObject", - "comments": "", - "properties": {} - } + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true }, - "optional": false + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } } } - }, - "optional": false + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } - } - } - }, - "optional": true - }, - "useSyncOne": { - "type": "function", - "alias": "(basicFilter: EqualityFilter, syncOptions: SyncOneOptions) => { data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }", - "arguments": [ - { - "name": "basicFilter", - "optional": false, - "type": "object", - "alias": "EqualityFilter", - "aliasSymbolescapedName": "EqualityFilter", - "comments": "Equality filter used for sync\nMultiple columns are combined with AND", - "properties": {} - }, - { - "name": "syncOptions", - "optional": false, - "type": "reference", - "alias": "SyncOneOptions", - "aliasSymbolescapedName": "SyncOneOptions", + }, "comments": "" } ], "returnType": { "type": "object", - "alias": "{ data: SyncDataItem> | undefined; isLoading: boolean; error?: any; }", + "alias": "{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", "properties": { "data": { "type": "union", - "alias": "SyncDataItem> | undefined", + "alias": "GetSelectReturnType | undefined", "types": [ { "type": "primitive", @@ -5939,53 +10601,10 @@ export const definitions = [ "subType": "undefined" }, { - "type": "object", - "alias": "SyncDataItem>", - "aliasSymbolescapedName": "SyncDataItem", - "properties": { - "$get": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$find": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$unsync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$delete": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$update": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$cloneSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$cloneMultiSync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - } + "type": "primitive", + "alias": "GetSelectReturnType", + "aliasSymbolescapedName": "GetSelectReturnType", + "subType": "any" } ], "optional": false @@ -5999,43 +10618,225 @@ export const definitions = [ "alias": "false", "subType": "boolean" } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - } - }, - "optional": true, - "comments": "Retrieves the first row matching the filter and keeps it in sync\n- use { handlesOnData: true } to get optimistic updates method: $update\n- any changes to the row using the $update method will be reflected instantly\n to all sync subscribers that were initiated with the same syncOptions" - }, - "_sync": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "useSubscribe": { - "type": "function", - "alias": ">(filter?: FullFilter | undefined, options?: SubParams | undefined) => { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + }, + "optional": false, + "comments": "Retrieves first matching record from the view/table" + }, + "useCount": { + "type": "function", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: number | undefined; isLoading: boolean; error?: any; }", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], "comments": "" }, { - "name": "options", + "name": "selectParams", "optional": true, "type": "object", - "alias": "SubscribeParams", - "aliasSymbolescapedName": "SubscribeParams", + "alias": "SelectParams", + "aliasSymbolescapedName": "SelectParams", "properties": { "limit": { "type": "union", @@ -6058,21 +10859,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -6115,13 +10919,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -6131,142 +10936,11 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - }, - "throttle": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "If true then the subscription will be throttled to the provided number of milliseconds" - }, - "throttleOpts": { - "type": "object", - "alias": "{ skipFirst?: boolean | undefined; }", - "properties": { - "skipFirst": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "False by default.\nIf true then the first value will be emitted at the end of the interval. Instant otherwise" - } - }, - "optional": true - } - }, - "comments": "" - } - ], - "returnType": { - "type": "object", - "alias": "{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", - "properties": { - "data": { - "type": "union", - "alias": "GetSelectReturnType | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" - } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "isLoading": { - "type": "union", - "alias": "boolean", - "types": [ - { - "type": "primitive", - "alias": "false", - "subType": "boolean" - } - ], - "optional": false - } - } - }, - "optional": false, - "comments": "Retrieves a list of matching records from the view/table and subscribes to changes" - }, - "useSubscribeOne": { - "type": "function", - "alias": ">(filter?: FullFilter | undefined, options?: SubParams | undefined) => { data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" - }, - { - "name": "options", - "optional": true, - "type": "object", - "alias": "SubscribeParams", - "aliasSymbolescapedName": "SubscribeParams", - "properties": { - "limit": { - "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" - }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" - }, - "groupBy": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" - }, - "returnType": { "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", @@ -6274,81 +10948,189 @@ export const definitions = [ "subType": "undefined" }, { - "type": "literal", - "alias": "\"row\"", - "value": "row" + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"value\"", - "value": "value" + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } }, { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } }, { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - }, - "throttle": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "If true then the subscription will be throttled to the provided number of milliseconds" - }, - "throttleOpts": { - "type": "object", - "alias": "{ skipFirst?: boolean | undefined; }", - "properties": { - "skipFirst": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "False by default.\nIf true then the first value will be emitted at the end of the interval. Instant otherwise" - } - }, - "optional": true + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" @@ -6356,11 +11138,11 @@ export const definitions = [ ], "returnType": { "type": "object", - "alias": "{ data: GetSelectReturnType | undefined; error?: any; isLoading: boolean; }", + "alias": "{ data: number | undefined; isLoading: boolean; error?: any; }", "properties": { "data": { "type": "union", - "alias": "GetSelectReturnType | undefined", + "alias": "number | undefined", "types": [ { "type": "primitive", @@ -6369,19 +11151,12 @@ export const definitions = [ }, { "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" + "alias": "number", + "subType": "number" } ], "optional": false }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, "isLoading": { "type": "union", "alias": "boolean", @@ -6391,23 +11166,217 @@ export const definitions = [ "alias": "false", "subType": "boolean" } - ], - "optional": false - } - } - }, - "optional": false, - "comments": "Retrieves a matching record from the view/table and subscribes to changes" - }, - "useFind": { - "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + }, + "optional": false, + "comments": "Returns the total number of rows matching the filter" + }, + "useSize": { + "type": "function", + "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: string | undefined; isLoading: boolean; error?: any; }", + "arguments": [ + { + "name": "filter", + "optional": true, + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], "comments": "" }, { @@ -6438,21 +11407,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -6495,13 +11467,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -6511,13 +11484,201 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", + "type": "union", "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" @@ -6525,11 +11686,11 @@ export const definitions = [ ], "returnType": { "type": "object", - "alias": "{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", + "alias": "{ data: string | undefined; isLoading: boolean; error?: any; }", "properties": { "data": { "type": "union", - "alias": "GetSelectReturnType | undefined", + "alias": "string | undefined", "types": [ { "type": "primitive", @@ -6538,9 +11699,8 @@ export const definitions = [ }, { "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" + "alias": "string", + "subType": "string" } ], "optional": false @@ -6554,33 +11714,128 @@ export const definitions = [ "alias": "false", "subType": "boolean" } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - } - }, - "optional": false, - "comments": "Retrieves a list of matching records from the view/table" - }, - "useFindOne": { - "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", - "arguments": [ + ], + "optional": false + }, + "error": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + }, + "optional": false, + "comments": "Returns result size in bits matching the filter and selectParams" + }, + "update": { + "type": "function", + "alias": "

>(filter: FullFilter, newData: Partial>, params?: P | undefined) => Promise<...>", + "arguments": [ + { + "name": "filter", + "optional": false, + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" + "name": "newData", + "optional": false, + "type": "object", + "alias": "Partial>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} }, { - "name": "selectParams", + "name": "params", "optional": true, "type": "object", "alias": "SelectParams", @@ -6607,21 +11862,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -6664,13 +11922,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -6680,76 +11939,344 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", + "type": "union", "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" } ], "returnType": { - "type": "object", - "alias": "{ data: GetSelectReturnType | undefined; isLoading: boolean; error?: any; }", - "properties": { - "data": { - "type": "union", - "alias": "GetSelectReturnType | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "GetSelectReturnType", - "aliasSymbolescapedName": "GetSelectReturnType", - "subType": "any" - } - ], - "optional": false - }, - "isLoading": { - "type": "union", - "alias": "boolean", - "types": [ - { - "type": "primitive", - "alias": "false", - "subType": "boolean" - } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } + "type": "promise", + "alias": "Promise | undefined>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "union", + "alias": "GetUpdateReturnType | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "primitive", + "alias": "GetUpdateReturnType", + "aliasSymbolescapedName": "GetUpdateReturnType", + "subType": "any" + } + ] } }, "optional": false, - "comments": "Retrieves first matching record from the view/table" + "comments": "Updates a record in the table based on the specified filter criteria\n- Use { multi: false } to ensure no more than one row is updated" }, - "useCount": { + "updateBatch": { "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: number | undefined; isLoading: boolean; error?: any; }", + "alias": "

>(data: [FullFilter, Partial>][], params?: P | undefined) => Promise<...>", "arguments": [ { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", + "name": "data", + "optional": false, + "type": "tuple", + "alias": "[FullFilter, Partial>][]", + "itemTypes": [ + { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + { + "type": "object", + "alias": "Partial>", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": {} + } + ], "comments": "" }, { - "name": "selectParams", + "name": "params", "optional": true, "type": "object", "alias": "SelectParams", @@ -6776,21 +12303,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -6833,13 +12363,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -6849,75 +12380,265 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" + }, + "having": { + "type": "union", + "alias": "FullFilter | undefined", + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" } ], "returnType": { - "type": "object", - "alias": "{ data: number | undefined; isLoading: boolean; error?: any; }", - "properties": { - "data": { - "type": "union", - "alias": "number | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": false - }, - "isLoading": { - "type": "union", - "alias": "boolean", - "types": [ - { - "type": "primitive", - "alias": "false", - "subType": "boolean" - } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } + "type": "promise", + "alias": "Promise>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "union", + "alias": "void | GetUpdateReturnType", + "types": [ + { + "type": "primitive", + "alias": "void", + "subType": "any" + }, + { + "type": "primitive", + "alias": "GetUpdateReturnType", + "aliasSymbolescapedName": "GetUpdateReturnType", + "subType": "any" + } + ] } }, "optional": false, - "comments": "Returns the total number of rows matching the filter" + "comments": "Updates multiple records in the table in a batch operation.\n- Each item in the `data` array contains a filter and the corresponding data to update." }, - "useSize": { + "insert": { "type": "function", - "alias": "

>(filter?: FullFilter | undefined, selectParams?: P | undefined) => { data: string | undefined; isLoading: boolean; error?: any; }", + "alias": "

, D extends InsertData>(data: D, params?: P | undefined) => Promise>", "arguments": [ { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", + "name": "data", + "optional": false, + "type": "union", + "alias": "InsertData", + "aliasSymbolescapedName": "InsertData", + "types": [ + { + "type": "object", + "alias": "UpsertDataToPGCast", + "aliasSymbolescapedName": "UpsertDataToPGCast", + "comments": "", + "properties": {} + }, + { + "type": "array", + "alias": "UpsertDataToPGCast[]", + "itemType": { + "type": "object", + "alias": "UpsertDataToPGCast", + "aliasSymbolescapedName": "UpsertDataToPGCast", + "comments": "", + "properties": {} + } + } + ], "comments": "" }, { - "name": "selectParams", + "name": "params", "optional": true, "type": "object", "alias": "SelectParams", @@ -6944,21 +12665,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -7001,13 +12725,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -7017,73 +12742,316 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", + "type": "union", "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "types": [ + { + "type": "primitive", + "alias": "undefined", + "subType": "undefined" + }, + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ], + "optional": true, + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" } ], "returnType": { - "type": "object", - "alias": "{ data: string | undefined; isLoading: boolean; error?: any; }", - "properties": { - "data": { - "type": "union", - "alias": "string | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "string", - "subType": "string" - } - ], - "optional": false - }, - "isLoading": { - "type": "union", - "alias": "boolean", - "types": [ - { - "type": "primitive", - "alias": "false", - "subType": "boolean" - } - ], - "optional": false - }, - "error": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } + "type": "promise", + "alias": "Promise>", + "comments": "Represents the completion of an asynchronous operation", + "innerType": { + "type": "primitive", + "alias": "GetInsertReturnType", + "aliasSymbolescapedName": "GetInsertReturnType", + "subType": "any" } }, "optional": false, - "comments": "Returns result size in bits matching the filter and selectParams" + "comments": "Inserts a new record into the table." }, - "update": { + "upsert": { "type": "function", "alias": "

>(filter: FullFilter, newData: Partial>, params?: P | undefined) => Promise<...>", "arguments": [ { "name": "filter", "optional": false, - "type": "reference", + "type": "union", "alias": "FullFilter", "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] }, { "name": "newData", @@ -7122,21 +13090,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -7179,13 +13150,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -7195,116 +13167,11 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise | undefined>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "union", - "alias": "GetUpdateReturnType | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "GetUpdateReturnType", - "aliasSymbolescapedName": "GetUpdateReturnType", - "subType": "any" - } - ] - } - }, - "optional": false, - "comments": "Updates a record in the table based on the specified filter criteria\n- Use { multi: false } to ensure no more than one row is updated" - }, - "updateBatch": { - "type": "function", - "alias": "

>(data: [FullFilter, Partial>][], params?: P | undefined) => Promise<...>", - "arguments": [ - { - "name": "data", - "optional": false, - "type": "tuple", - "alias": "[FullFilter, Partial>][]", - "itemTypes": [ - { - "type": "reference", - "alias": "FullFilter", - "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" - }, - { - "type": "object", - "alias": "Partial>", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} - } - ], - "comments": "" - }, - { - "name": "params", - "optional": true, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { - "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" - }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" - }, - "groupBy": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" - }, - "returnType": { "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", @@ -7312,60 +13179,189 @@ export const definitions = [ "subType": "undefined" }, { - "type": "literal", - "alias": "\"row\"", - "value": "row" + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"value\"", - "value": "value" + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } }, { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } }, { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" @@ -7373,16 +13369,16 @@ export const definitions = [ ], "returnType": { "type": "promise", - "alias": "Promise>", + "alias": "Promise | undefined>", "comments": "Represents the completion of an asynchronous operation", "innerType": { "type": "union", - "alias": "void | GetUpdateReturnType", + "alias": "GetUpdateReturnType | undefined", "types": [ { "type": "primitive", - "alias": "void", - "subType": "any" + "alias": "undefined", + "subType": "undefined" }, { "type": "primitive", @@ -7394,187 +13390,206 @@ export const definitions = [ } }, "optional": false, - "comments": "Updates multiple records in the table in a batch operation.\n- Each item in the `data` array contains a filter and the corresponding data to update." + "comments": "Inserts or updates a record in the table.\n- If a record matching the `filter` exists, it updates the record.\n- If no matching record exists, it inserts a new record." }, - "insert": { + "delete": { "type": "function", - "alias": "

, D extends InsertData>(data: D, params?: P | undefined) => Promise>", + "alias": "

>(filter?: FullFilter | undefined, params?: P | undefined) => Promise | undefined>", "arguments": [ { - "name": "data", - "optional": false, + "name": "filter", + "optional": true, "type": "union", - "alias": "InsertData", - "aliasSymbolescapedName": "InsertData", + "alias": "FullFilter | undefined", "types": [ { - "type": "object", - "alias": "UpsertDataToPGCast", - "aliasSymbolescapedName": "UpsertDataToPGCast", - "comments": "", - "properties": {} + "type": "primitive", + "alias": "undefined", + "subType": "undefined" }, { - "type": "array", - "alias": "UpsertDataToPGCast[]", - "itemType": { - "type": "object", - "alias": "UpsertDataToPGCast", - "aliasSymbolescapedName": "UpsertDataToPGCast", - "comments": "", - "properties": {} - } - } - ], - "comments": "" - }, - { - "name": "params", - "optional": true, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { - "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { "type": "primitive", - "alias": "number", - "subType": "number" + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + } }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, - "groupBy": { + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, - "returnType": { - "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", - "types": [ - { + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "literal", - "alias": "\"row\"", - "value": "row" - }, - { - "type": "literal", - "alias": "\"value\"", - "value": "value" - }, - { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true }, - { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true } - ], - "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + } } - }, + ], "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "primitive", - "alias": "GetInsertReturnType", - "aliasSymbolescapedName": "GetInsertReturnType", - "subType": "any" - } - }, - "optional": false, - "comments": "Inserts a new record into the table." - }, - "upsert": { - "type": "function", - "alias": "

>(filter: FullFilter, newData: Partial>, params?: P | undefined) => Promise<...>", - "arguments": [ - { - "name": "filter", - "optional": false, - "type": "reference", - "alias": "FullFilter", - "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" - }, - { - "name": "newData", - "optional": false, - "type": "object", - "alias": "Partial>", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": {} }, { "name": "params", @@ -7604,21 +13619,24 @@ export const definitions = [ } ], "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" + "comments": "Max number of rows to return. Defaults to 1000\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)", + "intersectionParent": "CommonSelectParams" }, "offset": { "type": "primitive", "alias": "number", "subType": "number", "optional": true, - "comments": "Number of rows to skip" + "comments": "Number of rows to skip", + "intersectionParent": "CommonSelectParams" }, "groupBy": { "type": "primitive", "alias": "false", "subType": "boolean", "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" + "comments": "Will group by all non aggregated fields specified in select (or all fields by default)", + "intersectionParent": "CommonSelectParams" }, "returnType": { "type": "union", @@ -7661,13 +13679,14 @@ export const definitions = [ } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" + "comments": "Result data structure/type:\n- **row**: the first row as an object\n- **value**: the first value from of first field\n- **values**: array of values from the selected field\n- **statement**: sql statement\n- **statement-no-rls**: sql statement without row level security\n- **statement-where**: sql statement where condition", + "intersectionParent": "CommonSelectParams" }, "select": { "type": "primitive", "alias": "Select", "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", + "comments": "Fields/expressions/linked data to select\n- `\"*\"` or empty will return all fields\n- `{ field: 0 }` - all fields except the specified field will be selected\n- `{ field: 1 }` - only the specified field will be selected\n- `{ field: { $funcName: [args] } }` - the field will be selected with the specified function applied\n- `{ field: 1, referencedTable: \"*\" }` - field together with all fields from referencedTable will be selected\n- `{ linkedData: { referencedTable: { field: 1 } } }` - linkedData will contain the linked/joined records from referencedTable", "subType": "any", "optional": true }, @@ -7677,101 +13696,11 @@ export const definitions = [ "aliasSymbolescapedName": "OrderBy", "subType": "any", "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" + "comments": "Order by options\n- Order is maintained in arrays\n- `[{ key: \"field\", asc: true, nulls: \"last\" }]`" }, "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true - } - }, - "comments": "" - } - ], - "returnType": { - "type": "promise", - "alias": "Promise | undefined>", - "comments": "Represents the completion of an asynchronous operation", - "innerType": { - "type": "union", - "alias": "GetUpdateReturnType | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "GetUpdateReturnType", - "aliasSymbolescapedName": "GetUpdateReturnType", - "subType": "any" - } - ] - } - }, - "optional": false, - "comments": "Inserts or updates a record in the table.\n- If a record matching the `filter` exists, it updates the record.\n- If no matching record exists, it inserts a new record." - }, - "delete": { - "type": "function", - "alias": "

>(filter?: FullFilter | undefined, params?: P | undefined) => Promise | undefined>", - "arguments": [ - { - "name": "filter", - "optional": true, - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "" - }, - { - "name": "params", - "optional": true, - "type": "object", - "alias": "SelectParams", - "aliasSymbolescapedName": "SelectParams", - "properties": { - "limit": { - "type": "union", - "alias": "number | null | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "primitive", - "alias": "null", - "subType": "null" - }, - { - "type": "primitive", - "alias": "number", - "subType": "number" - } - ], - "optional": true, - "comments": "Max number of rows to return\n- If undefined then 1000 will be applied as the default\n- On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)" - }, - "offset": { - "type": "primitive", - "alias": "number", - "subType": "number", - "optional": true, - "comments": "Number of rows to skip" - }, - "groupBy": { - "type": "primitive", - "alias": "false", - "subType": "boolean", - "optional": true, - "comments": "Will group by all non aggregated fields specified in select (or all fields by default)" - }, - "returnType": { "type": "union", - "alias": "\"row\" | \"value\" | \"values\" | \"statement\" | \"statement-no-rls\" | \"statement-where\" | undefined", + "alias": "FullFilter | undefined", "types": [ { "type": "primitive", @@ -7779,60 +13708,189 @@ export const definitions = [ "subType": "undefined" }, { - "type": "literal", - "alias": "\"row\"", - "value": "row" + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"value\"", - "value": "value" + "type": "object", + "alias": "{ $and: FullFilter[]; }", + "properties": { + "$and": { + "type": "array", + "alias": "FullFilter[]", + "itemType": { + "type": "union", + "alias": "FullFilter", + "aliasSymbolescapedName": "FullFilter", + "comments": "Data filter\n- `{ status: 'live' }`\n- `{ $or: [{ id: 1 }, { status: 'live' }] }`\n- `{ $existsJoined: { referencedTable: { id: 1 } } }`\n- `{\n $filter: [\n { $age: [\"created_at\"] },\n \"<\",\n '1 year'\n ]\n }`", + "types": [ + { + "type": "object", + "alias": "ComplexFilter", + "aliasSymbolescapedName": "ComplexFilter", + "comments": "Complex filter that allows applying functions to columns\n `{\n $filter: [\n { $funcName: [...args] },\n operand,\n value | funcFilter\n ]\n }`", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": false + } + } + }, + { + "type": "reference", + "alias": "{ $and: FullFilter[]; }" + }, + { + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } + }, + { + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } + }, + { + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" + }, + { + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } + } + ] + }, + "optional": false + } + } }, { - "type": "literal", - "alias": "\"values\"", - "value": "values" + "type": "object", + "alias": "{ $or: FullFilter[]; }", + "properties": { + "$or": { + "type": "reference", + "alias": "FullFilter[]", + "optional": false + } + } }, { - "type": "literal", - "alias": "\"statement\"", - "value": "statement" + "type": "object", + "alias": "NormalFilter>", + "aliasSymbolescapedName": "NormalFilter", + "comments": "Column filter with operators\nMultiple columns are combined with AND", + "properties": { + "$filter": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true, + "intersectionParent": "Partial" + } + } }, { - "type": "literal", - "alias": "\"statement-no-rls\"", - "value": "statement-no-rls" + "type": "primitive", + "alias": "ShorthandFilter>", + "aliasSymbolescapedName": "ShorthandFilter", + "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", + "subType": "any" }, { - "type": "literal", - "alias": "\"statement-where\"", - "value": "statement-where" + "type": "object", + "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", + "aliasSymbolescapedName": "Partial", + "comments": "Make all properties in T optional", + "properties": { + "$exists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExists": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$existsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + }, + "$notExistsJoined": { + "type": "primitive", + "alias": "any", + "subType": "any", + "optional": true + } + } } ], "optional": true, - "comments": "Result data structure/type:\n- row: the first row as an object\n- value: the first value from of first field\n- values: array of values from the selected field\n- statement: sql statement\n- statement-no-rls: sql statement without row level security\n- statement-where: sql statement where condition" - }, - "select": { - "type": "primitive", - "alias": "Select", - "aliasSymbolescapedName": "Select", - "comments": "Fields/expressions/linked data to select\n- If empty then all fields will be selected\n- If \"*\" then all fields will be selected\n- If { field: 0 } then all fields except the specified field will be selected\n- If { field: 1 } then only the specified field will be selected\n- If { field: { funcName: [args] } } then the field will be selected with the specified function applied\n- If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields", - "subType": "any", - "optional": true - }, - "orderBy": { - "type": "primitive", - "alias": "OrderBy", - "aliasSymbolescapedName": "OrderBy", - "subType": "any", - "optional": true, - "comments": "Order by options\n- If array then the order will be maintained" - }, - "having": { - "type": "reference", - "alias": "FullFilter | undefined", - "comments": "Filter applied after any aggregations (group by)", - "optional": true + "comments": "Filter applied after any aggregations (group by)" } }, "comments": "" @@ -8082,112 +14140,6 @@ export const definitions = [ } ] }, - { - "type": "union", - "alias": "FullFilter | undefined", - "types": [ - { - "type": "primitive", - "alias": "undefined", - "subType": "undefined" - }, - { - "type": "object", - "alias": "ComplexFilter", - "aliasSymbolescapedName": "ComplexFilter", - "comments": "Complex filter that allows applying functions to columns", - "properties": { - "$filter": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": false - } - } - }, - { - "type": "object", - "alias": "{ $and: FullFilter[]; }", - "properties": { - "$and": { - "type": "array", - "alias": "FullFilter[]", - "itemType": { - "type": "reference", - "alias": "FullFilter", - "aliasSymbolescapedName": "FullFilter", - "comments": "Group or simple filter" - }, - "optional": false - } - } - }, - { - "type": "object", - "alias": "{ $or: FullFilter[]; }", - "properties": { - "$or": { - "type": "reference", - "alias": "FullFilter[]", - "optional": false - } - } - }, - { - "type": "object", - "alias": "NormalFilter>", - "aliasSymbolescapedName": "NormalFilter", - "comments": "Column filter with operators\nMultiple columns are combined with AND", - "properties": { - "$filter": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - } - }, - { - "type": "primitive", - "alias": "ShorthandFilter>", - "aliasSymbolescapedName": "ShorthandFilter", - "comments": "Filters with shorthand notation for autocomplete convenience\nOperator is inside the key: ` \"{columnName}.{operator}\": value`", - "subType": "any" - }, - { - "type": "object", - "alias": "Partial<{ $exists: S extends DBSchema ? ExactlyOne<{ [tname in KeyofString]: FullFilter | { path: RawJoinPath[]; filter: FullFilter<...>; }; }> : any; $notExists: S extends DBSchema ? ExactlyOne<...> : any; $existsJoined: S extends DBSchema ? ExactlyOne<...> : any; $notExistsJoined: S exte...", - "aliasSymbolescapedName": "Partial", - "comments": "Make all properties in T optional", - "properties": { - "$exists": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$notExists": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$existsJoined": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - }, - "$notExistsJoined": { - "type": "primitive", - "alias": "any", - "subType": "any", - "optional": true - } - } - } - ] - }, { "type": "union", "alias": "FieldFilter | undefined", @@ -8249,43 +14201,50 @@ export const definitions = [ "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onChange": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onError": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "db": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "pushDebounce": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "skipFirstTrigger": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "select": { "type": "reference", @@ -8296,37 +14255,43 @@ export const definitions = [ "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "patchText": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "patchJSON": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onReady": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "skipIncomingDeltaCheck": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onDebug": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "handlesOnData": { "type": "primitive", @@ -8345,85 +14310,99 @@ export const definitions = [ "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "filter": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onChange": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onError": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "db": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "pushDebounce": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "skipFirstTrigger": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "select": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "storageType": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "patchText": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "patchJSON": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onReady": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "skipIncomingDeltaCheck": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "onDebug": { "type": "primitive", "alias": "any", "subType": "any", - "optional": true + "optional": true, + "intersectionParent": "Partial" }, "handlesOnData": { "type": "primitive", diff --git a/documentation/utils/generateClientDocs.ts b/documentation/utils/generateClientDocs.ts index 408f73ab..05560097 100644 --- a/documentation/utils/generateClientDocs.ts +++ b/documentation/utils/generateClientDocs.ts @@ -1,9 +1,8 @@ import * as fs from "fs"; import * as path from "path"; -import { isDefined } from "prostgles-types"; -import { getResolvedTypes } from "./getResolvedTypes"; -import { getObjectEntries } from "prostgles-types"; +import { getObjectEntries, isDefined, TableHandler } from "prostgles-types"; import { definitions } from "./clientTypes"; +import { getResolvedTypes } from "./getResolvedTypes"; import { TS_Function, TS_Type } from "./getSerializableType"; const testFolderPath = `${__dirname}/../../../tests/`; @@ -14,8 +13,8 @@ export const generateClientDocs = () => { `${testFolderPath}/client/node_modules/prostgles-client/dist/prostgles.d.ts` ); const excludedTypes = [ - "FullFilter", - "FullFilter | undefined", + // "FullFilter", + // "FullFilter | undefined", "FieldFilter | undefined", "SyncOptions", "SyncOneOptions", @@ -24,10 +23,7 @@ export const generateClientDocs = () => { const { resolvedTypes, visitedMaps } = getResolvedTypes({ filePath: clientFilePath, filter: { - nodeNames: [ - // "ViewHandlerClient", - "TableHandlerClient", - ], + nodeNames: ["TableHandlerClient"], excludedTypes, }, }); @@ -57,8 +53,51 @@ export const generateClientDocs = () => { } ); - const docPath = `${docsFolder}CLIENT.md`; - generateMDX(docPath); + const docPath = `${docsFolder}METHODS.md`; + + const tableHandler = definitions[0]; + const isomotphicMethodNames = { + count: 1, + delete: 1, + find: 1, + insert: 1, + update: 1, + findOne: 1, + getColumns: 1, + getInfo: 1, + size: 1, + subscribe: 1, + subscribeOne: 1, + updateBatch: 1, + upsert: 1, + } satisfies Record; + + const isomorphicMd = getMethodsDocs( + getObjectEntries(tableHandler.properties).filter( + ([methodName]) => isomotphicMethodNames[methodName] + ) + ); + const clientMd = getMethodsDocs( + getObjectEntries(tableHandler.properties).filter( + ([methodName]) => !isomotphicMethodNames[methodName] + ) + ); + + const result = [ + `# Isomorphic Methods`, + ``, + `The following methods are available on the client and server.`, + ``, + isomorphicMd.join("\n\n"), + + `# Client Methods`, + ``, + `The following methods are available on the client.`, + ``, + clientMd.join("\n\n"), + ].join("\n"); + + fs.writeFileSync(docPath, result, { encoding: "utf-8" }); }; const getAliasWithoutGenerics = (type: TS_Type) => { @@ -66,45 +105,65 @@ const getAliasWithoutGenerics = (type: TS_Type) => { return type.aliasSymbolescapedName || type.alias; }; -export const generateMDX = (filePath: string) => { - const tableHandler = definitions[0]; - const mdxContent = getObjectEntries(tableHandler.properties).map(([methodName, _methodInfo]) => { +const getMethodsDocs = (methods: [name: string, TS_Type][]) => { + return methods.map(([methodName, _methodInfo]) => { const methodInfo = ( _methodInfo.type === "function" ? (_methodInfo as TS_Function) // : _methodInfo.type === "union" ? _methodInfo.types.find((t) => t.type === "function") : undefined) as TS_Function | undefined; if (!methodInfo) return ""; + const args = `${methodInfo.arguments + .map((arg) => `${arg.name}${arg.optional ? "?" : ""}: ${getAliasWithoutGenerics(arg)}`) + .join(", ")}`; + const rType = `${methodInfo.returnType.aliasSymbolescapedName || methodInfo.returnType.alias}` + .replaceAll("<", "<") + .replaceAll(">", ">"); return [ - `## ${methodName}()`, + `## ${methodName}(${args}): ${rType}`, methodInfo.comments ?? "", - `\`\`\`typescript - ${methodName}: (${methodInfo.arguments - .map((arg) => `${arg.name}${arg.optional ? "?" : ""}: ${getAliasWithoutGenerics(arg)}`) - .join(", ")}): ${methodInfo.returnType.aliasSymbolescapedName || methodInfo.returnType.alias} - \`\`\``, - `#### Arguments`, + `\`\`\`typescript`, + `${methodName}: (): `, + `\`\`\``, + `#### Parameters`, ``, ...methodInfo.arguments.map((arg) => { return renderType(arg, 2, { name: arg.name, optional: arg.optional }); }), - `#### Return type`, - renderType(methodInfo.returnType, 0, undefined), + // `#### Return type`, + `#### ` + renderType(methodInfo.returnType, 0, undefined), ].join("\n"); }); - const result = mdxContent.join("\n\n"); - fs.writeFileSync(filePath, result, { encoding: "utf-8" }); }; +const renderedAliases = new Set(); const renderType = ( type: TS_Type, indent = 2, argOrProp: { name: string; optional: boolean } | undefined ): string => { const indentText = " ".repeat(indent); - const title = `${indentText}${argOrProp?.name ? `- **${argOrProp.name}**: ` : ""}\`${ - type.aliasSymbolescapedName || type.alias - }\` ${type.comments ? ` - ${removeLineBreaks(type.comments)}` : ""}`; + const typeAlias = `\`${type.aliasSymbolescapedName || type.alias}\``; + const typeText = + type.aliasSymbolescapedName && type.type === "object" ? + `${type.aliasSymbolescapedName}` + : typeAlias; + const title = [ + `${indentText}${argOrProp?.name ? `- **${argOrProp.name}**: ` : ""}${typeAlias}`, + `${type.comments ? `${removeLineBreaks(type.comments, indentText + " ")}` : ""}`, + ].join("\n\n"); + + if (typeAlias?.includes("FullFilter")) { + // debugger; + } + /** + * Re-use rendered types by linking them through an anchor tag + */ + if (type.aliasSymbolescapedName && argOrProp?.name) { + renderedAliases.add(type.aliasSymbolescapedName); + console.log(type.aliasSymbolescapedName); + } + if (type.type === "primitive" || type.type === "literal") { return title; } @@ -133,10 +192,19 @@ const renderType = ( return title; }; -const removeLineBreaks = (str = "") => +const removeLineBreaks = (str: string, indent: string) => str .split("\n") .map((line) => { - if (!line.trim().endsWith(".")) return `${line}.`; + return `${indent}${line.trimStart()}`; }) - .join(" "); + .join("\n"); + +const renderTypeAlias = (type: TS_Type) => { + const typeAlias = type.aliasSymbolescapedName || type.alias; + const style = type.aliasSymbolescapedName ? `style="color: green;"` : ""; + // if (renderedAliases.has(typeAlias)) { + // return `${typeAlias}`; + // } + return `${typeAlias}`; +}; diff --git a/documentation/utils/generateServerDocs.ts b/documentation/utils/generateServerDocs.ts index 41cf7a35..b357a5d1 100644 --- a/documentation/utils/generateServerDocs.ts +++ b/documentation/utils/generateServerDocs.ts @@ -15,7 +15,6 @@ export const generateServerDocs = () => { ); const { resolvedTypes: [ProstglesInitOptions], - visitedMaps, } = getResolvedTypes({ filePath: serverFilePath, filter: { @@ -28,8 +27,15 @@ export const generateServerDocs = () => { }, }); - if (!ProstglesInitOptions) throw new Error("ProstglesInitOptions not found"); - const prostglesInitOpts = definitions[0]; + const serverTypesStr = [ + `import type { TS_Type } from "./getSerializableType";`, + `export const definitions = ${JSON.stringify([ProstglesInitOptions], null, 2)} as const satisfies TS_Type[];`, + ].join("\n"); + fs.writeFileSync(`${docsFolder}/utils/serverTypes.ts`, serverTypesStr, { encoding: "utf-8" }); + + const prostglesInitOpts = (definitions as any)[0]; + if (!ProstglesInitOptions || !prostglesInitOpts) + throw new Error("ProstglesInitOptions not found"); const docs = [ `# Overview`, `Our Isomorphic Typescript API allows connecting to a PostgreSQL database to get a realtime view of the data and schema. Interact with the data with full end-to-end type safety.`, @@ -44,8 +50,8 @@ export const generateServerDocs = () => { `Basic example:`, `\`\`\`typescript`, `import prostgles from "prostgles-server";`, - `import { DBSchemaGenerated } from "./DBSchemaGenerated";`, - `prostgles({`, + `import { DBGeneratedSchema } from "./DBGeneratedSchema";`, + `prostgles({`, ` dbConnection: {`, ` host: "localhost",`, ` port: 5432,`, @@ -66,6 +72,7 @@ export const generateServerDocs = () => { `\`\`\``, `### Configuration options`, ...getObjectEntries(prostglesInitOpts.properties).map(([propName, prop]) => { + //@ts-ignore const title = ` - ${propName} \`${(prop as TS_Type).aliasSymbolescapedName || (prop as TS_Type).alias}\``; const comments = (prop as TS_Type).comments || ""; if (!comments) return title; @@ -73,10 +80,5 @@ export const generateServerDocs = () => { }), ].join("\n"); - const serverTypesStr = [ - `import type { TS_Type } from "./getSerializableType";`, - `export const definitions = ${JSON.stringify([ProstglesInitOptions], null, 2)} as const satisfies TS_Type[];`, - ].join("\n"); - fs.writeFileSync(`${docsFolder}/utils/serverTypes.ts`, serverTypesStr, { encoding: "utf-8" }); fs.writeFileSync(`${docsFolder}SERVER.md`, docs, { encoding: "utf-8" }); }; diff --git a/documentation/utils/getSerializableType.ts b/documentation/utils/getSerializableType.ts index 601ec19b..e58a6dfa 100644 --- a/documentation/utils/getSerializableType.ts +++ b/documentation/utils/getSerializableType.ts @@ -4,8 +4,8 @@ import { AnyObject, isDefined } from "prostgles-types"; type TS_Base = { alias?: string; aliasSymbolescapedName?: string; - intersectionParent?: string; comments?: string; + intersectionParent?: string; }; export type TS_Literal = TS_Base & { @@ -359,12 +359,22 @@ export const getSerializableType = ( opts, depth + 1 ); - intersectionType.intersectionParent = aliasSymbolescapedName || alias; + + if (intersectionType.type === "object") { + intersectionType.intersectionParent = aliasSymbolescapedName; + } return intersectionType; }); if (intersectionTypes.every((t) => t.type === "object")) { const properties = (intersectionTypes as TS_Object[]).reduce((acc, t) => { - return { ...acc, ...t.properties }; + const propertiesWithParentObject = Object.entries(t.properties).reduce( + (acc, [k, v]) => ({ + ...acc, + [k]: { ...v, intersectionParent: t.aliasSymbolescapedName }, + }), + {} + ); + return { ...acc, ...propertiesWithParentObject }; }, {}); return withAlias({ type: "object", diff --git a/documentation/utils/loadTsFile.ts b/documentation/utils/loadTsFile.ts index ac338562..12a9c06d 100644 --- a/documentation/utils/loadTsFile.ts +++ b/documentation/utils/loadTsFile.ts @@ -2,10 +2,8 @@ import * as path from "path"; import * as ts from "typescript"; export const loadTsFile = (filePath: string) => { - // Normalize file path const absolutePath = path.resolve(filePath); - // Create compiler host and program const configPath = ts.findConfigFile( path.dirname(absolutePath), ts.sys.fileExists, @@ -16,7 +14,6 @@ export const loadTsFile = (filePath: string) => { throw new Error("Could not find a valid 'tsconfig.json'."); } - // Parse the config file const configFile = ts.readConfigFile(configPath, ts.sys.readFile); const parsedConfig = ts.parseJsonConfigFileContent( configFile.config, @@ -24,7 +21,6 @@ export const loadTsFile = (filePath: string) => { path.dirname(configPath) ); - // Create program const program = ts.createProgram({ rootNames: [absolutePath], options: parsedConfig.options, diff --git a/documentation/utils/package.json b/documentation/utils/package.json index 9baf3d43..d09b1961 100644 --- a/documentation/utils/package.json +++ b/documentation/utils/package.json @@ -4,7 +4,7 @@ "description": "", "main": "generateDocs.js", "scripts": { - "start": "npm i && tsc && node dist/generateDocs.js" + "start": "npm i && tsc && node --inspect-brk dist/generateDocs.js" }, "author": "", "license": "ISC", diff --git a/documentation/utils/serverTypes.ts b/documentation/utils/serverTypes.ts index e80a8ef0..8e29f04e 100644 --- a/documentation/utils/serverTypes.ts +++ b/documentation/utils/serverTypes.ts @@ -46,15 +46,10 @@ export const definitions = [ "optional": false, "comments": "Called when the prostgles server is ready to accept connections.\nIt waits for auth, tableConfig and other async configurations to complete before executing" }, - "dbOptions": { - "type": "reference", - "alias": "IDefaults", - "optional": true - }, "tsGeneratedTypesDir": { "type": "reference", "alias": "string | undefined", - "comments": "If defined then a `DBSchemaGenerated.d.ts` file will be created in the provided directory.\nThis file exports a `DBSchemaGenerated` type which contains types for the database tables and\ncan be used as a generic type input for the prostgles instances to ensure type safety", + "comments": "If defined then a `DBGeneratedSchema.d.ts` file will be created in the provided directory.\nThis file exports a `DBGeneratedSchema` type which contains types for the database tables and\ncan be used as a generic type input for the prostgles instances to ensure type safety", "optional": true }, "disableRealtime": { @@ -295,7 +290,7 @@ export const definitions = [ } ], "optional": true, - "comments": "If truthy then DBSchemaGenerated.d.ts will be updated\nand \"onReady\" will be called with new schema on both client and server" + "comments": "If truthy then DBGeneratedSchema.d.ts will be updated\nand \"onReady\" will be called with new schema on both client and server" }, "keywords": { "type": "reference", @@ -310,8 +305,7 @@ export const definitions = [ }, "fileTable": { "type": "reference", - "alias": "FileTableConfig", - "aliasSymbolescapedName": "FileTableConfig", + "alias": "FileTableConfig | undefined", "comments": "Enables file storage and serving.\nCurrently supports saving files locally or to AWS S3", "optional": true }, diff --git a/documentation/utils/tsconfig.json b/documentation/utils/tsconfig.json index 5394fe93..93ff33b1 100644 --- a/documentation/utils/tsconfig.json +++ b/documentation/utils/tsconfig.json @@ -2,12 +2,12 @@ "files": ["generateDocs.ts"], "compilerOptions": { "baseUrl": ".", - "target": "es2019", + "target": "es2021", "lib": [ "es6", "dom", "es2017", - "es2019", + "es2021", ], "strict": true, "module": "commonjs", diff --git a/lib/DBSchemaBuilder.ts b/lib/DBSchemaBuilder.ts index c039c8eb..5fdd08bc 100644 --- a/lib/DBSchemaBuilder.ts +++ b/lib/DBSchemaBuilder.ts @@ -1,112 +1,144 @@ -import { AnyObject, DbJoinMaker, DBSchema, isObject, JSONB, SQLHandler, TableHandler, ViewHandler } from "prostgles-types"; +import { + AnyObject, + DbJoinMaker, + DBSchema, + isObject, + JSONB, + SQLHandler, + TableHandler, + ViewHandler, +} from "prostgles-types"; import prostgles from "."; import { Auth } from "./Auth/AuthTypes"; import { DboBuilder, escapeTSNames, postgresToTsType } from "./DboBuilder/DboBuilder"; -import { PublishAllOrNothing, PublishParams, PublishTableRule, PublishViewRule, } from "./PublishParser/PublishParser"; +import { + PublishAllOrNothing, + PublishParams, + PublishTableRule, + PublishViewRule, +} from "./PublishParser/PublishParser"; import { getJSONBSchemaTSTypes } from "./JSONBValidation/validation"; import { DBHandlerServer, TableSchemaColumn, TX } from "./DboBuilder/DboBuilderTypes"; - export const getDBSchema = (dboBuilder: DboBuilder): string => { const tables: string[] = []; const getColTypeForDBSchema = (udt_name: TableSchemaColumn["udt_name"]): string => { - if(udt_name === "interval"){ - const units = [ "years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; - - return `{ ${units.map(u => `${u}?: number;`).join(" ")} }`; + if (udt_name === "interval") { + const units = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"]; + + return `{ ${units.map((u) => `${u}?: number;`).join(" ")} }`; } return postgresToTsType(udt_name); - } - + }; + /** Tables and columns are sorted to avoid infinite loops due to changing order */ - dboBuilder.tablesOrViews?.slice(0).sort((a, b) => a.name.localeCompare(b.name)).forEach(tov => { - const cols = tov.columns.slice(0).sort((a, b) => a.name.localeCompare(b.name)); - const getColType = (c: typeof cols[number]) => { - - let type: string = (c.is_nullable? "null | " : "") + getColTypeForDBSchema(c.udt_name) + ";" - const colConf = dboBuilder.prostgles.tableConfigurator?.getColumnConfig(tov.name, c.name); - if(colConf){ - if(isObject(colConf) && (colConf.jsonbSchema || colConf.jsonbSchemaType)){ - const schema: JSONB.JSONBSchema = colConf.jsonbSchema || { ...colConf, type: colConf.jsonbSchemaType }; - - type = getJSONBSchemaTSTypes(schema, { nullable: colConf.nullable }, " ", dboBuilder.tablesOrViews ?? []); - } else if(isObject(colConf) && "enum" in colConf){ - if(!colConf.enum) throw "colConf.enum missing" - const types = colConf.enum.map(t => typeof t === "number"? t : JSON.stringify(t)); - if(colConf.nullable){ - types.unshift("null") + dboBuilder.tablesOrViews + ?.slice(0) + .sort((a, b) => a.name.localeCompare(b.name)) + .forEach((tov) => { + const cols = tov.columns.slice(0).sort((a, b) => a.name.localeCompare(b.name)); + const getColType = (c: (typeof cols)[number]) => { + let type: string = + (c.is_nullable ? "null | " : "") + getColTypeForDBSchema(c.udt_name) + ";"; + const colConf = dboBuilder.prostgles.tableConfigurator?.getColumnConfig(tov.name, c.name); + if (colConf) { + if (isObject(colConf) && (colConf.jsonbSchema || colConf.jsonbSchemaType)) { + const schema: JSONB.JSONBSchema = colConf.jsonbSchema || { + ...colConf, + type: colConf.jsonbSchemaType, + }; + + type = getJSONBSchemaTSTypes( + schema, + { nullable: colConf.nullable }, + " ", + dboBuilder.tablesOrViews ?? [] + ); + } else if (isObject(colConf) && "enum" in colConf) { + if (!colConf.enum) throw "colConf.enum missing"; + const types = colConf.enum.map((t) => (typeof t === "number" ? t : JSON.stringify(t))); + if (colConf.nullable) { + types.unshift("null"); + } + type = types.join(" | "); } - type = types.join(" | "); } - } - /** - * Columns that are nullable or have default values can be ommitted from an insert - * Non nullable columns with default values cannot containt null values in an insert so they must contain a valid value or be omitted - */ - return `${escapeTSNames(c.name)}${c.is_nullable || c.has_default? "?" : ""}: ${type}` - } -tables.push(`${escapeTSNames(tov.name)}: { + /** + * Columns that are nullable or have default values can be ommitted from an insert + * Non nullable columns with default values cannot containt null values in an insert so they must contain a valid value or be omitted + */ + return `${escapeTSNames(c.name)}${c.is_nullable || c.has_default ? "?" : ""}: ${type}`; + }; + tables.push(`${escapeTSNames(tov.name)}: { is_view: ${tov.is_view}; select: ${tov.privileges.select}; insert: ${tov.privileges.insert}; update: ${tov.privileges.update}; delete: ${tov.privileges.delete}; - columns: {${cols.map(c => ` - ${getColType(c)}`).join("")} + columns: {${cols + .map( + (c) => ` + ${getColType(c)}` + ) + .join("")} }; - };\n `) - }) -return ` -export type DBSchemaGenerated = { + };\n `); + }); + return ` +export type DBGeneratedSchema = { ${tables.join("")} } `; -} - -type ServerViewHandler = ViewHandler & { is_view: boolean; } -type ServerTableHandler = TableHandler & { is_view: boolean; } - -export type DBTableHandlersFromSchema = Schema extends DBSchema? { - [tov_name in keyof Schema]: Schema[tov_name]["is_view"] extends true? - ServerViewHandler : - ServerTableHandler -} : Record>; +}; + +type ServerViewHandler< + T extends AnyObject = AnyObject, + Schema extends DBSchema | void = void, +> = ViewHandler & { is_view: boolean }; +type ServerTableHandler< + T extends AnyObject = AnyObject, + Schema extends DBSchema | void = void, +> = TableHandler & { is_view: boolean }; + +export type DBTableHandlersFromSchema = + Schema extends DBSchema ? + { + [tov_name in keyof Schema]: Schema[tov_name]["is_view"] extends true ? + ServerViewHandler + : ServerTableHandler; + } + : Record>; -export type DBHandlerServerExtra>, WithTransactions = true> = { +export type DBHandlerServerExtra< + TH = Record>, + WithTransactions = true, +> = { sql: SQLHandler; -} & Partial & ( - WithTransactions extends true? { tx: TX } : - Record -); +} & Partial & + (WithTransactions extends true ? { tx: TX } : Record); // export type DBOFullyTyped = Schema extends DBSchema? ( // DBTableHandlersFromSchema & DBHandlerServerExtra> -// ) : +// ) : // DBHandlerServer; -export type DBOFullyTyped = DBTableHandlersFromSchema & DBHandlerServerExtra> - -export type PublishFullyTyped = Schema extends DBSchema? ( - | PublishAllOrNothing - | { - [tov_name in keyof Partial]: - | PublishAllOrNothing - | ( - Schema[tov_name]["is_view"] extends true? - PublishViewRule : - PublishTableRule - ); - } -) : ( - | PublishAllOrNothing - | Record -); - - +export type DBOFullyTyped = DBTableHandlersFromSchema & + DBHandlerServerExtra>; + +export type PublishFullyTyped = + Schema extends DBSchema ? + | PublishAllOrNothing + | { + [tov_name in keyof Partial]: + | PublishAllOrNothing + | (Schema[tov_name]["is_view"] extends true ? + PublishViewRule + : PublishTableRule); + } + : PublishAllOrNothing | Record; /** Type checks */ -(() => { - +() => { const ddb: DBOFullyTyped = 1 as any; ddb.dwad?.insert; ddb.dwad?.delete; @@ -124,102 +156,100 @@ export type PublishFullyTyped = Schema extends DBSchema? ( dbConnection: 1 as any, publish: async (params) => { const _rows = await params.dbo.dwadwa?.find?.({}); - - return "*" as const + + return "*" as const; }, transactions: true, onReady: ({ dbo }) => { dbo.tdwa?.find!(); - dbo.tx?.(t => { + dbo.tx?.((t) => { t.dwa?.find!(); - }) - } + }); + }, }); - const _auth: Auth = { sidKeyName: "sid_token", getUser: async (sid, db, _db) => { db.dwadaw?.find; return 1 as any; - } - } - + }, + }; type S = { tbl1: { columns: { col1: number | null; - col2: string; - } - }, + col2: string; + }; + }; tbl2: { columns: { col1: number | null; - col2: string; - } - } - } + col2: string; + }; + }; + }; /** Test the created schema */ const c: S = 1 as any; const _test: DBSchema = c; const dbt: DBOFullyTyped = 1 as any; - dbt.tx!(t => { + dbt.tx!((t) => { t.tbl1.delete(); }); const db: DBHandlerServer = 1 as any; - db.tx!(t => { - t.wadwa?.find!() + db.tx!((t) => { + t.wadwa?.find!(); }); - + const _publish = (): PublishFullyTyped => { const r = { tbl1: { select: { - fields: "*" as const, - forcedFilter: { col1: 32, col2: "" } + fields: "*" as const, + forcedFilter: { col1: 32, col2: "" }, }, getColumns: true, getInfo: true, delete: { - filterFields: {col1: 1} - } + filterFields: { col1: 1 }, + }, }, tbl2: { delete: { filterFields: "*" as const, - forcedFilter: {col1: 2} - } - } - } + forcedFilter: { col1: 2 }, + }, + }, + }; const res: PublishFullyTyped = { tbl1: { select: { fields: "*", - forcedFilter: { col1: 32, col2: "" } + forcedFilter: { col1: 32, col2: "" }, }, getColumns: true, getInfo: true, delete: { - filterFields: { col1: 1 } - } + filterFields: { col1: 1 }, + }, }, tbl2: { delete: { filterFields: "*" as const, - forcedFilter: { col1: 2 } - } - } - } - const _res1: PublishFullyTyped = r - + forcedFilter: { col1: 2 }, + }, + }, + }; + const _res1: PublishFullyTyped = r; + const p: PublishParams = 1 as any; - + p.dbo.dwadaw?.find?.(); - + return res; - } -}) + }; +}; diff --git a/lib/DboBuilder/getColumns.ts b/lib/DboBuilder/getColumns.ts index 660c60ed..7ad2674a 100644 --- a/lib/DboBuilder/getColumns.ts +++ b/lib/DboBuilder/getColumns.ts @@ -1,9 +1,17 @@ import { - AnyObject, PG_COLUMN_UDT_DATA_TYPE, - ValidatedColumnInfo, _PG_geometric, isObject + AnyObject, + PG_COLUMN_UDT_DATA_TYPE, + ValidatedColumnInfo, + _PG_geometric, + isObject, } from "prostgles-types"; import { TableRule } from "../PublishParser/PublishParser"; -import { LocalParams, getClientErrorFromPGError, getErrorAsObject, getSerializedClientErrorFromPGError, postgresToTsType } from "./DboBuilder"; +import { + LocalParams, + getErrorAsObject, + getSerializedClientErrorFromPGError, + postgresToTsType, +} from "./DboBuilder"; import { TableHandler } from "./TableHandler/TableHandler"; import { ViewHandler } from "./ViewHandler/ViewHandler"; @@ -12,14 +20,13 @@ export const isTableHandler = (v: any): v is TableHandler => "parseUpdateRules" export async function getColumns( this: ViewHandler, lang?: string, - params?: { rule: "update", filter: AnyObject, data: AnyObject }, + params?: { rule: "update"; filter: AnyObject; data: AnyObject }, _param3?: undefined, tableRules?: TableRule, localParams?: LocalParams ): Promise { const start = Date.now(); try { - const p = this.getValidatedRules(tableRules, localParams); if (!p.getColumns) throw "Not allowed"; @@ -27,12 +34,11 @@ export async function getColumns( let dynamicUpdateFields = this.column_names; if (params && tableRules && isTableHandler(this)) { - if ( - !isObject(params) || - !isObject(params.filter) || - params.rule !== "update" - ) { - throw "params must be { rule: 'update', filter: object } but received: " + JSON.stringify(params); + if (!isObject(params) || !isObject(params.filter) || params.rule !== "update") { + throw ( + "params must be { rule: 'update', filter: object } but received: " + + JSON.stringify(params) + ); } if (!tableRules?.update) { @@ -45,16 +51,16 @@ export async function getColumns( } const columns = this.columns - .filter(c => { + .filter((c) => { const { insert, select, update } = p || {}; return [ ...(insert?.fields || []), ...(select?.fields || []), ...(update?.fields || []), - ].includes(c.name) + ].includes(c.name); }) - .map(_c => { + .map((_c) => { const c = { ..._c }; const label = c.comment || capitalizeFirstLetter(c.name, " "); @@ -67,7 +73,10 @@ export async function getColumns( delete (c as any).privileges; const prostgles = this.dboBuilder?.prostgles; - const fileConfig = prostgles.fileManager?.getColInfo({ colName: c.name, tableName: this.name }); + const fileConfig = prostgles.fileManager?.getColInfo({ + colName: c.name, + tableName: this.name, + }); /** Do not allow updates to file table unless it's to delete fields */ if (prostgles.fileManager?.config && prostgles.fileManager.tableName === this.name) { @@ -80,35 +89,58 @@ export async function getColumns( ...c, label, tsDataType: postgresToTsType(c.udt_name), - insert: insert && Boolean(p.insert?.fields?.includes(c.name)) && tableRules?.insert?.forcedData?.[c.name] === undefined && c.is_updatable, + insert: + insert && + Boolean(p.insert?.fields?.includes(c.name)) && + tableRules?.insert?.forcedData?.[c.name] === undefined && + c.is_updatable, select: select && Boolean(p.select?.fields?.includes(c.name)), - orderBy: select && Boolean(p.select?.fields && p.select.orderByFields.includes(c.name)) && !nonOrderableUD_Types.includes(c.udt_name), + orderBy: + select && + Boolean(p.select?.fields && p.select.orderByFields.includes(c.name)) && + !nonOrderableUD_Types.includes(c.udt_name), filter: Boolean(p.select?.filterFields?.includes(c.name)), - update: update && Boolean(p.update?.fields?.includes(c.name)) && tableRules?.update?.forcedData?.[c.name] === undefined && c.is_updatable && dynamicUpdateFields.includes(c.name), - delete: _delete && Boolean(p.delete && p.delete.filterFields && p.delete.filterFields.includes(c.name)), - ...(prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name, lang }) || {}), - ...(fileConfig && { file: fileConfig }) - } + update: + update && + Boolean(p.update?.fields?.includes(c.name)) && + tableRules?.update?.forcedData?.[c.name] === undefined && + c.is_updatable && + dynamicUpdateFields.includes(c.name), + delete: + _delete && + Boolean(p.delete && p.delete.filterFields && p.delete.filterFields.includes(c.name)), + ...(prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name, lang }) || + {}), + ...(fileConfig && { file: fileConfig }), + }; return result; - }).filter(c => c.select || c.update || c.delete || c.insert) - - await this._log({ command: "getColumns", localParams, data: { lang, params }, duration: Date.now() - start }); + }) + .filter((c) => c.select || c.update || c.delete || c.insert); + + await this._log({ + command: "getColumns", + localParams, + data: { lang, params }, + duration: Date.now() - start, + }); return columns; - } catch (e) { - await this._log({ command: "getColumns", localParams, data: { lang, params }, duration: Date.now() - start, error: getErrorAsObject(e) }); + await this._log({ + command: "getColumns", + localParams, + data: { lang, params }, + duration: Date.now() - start, + error: getErrorAsObject(e), + }); throw getSerializedClientErrorFromPGError(e, { type: "tableMethod", localParams, view: this }); } } - - - function replaceNonAlphaNumeric(string: string, replacement = "_"): string { return string.replace(/[\W_]+/g, replacement); } -function capitalizeFirstLetter(string: string, nonalpha_replacement?: string) : string { +function capitalizeFirstLetter(string: string, nonalpha_replacement?: string): string { const str = replaceNonAlphaNumeric(string, nonalpha_replacement); return str.charAt(0).toUpperCase() + str.slice(1); } diff --git a/lib/Prostgles.ts b/lib/Prostgles.ts index 16680f9f..4c57aa20 100644 --- a/lib/Prostgles.ts +++ b/lib/Prostgles.ts @@ -124,7 +124,6 @@ export class Prostgles { disableRealtime: 1, onReady: 1, dbConnection: 1, - dbOptions: 1, publishMethods: 1, io: 1, publish: 1, @@ -176,7 +175,7 @@ export class Prostgles { } getTSFileName() { - const fileName = "DBSchemaGenerated.d.ts"; //`dbo_${this.schema}_types.ts`; + const fileName = "DBGeneratedSchema.d.ts"; //`dbo_${this.schema}_types.ts`; const _dir = this.opts.tsGeneratedTypesDir || ""; const dir = _dir.endsWith("/") ? _dir : `${_dir}/`; const fullPath = dir + fileName; diff --git a/lib/ProstglesTypes.ts b/lib/ProstglesTypes.ts index 7decc340..d275e8df 100644 --- a/lib/ProstglesTypes.ts +++ b/lib/ProstglesTypes.ts @@ -93,11 +93,14 @@ export type ProstglesInitOptions; - dbOptions?: DbConnectionOpts; + /** + * @deprecated + */ + // dbOptions?: DbConnectionOpts; /** - * If defined then a `DBSchemaGenerated.d.ts` file will be created in the provided directory. - * This file exports a `DBSchemaGenerated` type which contains types for the database tables and + * If defined then a `DBGeneratedSchema.d.ts` file will be created in the provided directory. + * This file exports a `DBGeneratedSchema` type which contains types for the database tables and * can be used as a generic type input for the prostgles instances to ensure type safety */ tsGeneratedTypesDir?: string; @@ -196,7 +199,7 @@ export type ProstglesInitOptions; const getDbConnection = function ({ dbConnection, onQuery, DEBUG_MODE, - dbOptions, onNotice, }: GetDbConnectionArgs): { db: DB; pgp: PGP } { const onQueryOrError: | undefined | ((error: any, ctx: pgPromise.IEventContext) => void) = - !onQuery && !DEBUG_MODE - ? undefined - : (error, ctx) => { - if (onQuery) { - onQuery(error, ctx); - } else if (DEBUG_MODE) { - if (error) { - console.error(error, ctx); - } else { - console.log(ctx); - } + !onQuery && !DEBUG_MODE ? + undefined + : (error, ctx) => { + if (onQuery) { + onQuery(error, ctx); + } else if (DEBUG_MODE) { + if (error) { + console.error(error, ctx); + } else { + console.log(ctx); } - }; + } + }; const pgp: PGP = pgPromise({ - ...(onQueryOrError - ? { - query: (ctx) => onQueryOrError(undefined, ctx), - error: onQueryOrError, - } - : {}), - ...(onNotice || DEBUG_MODE - ? { - connect: function ({ client, useCount }) { - const isFresh = !useCount; - if (isFresh && !client.listeners("notice").length) { - client.on("notice", function (msg) { - if (onNotice) { - onNotice(msg, msg?.message); - } else { - console.log("notice: %j", msg?.message); - } - }); - } - if (isFresh && !client.listeners("error").length) { - client.on("error", function (msg) { - if (onNotice) { - onNotice(msg, msg?.message); - } else { - console.log("error: %j", msg?.message); - } - }); - } - }, - } - : {}), + ...(onQueryOrError ? + { + query: (ctx) => onQueryOrError(undefined, ctx), + error: onQueryOrError, + } + : {}), + ...(onNotice || DEBUG_MODE ? + { + connect: function ({ client, useCount }) { + const isFresh = !useCount; + if (isFresh && !client.listeners("notice").length) { + client.on("notice", function (msg) { + if (onNotice) { + onNotice(msg, msg?.message); + } else { + console.log("notice: %j", msg?.message); + } + }); + } + if (isFresh && !client.listeners("error").length) { + client.on("error", function (msg) { + if (onNotice) { + onNotice(msg, msg?.message); + } else { + console.log("error: %j", msg?.message); + } + }); + } + }, + } + : {}), }); // pgp.pg.defaults.max = 70; @@ -340,9 +339,9 @@ const getDbConnection = function ({ pgp.pg.types.setTypeParser(pgp.pg.types.builtins.TIMESTAMPTZ, (v) => v); // timestamp with time zone pgp.pg.types.setTypeParser(pgp.pg.types.builtins.DATE, (v) => v); // date - if (dbOptions) { - Object.assign(pgp.pg.defaults, dbOptions); - } + // if (dbOptions) { + // Object.assign(pgp.pg.defaults, dbOptions); + // } return { db: pgp(dbConnection), diff --git a/lib/typeTests/DBoGenerated.d.ts b/lib/typeTests/DBoGenerated.d.ts index 0ba1fe40..2c574701 100644 --- a/lib/typeTests/DBoGenerated.d.ts +++ b/lib/typeTests/DBoGenerated.d.ts @@ -1,4 +1,4 @@ -export type DBSchemaGenerated = { +export type DBGeneratedSchema = { items: { is_view: false; select: true; @@ -188,20 +188,25 @@ export type DBSchemaGenerated = { update: true; delete: true; columns: { - colOneOf: "a" | "b" | "c" - json: { a: boolean; arr: '1' | '2' | '3'; arr1: 1 | 2 | 3; arr2: number[]; arrStr?: null | string[]; o?: | null - | { o1: number; } - | { o2: boolean; }; }; - jsonOneOf?: - | null - | { command: 'a'; } - | { command: 'b'; option: number[]; } - status?: - | null - | { ok: string; } - | { err: string; } - | { loading: { loaded: number; total: number; }; } - table_config?: null | { referencedTables?: ( { name: string; minFiles: number; } )[]; recType?: null | Record<'a' | 'b', { bools: boolean[]; }>; }; + colOneOf: "a" | "b" | "c"; + json: { + a: boolean; + arr: "1" | "2" | "3"; + arr1: 1 | 2 | 3; + arr2: number[]; + arrStr?: null | string[]; + o?: null | { o1: number } | { o2: boolean }; + }; + jsonOneOf?: null | { command: "a" } | { command: "b"; option: number[] }; + status?: + | null + | { ok: string } + | { err: string } + | { loading: { loaded: number; total: number } }; + table_config?: null | { + referencedTables?: { name: string; minFiles: number }[]; + recType?: null | Record<"a" | "b", { bools: boolean[] }>; + }; }; }; tr1: { @@ -261,8 +266,8 @@ export type DBSchemaGenerated = { columns: { email: string; id?: number; - preferences: { showIntro?: boolean; theme?: 'light' | 'dark' | 'auto'; others: any[]; }; - status: "active" | "disabled" | "pending" + preferences: { showIntro?: boolean; theme?: "light" | "dark" | "auto"; others: any[] }; + status: "active" | "disabled" | "pending"; }; }; users_public_info: { @@ -316,5 +321,4 @@ export type DBSchemaGenerated = { tsv?: null | string; }; }; - -} +}; diff --git a/lib/typeTests/dboTypeCheck.ts b/lib/typeTests/dboTypeCheck.ts index fb1cb343..109d40a2 100644 --- a/lib/typeTests/dboTypeCheck.ts +++ b/lib/typeTests/dboTypeCheck.ts @@ -2,7 +2,7 @@ import { ViewHandler } from "prostgles-types"; import type { DBOFullyTyped } from "../DBSchemaBuilder"; import type { DBHandlerServer } from "../DboBuilder/DboBuilder"; import { Publish } from "../PublishParser/PublishParser"; -import { DBSchemaGenerated } from "./DBoGenerated"; +import { DBGeneratedSchema } from "./DBoGenerated"; type DBSchema2 = { tr2: { @@ -18,24 +18,27 @@ type DBSchema2 = { tr1_id?: null | number; }; }; -} -export const testDboTypes = () => { - (async () => { +}; +export const testDboTypes = () => { + async () => { const dbo = {} as DBOFullyTyped; dbo.someTable?.find; const dbo1 = {} as DBHandlerServer; dbo1.w?.find; - const db = {} as DBOFullyTyped; + const db = {} as DBOFullyTyped; db.items2.find; - const r = await db.items2.find({ }, { - select: { id: 1 }, - orderBy: { - id: 1, - } - }); + const r = await db.items2.find( + {}, + { + select: { id: 1 }, + orderBy: { + id: 1, + }, + } + ); r[0]?.id; @@ -43,39 +46,50 @@ export const testDboTypes = () => { r[0]?.bad_col; const tr2 = {} as ViewHandler; - tr2.find({}, { - select: { id: 1 }, - orderBy: { tr1_id: 1 } - }); + tr2.find( + {}, + { + select: { id: 1 }, + orderBy: { tr1_id: 1 }, + } + ); - tr2.find({}, { - //@ts-expect-error - select: { bad_col: 1 } - }); + tr2.find( + {}, + { + //@ts-expect-error + select: { bad_col: 1 }, + } + ); - tr2.find({}, { - //@ts-expect-error - orderBy: { bad_col: 1 } - }); + tr2.find( + {}, + { + //@ts-expect-error + orderBy: { bad_col: 1 }, + } + ); - (await db.items2.find({}, { select: { items_id: 1 }, returnType: "values" })) satisfies (number | null)[]; - + (await db.items2.find({}, { select: { items_id: 1 }, returnType: "values" })) satisfies ( + | number + | null + )[]; - const publish: Publish = { + const publish: Publish = { items: { insert: { - fields: { - name: 1, + fields: { + name: 1, //@ts-expect-error - bad_col: 1 + bad_col: 1, }, validate: async (row) => ({ ...row, - h: [""] - }) - } - } + h: [""], + }), + }, + }, }; publish; - }) -} \ No newline at end of file + }; +}; diff --git a/package-lock.json b/package-lock.json index 014075da..06baad71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.2.179", + "version": "4.2.180", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.2.179", + "version": "4.2.180", "license": "MIT", "dependencies": { "@aws-sdk/client-ses": "^3.699.0", @@ -28,7 +28,7 @@ "pg": "^8.11.5", "pg-cursor": "^2.11.0", "pg-promise": "^11.9.1", - "prostgles-types": "^4.0.117" + "prostgles-types": "^4.0.119" }, "devDependencies": { "@types/express": "^4.17.21", @@ -3643,9 +3643,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.117", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.117.tgz", - "integrity": "sha512-TX4liHlRL0jGkZIoeao7312jk9MPamcp3xjGBd5IBWfneAFql73APcLz3GiD+Unt80CErZw82fZOLbxUpsSxyQ==", + "version": "4.0.119", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.119.tgz", + "integrity": "sha512-MmIbuz9HTysdg1s/xmO0wkxoZyPB8slM2mHeUjhGP/0w+knh4OseeRfbs2JoUV5l+mB4MHMKXz+wI0EkoJmU4Q==", "license": "MIT" }, "node_modules/punycode": { @@ -6863,9 +6863,9 @@ "dev": true }, "prostgles-types": { - "version": "4.0.117", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.117.tgz", - "integrity": "sha512-TX4liHlRL0jGkZIoeao7312jk9MPamcp3xjGBd5IBWfneAFql73APcLz3GiD+Unt80CErZw82fZOLbxUpsSxyQ==" + "version": "4.0.119", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.119.tgz", + "integrity": "sha512-MmIbuz9HTysdg1s/xmO0wkxoZyPB8slM2mHeUjhGP/0w+knh4OseeRfbs2JoUV5l+mB4MHMKXz+wI0EkoJmU4Q==" }, "punycode": { "version": "2.3.1", diff --git a/package.json b/package.json index 0f46bf63..e211c6c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.2.179", + "version": "4.2.180", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -15,7 +15,8 @@ "test-only": "cd tests/ && ./test.sh", "test-quick": "cd tests/ && ./test.sh -quick", "test": "rm -rf ./node_modules/* && rm -rf ./dist/* && npm i && npm run lint && npm run test-only", - "pushpublish": "npm version patch --git-tag-version false && git push && npm publish" + "generate-docs": "rm -f ./documentation/*.md && cd documentation/utils && npm start", + "pushpublish": "npm run generate-docs && npm version patch --git-tag-version false && git push && npm publish" }, "repository": { "type": "git", @@ -54,7 +55,7 @@ "pg": "^8.11.5", "pg-cursor": "^2.11.0", "pg-promise": "^11.9.1", - "prostgles-types": "^4.0.117" + "prostgles-types": "^4.0.119" }, "devDependencies": { "@types/express": "^4.17.21", diff --git a/tests/client/package-lock.json b/tests/client/package-lock.json index 5fd307cc..83b80495 100644 --- a/tests/client/package-lock.json +++ b/tests/client/package-lock.json @@ -10,9 +10,9 @@ "license": "ISC", "dependencies": { "@types/node": "^20.9.2", - "prostgles-client": "^4.0.176", + "prostgles-client": "^4.0.178", "prostgles-types": "^4.0.51", - "socket.io-client": "^4.7.5" + "socket.io-client": "^4.8.1" }, "devDependencies": { "jsdom": "^24.0.0", @@ -327,12 +327,12 @@ } }, "node_modules/prostgles-client": { - "version": "4.0.176", - "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.176.tgz", - "integrity": "sha512-1U6jYx0mQ12HNU5YNAG2LsVdzwCBDPoAVQKfXjVD7dv5FSyt17giVsGiurRH18zYU1rjKz6plGhn1WeNM9y4FA==", + "version": "4.0.178", + "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.178.tgz", + "integrity": "sha512-evh7cAr+7MTppuuyyUffkxFGfb3Vj7XZwEBwX4h7iPWj1mO+rAot+Eejn8owhF6ilzv29LPt3FoUFyKUGfaOvQ==", "license": "MIT", "dependencies": { - "prostgles-types": "^4.0.117" + "prostgles-types": "^4.0.119" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", @@ -348,9 +348,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.117", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.117.tgz", - "integrity": "sha512-TX4liHlRL0jGkZIoeao7312jk9MPamcp3xjGBd5IBWfneAFql73APcLz3GiD+Unt80CErZw82fZOLbxUpsSxyQ==", + "version": "4.0.119", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.119.tgz", + "integrity": "sha512-MmIbuz9HTysdg1s/xmO0wkxoZyPB8slM2mHeUjhGP/0w+knh4OseeRfbs2JoUV5l+mB4MHMKXz+wI0EkoJmU4Q==", "license": "MIT" }, "node_modules/psl": { diff --git a/tests/client/package.json b/tests/client/package.json index d2f43ecc..0c6acc39 100644 --- a/tests/client/package.json +++ b/tests/client/package.json @@ -13,9 +13,9 @@ "license": "ISC", "dependencies": { "@types/node": "^20.9.2", - "prostgles-client": "^4.0.176", + "prostgles-client": "^4.0.178", "prostgles-types": "^4.0.51", - "socket.io-client": "^4.7.5" + "socket.io-client": "^4.8.1" }, "devDependencies": { "jsdom": "^24.0.0", diff --git a/tests/config_test/DBoGenerated.d.ts b/tests/config_test/DBoGenerated.d.ts index f7c3acf0..0588b5ae 100644 --- a/tests/config_test/DBoGenerated.d.ts +++ b/tests/config_test/DBoGenerated.d.ts @@ -1,23 +1,23 @@ -/* This file was generated by Prostgles -*/ +/* This file was generated by Prostgles + */ - /* SCHEMA DEFINITON. Table names have been altered to work with Typescript */ +/* SCHEMA DEFINITON. Table names have been altered to work with Typescript */ /* DBO Definition */ -export type DBSchemaGenerated = { - "\"\"\"*\"\"\"": { +export type DBGeneratedSchema = { + '"""*"""': { is_view: false; select: true; insert: true; update: true; delete: true; columns: { - "\"*\""?: null | string; + '"*"'?: null | string; id?: number; qq?: null | string; }; }; - "\"*\"": { + '"*"': { is_view: false; select: true; insert: true; @@ -122,7 +122,7 @@ export type DBSchemaGenerated = { items3_id?: null | number; name?: null | string; }; - }; + }; items2: { is_view: false; select: true; @@ -403,5 +403,4 @@ export type DBSchemaGenerated = { various_id?: null | number; }; }; - -} +}; diff --git a/tests/config_test/index.js b/tests/config_test/index.js index f27442c6..1725059b 100644 --- a/tests/config_test/index.js +++ b/tests/config_test/index.js @@ -1,12 +1,14 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; +var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod }; + }; Object.defineProperty(exports, "__esModule", { value: true }); const express_1 = __importDefault(require("express")); -process.on('unhandledRejection', (reason, p) => { - console.trace('Unhandled Rejection at:', p, 'reason:', reason); - process.exit(1); +process.on("unhandledRejection", (reason, p) => { + console.trace("Unhandled Rejection at:", p, "reason:", reason); + process.exit(1); }); const app = (0, express_1.default)(); app.use(express_1.default.json()); @@ -14,12 +16,12 @@ app.use(express_1.default.urlencoded({ extended: true })); const _http = require("http"); const http = _http.createServer(app); const io = require("socket.io")(http, { - path: "/teztz/s", - // maxHttpBufferSize: 1e8, // 100Mb + path: "/teztz/s", + // maxHttpBufferSize: 1e8, // 100Mb }); http.listen(process.env.NPORT || 3000); const log = (msg, extra) => { - console.log(...["(server): " + msg, extra].filter(v => v)); + console.log(...["(server): " + msg, extra].filter((v) => v)); }; // import WebSocket from 'ws'; // const wss = new WebSocket.Server({ @@ -58,11 +60,11 @@ const connectionString = `postgresql://api:api@localhost/postgres`; // preferences JSONB, // status TEXT, // type TEXT -// ); +// ); // `); -// type DBSchemaGenerated = any; +// type DBGeneratedSchema = any; // const user = await db.users.find( -// { type: "admin", status: "active" }, +// { type: "admin", status: "active" }, // { select: { email: 1 } } // ) // await db.sql(` @@ -73,14 +75,14 @@ const connectionString = `postgresql://api:api@localhost/postgres`; // preferences JSONB, // status TEXT NOT NULL, // type TEXT NOT NULL -// ); +// ); // `); const prostgles_server_1 = __importDefault(require("prostgles-server")); (0, prostgles_server_1.default)({ - dbConnection: { connectionString }, - tsGeneratedTypesDir: __dirname, - watchSchema: true, - onReady: async (db) => { - await db.users.insert({}); - } -}); \ No newline at end of file + dbConnection: { connectionString }, + tsGeneratedTypesDir: __dirname, + watchSchema: true, + onReady: async (db) => { + await db.users.insert({}); + }, +}); diff --git a/tests/config_test/index.ts b/tests/config_test/index.ts index e44e0d2e..0f5ca664 100644 --- a/tests/config_test/index.ts +++ b/tests/config_test/index.ts @@ -1,21 +1,17 @@ - - /* Dashboard */ -import express from 'express'; +import express from "express"; -process.on('unhandledRejection', (reason, p) => { - console.trace('Unhandled Rejection at:', p, 'reason:', reason) - process.exit(1) +process.on("unhandledRejection", (reason, p) => { + console.trace("Unhandled Rejection at:", p, "reason:", reason); + process.exit(1); }); -const app = express(); +const app = express(); app.use(express.json()); app.use(express.urlencoded({ extended: true })); const _http = require("http"); -const http = _http.createServer(app); +const http = _http.createServer(app); http.listen(process.env.NPORT || 3000); - - // import WebSocket from 'ws'; // const wss = new WebSocket.Server({ @@ -56,12 +52,12 @@ const connectionString = `postgresql://api:api@localhost/postgres`; // preferences JSONB, // status TEXT, // type TEXT -// ); +// ); // `); -// type DBSchemaGenerated = any; +// type DBGeneratedSchema = any; // const user = await db.users.find( -// { type: "admin", status: "active" }, +// { type: "admin", status: "active" }, // { select: { email: 1 } } // ) // await db.sql(` @@ -72,20 +68,17 @@ const connectionString = `postgresql://api:api@localhost/postgres`; // preferences JSONB, // status TEXT NOT NULL, // type TEXT NOT NULL -// ); +// ); // `); import prostgles from "prostgles-server"; -import { DBSchemaGenerated } from "./DBoGenerated"; +import { DBGeneratedSchema } from "./DBoGenerated"; -prostgles({ +prostgles({ dbConnection: { connectionString }, tsGeneratedTypesDir: __dirname, watchSchema: true, onReady: async (db) => { - - await db.users.insert({ - - }) - } + await db.users.insert({}); + }, }); diff --git a/tests/config_testDBoGenerated.d.ts b/tests/config_testDBoGenerated.d.ts index ea2066e7..0ee9f202 100644 --- a/tests/config_testDBoGenerated.d.ts +++ b/tests/config_testDBoGenerated.d.ts @@ -1,23 +1,23 @@ -/* This file was generated by Prostgles -*/ +/* This file was generated by Prostgles + */ - /* SCHEMA DEFINITON. Table names have been altered to work with Typescript */ +/* SCHEMA DEFINITON. Table names have been altered to work with Typescript */ /* DBO Definition */ -export type DBSchemaGenerated = { - "\"\"\"*\"\"\"": { +export type DBGeneratedSchema = { + '"""*"""': { is_view: false; select: true; insert: true; update: true; delete: true; columns: { - "\"*\""?: null | string; + '"*"'?: null | string; id?: number; qq?: null | string; }; }; - "\"*\"": { + '"*"': { is_view: false; select: true; insert: true; @@ -122,7 +122,7 @@ export type DBSchemaGenerated = { items3_id?: null | number; name?: null | string; }; - }; + }; items2: { is_view: false; select: true; @@ -403,5 +403,4 @@ export type DBSchemaGenerated = { various_id?: null | number; }; }; - -} +}; diff --git a/tests/server/DBSchemaGenerated.d.ts b/tests/server/DBGeneratedSchema.d.ts similarity index 99% rename from tests/server/DBSchemaGenerated.d.ts rename to tests/server/DBGeneratedSchema.d.ts index aeccf676..9d1a59b6 100644 --- a/tests/server/DBSchemaGenerated.d.ts +++ b/tests/server/DBGeneratedSchema.d.ts @@ -4,7 +4,7 @@ /* SCHEMA DEFINITON. Table names have been altered to work with Typescript */ /* DBO Definition */ -export type DBSchemaGenerated = { +export type DBGeneratedSchema = { "\"\"\"*\"\"\"": { is_view: false; select: true; diff --git a/tests/server/index.ts b/tests/server/index.ts index aa25fe94..ef40032b 100644 --- a/tests/server/index.ts +++ b/tests/server/index.ts @@ -19,7 +19,7 @@ http.listen(3001); import { isomorphicQueries } from "../isomorphicQueries.spec"; import { serverOnlyQueries } from "../serverOnlyQueries.spec"; -import { DBSchemaGenerated } from "./DBSchemaGenerated"; +import { DBGeneratedSchema } from "./DBGeneratedSchema"; import type { DBOFullyTyped } from "prostgles-server/dist/DBSchemaBuilder"; import { spawn } from "child_process"; @@ -78,7 +78,7 @@ function dd() { } (async () => { if (isClientTest && process.env.TEST_NAME === "useProstgles") { - await prostgles({ + await prostgles({ dbConnection, io: ioWatchSchema, transactions: true, @@ -89,7 +89,7 @@ function dd() { }); } - prostgles({ + prostgles({ dbConnection, sqlFilePath: path.join(__dirname + "/../../init.sql"), io, diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index d3530bc6..e5d0d963 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.2.179", + "version": "4.2.180", "license": "MIT", "dependencies": { "@aws-sdk/client-ses": "^3.699.0", @@ -43,7 +43,7 @@ "pg": "^8.11.5", "pg-cursor": "^2.11.0", "pg-promise": "^11.9.1", - "prostgles-types": "^4.0.117" + "prostgles-types": "^4.0.119" }, "devDependencies": { "@types/express": "^4.17.21", @@ -1828,7 +1828,7 @@ "pg-cursor": "^2.11.0", "pg-promise": "^11.9.1", "prettier": "^3.4.2", - "prostgles-types": "^4.0.117", + "prostgles-types": "^4.0.119", "socket.io": "^4.8.1", "typescript": "^5.3.3" } diff --git a/tests/server/publishTypeCheck.ts b/tests/server/publishTypeCheck.ts index aa56db7a..8b5dff88 100644 --- a/tests/server/publishTypeCheck.ts +++ b/tests/server/publishTypeCheck.ts @@ -1,48 +1,47 @@ - -import { DBSchemaGenerated } from "./DBoGenerated"; +import { DBGeneratedSchema } from "./DBGeneratedSchema"; import { PublishFullyTyped } from "prostgles-server/dist/DBSchemaBuilder"; export const testPublishTypes = () => { - (() => { - const p1: PublishFullyTyped = { + () => { + const p1: PublishFullyTyped = { items: { delete: "*", select: { fields: { h: 1, id: 1 }, - forcedFilter: { $and: [ - { h: { $overlaps: ["23", "32"]} }, - { $existsJoined: { items: { "h.$eq": [] } } } - ]} - } + forcedFilter: { + $and: [ + { h: { $overlaps: ["23", "32"] } }, + { $existsJoined: { items: { "h.$eq": [] } } }, + ], + }, + }, }, - items3: "*" - } - const p2: PublishFullyTyped = "*" + items3: "*", + }; + const p2: PublishFullyTyped = "*"; const p11: PublishFullyTyped = { items: { delete: "*", select: { fields: { h: 1, id: 1 }, - forcedFilter: { - $and: [ - { h: { $overlaps: ["23", "32"]} }, - { $existsJoined: { items: { "h.$eq": [] } } } - ] - } - } + forcedFilter: { + $and: [ + { h: { $overlaps: ["23", "32"] } }, + { $existsJoined: { items: { "h.$eq": [] } } }, + ], + }, + }, }, - items3: "*" + items3: "*", }; - const p123: PublishFullyTyped = p11; - //@ts-ignore + const p123: PublishFullyTyped = p11; + //@ts-ignore const p1234: PublishFullyTyped = p1; const p12: PublishFullyTyped = "*"; - - - const res: PublishFullyTyped = { + const res: PublishFullyTyped = { shapes: "*", items: "*", items2: "*", @@ -59,78 +58,80 @@ export const testPublishTypes = () => { delete: "*", sync: { id_fields: ["id"], - synced_field: "last_updated" - } + synced_field: "last_updated", + }, }, items4: { - select: Math.random()? "*" : { - fields: { name: 0 }, - forcedFilter: { name: "abc" } - }, + select: + Math.random() ? "*" : ( + { + fields: { name: 0 }, + forcedFilter: { name: "abc" }, + } + ), insert: "*", update: "*", - delete: "*" + delete: "*", }, items4_pub: "*", "*": { - select: { fields: { "*": 0 }}, + select: { fields: { "*": 0 } }, insert: "*", update: "*", }, [`"*"`]: { - select: { fields: { [`"*"`]: 0 }}, + select: { fields: { [`"*"`]: 0 } }, insert: "*", update: "*", }, obj_table: "*", - media: "*", + media: "*", insert_rules: { insert: { fields: "*", returningFields: { name: 1 }, validate: async ({ row }) => { - if(row.name === "a") row.name = "b" - return row - } - } + if (row.name === "a") row.name = "b"; + return row; + }, + }, }, uuid_text: { insert: { fields: "*", forcedData: { - id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' - } + id: "c81089e1-c4c1-45d7-a73d-e2d613cb7c3e", + }, }, update: { fields: [], - dynamicFields: [{ - fields: { id: 1 }, - filter: { - id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' - } - }] - } - } + dynamicFields: [ + { + fields: { id: 1 }, + filter: { + id: "c81089e1-c4c1-45d7-a73d-e2d613cb7c3e", + }, + }, + ], + }, + }, }; - const res2: PublishFullyTyped = res; - const res3: PublishFullyTyped = { + const res2: PublishFullyTyped = res; + const res3: PublishFullyTyped = { items: { select: { fields: { - h: 1 + h: 1, }, forcedFilter: { // "h.$eq": ["2"] - $and: [ - { "h.$eq": ["2"] } - ] - } - } - } - }; - - }) -} \ No newline at end of file + $and: [{ "h.$eq": ["2"] }], + }, + }, + }, + }; + }; +}; diff --git a/tests/server/server.ts b/tests/server/server.ts index 5ecb49f3..ee3ebd26 100644 --- a/tests/server/server.ts +++ b/tests/server/server.ts @@ -1,8 +1,8 @@ import path from "path"; import prostgles from "prostgles-server"; -import { DBSchemaGenerated } from "./DBoGenerated"; +import { DBGeneratedSchema } from "./DBoGenerated"; -prostgles({ +prostgles({ dbConnection: { connectionString: process.env.DB_CONNECTION, }, diff --git a/tests/server/testPublish.ts b/tests/server/testPublish.ts index f6f69533..7c31b029 100644 --- a/tests/server/testPublish.ts +++ b/tests/server/testPublish.ts @@ -1,22 +1,21 @@ - import { Publish, PublishTableRule } from "prostgles-server/dist/PublishParser/PublishParser"; -import { DBSchemaGenerated } from "./DBoGenerated"; -import type { PublishFullyTyped } from "prostgles-server/dist/DBSchemaBuilder"; +import { DBGeneratedSchema } from "./DBGeneratedSchema"; +import type { PublishFullyTyped } from "prostgles-server/dist/DBSchemaBuilder"; -export const testPublish: Publish = async ({ user, sid }) => { - if(sid === "noAuth"){ +export const testPublish: Publish = async ({ user, sid }) => { + if (sid === "noAuth") { return { planes: { - select: { fields: { last_updated: 0 } } - } - } + select: { fields: { last_updated: 0 } }, + }, + }; } - if(sid === "rest_api"){ + if (sid === "rest_api") { return { - planes: "*" - } + planes: "*", + }; } - const users_public_info = { + const users_public_info = { select: { fields: "*", forcedFilter: { sid }, @@ -33,105 +32,115 @@ export const testPublish: Publish = async ({ user, sid }) => fields: "*", forcedFilter: { sid }, }, - } satisfies PublishTableRule; + } satisfies PublishTableRule< + DBGeneratedSchema["users_public_info"]["columns"], + DBGeneratedSchema + >; - if(sid === "files"){ + if (sid === "files") { return { - users_public_info - } + users_public_info, + }; } - const res: PublishFullyTyped = { + const res: PublishFullyTyped = { shapes: "*", items: "*", items2: "*", items3: "*", items4a: "*", - tjson: "*", - items_multi: "*", + tjson: "*", + items_multi: "*", v_items: "*", various: "*", tr1: "*", tr2: "*", tr3: "*", planes: { - select: sid === "client_only"? { fields: { last_updated: false } } : "*", + select: sid === "client_only" ? { fields: { last_updated: false } } : "*", update: "*", insert: "*", delete: "*", sync: { id_fields: ["id"], - synced_field: "last_updated" - } + synced_field: "last_updated", + }, }, items4: { - select: user? "*" : { - fields: { name: 0 }, - orderByFields: { added: 1 }, - forcedFilter: { name: "abc" } - }, + select: + user ? "*" : ( + { + fields: { name: 0 }, + orderByFields: { added: 1 }, + forcedFilter: { name: "abc" }, + } + ), insert: "*", update: "*", - delete: "*" + delete: "*", }, items4_pub: "*", [`"*"`]: { - select: { fields: { "*": 0 }}, + select: { fields: { "*": 0 } }, insert: "*", update: "*", }, [`"""*"""`]: { - select: { fields: { [`"*"`]: 0 }}, + select: { fields: { [`"*"`]: 0 } }, insert: "*", update: "*", }, obj_table: "*", files: "*", users_public_info, - self_join: "*", + self_join: "*", insert_rules: { select: "*", insert: { fields: { added: 0 }, returningFields: { name: 1 }, validate: async ({ row }) => { - if(row.name === "a") row.name = "b"; - row.added = (new Date()).toUTCString(); - return row + if (row.name === "a") row.name = "b"; + row.added = new Date().toUTCString(); + return row; }, checkFilter: { - $and: [{ "name.<>": "fail-check" }] + $and: [{ "name.<>": "fail-check" }], }, - postValidate: async ({ row, dbx: dboTx}) => { + postValidate: async ({ row, dbx: dboTx }) => { /** Records must exist in this transaction */ - const exists = await dboTx.sql("SELECT * FROM insert_rules WHERE id = ${id}", row, { returnType: "row" }); + const exists = await dboTx.sql("SELECT * FROM insert_rules WHERE id = ${id}", row, { + returnType: "row", + }); const existsd = await dboTx.insert_rules.findOne({ id: row.id }); - if(row.id !== exists.id || row.id !== existsd.id){ + if (row.id !== exists.id || row.id !== existsd.id) { console.error("postValidate failed"); - // process.exit(1) + // process.exit(1) } - if(row.name === "fail") throw "Failed"; - return undefined - } - } + if (row.name === "fail") throw "Failed"; + return undefined; + }, + }, }, uuid_text: { insert: { fields: "*", forcedData: { - id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' - } + id: "c81089e1-c4c1-45d7-a73d-e2d613cb7c3e", + }, }, update: { fields: [], - dynamicFields: [{ - fields: { id: 1 }, - filter: { - id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' - } - }] - } + dynamicFields: [ + { + fields: { id: 1 }, + filter: { + id: "c81089e1-c4c1-45d7-a73d-e2d613cb7c3e", + }, + }, + ], + }, }, "prostgles_test.basic": "*", "prostgles_test.basic1": "*", @@ -142,6 +151,6 @@ export const testPublish: Publish = async ({ user, sid }) => symbols: "*", trades: "*", }; - + return res; -} \ No newline at end of file +}; diff --git a/tests/test.sh b/tests/test.sh index 3225f975..a237844e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -9,9 +9,7 @@ if [ $# -eq 0 ]; then npm i fi -npm run build - -#npm run test-server 2>&1 ./server.log +npm run build && \ npm run test-server && \ TEST_NAME="main" npm run test-client && \ TEST_NAME="useProstgles" npm run test-client && \