@livequery/types
Advanced tools
| import { Observable } from 'rxjs'; | ||
| export declare type FilterExpression = '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in-array' | 'contains' | 'not-in-array'; | ||
| export declare type FilterCondition<T extends {}, K extends keyof T = keyof T> = { | ||
| name: K; | ||
| expression: FilterExpression; | ||
| value: T[K] extends Array<any> ? (T[K][0] | T[K]) : T[K]; | ||
| }; | ||
| export declare type RequestMethod = 'put' | 'patch' | 'delete' | 'post'; | ||
| export declare type UpdatedDataType = 'added' | 'removed' | 'modified'; | ||
| export declare type QueryOption<T> = { | ||
| _limit: number; | ||
| _cursor: any; | ||
| _q: string; | ||
| _order_by: keyof T; | ||
| _sort: 'asc' | 'desc'; | ||
| filters: Array<FilterCondition<T>>; | ||
| }; | ||
| export declare type UpdatedData<T> = { | ||
| data: Partial<T> & { | ||
| id: string; | ||
| }; | ||
| type: UpdatedDataType; | ||
| }; | ||
| export declare type QueryStream<T> = { | ||
| ref: string; | ||
| n: number; | ||
| has_more?: boolean; | ||
| next_cursor?: any; | ||
| changes: Array<UpdatedData<T>>; | ||
| }; | ||
| export declare type Transporter = { | ||
| query: <T extends {}>(query_id: number, ref: string, options?: Partial<QueryOption<T>>) => Observable<QueryStream<T>>; | ||
| add: <T extends {} = {}, K = void>(ref: string, data: Partial<T>) => Promise<K | void>; | ||
| update: <T extends {} = {}, K = void>(ref: string, data: Partial<T>) => Promise<K | void>; | ||
| remove: (ref: string) => Promise<void | void>; | ||
| trigger: <T, K>(ref: string, payload: T) => Promise<K | void>; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
+1
-2
@@ -1,2 +0,1 @@ | ||
| export { QueryTransporter, QueryOption, FilterCondition, FilterExpression, FilterOption, RequestMethod, QueryResponse } from './QueryTransporter'; | ||
| export { RealtimeTransporter, UpdatedData } from './RealtimeTransporter'; | ||
| export { Transporter, QueryOption, FilterCondition, FilterExpression, RequestMethod, QueryStream, UpdatedData, UpdatedDataType } from './Transporter'; |
+2
-2
@@ -6,3 +6,3 @@ { | ||
| }, | ||
| "version": "1.0.4", | ||
| "version": "1.0.5", | ||
| "description": "", | ||
@@ -16,3 +16,3 @@ "main": "build/index.js", | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "build": "tsc -b .", | ||
| "build": "rm -rf build; tsc -b .", | ||
| "deploy": "yarn build; git add .; git commit -m \"Update\"; git push origin master; npm publish --access publish" | ||
@@ -19,0 +19,0 @@ }, |
| export declare type FilterExpression = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'contains' | 'nin'; | ||
| export declare type FilterCondition<T> = { | ||
| expression: FilterExpression; | ||
| value: T; | ||
| }; | ||
| export declare type RequestMethod = 'get' | 'post' | 'patch' | 'put' | 'delete'; | ||
| export declare type FilterOption<T> = { | ||
| [key in keyof T]: T[key] | FilterCondition<T[key]> | Array<FilterCondition<T[key]>>; | ||
| }; | ||
| export declare type QueryOption<T> = FilterOption<T> & { | ||
| _limit: number; | ||
| _cursor: any; | ||
| _q: string; | ||
| _order_by: keyof T; | ||
| _sort: 'ASC' | 'DESC'; | ||
| }; | ||
| export declare type QueryResponse<T> = { | ||
| items: T[]; | ||
| has_more: boolean; | ||
| next_cursor: any; | ||
| }; | ||
| export declare type QueryTransporter = { | ||
| query: <T extends {}>(ref: string, filters?: Partial<QueryOption<T>>) => Promise<QueryResponse<T>>; | ||
| request: (ref: string, method?: RequestMethod, query?: any, data?: any) => Promise<any>; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| export declare type UpdatedData<T> = { | ||
| data: Partial<T> & { | ||
| id: string; | ||
| }; | ||
| type: 'INSERT' | 'UPDATE' | 'DELETE'; | ||
| ref: string; | ||
| }; | ||
| export declare type RealtimeTransporter = { | ||
| listen: <T extends {}>(ref: string, handler: (payload: UpdatedData<T>[]) => void) => () => void; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
2293
2.96%5
-28.57%42
-2.33%