@sentio/api 1.0.5-rc.8 → 2.0.0-rc.1

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/README.md CHANGED
@@ -2,74 +2,112 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/@sentio%2Fapi.svg)](https://npmjs.com/package/@sentio/api) [![Release](https://github.com/sentioxyz/api/actions/workflows/cut-release.yaml/badge.svg)](https://github.com/sentioxyz/api/actions/workflows/cut-release.yaml)
4
4
 
5
+ TypeScript client for the [Sentio](https://sentio.xyz) API. The bindings are
6
+ generated from Sentio's protobuf definitions with
7
+ [protobuf-es](https://github.com/bufbuild/protobuf-es) and call the REST API
8
+ through [connect-es](https://github.com/connectrpc/connect-es) with the
9
+ [@sentio/connect-gateway-es](https://github.com/sentioxyz/connect-gateway-es)
10
+ transport — fully typed requests and responses, including server-streaming
11
+ endpoints.
12
+
13
+ > **v3 is a breaking rewrite.** v2 (`openapi-ts` based: `client.setConfig` +
14
+ > static service classes) is replaced by connect-es style clients. The REST
15
+ > API itself is unchanged; see the examples below for the new shapes. The
16
+ > package is ESM-only and requires Node 20+.
17
+
5
18
  ## Setup
6
19
 
7
20
  ```
8
21
  pnpm add @sentio/api
9
22
  ```
10
23
 
24
+ Create an API key under your project's settings on
25
+ [app.sentio.xyz](https://app.sentio.xyz).
26
+
11
27
  ## Usage
12
28
 
13
- ### Example 1: get project list
29
+ ### Example 1: list dashboards
14
30
 
15
31
  ```ts
16
- import { client, WebService } from "@sentio/api";
32
+ import { createSentioClient, WebService } from "@sentio/api";
17
33
 
18
- client.setConfig({
19
- auth: process.env.SENTIO_API_KEY,
34
+ const web = createSentioClient(WebService, {
35
+ apiKey: process.env.SENTIO_API_KEY,
20
36
  });
21
- const projects = await WebService.getProjectList();
22
- console.log(projects);
37
+ const dashboards = await web.listDashboards({
38
+ ownerName: "sentio",
39
+ slug: "coinbase",
40
+ });
41
+ console.log(dashboards);
23
42
  ```
24
43
 
25
44
  ### Example 2: insight query
26
45
 
27
46
  ```ts
28
- import { client, DataService } from "@sentio/api";
47
+ import { createSentioClient, InsightsService } from "@sentio/api";
29
48
 
30
- client.setConfig({
31
- auth: process.env.SENTIO_API_KEY,
49
+ const insights = createSentioClient(InsightsService, {
50
+ apiKey: process.env.SENTIO_API_KEY,
32
51
  });
33
52
 
34
- const res = await DataService.query({
35
- path: {
36
- owner: "sentio",
37
- slug: "coinbase",
53
+ const res = await insights.query({
54
+ projectOwner: "sentio",
55
+ projectSlug: "coinbase",
56
+ timeRange: {
57
+ start: "now-30d",
58
+ end: "now",
59
+ step: 3600,
60
+ timezone: "America/Los_Angeles",
38
61
  },
39
- body: {
40
- timeRange: {
41
- start: "now-30d",
42
- end: "now",
43
- step: 3600,
44
- timezone: "America/Los_Angeles",
45
- },
46
- limit: 20,
47
- queries: [
48
- {
49
- metricsQuery: {
50
- query: "cbETH_price",
51
- alias: "",
52
- id: "a",
53
- labelSelector: {},
54
- aggregate: undefined,
55
- functions: [],
56
- disabled: false,
57
- },
58
- dataSource: "METRICS",
59
- sourceName: "",
62
+ limit: 20,
63
+ queries: [
64
+ {
65
+ metricsQuery: {
66
+ query: "cbETH_price",
60
67
  },
61
- ],
62
- formulas: [],
63
- cachePolicy: {
64
- noCache: false,
65
- cacheTtlSecs: 1296000,
66
- cacheRefreshTtlSecs: 1800,
67
68
  },
68
- },
69
+ ],
69
70
  });
70
71
  console.log(res);
71
72
  ```
72
73
 
73
- ## Documentation
74
+ Request messages are plain partial objects (protobuf-es init shapes) — omitted
75
+ fields take their proto defaults.
76
+
77
+ ### Several services over one transport
78
+
79
+ ```ts
80
+ import { createClient, createSentioTransport, AnalyticService, WebService } from "@sentio/api";
81
+
82
+ const transport = createSentioTransport({ apiKey: process.env.SENTIO_API_KEY });
83
+ const web = createClient(WebService, transport);
84
+ const analytics = createClient(AnalyticService, transport);
85
+ ```
86
+
87
+ ### Message and enum types
88
+
89
+ Each service module exports its request/response types; deep-import them via
90
+ the `gen` subpath:
91
+
92
+ ```ts
93
+ import type { Project } from "@sentio/api/gen/service/common/protos/common_pb.js";
94
+ ```
95
+
96
+ ### Options
97
+
98
+ `createSentioClient` / `createSentioTransport` accept:
99
+
100
+ - `apiKey` — sent as the `api-key` header.
101
+ - `baseUrl` — defaults to `https://app.sentio.xyz`.
102
+ - everything else from `GatewayTransportOptions`
103
+ (`headers`, `fetch`, `interceptors`, `defaultTimeoutMs`, ...).
104
+
105
+ Errors are connect-es `ConnectError`s carrying the mapped gRPC code and the
106
+ server's `google.rpc.Status` details.
107
+
108
+ ## REST / OpenAPI
74
109
 
75
- [Sentio API Reference](https://docs.sentio.xyz/reference)
110
+ The raw REST API is documented at [docs.sentio.xyz](https://docs.sentio.xyz/reference);
111
+ this repository also ships the [OpenAPI spec](./openapi.json) and a generated
112
+ [HTML reference](./doc). Both reflect the same API surface as the TypeScript
113
+ client.
package/package.json CHANGED
@@ -1,30 +1,36 @@
1
1
  {
2
2
  "name": "@sentio/api",
3
- "version": "1.0.5-rc.8",
3
+ "version": "2.0.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/sentioxyz/api.git"
8
8
  },
9
+ "type": "module",
9
10
  "exports": {
10
- ".": "./dist/src/index.js"
11
+ ".": "./dist/src/index.js",
12
+ "./gen/*": "./dist/src/gen/*"
11
13
  },
12
14
  "files": [
13
15
  "{dist,src}",
14
- "!dist/test",
15
- "!**/.openapi-generator*"
16
+ "!dist/test"
16
17
  ],
17
18
  "sideEffects": false,
19
+ "engines": {
20
+ "node": ">=24"
21
+ },
18
22
  "dependencies": {
19
- "@hey-api/client-fetch": "^0.8.3"
23
+ "@bufbuild/protobuf": "^2.12.0",
24
+ "@connectrpc/connect": "^2.1.2",
25
+ "@sentio/connect-gateway-es": "^1.0.0"
20
26
  },
21
27
  "devDependencies": {
22
- "@types/node": "^20.14.1",
23
- "conventional-changelog-conventionalcommits": "^8.0.0",
28
+ "@types/node": "^24.13.2",
29
+ "conventional-changelog-conventionalcommits": "^9.3.1",
24
30
  "json": "^11.0.0",
25
- "semantic-release": "^24.0.0",
26
- "tsx": "^4.12.0",
27
- "typescript": "^5.4.5"
31
+ "semantic-release": "^25.0.5",
32
+ "tsx": "^4.22.4",
33
+ "typescript": "^6.0.3"
28
34
  },
29
35
  "scripts": {
30
36
  "build": "tsc",
@@ -1,12 +0,0 @@
1
- import type { ClientOptions } from './types.gen';
2
- import { type Config, type ClientOptions as DefaultClientOptions } from '@hey-api/client-fetch';
3
- /**
4
- * The `createClientConfig()` function will be called on client initialization
5
- * and the returned object will become the client's initial configuration.
6
- *
7
- * You may want to initialize your client this way instead of calling
8
- * `setConfig()`. This is useful for example if you're using Next.js
9
- * to ensure your client always has the correct values.
10
- */
11
- export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
12
- export declare const client: import("@hey-api/client-fetch").Client;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.client = void 0;
5
- const client_fetch_1 = require("@hey-api/client-fetch");
6
- exports.client = (0, client_fetch_1.createClient)((0, client_fetch_1.createConfig)({
7
- baseUrl: 'https://api.sentio.xyz'
8
- }));
9
- //# sourceMappingURL=client.gen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.gen.js","sourceRoot":"","sources":["../../src/client.gen.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,wDAA4H;AAY/G,QAAA,MAAM,GAAG,IAAA,2BAAY,EAAC,IAAA,2BAAY,EAAgB;IAC3D,OAAO,EAAE,wBAAwB;CACpC,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './types.gen';
2
- export * from './client.gen';
3
- export * from './sdk.gen';
package/dist/src/index.js DELETED
@@ -1,21 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- // This file is auto-generated by @hey-api/openapi-ts
18
- __exportStar(require("./types.gen"), exports);
19
- __exportStar(require("./client.gen"), exports);
20
- __exportStar(require("./sdk.gen"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,8CAA4B;AAC5B,+CAA6B;AAC7B,4CAA0B"}