-
Notifications
You must be signed in to change notification settings - Fork 375
/
container.gen.js.hbs
122 lines (106 loc) · 3.44 KB
/
container.gen.js.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{{~#if (contains filename "api/node/service.proto")~}}
import { observer } from 'mobx-react'
import { Stream, StreamPagination } from './stream'
import { Unary } from './unary'
import { Entity } from './entity'
import { withStoreContext } from '@berty/store/context'
import { Component } from 'react'
{{#with (lookup 'berty.node.CommitLog')}}
{{#with fields.entity.resolvedType}}
{{#each fields}}
{{#with resolvedType}}
{{#if fields.id}}
@withStoreContext
@observer
export class {{name}}Entity extends Entity {
fetch = () => {
const { context, children, ...input } = this.props
return context.node.service.{{case 'camel' name}}(input)
}
get store () {
const { context } = this.props
return context.entity.{{case 'camel' name}}
}
}
{{/if}}
{{/with}}
{{/each}}
{{/with}}
{{/with}}
{{#with (lookup 'berty.node.Service')}}
{{#each methods}}
{{#if responseStream}}
@withStoreContext
export class {{name}}ServiceNode extends Stream {
get method () {
return this.props.context.node.service.{{case 'camel' name}}
}
}
{{#with (lookup 'berty.node.CommitLog.Entity')}}
{{#each fields}}
{{#if (eq resolvedType.name ../../resolvedResponseType.name)}}
{{#with ../../this}}
{{#if (hasOwn resolvedRequestType.fields 'paginate')}}
@withStoreContext
class {{name}}ServiceNodePagination extends StreamPagination {
get store () {
return this.props.context.entity.{{case 'camel' resolvedResponseType.name}}
}
get method () {
return this.props.context.node.service.{{case 'camel' name}}
}
}
{{name}}ServiceNode.Pagination = {{name}}ServiceNodePagination
{{/if}}
{{/with}}
{{/if}}
{{/each}}
{{/with}}
{{else}}
@withStoreContext
export class {{name}}ServiceNode extends Unary {
get method () {
return this.props.context.node.service.{{case 'camel' name}}
}
}
{{/if}}
{{/each}}
@withStoreContext
export class ServiceNode extends Component {
{{#each methods}}
{{#if responseStream}}
static {{name}} = {{name}}ServiceNode
{{/if}}
{{/each}}
render () {
return context => this.props.children(context.node)
}
}
{{/with}}
@withStoreContext
export class Store extends Component {
static Entity = {
{{#with (lookup 'berty.node.CommitLog')}}
{{#with fields.entity.resolvedType}}
{{#each fields}}
{{#with resolvedType}}
{{#if fields.id}}
{{name}}: {{name}}Entity,
{{/if}}
{{/with}}
{{/each}}
{{/with}}
{{/with}}
}
static Node = {
Service: ServiceNode,
}
render () {
const { context } = this.props
return (
this.props.children(context)
)
}
}
export default Store
{{~/if~}}