@apibara/protocol 0.4.7 → 0.4.9

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 (43) hide show
  1. package/dist/client.d.ts +9 -9
  2. package/dist/client.js +26 -14
  3. package/dist/client.js.map +1 -1
  4. package/dist/cursor.d.ts +15 -2
  5. package/dist/cursor.js +26 -2
  6. package/dist/cursor.js.map +1 -1
  7. package/dist/cursor.test.d.ts +1 -0
  8. package/dist/cursor.test.js +22 -0
  9. package/dist/cursor.test.js.map +1 -0
  10. package/dist/index.d.ts +4 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/proto/apibara/node/v1alpha2/Data.d.ts +3 -3
  13. package/dist/proto/apibara/node/v1alpha2/DataFinality.d.ts +8 -6
  14. package/dist/proto/apibara/node/v1alpha2/DataFinality.js +6 -7
  15. package/dist/proto/apibara/node/v1alpha2/DataFinality.js.map +1 -1
  16. package/dist/proto/apibara/node/v1alpha2/StreamDataRequest.d.ts +3 -3
  17. package/dist/proto/index.d.ts +1 -1
  18. package/dist/proto/index.js.map +1 -1
  19. package/dist/proto/stream.d.ts +1 -1
  20. package/dist/proto/testing.d.ts +1 -1
  21. package/dist/proto/testing.js +4 -2
  22. package/dist/proto/testing.js.map +1 -1
  23. package/dist/proto/v1alpha2.d.ts +9 -9
  24. package/dist/proto/v1alpha2.js +1 -1
  25. package/dist/proto/v1alpha2.js.map +1 -1
  26. package/dist/request.d.ts +2 -2
  27. package/dist/request.js +1 -0
  28. package/dist/request.js.map +1 -1
  29. package/dist/request.test.js +9 -10
  30. package/dist/request.test.js.map +1 -1
  31. package/package.json +4 -3
  32. package/src/client.ts +118 -97
  33. package/src/cursor.test.ts +21 -0
  34. package/src/cursor.ts +35 -7
  35. package/src/index.ts +4 -4
  36. package/src/proto/apibara/node/v1alpha2/Data.ts +3 -3
  37. package/src/proto/apibara/node/v1alpha2/DataFinality.ts +18 -6
  38. package/src/proto/apibara/node/v1alpha2/StreamDataRequest.ts +3 -3
  39. package/src/proto/index.ts +1 -1
  40. package/src/proto/testing.ts +5 -5
  41. package/src/proto/v1alpha2.ts +16 -14
  42. package/src/request.test.ts +19 -20
  43. package/src/request.ts +16 -16
@@ -1,31 +1,30 @@
1
- import { v1alpha2 } from './proto'
2
- import { TestFilter } from './proto/testing'
3
- import { StreamDataRequest } from './request'
1
+ import { v1alpha2 } from "./proto";
2
+ import { TestFilter } from "./proto/testing";
3
+ import { StreamDataRequest } from "./request";
4
4
 
5
- describe('RequestBuilder', () => {
6
- it('returns the final request', () => {
7
- const filter = new TestFilter({
8
- num: 123,
9
- text: 'abcdef',
10
- })
5
+ describe("RequestBuilder", () => {
6
+ it("returns the final request", () => {
7
+ const filter = new TestFilter();
8
+ filter.num = 123;
9
+ filter.text = "abcdef";
11
10
 
12
11
  const request = StreamDataRequest.create()
13
12
  .withBatchSize(10)
14
13
  .withFilter(TestFilter.encode(filter).finish())
15
14
  .withFinality(v1alpha2.DataFinality.DATA_STATUS_FINALIZED)
16
- .encode()
15
+ .encode();
17
16
 
18
- expect(request.batchSize).toEqual(10)
19
- expect(request.filter).toBeInstanceOf(Buffer)
20
- expect(request.filter?.length).toEqual(10)
17
+ expect(request.batchSize).toEqual(10);
18
+ expect(request.filter).toBeInstanceOf(Buffer);
19
+ expect(request.filter?.length).toEqual(10);
21
20
 
22
21
  // make ts happy
23
- if (!request.filter || typeof request.filter == 'string') {
24
- throw new Error('undefined filter')
22
+ if (!request.filter || typeof request.filter === "string") {
23
+ throw new Error("undefined filter");
25
24
  }
26
25
 
27
- const back = TestFilter.decode(request.filter)
28
- expect(back.num.toString()).toEqual('123')
29
- expect(back.text).toEqual('abcdef')
30
- })
31
- })
26
+ const back = TestFilter.decode(request.filter);
27
+ expect(back.num.toString()).toEqual("123");
28
+ expect(back.text).toEqual("abcdef");
29
+ });
30
+ });
package/src/request.ts CHANGED
@@ -1,64 +1,64 @@
1
- import Long from 'long'
2
- import { v1alpha2 } from './proto'
1
+ import Long from "long";
2
+ import { v1alpha2 } from "./proto";
3
3
 
4
4
  export const StreamDataRequest = {
5
5
  /**
6
6
  * Start building a `StreamData` request.
7
7
  */
8
8
  create: () => new StreamDataRequestBuilder(),
9
- }
9
+ };
10
10
 
11
11
  export class StreamDataRequestBuilder {
12
- private request: v1alpha2.IStreamDataRequest
12
+ private request: v1alpha2.IStreamDataRequest;
13
13
 
14
14
  constructor() {
15
- this.request = {}
15
+ this.request = {};
16
16
  }
17
17
 
18
18
  /**
19
19
  * Set the new stream id.
20
20
  */
21
21
  withStreamId(streamId: number | Long) {
22
- this.request.streamId = streamId
23
- return this
22
+ this.request.streamId = streamId;
23
+ return this;
24
24
  }
25
25
 
26
26
  /**
27
27
  * Set the number of items in each response batch.
28
28
  */
29
29
  withBatchSize(size: number | Long) {
30
- this.request.batchSize = size
31
- return this
30
+ this.request.batchSize = size;
31
+ return this;
32
32
  }
33
33
 
34
34
  /**
35
35
  * Set the cursor from where to resume streaming.
36
36
  */
37
37
  withStartingCursor(cursor: v1alpha2.ICursor) {
38
- this.request.startingCursor = cursor
39
- return this
38
+ this.request.startingCursor = cursor;
39
+ return this;
40
40
  }
41
41
 
42
42
  /**
43
43
  * Set the request finality for data.
44
44
  */
45
45
  withFinality(finality: v1alpha2.DataFinality) {
46
- this.request.finality = finality
47
- return this
46
+ this.request.finality = finality;
47
+ return this;
48
48
  }
49
49
 
50
50
  /**
51
51
  * Set the stream-specific filter.
52
52
  */
53
53
  withFilter(filter: Uint8Array) {
54
- this.request.filter = filter
55
- return this
54
+ this.request.filter = filter;
55
+ return this;
56
56
  }
57
57
 
58
58
  /**
59
59
  * Build and return the request.
60
60
  */
61
61
  encode() {
62
- return this.request
62
+ return this.request;
63
63
  }
64
64
  }