@poap-xyz/drops
Advanced tools
Comparing version 0.0.31 to 0.0.33
/// <reference types="node" /> | ||
import { Order } from '@poap-xyz/utils'; | ||
import { Order, PaginationInput } from '@poap-xyz/utils'; | ||
export declare enum DropsSortFields { | ||
@@ -8,5 +8,3 @@ Name = "name", | ||
} | ||
export interface FetchDropsInput { | ||
limit: number; | ||
offset: number; | ||
export interface FetchDropsInput extends PaginationInput { | ||
name?: string; | ||
@@ -13,0 +11,0 @@ sort_field?: DropsSortFields; |
/// <reference types="node" /> | ||
import { Order } from '@poap-xyz/utils'; | ||
import { Order, PaginationInput } from '@poap-xyz/utils'; | ||
export declare enum DropsSortFields { | ||
@@ -8,5 +8,3 @@ Name = "name", | ||
} | ||
export interface FetchDropsInput { | ||
limit: number; | ||
offset: number; | ||
export interface FetchDropsInput extends PaginationInput { | ||
name?: string; | ||
@@ -13,0 +11,0 @@ sort_field?: DropsSortFields; |
@@ -105,25 +105,2 @@ (function (global, factory) { | ||
function creatUndefinedOrder(key, value) { | ||
return key && value ? { [key]: value } : {}; | ||
} | ||
function createFilter(key, value) { | ||
return value ? { [key]: { _ilike: `%${value}%` } } : {}; | ||
} | ||
function creatPrivateFilter(key, value) { | ||
return typeof value === 'boolean' | ||
? { [key]: { _eq: value ? 'true' : 'false' } } | ||
: {}; | ||
} | ||
function createInFilter(key, values) { | ||
return values && values.length ? { [key]: { _in: values } } : {}; | ||
} | ||
function createBetweenFilter(key, from, to) { | ||
const dateFilter = {}; | ||
if (from) | ||
dateFilter._gte = from; | ||
if (to) | ||
dateFilter._lte = to; | ||
return from || to ? { [key]: dateFilter } : {}; | ||
} | ||
class DropsClient { | ||
@@ -139,8 +116,8 @@ constructor(CompassProvider, DropApiProvider) { | ||
offset, | ||
orderBy: creatUndefinedOrder(sort_field, sort_dir), | ||
orderBy: utils.creatUndefinedOrder(sort_field, sort_dir), | ||
where: { | ||
...creatPrivateFilter('private', is_private), | ||
...createFilter('name', name), | ||
...createBetweenFilter('created_date', from, to), | ||
...createInFilter('id', ids), | ||
...utils.creatPrivateFilter('private', is_private), | ||
...utils.createFilter('name', name), | ||
...utils.createBetweenFilter('created_date', from, to), | ||
...utils.createInFilter('id', ids), | ||
}, | ||
@@ -147,0 +124,0 @@ }; |
/// <reference types="node" /> | ||
import { Order } from '@poap-xyz/utils'; | ||
import { Order, PaginationInput } from '@poap-xyz/utils'; | ||
export declare enum DropsSortFields { | ||
@@ -8,5 +8,3 @@ Name = "name", | ||
} | ||
export interface FetchDropsInput { | ||
limit: number; | ||
offset: number; | ||
export interface FetchDropsInput extends PaginationInput { | ||
name?: string; | ||
@@ -13,0 +11,0 @@ sort_field?: DropsSortFields; |
{ | ||
"name": "@poap-xyz/drops", | ||
"version": "0.0.31", | ||
"version": "0.0.33", | ||
"description": "Drops module for the poap.js library", | ||
@@ -33,4 +33,4 @@ "main": "dist/cjs/index.cjs", | ||
"@poap-xyz/providers": "0.0.31", | ||
"@poap-xyz/utils": "0.0.31" | ||
"@poap-xyz/utils": "0.0.34" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93188
42
1386