@codex-data/sdk 0.5.7

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.
Files changed (97) hide show
  1. package/README.md +104 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +32 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/resources/graphql.d.ts +7438 -0
  7. package/dist/resources/graphql.d.ts.map +1 -0
  8. package/dist/resources/graphql.js +1314 -0
  9. package/dist/resources/graphql.js.map +1 -0
  10. package/dist/resources/graphql.schema.json +50830 -0
  11. package/dist/resources/graphql.ts +7976 -0
  12. package/dist/resources/schema.graphql +10393 -0
  13. package/dist/sdk/Mutation.d.ts +14 -0
  14. package/dist/sdk/Mutation.d.ts.map +1 -0
  15. package/dist/sdk/Mutation.js +22 -0
  16. package/dist/sdk/Mutation.js.map +1 -0
  17. package/dist/sdk/Query.d.ts +22 -0
  18. package/dist/sdk/Query.d.ts.map +1 -0
  19. package/dist/sdk/Query.js +35 -0
  20. package/dist/sdk/Query.js.map +1 -0
  21. package/dist/sdk/Query.test.d.ts +2 -0
  22. package/dist/sdk/Query.test.d.ts.map +1 -0
  23. package/dist/sdk/Query.test.js +50 -0
  24. package/dist/sdk/Query.test.js.map +1 -0
  25. package/dist/sdk/Subscribe.d.ts +17 -0
  26. package/dist/sdk/Subscribe.d.ts.map +1 -0
  27. package/dist/sdk/Subscribe.js +28 -0
  28. package/dist/sdk/Subscribe.js.map +1 -0
  29. package/dist/sdk/generated/fragment-masking.d.ts +16 -0
  30. package/dist/sdk/generated/fragment-masking.d.ts.map +1 -0
  31. package/dist/sdk/generated/fragment-masking.js +23 -0
  32. package/dist/sdk/generated/fragment-masking.js.map +1 -0
  33. package/dist/sdk/generated/gql.d.ts +243 -0
  34. package/dist/sdk/generated/gql.d.ts.map +1 -0
  35. package/dist/sdk/generated/gql.js +70 -0
  36. package/dist/sdk/generated/gql.js.map +1 -0
  37. package/dist/sdk/generated/graphql.d.ts +11765 -0
  38. package/dist/sdk/generated/graphql.d.ts.map +1 -0
  39. package/dist/sdk/generated/graphql.js +1338 -0
  40. package/dist/sdk/generated/graphql.js.map +1 -0
  41. package/dist/sdk/generated/index.d.ts +3 -0
  42. package/dist/sdk/generated/index.d.ts.map +1 -0
  43. package/dist/sdk/generated/index.js +19 -0
  44. package/dist/sdk/generated/index.js.map +1 -0
  45. package/dist/sdk/index.d.ts +23 -0
  46. package/dist/sdk/index.d.ts.map +1 -0
  47. package/dist/sdk/index.js +76 -0
  48. package/dist/sdk/index.js.map +1 -0
  49. package/dist/sdk/index.test.d.ts +2 -0
  50. package/dist/sdk/index.test.d.ts.map +1 -0
  51. package/dist/sdk/index.test.js +78 -0
  52. package/dist/sdk/index.test.js.map +1 -0
  53. package/dist/sdk/invariant.d.ts +2 -0
  54. package/dist/sdk/invariant.d.ts.map +1 -0
  55. package/dist/sdk/invariant.js +31 -0
  56. package/dist/sdk/invariant.js.map +1 -0
  57. package/package.json +60 -0
  58. package/src/index.ts +2 -0
  59. package/src/resources/.keep +0 -0
  60. package/src/resources/graphql.schema.json +50830 -0
  61. package/src/resources/graphql.ts +7976 -0
  62. package/src/resources/schema.graphql +10393 -0
  63. package/src/sdk/Mutation.ts +15 -0
  64. package/src/sdk/Query.test.ts +40 -0
  65. package/src/sdk/Query.ts +65 -0
  66. package/src/sdk/Subscribe.ts +61 -0
  67. package/src/sdk/generated/fragment-masking.ts +66 -0
  68. package/src/sdk/generated/gql.ts +157 -0
  69. package/src/sdk/generated/graphql.ts +8215 -0
  70. package/src/sdk/generated/index.ts +2 -0
  71. package/src/sdk/graphql/CreateWebhooks.graphql +1145 -0
  72. package/src/sdk/graphql/DeleteWebhooks.graphql +5 -0
  73. package/src/sdk/graphql/FilterExchanges.graphql +23 -0
  74. package/src/sdk/graphql/FilterPairs.graphql +124 -0
  75. package/src/sdk/graphql/FilterTokens.graphql +129 -0
  76. package/src/sdk/graphql/GetBars.graphql +32 -0
  77. package/src/sdk/graphql/GetDetailedPairStats.graphql +941 -0
  78. package/src/sdk/graphql/GetNetworkStatus.graphql +7 -0
  79. package/src/sdk/graphql/GetNetworks.graphql +6 -0
  80. package/src/sdk/graphql/GetPairEvents.graphql +28 -0
  81. package/src/sdk/graphql/GetPrice.graphql +9 -0
  82. package/src/sdk/graphql/GetSparklines.graphql +10 -0
  83. package/src/sdk/graphql/GetSymbol.graphql +11 -0
  84. package/src/sdk/graphql/GetTokens.graphql +14 -0
  85. package/src/sdk/graphql/GetWebhooks.graphql +168 -0
  86. package/src/sdk/graphql/ListPairsForToken.graphql +105 -0
  87. package/src/sdk/graphql/ListTopTokens.graphql +48 -0
  88. package/src/sdk/graphql/OnBarsUpdated.graphql +183 -0
  89. package/src/sdk/graphql/OnDetailedStatsUpdated.graphql +324 -0
  90. package/src/sdk/graphql/OnEventsCreated.graphql +62 -0
  91. package/src/sdk/graphql/OnNftAssetsCreated.graphql +29 -0
  92. package/src/sdk/graphql/OnNftEventsCreated.graphql +83 -0
  93. package/src/sdk/graphql/OnPairMetadataUpdated.graphql +55 -0
  94. package/src/sdk/graphql/OnPriceUpdated.graphql +9 -0
  95. package/src/sdk/index.test.ts +78 -0
  96. package/src/sdk/index.ts +100 -0
  97. package/src/sdk/invariant.ts +34 -0
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Codex SDK
2
+
3
+ This package exists to help you develop on top of the Codex API (https://docs.codex.io).
4
+
5
+ It provides the public schema SDL for you to use. You can use graphql-codegen to generate types and queries for example.
6
+
7
+ > [!NOTE]
8
+ > We've changed our name from Defined to Codex.
9
+ >
10
+ > You will see references to our previous company name, Defined, while we make the switch to Codex.
11
+
12
+ ## Installation
13
+
14
+ | packager | command |
15
+ | ----------------------------- | ------------------------- |
16
+ | [npm](https://www.npmjs.com/) | `npm add @codex-data/sdk` |
17
+ | [yarn](https://yarnpkg.com/) | `yarn add @codex-data/sdk` |
18
+ | [bun](https://bun.sh/) | `bun add @codex-data/sdk` |
19
+
20
+ ## Usage
21
+
22
+ Follow one of the examples in the [examples](/examples) directory, or simply run.
23
+
24
+ Fetch a token.
25
+
26
+ ```typescript
27
+ import { Codex } from "@codex-data/sdk";
28
+
29
+ const sdk = new Codex(MY_API_KEY);
30
+
31
+ sdk.queries
32
+ .token({
33
+ input: {
34
+ address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
35
+ networkId: 56,
36
+ },
37
+ })
38
+ .then(console.log);
39
+ ```
40
+
41
+ Use your own GraphQL selections
42
+
43
+ ```typescript
44
+ import { Network } from "../../src/resources/graphql";
45
+ import { Codex } from "@codex-data/sdk/dist/sdk";
46
+
47
+ const sdk = new Codex(process.env.CODEX_API_KEY || "");
48
+
49
+ sdk
50
+ .send<{ getNetworks: Network[] }>(
51
+ `
52
+ query GetNetworks {
53
+ getNetworks { id name }
54
+ }
55
+ `,
56
+ {}
57
+ )
58
+ .then((res) => {
59
+ console.log("Networks: ", res.getNetworks);
60
+ });
61
+ ```
62
+
63
+ ## Running the examples
64
+
65
+ You'll need to have [`curl`](https://curl.se/) installed in order to build this locally, as it fetches the schema from the Codex API.
66
+
67
+ You need to provide an API key in order for the examples to work. We have [bun](https://bun.sh) in use for development here.
68
+
69
+ After installing [bun](https://bun.sh), from the project root.
70
+
71
+ - `bun i`
72
+ - `bun run build`
73
+
74
+ ### Simple
75
+
76
+ This performs a simple inline graphql request, and uses a user-provided query and selection set.
77
+
78
+ - `cd examples/simple`
79
+ - `bun i`
80
+ - `CODEX_API_KEY=xyz bun run index.ts`
81
+
82
+ You can define your own GraphQL queries and use those with codegen (see next section). The pre-defined queries we provide in the
83
+ examples do not include all of the fields for every query.
84
+
85
+ ### Codegen
86
+
87
+ This shows how to use graphql-codegen to generate query types and get a fully typed end-to-end experience.
88
+
89
+ - `cd examples/codegen`
90
+ - `bun i`
91
+ - `bun run codegen`
92
+ - `CODEX_API_KEY=xyz bun run src/index.ts`
93
+
94
+ ### Next
95
+
96
+ This shows how you could use it in a NextJS project.
97
+
98
+ - `cd examples/next`
99
+ - `bun i`
100
+ - `NEXT_PUBLIC_CODEX_API_KEY=xyz bun run dev`
101
+
102
+ ## Contributing
103
+
104
+ Prs open!
@@ -0,0 +1,3 @@
1
+ export * as GraphQL from "./resources/graphql";
2
+ export * from "./sdk";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,cAAc,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.GraphQL = void 0;
30
+ exports.GraphQL = __importStar(require("./resources/graphql"));
31
+ __exportStar(require("./sdk"), exports);
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA+C;AAC/C,wCAAsB"}