@wishknish/knishio-client-ts 0.7.0
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/LICENSE +674 -0
- package/README.md +425 -0
- package/dist/index.cjs +9961 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +32241 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +9853 -0
- package/dist/index.js.map +1 -0
- package/package.json +113 -0
- package/src/AuthToken.ts +214 -0
- package/src/KnishIOClient.ts +2020 -0
- package/src/constants.ts +398 -0
- package/src/core/Atom.ts +646 -0
- package/src/core/AtomMeta.ts +278 -0
- package/src/core/Meta.ts +428 -0
- package/src/core/Molecule.ts +825 -0
- package/src/core/PolicyMeta.ts +130 -0
- package/src/core/TokenUnit.ts +148 -0
- package/src/core/Wallet.ts +467 -0
- package/src/exception/AtomIndexException.ts +97 -0
- package/src/exception/AtomsMissingException.ts +109 -0
- package/src/exception/AuthorizationRejectedException.ts +63 -0
- package/src/exception/BalanceInsufficientException.ts +58 -0
- package/src/exception/BaseException.ts +275 -0
- package/src/exception/BatchIdException.ts +58 -0
- package/src/exception/CodeException.ts +119 -0
- package/src/exception/DecryptionKeyException.ts +65 -0
- package/src/exception/InvalidResponseException.ts +112 -0
- package/src/exception/MetaMissingException.ts +58 -0
- package/src/exception/MolecularHashMismatchException.ts +115 -0
- package/src/exception/MolecularHashMissingException.ts +58 -0
- package/src/exception/NegativeAmountException.ts +58 -0
- package/src/exception/PolicyInvalidException.ts +58 -0
- package/src/exception/SignatureMalformedException.ts +58 -0
- package/src/exception/SignatureMismatchException.ts +98 -0
- package/src/exception/StackableUnitAmountException.ts +65 -0
- package/src/exception/StackableUnitDecimalsException.ts +65 -0
- package/src/exception/TransferBalanceException.ts +98 -0
- package/src/exception/TransferMalformedException.ts +58 -0
- package/src/exception/TransferMismatchedException.ts +58 -0
- package/src/exception/TransferRemainderException.ts +58 -0
- package/src/exception/TransferToSelfException.ts +58 -0
- package/src/exception/TransferUnbalancedException.ts +58 -0
- package/src/exception/UnauthenticatedException.ts +147 -0
- package/src/exception/WalletCredentialException.ts +108 -0
- package/src/exception/WalletShadowException.ts +65 -0
- package/src/exception/WrongTokenTypeException.ts +58 -0
- package/src/exception/index.ts +272 -0
- package/src/index.ts +512 -0
- package/src/instance/rules/Callback.ts +257 -0
- package/src/instance/rules/Condition.ts +96 -0
- package/src/instance/rules/Meta.ts +163 -0
- package/src/instance/rules/Rule.ts +29 -0
- package/src/instance/rules/exception/RuleArgumentException.ts +65 -0
- package/src/libraries/CheckMolecule.ts +581 -0
- package/src/libraries/Decimal.ts +94 -0
- package/src/libraries/Dot.ts +202 -0
- package/src/libraries/GraphQLClient.ts +276 -0
- package/src/libraries/Hex.ts +155 -0
- package/src/libraries/UrqlClientWrapper.ts +336 -0
- package/src/libraries/array.ts +91 -0
- package/src/libraries/crypto.ts +816 -0
- package/src/libraries/strings.ts +458 -0
- package/src/mutation/Mutation.ts +103 -0
- package/src/mutation/MutationActiveSession.ts +108 -0
- package/src/mutation/MutationClaimShadowWallet.ts +91 -0
- package/src/mutation/MutationCreateIdentifier.ts +86 -0
- package/src/mutation/MutationCreateMeta.ts +92 -0
- package/src/mutation/MutationCreateRule.ts +90 -0
- package/src/mutation/MutationCreateToken.ts +92 -0
- package/src/mutation/MutationCreateWallet.ts +78 -0
- package/src/mutation/MutationDepositBufferToken.ts +72 -0
- package/src/mutation/MutationLinkIdentifier.ts +87 -0
- package/src/mutation/MutationProposeMolecule.ts +147 -0
- package/src/mutation/MutationRequestAuthorization.ts +77 -0
- package/src/mutation/MutationRequestAuthorizationGuest.ts +85 -0
- package/src/mutation/MutationRequestTokens.ts +98 -0
- package/src/mutation/MutationTransferTokens.ts +87 -0
- package/src/mutation/MutationWithdrawBufferToken.ts +73 -0
- package/src/query/Query.ts +187 -0
- package/src/query/QueryActiveSession.ts +89 -0
- package/src/query/QueryAtom.ts +275 -0
- package/src/query/QueryBalance.ts +102 -0
- package/src/query/QueryBatch.ts +145 -0
- package/src/query/QueryBatchHistory.ts +86 -0
- package/src/query/QueryContinuId.ts +91 -0
- package/src/query/QueryMetaType.ts +177 -0
- package/src/query/QueryMetaTypeViaAtom.ts +199 -0
- package/src/query/QueryPolicy.ts +91 -0
- package/src/query/QueryToken.ts +90 -0
- package/src/query/QueryUserActivity.ts +153 -0
- package/src/query/QueryWalletBundle.ts +92 -0
- package/src/query/QueryWalletList.ts +106 -0
- package/src/response/EnhancedResponse.ts +345 -0
- package/src/response/Response.ts +254 -0
- package/src/response/ResponseActiveSession.ts +72 -0
- package/src/response/ResponseAtom.ts +132 -0
- package/src/response/ResponseAuthorizationGuest.ts +119 -0
- package/src/response/ResponseBalance.ts +153 -0
- package/src/response/ResponseClaimShadowWallet.ts +56 -0
- package/src/response/ResponseContinuId.ts +101 -0
- package/src/response/ResponseCreateIdentifier.ts +56 -0
- package/src/response/ResponseCreateMeta.ts +58 -0
- package/src/response/ResponseCreateRule.ts +56 -0
- package/src/response/ResponseCreateToken.ts +58 -0
- package/src/response/ResponseCreateWallet.ts +58 -0
- package/src/response/ResponseLinkIdentifier.ts +87 -0
- package/src/response/ResponseMetaBatch.ts +72 -0
- package/src/response/ResponseMetaType.ts +108 -0
- package/src/response/ResponseMetaTypeViaAtom.ts +108 -0
- package/src/response/ResponsePolicy.ts +90 -0
- package/src/response/ResponseProposeMolecule.ts +155 -0
- package/src/response/ResponseQueryActiveSession.ts +105 -0
- package/src/response/ResponseQueryUserActivity.ts +89 -0
- package/src/response/ResponseRequestAuthorization.ts +100 -0
- package/src/response/ResponseRequestAuthorizationGuest.ts +133 -0
- package/src/response/ResponseRequestTokens.ts +58 -0
- package/src/response/ResponseTransferTokens.ts +72 -0
- package/src/response/ResponseWalletBundle.ts +95 -0
- package/src/response/ResponseWalletList.ts +165 -0
- package/src/schemas/index.ts +457 -0
- package/src/subscribe/ActiveSessionSubscribe.ts +72 -0
- package/src/subscribe/ActiveWalletSubscribe.ts +99 -0
- package/src/subscribe/CreateMoleculeSubscribe.ts +106 -0
- package/src/subscribe/Subscribe.ts +182 -0
- package/src/subscribe/WalletStatusSubscribe.ts +70 -0
- package/src/subscribe/index.ts +59 -0
- package/src/types/assertions.ts +722 -0
- package/src/types/client.ts +567 -0
- package/src/types/crypto.ts +541 -0
- package/src/types/graphql.ts +630 -0
- package/src/types/guards.ts +659 -0
- package/src/types/index.ts +614 -0
- package/src/types/response.ts +133 -0
- package/src/types/template-literals.ts +382 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +580 -0
- package/src/validation/ValidationService.ts +607 -0
- package/src/validation/schemas.ts +447 -0
- package/src/versions/HashAtom.ts +170 -0
- package/src/versions/Version4.ts +120 -0
- package/src/versions/index.ts +80 -0
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Query from './Query'
|
|
50
|
+
import Response from '../response/Response'
|
|
51
|
+
import type { UrqlClientWrapper } from '../client/GraphQLClient'
|
|
52
|
+
import type KnishIOClient from '../KnishIOClient'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* QueryBatch class - Query for retrieving batch information
|
|
56
|
+
* Matches JavaScript SDK QueryBatch implementation exactly
|
|
57
|
+
*/
|
|
58
|
+
export default class QueryBatch extends Query {
|
|
59
|
+
/**
|
|
60
|
+
* Create new QueryBatch instance
|
|
61
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
62
|
+
*/
|
|
63
|
+
constructor(graphQLClient: UrqlClientWrapper, knishIOClient: KnishIOClient) {
|
|
64
|
+
super(graphQLClient, knishIOClient)
|
|
65
|
+
|
|
66
|
+
this.$__query = `query( $batchId: String ) {
|
|
67
|
+
Batch( batchId: $batchId ) {
|
|
68
|
+
${QueryBatch.getFields()},
|
|
69
|
+
children {
|
|
70
|
+
${QueryBatch.getFields()}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get GraphQL fields for batch query
|
|
78
|
+
* Matches JavaScript SDK getFields method exactly
|
|
79
|
+
*/
|
|
80
|
+
static getFields(): string {
|
|
81
|
+
return `batchId,
|
|
82
|
+
molecularHash,
|
|
83
|
+
type,
|
|
84
|
+
status,
|
|
85
|
+
createdAt,
|
|
86
|
+
wallet {
|
|
87
|
+
address,
|
|
88
|
+
bundleHash,
|
|
89
|
+
amount,
|
|
90
|
+
tokenSlug,
|
|
91
|
+
token {
|
|
92
|
+
name,
|
|
93
|
+
amount
|
|
94
|
+
},
|
|
95
|
+
tokenUnits {
|
|
96
|
+
id,
|
|
97
|
+
name,
|
|
98
|
+
metas
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
fromWallet {
|
|
102
|
+
address,
|
|
103
|
+
bundleHash,
|
|
104
|
+
amount,
|
|
105
|
+
batchId
|
|
106
|
+
},
|
|
107
|
+
toWallet {
|
|
108
|
+
address,
|
|
109
|
+
bundleHash,
|
|
110
|
+
amount,
|
|
111
|
+
batchId
|
|
112
|
+
},
|
|
113
|
+
sourceTokenUnits {
|
|
114
|
+
id,
|
|
115
|
+
name,
|
|
116
|
+
metas
|
|
117
|
+
},
|
|
118
|
+
transferTokenUnits {
|
|
119
|
+
id,
|
|
120
|
+
name,
|
|
121
|
+
metas
|
|
122
|
+
},
|
|
123
|
+
metas {
|
|
124
|
+
key,
|
|
125
|
+
value,
|
|
126
|
+
},
|
|
127
|
+
throughMetas {
|
|
128
|
+
key,
|
|
129
|
+
value
|
|
130
|
+
}`
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns a Response object
|
|
135
|
+
* Matches JavaScript SDK createResponse method exactly
|
|
136
|
+
*/
|
|
137
|
+
override createResponse(json: any): Response {
|
|
138
|
+
const responseObject = new Response({
|
|
139
|
+
query: this,
|
|
140
|
+
json
|
|
141
|
+
})
|
|
142
|
+
responseObject.dataKey = 'data.Batch'
|
|
143
|
+
return responseObject
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Query from './Query'
|
|
50
|
+
import QueryBatch from './QueryBatch'
|
|
51
|
+
import Response from '@/response/Response'
|
|
52
|
+
import { gql } from '@urql/core'
|
|
53
|
+
import type { GraphQLClient as IGraphQLClient } from '@/types'
|
|
54
|
+
import type KnishIOClient from '@/KnishIOClient'
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Query for retrieving Batch History information
|
|
58
|
+
*/
|
|
59
|
+
export default class QueryBatchHistory extends Query {
|
|
60
|
+
/**
|
|
61
|
+
* Constructor
|
|
62
|
+
*/
|
|
63
|
+
constructor(graphQLClient: IGraphQLClient, knishIOClient: KnishIOClient) {
|
|
64
|
+
super(graphQLClient, knishIOClient)
|
|
65
|
+
|
|
66
|
+
this.$__query = gql`
|
|
67
|
+
query($batchId: String) {
|
|
68
|
+
BatchHistory(batchId: $batchId) {
|
|
69
|
+
${QueryBatch.getFields()}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a Response object
|
|
77
|
+
*/
|
|
78
|
+
override createResponse(json: Record<string, any>): Response {
|
|
79
|
+
const responseObject = new Response({
|
|
80
|
+
query: this,
|
|
81
|
+
json
|
|
82
|
+
})
|
|
83
|
+
responseObject.dataKey = 'data.BatchHistory'
|
|
84
|
+
return responseObject
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Query from './Query'
|
|
50
|
+
import ResponseContinuId from '../response/ResponseContinuId'
|
|
51
|
+
import type { UrqlClientWrapper } from '../client/GraphQLClient'
|
|
52
|
+
import type KnishIOClient from '../KnishIOClient'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* QueryContinuId class - Queries the node for the next wallet to sign with for ContinuID
|
|
56
|
+
* Matches JavaScript SDK QueryContinuId implementation exactly
|
|
57
|
+
*/
|
|
58
|
+
export default class QueryContinuId extends Query {
|
|
59
|
+
/**
|
|
60
|
+
* Create new QueryContinuId instance
|
|
61
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
62
|
+
*/
|
|
63
|
+
constructor(graphQLClient: UrqlClientWrapper, knishIOClient: KnishIOClient) {
|
|
64
|
+
super(graphQLClient, knishIOClient)
|
|
65
|
+
|
|
66
|
+
this.$__query = `query ($bundle: String!) {
|
|
67
|
+
ContinuId(bundle: $bundle) {
|
|
68
|
+
address,
|
|
69
|
+
bundleHash,
|
|
70
|
+
tokenSlug,
|
|
71
|
+
position,
|
|
72
|
+
batchId,
|
|
73
|
+
characters,
|
|
74
|
+
pubkey,
|
|
75
|
+
amount,
|
|
76
|
+
createdAt
|
|
77
|
+
}
|
|
78
|
+
}`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns a Response object
|
|
83
|
+
* Matches JavaScript SDK createResponse method exactly
|
|
84
|
+
*/
|
|
85
|
+
override createResponse(json: any): ResponseContinuId {
|
|
86
|
+
return new ResponseContinuId({
|
|
87
|
+
query: this,
|
|
88
|
+
json
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Query from './Query'
|
|
50
|
+
import ResponseMetaType from '../response/ResponseMetaType'
|
|
51
|
+
import type { UrqlClientWrapper } from '../client/GraphQLClient'
|
|
52
|
+
import type KnishIOClient from '../KnishIOClient'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* QueryMetaType class - Query for retrieving Meta Asset information
|
|
56
|
+
* Matches JavaScript SDK QueryMetaType implementation exactly
|
|
57
|
+
*/
|
|
58
|
+
export default class QueryMetaType extends Query {
|
|
59
|
+
/**
|
|
60
|
+
* Create new QueryMetaType instance
|
|
61
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
62
|
+
*/
|
|
63
|
+
constructor(graphQLClient: UrqlClientWrapper, knishIOClient: KnishIOClient) {
|
|
64
|
+
super(graphQLClient, knishIOClient)
|
|
65
|
+
|
|
66
|
+
this.$__query = `query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String, $cellSlug: String ) {
|
|
67
|
+
MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy, cellSlug: $cellSlug ) {
|
|
68
|
+
metaType,
|
|
69
|
+
instanceCount {
|
|
70
|
+
key,
|
|
71
|
+
value
|
|
72
|
+
},
|
|
73
|
+
instances {
|
|
74
|
+
metaType,
|
|
75
|
+
metaId,
|
|
76
|
+
createdAt,
|
|
77
|
+
metas(latest:$latest) {
|
|
78
|
+
molecularHash,
|
|
79
|
+
position,
|
|
80
|
+
key,
|
|
81
|
+
value,
|
|
82
|
+
createdAt
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
paginatorInfo {
|
|
86
|
+
currentPage,
|
|
87
|
+
total
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}`
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Builds a GraphQL-friendly variables object based on input fields
|
|
95
|
+
* Matches JavaScript SDK createVariables method exactly
|
|
96
|
+
*/
|
|
97
|
+
static createVariables({
|
|
98
|
+
metaType = null,
|
|
99
|
+
metaId = null,
|
|
100
|
+
key = null,
|
|
101
|
+
value = null,
|
|
102
|
+
latest = null,
|
|
103
|
+
filter = null,
|
|
104
|
+
queryArgs = null,
|
|
105
|
+
count = null,
|
|
106
|
+
countBy = null,
|
|
107
|
+
cellSlug = null
|
|
108
|
+
}: {
|
|
109
|
+
metaType?: string | string[] | null
|
|
110
|
+
metaId?: string | string[] | null
|
|
111
|
+
key?: string | string[] | null
|
|
112
|
+
value?: string | string[] | null
|
|
113
|
+
latest?: boolean | null
|
|
114
|
+
filter?: any | null
|
|
115
|
+
queryArgs?: any | null
|
|
116
|
+
count?: string | null
|
|
117
|
+
countBy?: string | null
|
|
118
|
+
cellSlug?: string | null
|
|
119
|
+
} = {}): Record<string, any> {
|
|
120
|
+
const variables: Record<string, any> = {}
|
|
121
|
+
|
|
122
|
+
if (metaType) {
|
|
123
|
+
variables[typeof metaType === 'string' ? 'metaType' : 'metaTypes'] = metaType
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (metaId) {
|
|
127
|
+
variables[typeof metaId === 'string' ? 'metaId' : 'metaIds'] = metaId
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (key) {
|
|
131
|
+
variables[typeof key === 'string' ? 'key' : 'keys'] = key
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (value) {
|
|
135
|
+
variables[typeof value === 'string' ? 'value' : 'values'] = value
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
variables.latest = latest === true
|
|
139
|
+
|
|
140
|
+
if (filter) {
|
|
141
|
+
variables.filter = filter
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (queryArgs) {
|
|
145
|
+
if (typeof queryArgs.limit === 'undefined' || queryArgs.limit === 0) {
|
|
146
|
+
queryArgs.limit = '*'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
variables.queryArgs = queryArgs
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (count) {
|
|
153
|
+
variables.count = count
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (countBy) {
|
|
157
|
+
variables.countBy = countBy
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (cellSlug) {
|
|
161
|
+
variables.cellSlug = cellSlug
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return variables
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Returns a Response object
|
|
169
|
+
* Matches JavaScript SDK createResponse method exactly
|
|
170
|
+
*/
|
|
171
|
+
override createResponse(json: any): ResponseMetaType {
|
|
172
|
+
return new ResponseMetaType({
|
|
173
|
+
query: this,
|
|
174
|
+
json
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}
|