@poap-xyz/poaps
Advanced tools
Comparing version 0.1.8 to 0.2.0
@@ -0,1 +1,2 @@ | ||
import { FilterVariables, OrderByVariables, PaginatedVariables } from '@poap-xyz/utils'; | ||
export declare const PAGINATED_POAPS_QUERY = "\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n"; | ||
@@ -19,5 +20,4 @@ export interface PoapsResponse { | ||
export interface PaginatedPoapsResponse { | ||
data: { | ||
poaps: PoapsResponse[]; | ||
}; | ||
poaps: PoapsResponse[]; | ||
} | ||
export type PaginatedPoapsVariables = FilterVariables & OrderByVariables & PaginatedVariables; |
@@ -0,1 +1,2 @@ | ||
import { FilterVariables, OrderByVariables, PaginatedVariables } from '@poap-xyz/utils'; | ||
export declare const PAGINATED_POAPS_QUERY = "\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n"; | ||
@@ -19,5 +20,4 @@ export interface PoapsResponse { | ||
export interface PaginatedPoapsResponse { | ||
data: { | ||
poaps: PoapsResponse[]; | ||
}; | ||
poaps: PoapsResponse[]; | ||
} | ||
export type PaginatedPoapsVariables = FilterVariables & OrderByVariables & PaginatedVariables; |
@@ -71,2 +71,21 @@ (function (global, factory) { | ||
class PaginatedResult { | ||
constructor(items, nextCursor) { | ||
this.items = items; | ||
this.nextCursor = nextCursor; | ||
} | ||
} | ||
var Order; | ||
(function (Order) { | ||
Order["ASC"] = "asc"; | ||
Order["DESC"] = "desc"; | ||
})(Order || (Order = {})); | ||
var Chain; | ||
(function (Chain) { | ||
Chain["Ethereum"] = "mainnet"; | ||
Chain["Gnosis"] = "xdai"; | ||
})(Chain || (Chain = {})); | ||
var TransactionRequestStatus; | ||
@@ -80,21 +99,2 @@ (function (TransactionRequestStatus) { | ||
var Chain; | ||
(function (Chain) { | ||
Chain["Ethereum"] = "mainnet"; | ||
Chain["Gnosis"] = "xdai"; | ||
})(Chain || (Chain = {})); | ||
var Order; | ||
(function (Order) { | ||
Order["ASC"] = "asc"; | ||
Order["DESC"] = "desc"; | ||
})(Order || (Order = {})); | ||
class PaginatedResult { | ||
constructor(items, nextCursor) { | ||
this.items = items; | ||
this.nextCursor = nextCursor; | ||
} | ||
} | ||
function nextCursor(length, limit, offset) { | ||
@@ -104,22 +104,17 @@ const endIndex = offset + length; | ||
} | ||
function createUndefinedOrder(key, value) { | ||
return key && value ? { [key]: value } : {}; | ||
} | ||
function creatEqFilter(key, value) { | ||
function createEqFilter(key, value) { | ||
return value ? { [key]: { _eq: value } } : {}; | ||
} | ||
function filterZeroAddress(filter) { | ||
return filter ? { _neq: '0x0000000000000000000000000000000000000000' } : {}; | ||
function createAddressFilter(key, filterZeroAddress, value) { | ||
return filterZeroAddress || value | ||
? { | ||
[key]: { | ||
...(filterZeroAddress | ||
? { _neq: '0x0000000000000000000000000000000000000000' } | ||
: {}), | ||
...(value ? { _eq: value.toLowerCase() } : {}), | ||
}, | ||
} | ||
: {}; | ||
} | ||
function creatAddressFilter(key, filter, value) { | ||
const addressFilter = { | ||
[key]: { | ||
...filterZeroAddress(filter), | ||
}, | ||
}; | ||
if (value) { | ||
addressFilter[key]._eq = value.toLocaleLowerCase(); | ||
} | ||
return filter || value ? addressFilter : {}; | ||
} | ||
function createInFilter(key, values) { | ||
@@ -129,12 +124,16 @@ return values && values.length ? { [key]: { _in: values } } : {}; | ||
function createBetweenFilter(key, from, to) { | ||
const dateFilter = {}; | ||
const betweenFilter = {}; | ||
if (from) { | ||
dateFilter._gte = from; | ||
betweenFilter._gte = from; | ||
} | ||
if (to) { | ||
dateFilter._lte = to; | ||
betweenFilter._lte = to; | ||
} | ||
return from || to ? { [key]: dateFilter } : {}; | ||
return from || to ? { [key]: betweenFilter } : {}; | ||
} | ||
function createOrderBy(key, value) { | ||
return key && value ? { [key]: value } : {}; | ||
} | ||
class CodeAlreadyMintedError extends Error { | ||
@@ -258,7 +257,7 @@ constructor(code) { | ||
offset, | ||
orderBy: createUndefinedOrder(sortField, sortDir), | ||
orderBy: createOrderBy(sortField, sortDir), | ||
where: { | ||
...creatAddressFilter('collector_address', filterByZeroAddress, collectorAddress), | ||
...creatEqFilter('chain', chain), | ||
...creatEqFilter('drop_id', dropId), | ||
...createAddressFilter('collector_address', filterByZeroAddress, collectorAddress), | ||
...createEqFilter('chain', chain), | ||
...createEqFilter('drop_id', dropId), | ||
...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo), | ||
@@ -265,0 +264,0 @@ ...createInFilter('id', ids), |
@@ -0,1 +1,2 @@ | ||
import { FilterVariables, OrderByVariables, PaginatedVariables } from '@poap-xyz/utils'; | ||
export declare const PAGINATED_POAPS_QUERY = "\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n"; | ||
@@ -19,5 +20,4 @@ export interface PoapsResponse { | ||
export interface PaginatedPoapsResponse { | ||
data: { | ||
poaps: PoapsResponse[]; | ||
}; | ||
poaps: PoapsResponse[]; | ||
} | ||
export type PaginatedPoapsVariables = FilterVariables & OrderByVariables & PaginatedVariables; |
{ | ||
"name": "@poap-xyz/poaps", | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
"description": "Poaps module for the poap.js library", | ||
@@ -29,4 +29,4 @@ "main": "dist/cjs/index.cjs", | ||
"dependencies": { | ||
"@poap-xyz/providers": "0.1.8", | ||
"@poap-xyz/utils": "0.1.8" | ||
"@poap-xyz/providers": "0.2.0", | ||
"@poap-xyz/utils": "0.2.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "engines": { |
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
223318
1528
+ Added@poap-xyz/providers@0.2.0(transitive)
+ Added@poap-xyz/utils@0.2.0(transitive)
- Removed@poap-xyz/providers@0.1.8(transitive)
- Removed@poap-xyz/utils@0.1.8(transitive)
Updated@poap-xyz/providers@0.2.0
Updated@poap-xyz/utils@0.2.0