timegraph-client 0.1.10

Timegraph Client
Documentation
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
"""
User information
"""
type Account {
	"""
	The user wallet
	"""
	wallet: String!
	"""
	The user Id
	"""
	id: Int!
}

type AliasResult {
	status: String!
	function: FunctionInfo
	view: ViewInfo
}


"""
The result of collecting data for teh specified cycle
"""
type CollectResult {
	"""
	Collecting status
	"""
	status: String!
	"""
	Error information if failed to collect data
	"""
	error: String
	"""
	The task Id of collected data
	"""
	taskId: Int!
	"""
	The task update counter (execution cycle number) of collected data
	"""
	taskCycle: Int!
	"""
	The target network block of collected data
	"""
	targetBlock: Int!
	"""
	The timechain network block of collected data
	"""
	timechainBlock: Int!
}

"""
Collections in the current subgraph
"""
type Collection {
	_count: Int!
}

"""
Contract Input/Output information
"""
type ContractInOutInfo {
	"""
	Data type
	"""
	type: String!
}

"""
Contract Input/Output specification
"""
input ContractInOutSpec {
	"""
	Data type
	"""
	type: String!
}

"""
Smart contract as a group of function
"""
type ContractInfo {
	"""
	Unique Identifier
	"""
	id: Int!
	"""
	The smart contract address
	"""
	address: String!
	"""
	The smart contract network
	"""
	network: String!
	"""
	The smart contract global identifier
	"""
	identifier: String
	"""
	The smart contract description
	"""
	description: String
	"""
	The wallet created the contract
	"""
	creator: String!
	"""
	The time when the smart contract group was created
	"""
	createdAt: String!
	"""
	Composed ABI from all functions grouped in the smart contract
	"""
	abi: [FunctionContractAbiInfo!]!
	"""
	Functions associated with the smart contract
	"""
	functions: [FunctionInfo!]!
	"""
	Feeds associated with the smart contract
	"""
	feeds: [FeedInfo!]!
	"""
	Views associated with the smart contract
	"""
	views: [ViewInfo!]!
}

type ContractMutationResult {
	"""
	mutation result - can be "Completed" or "Failed"
	"""
	status: String!
	"""
	error text if status is "Failed"
	"""
	error: String
	"""
	proposed or merged functions
	"""
	functions: [FunctionResult!]!
	"""
	proposed or merged contract
	"""
	contract: ContractResult!
}

type ContractResult {
	"""
	contract mutation result - can be "Failed", "Created", "Untouched"
	"""
	status: String!
	"""
	error text if status is "Failed"
	"""
	error: String
	"""
	contract address
	"""
	address: String!
	"""
	contract network
	"""
	network: String!
	"""
	unique identifier
	"""
	identifier: String
}

"""
Count of objects
"""
type Count {
	"""
	Count of collections
	"""
	collections: Int!
	"""
	Count of functions
	"""
	functions: Int!
	"""
	Count of views
	"""
	views: Int!
}

"""
Reference to bounded function used by view
"""
type FeedInfo {
	hashId: String!
	view: ViewInfo
	function: FunctionInfo
	args: [String!]
}


"""
Contract ABI information
"""
type FunctionContractAbiInfo {
	"""
	ABI entrypoint name
	"""
	name: String!
	"""
	Input information
	"""
	inputs: [ContractInOutInfo!]!
	"""
	Output information
	"""
	outputs: [ContractInOutInfo!]!
}

"""
Contract ABI specification
"""
input FunctionContractAbiSpec {
	"""
	ABI entrypoint name
	"""
	name: String!
	"""
	Input specification
	"""
	inputs: [ContractInOutSpec!]!
	"""
	Output specification
	"""
	outputs: [ContractInOutSpec!]!
}

"""
Contract information
"""
type FunctionContractInfo {
	"""
	Contract address
	"""
	address: String!
	"""
	Contract ABI
	"""
	abi: FunctionContractAbiInfo!
}

"""
Contract specification
"""
input FunctionContractSpec {
	"""
	Contract address
	"""
	address: String!
	"""
	Contract ABI
	"""
	abi: FunctionContractAbiSpec!
}

"""
Function information
"""
type FunctionInfo {
	"""
	Object hash id
	"""
	hashId: String!
	"""
	Target network
	"""
	network: String!
	"""
	Local name in the current subgraph
	"""
	name: String
	"""
	Global unique identifier
	"""
	identifier: String!
	"""
	Description
	"""
	description: String
	"""
	Function inputs
	"""
	inputs: [FunctionInputInfo!]!
	"""
	Function outputs
	"""
	outputs: [FunctionOutputInfo!]!
	"""
	Contract information
	"""
	contract: FunctionContractInfo
	"""
	Wallet created the function
	"""
	creator: String!
}

"""
Function input information
"""
type FunctionInputInfo {
	"""
	Type conversion
	"""
	value: String
	"""
	Nested array
	"""
	array: [FunctionInputInfo!]
	"""
	Predefined constant is used as argument
	"""
	constant: String
}

