@whisk/client 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WhiskClient.js +12 -9
- package/dist/WhiskClient.js.map +1 -1
- package/dist/actions/fragments/vault.js +4 -5
- package/dist/actions/fragments/vault.js.map +1 -1
- package/dist/actions/getVaultSummaries.js +6 -6
- package/dist/actions/getVaultSummaries.js.map +1 -1
- package/dist/errors.js +3 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/scalarExchange.js +5 -6
- package/dist/scalarExchange.js.map +1 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/WhiskClient.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
cacheExchange,
|
|
3
|
+
fetchExchange,
|
|
4
|
+
Client as UrqlClient
|
|
5
|
+
} from "@urql/core";
|
|
6
|
+
import { errAsync, okAsync, ResultAsync } from "neverthrow";
|
|
7
|
+
import { WhiskError } from "./errors.js";
|
|
8
|
+
import { scalarsExchange } from "./scalarExchange.js";
|
|
6
9
|
const DEFAULT_WHISK_API_URL = "https://api-v2.whisk.so/graphql";
|
|
7
10
|
class WhiskClient {
|
|
8
11
|
urql;
|
|
9
12
|
debug;
|
|
10
13
|
constructor({ apiKey, url = DEFAULT_WHISK_API_URL, debug = false }) {
|
|
11
|
-
this.urql = new
|
|
14
|
+
this.urql = new UrqlClient({
|
|
12
15
|
url,
|
|
13
16
|
exchanges: [scalarsExchange, cacheExchange, fetchExchange],
|
|
14
17
|
fetchOptions: {
|
|
@@ -37,7 +40,7 @@ class WhiskClient {
|
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
export {
|
|
44
|
+
WhiskClient
|
|
45
|
+
};
|
|
43
46
|
//# sourceMappingURL=WhiskClient.js.map
|
package/dist/WhiskClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/WhiskClient.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/WhiskClient.ts"],"sourcesContent":["import {\n type AnyVariables,\n cacheExchange,\n fetchExchange,\n type TypedDocumentNode,\n Client as UrqlClient,\n} from \"@urql/core\"\nimport { errAsync, okAsync, ResultAsync } from \"neverthrow\"\nimport { WhiskError } from \"./errors.js\"\nimport { scalarsExchange } from \"./scalarExchange.js\"\n\nconst DEFAULT_WHISK_API_URL = \"https://api-v2.whisk.so/graphql\"\n\nexport interface WhiskClientConfig {\n readonly apiKey: string\n readonly url?: string\n readonly debug?: boolean\n}\n\nexport class WhiskClient {\n private readonly urql: UrqlClient\n private readonly debug: boolean\n\n constructor({ apiKey, url = DEFAULT_WHISK_API_URL, debug = false }: WhiskClientConfig) {\n this.urql = new UrqlClient({\n url,\n exchanges: [scalarsExchange, cacheExchange, fetchExchange],\n fetchOptions: {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n },\n })\n\n this.debug = debug\n }\n\n public query<TValue, TVariables extends AnyVariables>(\n document: TypedDocumentNode<TValue, TVariables>,\n variables: TVariables,\n ): ResultAsync<TValue, WhiskError> {\n return ResultAsync.fromPromise(this.urql.query(document, variables), (error: unknown) =>\n WhiskError.from(error),\n ).andThen((result) => {\n // Bubbles up any network errors\n if (result.error?.networkError) {\n return errAsync(WhiskError.from(result.error.networkError))\n }\n\n // Error if we have no data\n if (result.data === undefined) {\n return errAsync(WhiskError.from(\"No data returned from query\"))\n }\n\n // Log any graphql errors (but don't put into error, since partial is fine)\n if ((result.error?.graphQLErrors?.length ?? 0) > 0 && this.debug) {\n console.debug(\"[Whisk Client] GraphQL errors:\", result.error?.graphQLErrors)\n }\n\n return okAsync(result.data)\n })\n }\n}\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EAEA,UAAU;AAAA,OACL;AACP,SAAS,UAAU,SAAS,mBAAmB;AAC/C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,MAAM,wBAAwB;AAQvB,MAAM,YAAY;AAAA,EACN;AAAA,EACA;AAAA,EAEjB,YAAY,EAAE,QAAQ,MAAM,uBAAuB,QAAQ,MAAM,GAAsB;AACrF,SAAK,OAAO,IAAI,WAAW;AAAA,MACzB;AAAA,MACA,WAAW,CAAC,iBAAiB,eAAe,aAAa;AAAA,MACzD,cAAc;AAAA,QACZ,SAAS;AAAA,UACP,eAAe,UAAU,MAAM;AAAA,QACjC;AAAA,MACF;AAAA,IACF,CAAC;AAED,SAAK,QAAQ;AAAA,EACf;AAAA,EAEO,MACL,UACA,WACiC;AACjC,WAAO,YAAY;AAAA,MAAY,KAAK,KAAK,MAAM,UAAU,SAAS;AAAA,MAAG,CAAC,UACpE,WAAW,KAAK,KAAK;AAAA,IACvB,EAAE,QAAQ,CAAC,WAAW;AAEpB,UAAI,OAAO,OAAO,cAAc;AAC9B,eAAO,SAAS,WAAW,KAAK,OAAO,MAAM,YAAY,CAAC;AAAA,MAC5D;AAGA,UAAI,OAAO,SAAS,QAAW;AAC7B,eAAO,SAAS,WAAW,KAAK,6BAA6B,CAAC;AAAA,MAChE;AAGA,WAAK,OAAO,OAAO,eAAe,UAAU,KAAK,KAAK,KAAK,OAAO;AAChE,gBAAQ,MAAM,kCAAkC,OAAO,OAAO,aAAa;AAAA,MAC7E;AAEA,aAAO,QAAQ,OAAO,IAAI;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { graphql } from
|
|
2
|
-
|
|
1
|
+
import { graphql } from "@whisk/graphql";
|
|
3
2
|
const vaultSummaryFragment = graphql(`
|
|
4
3
|
fragment VaultSummaryFragment on MorphoVault {
|
|
5
4
|
chain {
|
|
@@ -11,7 +10,7 @@ const vaultSummaryFragment = graphql(`
|
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
`);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export {
|
|
14
|
+
vaultSummaryFragment
|
|
15
|
+
};
|
|
17
16
|
//# sourceMappingURL=vault.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/fragments/vault.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/fragments/vault.ts"],"sourcesContent":["import { type FragmentOf, graphql } from \"@whisk/graphql\"\n\nexport const vaultSummaryFragment = graphql(`\n fragment VaultSummaryFragment on MorphoVault {\n chain {\n id\n }\n vaultAddress\n totalSupplied {\n raw\n }\n }\n`)\n\nexport type VaultSummary = FragmentOf<typeof vaultSummaryFragment>\n"],"mappings":"AAAA,SAA0B,eAAe;AAElC,MAAM,uBAAuB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAU3C;","names":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { graphql } from
|
|
2
|
-
import { vaultSummaryFragment } from
|
|
3
|
-
|
|
1
|
+
import { graphql } from "@whisk/graphql";
|
|
2
|
+
import { vaultSummaryFragment } from "./fragments/vault.js";
|
|
4
3
|
const vaultSummaryQuery = graphql(
|
|
5
4
|
`
|
|
6
5
|
query ($limit: Int!) {
|
|
@@ -16,7 +15,8 @@ const vaultSummaryQuery = graphql(
|
|
|
16
15
|
const getVaultSummaries = (client, variables) => {
|
|
17
16
|
return client.query(vaultSummaryQuery, variables).map((result) => result.morphoVaults.items);
|
|
18
17
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export {
|
|
19
|
+
getVaultSummaries,
|
|
20
|
+
vaultSummaryQuery
|
|
21
|
+
};
|
|
22
22
|
//# sourceMappingURL=getVaultSummaries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/getVaultSummaries.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/getVaultSummaries.ts"],"sourcesContent":["import { graphql, type ResultOf } from \"@whisk/graphql\"\nimport type { VariablesOf } from \"gql.tada\"\nimport type { WhiskActionFn } from \"../types.js\"\nimport { vaultSummaryFragment } from \"./fragments/vault.js\"\n\nexport const vaultSummaryQuery = graphql(\n `\n query ($limit: Int!) {\n morphoVaults(limit: $limit) {\n items {\n ...VaultSummaryFragment\n }\n }\n }\n `,\n [vaultSummaryFragment],\n)\n\nexport type GetVaultSummariesVariables = VariablesOf<typeof vaultSummaryQuery>\nexport type GetVaultSummariesResult = ResultOf<typeof vaultSummaryQuery>[\"morphoVaults\"][\"items\"]\n\nexport const getVaultSummaries: WhiskActionFn<\n GetVaultSummariesResult,\n GetVaultSummariesVariables\n> = (client, variables) => {\n return client.query(vaultSummaryQuery, variables).map((result) => result.morphoVaults.items)\n}\n"],"mappings":"AAAA,SAAS,eAA8B;AAGvC,SAAS,4BAA4B;AAE9B,MAAM,oBAAoB;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,CAAC,oBAAoB;AACvB;AAKO,MAAM,oBAGT,CAAC,QAAQ,cAAc;AACzB,SAAO,OAAO,MAAM,mBAAmB,SAAS,EAAE,IAAI,CAAC,WAAW,OAAO,aAAa,KAAK;AAC7F;","names":[]}
|
package/dist/errors.js
CHANGED
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export class WhiskError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"WhiskError\"\n }\n\n static from(error: unknown): WhiskError {\n if (error instanceof WhiskError) {\n return error\n }\n if (error instanceof Error) {\n return new WhiskError(error.message, { cause: error })\n }\n return new WhiskError(String(error))\n }\n}\n"],"mappings":"AAAO,MAAM,mBAAmB,MAAM;AAAA,EACpC,YAAY,SAAiB,SAAwB;AACnD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,KAAK,OAA4B;AACtC,QAAI,iBAAiB,YAAY;AAC/B,aAAO;AAAA,IACT;AACA,QAAI,iBAAiB,OAAO;AAC1B,aAAO,IAAI,WAAW,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC;AAAA,IACvD;AACA,WAAO,IAAI,WAAW,OAAO,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./actions/getVaultSummaries.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./WhiskClient.js";
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./actions/getVaultSummaries.js\"\nexport * from \"./types.js\"\nexport * from \"./WhiskClient.js\"\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
package/dist/scalarExchange.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import customScalarsExchange from
|
|
2
|
-
import { schema } from
|
|
3
|
-
|
|
1
|
+
import customScalarsExchange from "@atmina/urql-custom-scalars-exchange";
|
|
2
|
+
import { schema } from "@whisk/graphql";
|
|
4
3
|
const scalarsExchange = customScalarsExchange({
|
|
5
4
|
schema,
|
|
6
5
|
scalars: {
|
|
@@ -9,7 +8,7 @@ const scalarsExchange = customScalarsExchange({
|
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export {
|
|
12
|
+
scalarsExchange
|
|
13
|
+
};
|
|
15
14
|
//# sourceMappingURL=scalarExchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scalarExchange.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/scalarExchange.ts"],"sourcesContent":["import customScalarsExchange from \"@atmina/urql-custom-scalars-exchange\"\nimport { schema } from \"@whisk/graphql\"\n\n// @ts-expect-error - Package has CJS/ESM interop issues with verbatimModuleSyntax\nexport const scalarsExchange = customScalarsExchange({\n schema,\n scalars: {\n BigInt(value: string) {\n return BigInt(value)\n },\n },\n})\n"],"mappings":"AAAA,OAAO,2BAA2B;AAClC,SAAS,cAAc;AAGhB,MAAM,kBAAkB,sBAAsB;AAAA,EACnD;AAAA,EACA,SAAS;AAAA,IACP,OAAO,OAAe;AACpB,aAAO,OAAO,KAAK;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whisk/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@urql/core": "^6.0.1",
|
|
14
14
|
"gql.tada": "1.9.0",
|
|
15
15
|
"neverthrow": "^8.2.0",
|
|
16
|
-
"@whisk/graphql": "0.0.
|
|
16
|
+
"@whisk/graphql": "0.0.4"
|
|
17
17
|
},
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"module": "./dist/index.js",
|