@sentio/sdk 2.36.2-rc.1 → 2.37.0-rc.2
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/lib/core/base-context.d.ts +4 -0
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +20 -4
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +6 -0
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/database-schema.d.ts +8 -0
- package/lib/core/database-schema.d.ts.map +1 -0
- package/lib/core/database-schema.js +10 -0
- package/lib/core/database-schema.js.map +1 -0
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -0
- package/lib/core/index.js.map +1 -1
- package/lib/store/codegen.d.ts +4 -0
- package/lib/store/codegen.d.ts.map +1 -0
- package/lib/store/codegen.js +180 -0
- package/lib/store/codegen.js.map +1 -0
- package/lib/store/context.d.ts +2 -0
- package/lib/store/context.d.ts.map +1 -0
- package/lib/store/context.js +2 -0
- package/lib/store/context.js.map +1 -0
- package/lib/store/decorators.d.ts +7 -0
- package/lib/store/decorators.d.ts.map +1 -0
- package/lib/store/decorators.js +7 -0
- package/lib/store/decorators.js.map +1 -0
- package/lib/store/entity.d.ts +18 -0
- package/lib/store/entity.d.ts.map +1 -0
- package/lib/store/entity.js +51 -0
- package/lib/store/entity.js.map +1 -0
- package/lib/store/index.d.ts +6 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/store/index.js +6 -0
- package/lib/store/index.js.map +1 -0
- package/lib/store/run.d.ts +2 -0
- package/lib/store/run.d.ts.map +1 -0
- package/lib/store/run.js +11 -0
- package/lib/store/run.js.map +1 -0
- package/lib/store/schema.d.ts +7 -0
- package/lib/store/schema.d.ts.map +1 -0
- package/lib/store/schema.js +30 -0
- package/lib/store/schema.js.map +1 -0
- package/lib/store/store.d.ts +12 -0
- package/lib/store/store.d.ts.map +1 -0
- package/lib/store/store.js +61 -0
- package/lib/store/store.js.map +1 -0
- package/lib/store/types.d.ts +10 -0
- package/lib/store/types.d.ts.map +1 -0
- package/lib/store/types.js +2 -0
- package/lib/store/types.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +2 -5
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +2 -2
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +8 -5
- package/src/core/base-context.ts +22 -4
- package/src/core/core-plugin.ts +7 -0
- package/src/core/database-schema.ts +11 -0
- package/src/core/index.ts +1 -0
- package/src/store/codegen.ts +213 -0
- package/src/store/context.ts +1 -0
- package/src/store/decorators.ts +9 -0
- package/src/store/entity.ts +61 -0
- package/src/store/index.ts +5 -0
- package/src/store/run.ts +10 -0
- package/src/store/schema.ts +35 -0
- package/src/store/store.ts +68 -0
- package/src/store/types.ts +10 -0
- package/src/testing/test-processor-server.ts +13 -2
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Entity, EntityClass } from './entity.js'
|
2
|
+
import { StoreContext } from './context.js'
|
3
|
+
|
4
|
+
export class Store {
|
5
|
+
constructor(private readonly context: StoreContext) {}
|
6
|
+
|
7
|
+
async get<T extends Entity>(entity: EntityClass<T> | string, id: string): Promise<T | undefined> {
|
8
|
+
const promise = this.context.sendRequest({
|
9
|
+
get: {
|
10
|
+
entity: typeof entity == 'string' ? entity : entity.name,
|
11
|
+
id
|
12
|
+
}
|
13
|
+
})
|
14
|
+
|
15
|
+
const data = (await promise) as any
|
16
|
+
if (data?.['id'] != null) {
|
17
|
+
return this.newEntity(entity as EntityClass<T>, data)
|
18
|
+
}
|
19
|
+
return undefined
|
20
|
+
}
|
21
|
+
|
22
|
+
async delete(entity: EntityClass<any>, id: string | string[]): Promise<void> {
|
23
|
+
await this.context.sendRequest({
|
24
|
+
delete: {
|
25
|
+
entity: entity.name,
|
26
|
+
id: Array.isArray(id) ? id : [id]
|
27
|
+
}
|
28
|
+
})
|
29
|
+
}
|
30
|
+
|
31
|
+
async upsert<T extends Entity>(entity: T | T[]): Promise<T> {
|
32
|
+
const promise = this.context.sendRequest({
|
33
|
+
upsert: {
|
34
|
+
entity: entity.constructor.name,
|
35
|
+
data: Array.isArray(entity) ? entity.map((e) => e.data) : [entity.data]
|
36
|
+
}
|
37
|
+
})
|
38
|
+
|
39
|
+
if (Array.isArray(entity)) {
|
40
|
+
entity.forEach((e) => (e.store = this))
|
41
|
+
} else {
|
42
|
+
entity.store = this
|
43
|
+
}
|
44
|
+
|
45
|
+
return promise as Promise<T>
|
46
|
+
}
|
47
|
+
|
48
|
+
async list<T extends Entity>(entity: EntityClass<T>, limit?: number, offset?: number): Promise<T[]> {
|
49
|
+
const promise = this.context.sendRequest({
|
50
|
+
list: {
|
51
|
+
entity: entity.name,
|
52
|
+
limit,
|
53
|
+
offset
|
54
|
+
}
|
55
|
+
})
|
56
|
+
|
57
|
+
const list = (await promise) as any[]
|
58
|
+
return list.map((data) => {
|
59
|
+
return this.newEntity(entity, data)
|
60
|
+
})
|
61
|
+
}
|
62
|
+
|
63
|
+
private newEntity<T extends Entity>(entity: EntityClass<T>, data: any) {
|
64
|
+
const e = new (entity as EntityClass<T>)(data)
|
65
|
+
e.store = this
|
66
|
+
return e
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export type { BigDecimal } from '@sentio/bigdecimal'
|
2
|
+
|
3
|
+
export type ID = string
|
4
|
+
export type String = string
|
5
|
+
export type Int = number
|
6
|
+
export type Float = number
|
7
|
+
export type Boolean = boolean
|
8
|
+
export type DateTime = Date
|
9
|
+
export type Json = any
|
10
|
+
export type Bytes = Uint8Array
|
@@ -2,12 +2,16 @@ import {
|
|
2
2
|
AccountConfig,
|
3
3
|
ContractConfig,
|
4
4
|
DataBinding,
|
5
|
+
DeepPartial,
|
5
6
|
Empty,
|
6
7
|
ProcessBindingResponse,
|
7
8
|
ProcessBindingsRequest,
|
8
9
|
ProcessConfigRequest,
|
9
10
|
ProcessConfigResponse,
|
10
11
|
ProcessorServiceImplementation,
|
12
|
+
ProcessStreamRequest,
|
13
|
+
ProcessStreamResponse,
|
14
|
+
ServerStreamingMethodResult,
|
11
15
|
StartRequest
|
12
16
|
} from '@sentio/protos'
|
13
17
|
import { CallContext } from 'nice-grpc-common'
|
@@ -80,7 +84,14 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
80
84
|
return this.service.processBindings({ bindings: [request] }, context)
|
81
85
|
}
|
82
86
|
|
83
|
-
processBindingsStream(
|
84
|
-
|
87
|
+
processBindingsStream(
|
88
|
+
requests: AsyncIterable<ProcessStreamRequest>,
|
89
|
+
context: CallContext
|
90
|
+
): ServerStreamingMethodResult<DeepPartial<ProcessStreamResponse>> {
|
91
|
+
throw new Error('Method not implemented.')
|
85
92
|
}
|
93
|
+
|
94
|
+
// processBindingsStream(request: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
|
95
|
+
// return this.service.processBindingsStream(request, context)
|
96
|
+
// }
|
86
97
|
}
|