Merge pull request #34 from FlipsideCrypto/support-cloudflare-worker

Support cloudflare worker
This commit is contained in:
Jim Myers 2024-03-07 15:26:14 -05:00 committed by GitHub
commit 8b98a4b924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 61 deletions

View File

@ -20,5 +20,5 @@ Get your [free API key here](https://flipsidecrypto.xyz/account/api-keys)
| Language | Version | Status |
| ------------------------ | ------- | ---------------------------------------------------------------------------------- |
| ✅ [Python](./python/) | 2.0.8 | [![tests](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_python.yml/badge.svg)](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_python.yml) |
| ✅ [JS/TypeScript](./js) | 2.0.0 | [![tests](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_js.yml/badge.svg)](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_js.yml)
| ✅ [JS/TypeScript](./js) | 2.0.1 | [![tests](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_js.yml/badge.svg)](https://github.com/FlipsideCrypto/sdk/actions/workflows/ci_js.yml)
| ✅ [R](./r/shroomDK/) | 0.2.2 | [Available on CRAN](https://cran.r-project.org/web/packages/shroomDK/shroomDK.pdf) |

View File

@ -1,6 +1,6 @@
{
"name": "@flipsidecrypto/sdk",
"version": "2.0.0",
"version": "2.1.0",
"description": "The official Flipside Crypto SDK",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -32,6 +32,6 @@
"license": "MIT",
"dependencies": {
"@types/eslint": "^8.4.8",
"axios": "^0.27.2"
"xior": "^0.1.1"
}
}

View File

@ -1,4 +1,4 @@
import axios, { AxiosError, AxiosResponse } from "axios";
import xior, { XiorError as AxiosError, XiorResponse as AxiosResponse } from "xior";
import { ServerError, UnexpectedSDKError, UserError } from "./errors";
import {
CompassApiClient,
@ -26,6 +26,7 @@ import {
const PARSE_ERROR_MSG = "the api returned an error and there was a fatal client side error parsing that error msg";
const axios = xior.create();
export class Api implements CompassApiClient {
url: string;
#baseUrl: string;

View File

@ -21,7 +21,7 @@ const runIt = async (): Promise<void> => {
async function runWithSuccess(flipside: Flipside) {
// Create a query object for the `query.run` function to execute
const query: Query = {
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.core.ez_nft_mints limit 100",
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints limit 100",
ttlMinutes: 10,
pageSize: 5,
pageNumber: 1,
@ -41,7 +41,7 @@ async function runWithSuccess(flipside: Flipside) {
async function runWithError(flipside: Flipside) {
// Create a query object for the `query.run` function to execute
const query: Query = {
sql: "select nft_address mint_price_eth mint_price_usd from ethereum.core.ez_nft_mints limit 100",
sql: "select nft_address mint_price_eth mint_price_usd from ethereum.nft.ez_nft_mints limit 100",
ttlMinutes: 10,
pageSize: 5,
pageNumber: 1,
@ -58,7 +58,7 @@ async function runWithError(flipside: Flipside) {
async function pageThruResults(flipside: Flipside) {
// Create a query object for the `query.run` function to execute
const query: Query = {
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.core.ez_nft_mints limit 100",
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints limit 100",
ttlMinutes: 10,
pageSize: 25,
pageNumber: 1,
@ -93,7 +93,7 @@ async function pageThruResults(flipside: Flipside) {
async function getQueryRunSuccess(flipside: Flipside) {
// Create a query object for the `query.run` function to execute
const query: Query = {
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.core.ez_nft_mints limit 100",
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints limit 100",
ttlMinutes: 10,
pageSize: 5,
pageNumber: 1,
@ -124,11 +124,11 @@ async function getQueryRunError(flipside: Flipside) {
async function cancelQueryRun(flipside: Flipside) {
// Create a query object for the `query.run` function to execute
const query: Query = {
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.core.ez_nft_mints limit 100",
sql: "select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints limit 999",
ttlMinutes: 10,
pageSize: 5,
pageNumber: 1,
maxAgeMinutes: 10,
maxAgeMinutes: 0,
};
const queryRun = await flipside.query.createQueryRun(query);

View File

@ -94,19 +94,6 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
axios@^0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
dependencies:
follow-redirects "^1.14.9"
form-data "^4.0.0"
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
@ -177,13 +164,6 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@ -212,11 +192,6 @@ deep-eql@^3.0.1:
dependencies:
type-detect "^4.0.0"
delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk=
emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
@ -361,11 +336,6 @@ find-up@^5.0.0:
locate-path "^6.0.0"
path-exists "^4.0.0"
follow-redirects@^1.14.9:
version "1.15.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
foreground-child@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-2.0.0.tgz#71b32800c9f15aa8f2f83f4a6bd9bff35d861a53"
@ -374,15 +344,6 @@ foreground-child@^2.0.0:
cross-spawn "^7.0.0"
signal-exit "^3.0.2"
form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@ -515,18 +476,6 @@ make-dir@^3.0.0:
dependencies:
semver "^6.0.0"
mime-db@1.52.0:
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
dependencies:
mime-db "1.52.0"
minimatch@^3.0.4, minimatch@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@ -710,6 +659,11 @@ test-exclude@^6.0.0:
glob "^7.1.4"
minimatch "^3.0.4"
tiny-lru@^11.2.5:
version "11.2.5"
resolved "https://registry.yarnpkg.com/tiny-lru/-/tiny-lru-11.2.5.tgz#b138b99022aa26c567fa51a8dbf9e3e2959b2b30"
integrity sha512-JpqM0K33lG6iQGKiigcwuURAKZlq6rHXfrgeL4/I8/REoyJTGU+tEMszvT/oTRVHG2OiylhGDjqPp1jWMlr3bw==
tinypool@^0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-0.1.3.tgz#b5570b364a1775fd403de5e7660b325308fee26b"
@ -725,6 +679,11 @@ totalist@^3.0.0:
resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.0.tgz#4ef9c58c5f095255cdc3ff2a0a55091c57a3a1bd"
integrity sha512-eM+pCBxXO/njtF7vdFsHuqb+ElbxqtI4r5EAvk6grfAFyJ6IvWlSkfZ5T9ozC6xWw3Fj1fGoSmrl0gUs46JVIw==
ts-deepmerge@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/ts-deepmerge/-/ts-deepmerge-7.0.0.tgz#ee824dc177d452603348c7e6f3b90223434a6b44"
integrity sha512-WZ/iAJrKDhdINv1WG6KZIGHrZDar6VfhftG1QJFpVbOYZMYJLJOvZOo1amictRXVdBXZIgBHKswMTXzElngprA==
type-detect@^4.0.0, type-detect@^4.0.5:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
@ -785,6 +744,14 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
xior@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/xior/-/xior-0.1.1.tgz#285e996585e1c0ab42ee3aca3edcef5c0d06c4aa"
integrity sha512-GZwWfZ7DoZpNMsUCRaKJKAPgBcfLx8/IJM9NOlFJVF87PPRHHjLhhblWOOOxyLPgC3NJkT+fFHzxYlQlGbCbhw==
dependencies:
tiny-lru "^11.2.5"
ts-deepmerge "^7.0.0"
y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"