// backwards compatible alternative for: Extract type StringKeyof = keyof T & string; export interface WithId { id: number; } export interface PineDeferred { __id: number; } /** * When not selected-out holds a deferred. * When expanded hold an array with a single element. */ export type NavigationResource = T[] | PineDeferred; /** * When expanded holds an array, otherwise the property is not present. * Selecting is not suggested, * in that case it holds a deferred to the original resource. */ export type ReverseNavigationResource = T[] | undefined; // based on https://github.com/resin-io/pinejs-client-js/blob/master/core.d.ts type RawFilter = | string | Array> | { $string: string; [index: string]: Filter | string }; type Lambda = { $alias: string; $expr: Filter; }; type OrderByValues = 'asc' | 'desc'; type OrderBy = string | string[] | { [index: string]: OrderByValues }; type ResourceObjFilter = { [k in keyof T]?: object | number | string | boolean }; interface FilterArray extends Array> {} type FilterExpressions = { $raw?: RawFilter; $?: string | string[]; $and?: Filter | FilterArray; $or?: Filter | FilterArray; $in?: Filter | FilterArray; $not?: Filter | FilterArray; $any?: Lambda; $all?: Lambda; }; type Filter = ResourceObjFilter & FilterExpressions; type BaseExpandFor = { [k in keyof T]?: object } | StringKeyof; export type Expand = BaseExpandFor | Array>; export interface PineOptions { $select?: string[] | string | '*'; $filter?: object; $expand?: object | string; $orderby?: OrderBy; $top?: number; $skip?: number; } export interface PineOptionsFor extends PineOptions { $select?: Array> | StringKeyof | '*'; $filter?: Filter; $expand?: Expand; } export interface PineParams { resource: string; id?: number; body?: object; options?: PineOptions; } export interface PineParamsFor extends PineParams { body?: Partial; options?: PineOptionsFor; } export interface PineParamsWithIdFor extends PineParamsFor { id: number; }