@ironforge/sdk
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,7 +0,7 @@ | ||
import { AccountsRequestResult } from '../types'; | ||
import { AccountsAggregateBody, AccountsRequestResult } from '../types'; | ||
import { Cluster } from '../utils'; | ||
/** Configures the accounts aggregate request. */ | ||
export type AccountsAggregateConfig = { | ||
/** The query to execute. */ | ||
query: object; | ||
/** The request body. */ | ||
body: AccountsAggregateBody; | ||
/** The cluster to execute the query on, i.e. mainnet or devnet. */ | ||
@@ -8,0 +8,0 @@ cluster: Cluster; |
@@ -6,6 +6,6 @@ "use strict"; | ||
async function accountsAggregate(apiKey, host, config) { | ||
const { query, cluster, program, cacheControl } = config; | ||
const { body, cluster, program, cacheControl } = config; | ||
const res = await fetch(`https://${host}/v1/${cluster}/${program}/aggregate` + `?apiKey=${apiKey}`, { | ||
headers: (0, utils_1.requestHeaders)({ cacheControl }), | ||
body: JSON.stringify(query), | ||
body: JSON.stringify(body), | ||
method: 'POST', | ||
@@ -12,0 +12,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { AccountsRequestResultWithMetadata } from '../types'; | ||
import { AccountsFilterBody, AccountsRequestResultWithMetadata } from '../types'; | ||
import { Cluster } from '../utils'; | ||
@@ -7,4 +7,4 @@ /** Configures the accounts filterByType request. */ | ||
accountType: string; | ||
/** The query to execute. */ | ||
query: object; | ||
/** The request body. */ | ||
body: AccountsFilterBody; | ||
/** The cluster to execute the query on, i.e. mainnet or devnet. */ | ||
@@ -11,0 +11,0 @@ cluster: Cluster; |
@@ -6,7 +6,7 @@ "use strict"; | ||
async function accountsFilterByType(apiKey, host, config) { | ||
const { accountType, query, cluster, program, limit, offset, cacheControl } = config; | ||
const { accountType, body, cluster, program, limit, offset, cacheControl } = config; | ||
const res = await fetch(`https://${host}/v1/${cluster}/${program}/filter` + | ||
`/${accountType}?limit=${limit}&offset=${offset}&apiKey=${apiKey}`, { | ||
headers: (0, utils_1.requestHeaders)({ cacheControl }), | ||
body: JSON.stringify(query), | ||
body: JSON.stringify(body), | ||
method: 'POST', | ||
@@ -13,0 +13,0 @@ }); |
@@ -1,7 +0,7 @@ | ||
import { AccountsRequestResultWithMetadata } from '../types'; | ||
import { AccountsFilterBody, AccountsRequestResultWithMetadata } from '../types'; | ||
import { Cluster } from '../utils'; | ||
/** Configures the accounts filter request. */ | ||
export type AccountsFilterConfig = { | ||
/** The query to execute. */ | ||
query: object; | ||
/** The request body. */ | ||
body: AccountsFilterBody; | ||
/** The cluster to execute the query on, i.e. mainnet or devnet. */ | ||
@@ -8,0 +8,0 @@ cluster: Cluster; |
@@ -6,7 +6,7 @@ "use strict"; | ||
async function accountsFilter(apiKey, host, config) { | ||
const { query, cluster, program, limit, offset, cacheControl } = config; | ||
const { body, cluster, program, limit, offset, cacheControl } = config; | ||
const res = await fetch(`https://${host}/v1/${cluster}/${program}/filter` + | ||
`?limit=${limit}&offset=${offset}&apiKey=${apiKey}`, { | ||
headers: (0, utils_1.requestHeaders)({ cacheControl }), | ||
body: JSON.stringify(query), | ||
body: JSON.stringify(body), | ||
method: 'POST', | ||
@@ -13,0 +13,0 @@ }); |
@@ -1,7 +0,7 @@ | ||
import { AccountsRequestResultWithMetadata } from '../types'; | ||
import { AccountsRequestResultWithMetadata, AccountsMemcmpBody } from '../types'; | ||
import { Cluster } from '../utils'; | ||
/** Configures the accounts memcmp request. */ | ||
export type AccountsMemcmpConfig = { | ||
/** The query to execute. */ | ||
query: object; | ||
/** The request body. */ | ||
body: AccountsMemcmpBody; | ||
/** The cluster to execute the query on, i.e. mainnet or devnet. */ | ||
@@ -8,0 +8,0 @@ cluster: Cluster; |
@@ -6,7 +6,7 @@ "use strict"; | ||
async function accountsMemcmp(apiKey, host, config) { | ||
const { query, cluster, program, limit, offset, cacheControl } = config; | ||
const { body, cluster, program, limit, offset, cacheControl } = config; | ||
const res = await fetch(`https://${host}/v1/${cluster}/${program}/memcmp` + | ||
`?limit=${limit}&offset=${offset}&apiKey=${apiKey}`, { | ||
headers: (0, utils_1.requestHeaders)({ cacheControl }), | ||
body: JSON.stringify(query), | ||
body: JSON.stringify(body), | ||
method: 'POST', | ||
@@ -13,0 +13,0 @@ }); |
@@ -36,1 +36,31 @@ /** | ||
}; | ||
export declare const SortValues: readonly [1, -1, "asc", "desc", "ascending", "descending"]; | ||
export type SortValue = (typeof SortValues)[number]; | ||
export type Sort = [string, SortValue][]; | ||
export type Pagination = { | ||
offset?: number; | ||
limit?: number; | ||
sort: Sort; | ||
}; | ||
export type Projection = any; | ||
export type AccountsFilterBody = { | ||
filter?: object; | ||
projection?: object; | ||
pagination?: Pagination; | ||
}; | ||
export type MemcmpFilter = { | ||
memcmp: { | ||
offset: number; | ||
bytes: string; | ||
}; | ||
} | { | ||
dataSize: number; | ||
}; | ||
export type AccountsMemcmpBody = { | ||
filters: MemcmpFilter[]; | ||
projection?: Projection; | ||
pagination?: Pagination; | ||
}; | ||
export type AccountsAggregateBody = { | ||
pipeline: Record<string, any>[]; | ||
}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSuccessResult = exports.isFailureResult = void 0; | ||
exports.SortValues = exports.isSuccessResult = exports.isFailureResult = void 0; | ||
/** | ||
@@ -22,2 +22,13 @@ * Checks if the given result is a failure result. | ||
exports.isSuccessResult = isSuccessResult; | ||
// ----------------- | ||
// Body Types | ||
// ----------------- | ||
exports.SortValues = [ | ||
1, | ||
-1, | ||
'asc', | ||
'desc', | ||
'ascending', | ||
'descending', | ||
]; | ||
//# sourceMappingURL=types.js.map |
@@ -10,3 +10,2 @@ export * from './cluster'; | ||
export declare function requestHeaders(headers?: Partial<RequestHeaders>): { | ||
'cache-control': string; | ||
'content-type': string; | ||
@@ -13,0 +12,0 @@ 'x-ironforge-cache-control': string; |
@@ -34,3 +34,2 @@ "use strict"; | ||
return { | ||
'cache-control': 'no-cache', | ||
'content-type': 'application/json', | ||
@@ -37,0 +36,0 @@ 'x-ironforge-cache-control': cacheControl, |
{ | ||
"name": "@ironforge/sdk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "IronForge SDK.", | ||
@@ -5,0 +5,0 @@ "main": "dist/sdk.js", |
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
Sorry, the diff of this file is not supported yet
33741
654