"""
Function input specification ( either input or constant or array )
"""
input FunctionInputSpec {
	"""
	Type conversion
	"""
	value: String
	"""
	Nested array
	"""
	array: [FunctionInputSpec!]
	"""
	Predefined constant is used as argument
	"""
	constant: String
}

"""
Function output information
"""
type FunctionOutputInfo {
	"""
	Nested array
	"""
	array: [FunctionOutputInfo!]
	"""
	Possible values:
	numeric
	string
	integer
	boolean
	skip (skip value in result)
	None (if array field isn't None)
	"""
	value: String
	"""
	Name to store in database
	"""
	name: String
}

"""
Function output specification (either output or array)
"""
input FunctionOutputSpec {
	"""
	Nested array
	"""
	array: [FunctionOutputSpec!]
	"""
	Type to store in the database
	numeric
	string
	integer
	boolean
	data (use default from the ABI)
	skip  (skip value in results)
	None (if the array field isn't None)
	"""
	value: String
	"""
	Name to store in database
	"""
	name: String
}

type FunctionResult {
	"""
	Merging status
	can be Merged, Unchanged, Error
	"""
	status: String!
	"""
	Error message if error happens
	"""
	error: String
	"""
	Requested function name
	"""
	name: String
	"""
	The wallet created the function
	"""
	function: FunctionInfo
}

"""
Function specification
"""
input FunctionSpec {
	"""
	Function unique global name
	"""
	identifier: String
	"""
	Local name in the current subgraph
	"""
	name: String!
	"""
	Target network
	"""
	network: String!
	"""
	Function inputs
	"""
	inputs: [FunctionInputSpec!]!
	"""
	Function outputs
	"""
	outputs: [FunctionOutputSpec!]!
	"""
	Contract information
	"""
	contract: FunctionContractSpec
}

"""
Global objects view
"""
type Global {
	"""
	Count of accessible collections, functions, and views
	"""
	count: Count!
	"""
	List accessible subgraphs
	@id: id of the subgraph to list only one
	@limit: count of subgraphs to list"
	@before: the subgraph id to list before it
	@after: the subgraph id to list after it"
	@user: user id to list only subgraphs created by the user
	"""
	subgraphs(id: Int, limit: Int, before: Int, after: Int, user: Int): [SubgraphInfo!]!
	"""
	List accessible feeds
	@hash: the hash of the collection to list only one
	@limit: max count of collections to list
	@before: the hash to list collections before it
	@after: the hash to list collections after it
	"""
	feeds(hash: String, limit: Int, before: String, after: String): [FeedInfo!]!
	"""
	List accessible functions
	@hash: the hash of the function to list only one
	@limit: max count of functions to list
	@before: the hash to list functions before it
	@after: the hash to list functions after it
	"""
	functions(hash: String, limit: Int, before: String, after: String): [FunctionInfo!]!
	"""
	List accessible views
	@hash: the hash of the view to list only one
	@limit: max count of views to list
	@before: the hash to list views before it
	@after: the hash to list views after it
	"""
	views(hash: String, limit: Int, before: String, after: String): [ViewInfo!]!
	contracts(address: String, network: String, limit: Int, before: Int, after: Int): [ContractInfo!]!
	query(view: String!, limit: Int, before: Int, after: Int): QueryResult!
}



"""
User API key information
"""
type KeyInfo {
	"""
	User id
	"""
	userId: Int!
	"""
	Public key
	"""
	key: String!
	"""
	Key role
	"""
	role: String!
	"""
	Key certificate
	"""
	cert: [Int!]!
	"""
	Status (enabled/disabled/revoked)
	"""
	status: String!
}

type MergeResult {
	status: String!
	views: [ViewResult!]!
	functions: [FunctionResult!]!
}

type Mutation {
	"""
	Create new account
	@wallet: Public key of the user wallet or Substrate wallet address
	!user must be authenticated with as the wallet owner
	"""
	createAccount(wallet: String!): UserInfo!
	"""
	Add the ApiKey certification
	@cert: the APIKEY certificate
	!user must be authenticated with as the key owner
	"""
	certifyKey(cert: String!): KeyInfo!
	"""
	Disable APIkey temporally
	@key: the public key of the APIKEY
	!user must be authenticated with as the key owner
	"""
	enableKey(key: String!): KeyInfo!
	"""
	Enable temporally disabled APIkey
	@key: the public key of the APIKEY
	!user must be authenticated with as the key owner
	"""
	disableKey(key: String!): KeyInfo!
	"""
	Permanently revoke APIkey
	@key: the public key of the APIKEY
	!user must be authenticated with as the key owner
	"""
	revokeKey(key: String!): KeyInfo!
	drop(name: String!): AliasResult!
	alias(hash: String!, name: String!): AliasResult!
	withdrawToken(amount: Int!): String!
	sponsorView(viewId: Int!, amount: Int!): String!
	"""
	Merge object specifications
	@functions: function specifications
	@collections: collection specifications
	@views: view specifications
	"""
	merge(functions: [FunctionSpec!], views: [ViewSpec!], scope: String, dryRun: Boolean): MergeResult!
	"""
	Add data into collection (user must have Collector role)
	@feed: feed hashId
	@taskCycle: task updating cycle
	@targetBlock: target network block number
	@timechainBlock: timechain block number
	@taskId: task associated with data
	@signature: TSS signature
	@data: data to add into collection (the flat values list)
	@eventId: unused
	"""
	collect(feed: String!, taskId: Int!, taskCycle: Int!, targetBlock: Int!, timechainBlock: Int!, shardId: Int!, signature: String!, data: [String!]!, eventId: Int): CollectResult!
	"""
	Automerge deployed smart contract
	@address - extract contract with specified address
	@network - extract contract from specified network
	@chain - look into specified network chain instead of mainnet
	@identifier - propose identifier for the smart contract functions group
	@methods - look for specified methods only
	@scope - merging scope: "global" or "subgraph"
	@dry_run - do not merge, just propose mutations
	"""
	contract(address: String!, network: String!, identifier: String!, chain: String, methods: [String!], scope: String, dryRun: Boolean): ContractMutationResult!
}

"""
Query (readonly operations)
"""
type Query {
	"""
	Interface revision
	"""
	revision: String!
	gitHash: String!
	"""
	Current subgraph collections
	"""
	collection: Collection!
	"""
	Binary representation of the collection spec
	@hash: the collection hash to get bytes
	"""
	bytes(hash: String!): [Int!]!
	"""
	Subgraph view
	@id: optional subgraph id
	"""
	subgraph(id: Int): Subgraph!
	"""
	Global view
	"""
	global: Global!
	"""
	Current user info
	"""
	userInfo: UserInfo!
	"""
	API keys information
	@key: the key to list only one
	@limit: max count of keys to list
	@before: the key to list keys before it
	@after: the key to list keys after it
	"""
	keys(key: String, limit: Int, before: String, after: String): [KeyInfo!]!
	"""
	List of users
	@limit: max count of users to list
	@before: the user id to list users before it
	@after: the user id to list users after it
	"""
	users(limit: Int, before: Int, after: Int): [UserInfo!]!
}

type QueryResult {
	header: [String!]!
	data: [[String]!]!
	schema: [String!]!
}


"""
User subgraph referencing objects like collections, functions and views
"""
type Subgraph {
	id: Int!
	info: SubgraphInfo!
	"""
	Count of collections, functions, views in the subgraph
	"""
	count: Count!
	"""
	List functions in the subgraph
	@name: the function name in the subgraph to list only one
	@hash: the hash of the function to list only one
	@limit: max count of functions to list
	@before: hash to list functions before it
	@after: hash to list functions after it
	"""
	functions(name: String, hash: String, limit: Int, before: String, after: String): [FunctionInfo!]!
	"""
	List views in the subgraph
	@name: the view name in the subgraph to list only one
	@hash: the hash of the view to list only one
	@limit: max count of views to list
	@before: hash to list views before it
	@after: hash to list views after it
	"""
	views(name: String, hash: String, limit: Int, before: String, after: String): [ViewInfo!]!
	"""
	Current subgraph collections
	"""
	collection: Collection!
}

"""
Subgraph Information
"""
type SubgraphInfo {
	"""
	The subgraph Id
	"""
	id: Int!
}

"""
Task Information
"""
type TaskInfo {
	"""
	timechain task identifier
	"""
	taskId: Int
	"""
	scheduling state
	"""
	state: String!
	"""
	scheduling error if failed
	"""
	error: String
	"""
	task owner
	"""
	sponsors: [Account!]!
	"""
	last updating cycle
	"""
	lastCycle: Int!
	"""
	seconds/minutes/hours passed from the last update
	"""
	validity(units: String): Int!
}

"""
User information
"""
type UserInfo {
	"""
	The unique user identifier
	"""
	userId: Int!
	"""
	The user role (can be limited by an APIKEY)
	"""
	userRole: String!
	"""
	The user subgraph identifier
	"""
	subgraph: Int!
	"""
	The user wallet
	"""
	wallet: String!
	balance: String!
}

"""
Collection Information
"""
type ViewInfo {
	"""
	SQL query
	"""
	sql: String!
	"""
	Collection unique hash id
	"""
	hashId: String!
	"""
	Collection name in the user subgraph
	"""
	name: String
	"""
	Collection global identifier
	"""
	identifier: String
	"""
	Description
	"""
	description: String
	"""
	Feeds the View's SQL refers to
	"""
	references: [FeedInfo!]!
	"""
	Wallet created the view
	"""
	creator: String!
	"""
	The updating tasks
	"""
	tasks: [TaskInfo!]!
}

type ViewResult {
	"""
	Merging status
	can be Merged, Unchanged, Error
	"""
	status: String!
	"""
	Error message if error happens
	"""
	error: String
	"""
	Requested view name
	"""
	name: String
	"""
	The wallet created the view
	"""
	view: ViewInfo
	data: [[String]!]
	header: [String!]
}

"""
View specification
"""
input ViewSpec {
	"""
	View unique name
	"""
	identifier: String
	"""
	Description
	"""
	description: String
	"""
	View name in the subgraph
	"""
	name: String
	"""
	Sql expression
	"""
	sql: String!
}

schema {
	query: Query
	mutation: Mutation
}