@wishknish/knishio-client-js 0.5.2 → 0.6.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.
Files changed (138) hide show
  1. package/README.md +207 -274
  2. package/dist/client.iife.js +577 -0
  3. package/package.json +36 -79
  4. package/src/.babelrc +0 -22
  5. package/src/Atom.js +171 -132
  6. package/src/AtomMeta.js +76 -50
  7. package/src/AuthToken.js +37 -46
  8. package/src/KnishIOClient.js +932 -985
  9. package/src/Meta.js +15 -17
  10. package/src/Molecule.js +423 -494
  11. package/src/PolicyMeta.js +32 -41
  12. package/src/TokenUnit.js +30 -32
  13. package/src/Wallet.js +275 -265
  14. package/src/exception/AtomIndexException.js +4 -8
  15. package/src/exception/AtomsMissingException.js +4 -6
  16. package/src/exception/AuthorizationRejectedException.js +4 -5
  17. package/src/exception/BalanceInsufficientException.js +4 -8
  18. package/src/exception/BaseException.js +6 -8
  19. package/src/exception/BatchIdException.js +5 -7
  20. package/src/exception/CodeException.js +4 -8
  21. package/src/{libraries/ApolloLink/HttpLink.js → exception/DecryptionKeyException.js} +12 -15
  22. package/src/exception/InvalidResponseException.js +4 -5
  23. package/src/exception/MetaMissingException.js +4 -6
  24. package/src/exception/MolecularHashMismatchException.js +4 -6
  25. package/src/exception/MolecularHashMissingException.js +4 -5
  26. package/src/exception/NegativeAmountException.js +4 -5
  27. package/src/exception/PolicyInvalidException.js +4 -4
  28. package/src/exception/SignatureMalformedException.js +4 -5
  29. package/src/exception/SignatureMismatchException.js +4 -5
  30. package/src/exception/StackableUnitAmountException.js +4 -5
  31. package/src/exception/StackableUnitDecimalsException.js +4 -5
  32. package/src/exception/TransferBalanceException.js +4 -5
  33. package/src/exception/TransferMalformedException.js +4 -5
  34. package/src/exception/TransferMismatchedException.js +4 -5
  35. package/src/exception/TransferRemainderException.js +4 -5
  36. package/src/exception/TransferToSelfException.js +4 -5
  37. package/src/exception/TransferUnbalancedException.js +4 -5
  38. package/src/exception/UnauthenticatedException.js +4 -5
  39. package/src/{libraries/ApolloLink/AuthLink.js → exception/WalletCredentialException.js} +12 -40
  40. package/src/exception/WalletShadowException.js +4 -5
  41. package/src/exception/WrongTokenTypeException.js +4 -5
  42. package/src/exception/index.js +26 -26
  43. package/src/index.js +8 -10
  44. package/src/instance/Rules/Callback.js +91 -93
  45. package/src/instance/Rules/Condition.js +21 -23
  46. package/src/instance/Rules/Meta.js +13 -14
  47. package/src/instance/Rules/Rule.js +39 -43
  48. package/src/instance/Rules/exception/RuleArgumentException.js +4 -4
  49. package/src/libraries/CheckMolecule.js +253 -232
  50. package/src/libraries/Decimal.js +13 -17
  51. package/src/libraries/Dot.js +74 -48
  52. package/src/libraries/Hex.js +49 -54
  53. package/src/libraries/apollo/ApolloClientWrapper.js +143 -0
  54. package/src/libraries/apollo/CipherLink.js +116 -0
  55. package/src/libraries/apollo/Client.js +154 -0
  56. package/src/libraries/apollo/ErrorHandler.js +32 -0
  57. package/src/libraries/apollo/SubscriptionManager.js +60 -0
  58. package/src/libraries/apollo/operationUtils.js +26 -0
  59. package/src/libraries/array.js +50 -41
  60. package/src/libraries/crypto.js +20 -27
  61. package/src/libraries/strings.js +58 -91
  62. package/src/mutation/Mutation.js +44 -25
  63. package/src/mutation/MutationActiveSession.js +12 -12
  64. package/src/mutation/MutationClaimShadowWallet.js +15 -17
  65. package/src/mutation/MutationCreateIdentifier.js +11 -12
  66. package/src/mutation/MutationCreateMeta.js +11 -12
  67. package/src/mutation/MutationCreateRule.js +11 -12
  68. package/src/mutation/MutationCreateToken.js +18 -13
  69. package/src/mutation/MutationCreateWallet.js +9 -11
  70. package/src/mutation/MutationDepositBufferToken.js +7 -9
  71. package/src/mutation/MutationLinkIdentifier.js +12 -14
  72. package/src/mutation/MutationProposeMolecule.js +24 -25
  73. package/src/mutation/MutationRequestAuthorization.js +9 -10
  74. package/src/mutation/MutationRequestAuthorizationGuest.js +12 -15
  75. package/src/mutation/MutationRequestTokens.js +11 -14
  76. package/src/mutation/MutationTransferTokens.js +11 -14
  77. package/src/mutation/MutationWithdrawBufferToken.js +7 -10
  78. package/src/query/Query.js +62 -36
  79. package/src/query/QueryActiveSession.js +11 -13
  80. package/src/query/QueryAtom.js +75 -76
  81. package/src/query/QueryBalance.js +11 -12
  82. package/src/query/QueryBatch.js +17 -14
  83. package/src/query/QueryBatchHistory.js +16 -13
  84. package/src/query/QueryContinuId.js +13 -10
  85. package/src/query/QueryMetaType.js +45 -57
  86. package/src/query/QueryMetaTypeViaAtom.js +49 -57
  87. package/src/query/QueryPolicy.js +11 -12
  88. package/src/query/QueryToken.js +11 -13
  89. package/src/query/QueryUserActivity.js +11 -13
  90. package/src/query/QueryWalletBundle.js +15 -47
  91. package/src/query/QueryWalletList.js +15 -16
  92. package/src/response/Response.js +29 -34
  93. package/src/response/ResponseActiveSession.js +6 -6
  94. package/src/response/ResponseAtom.js +29 -30
  95. package/src/response/ResponseAuthorizationGuest.js +17 -18
  96. package/src/response/ResponseBalance.js +12 -13
  97. package/src/response/ResponseClaimShadowWallet.js +1 -1
  98. package/src/response/ResponseContinuId.js +21 -22
  99. package/src/response/ResponseCreateIdentifier.js +1 -1
  100. package/src/response/ResponseCreateMeta.js +1 -1
  101. package/src/response/ResponseCreateRule.js +1 -1
  102. package/src/response/ResponseCreateToken.js +1 -1
  103. package/src/response/ResponseCreateWallet.js +1 -1
  104. package/src/response/ResponseLinkIdentifier.js +9 -10
  105. package/src/response/ResponseMetaBatch.js +6 -8
  106. package/src/response/ResponseMetaType.js +19 -20
  107. package/src/response/ResponseMetaTypeViaAtom.js +19 -19
  108. package/src/response/ResponsePolicy.js +14 -15
  109. package/src/response/ResponseProposeMolecule.js +27 -30
  110. package/src/response/ResponseQueryActiveSession.js +20 -23
  111. package/src/response/ResponseQueryUserActivity.js +11 -12
  112. package/src/response/ResponseRequestAuthorization.js +11 -16
  113. package/src/response/ResponseRequestAuthorizationGuest.js +18 -21
  114. package/src/response/ResponseRequestTokens.js +1 -1
  115. package/src/response/ResponseTransferTokens.js +8 -9
  116. package/src/response/ResponseWalletBundle.js +16 -17
  117. package/src/response/ResponseWalletList.js +44 -47
  118. package/src/subscribe/ActiveSessionSubscribe.js +5 -6
  119. package/src/subscribe/ActiveWalletSubscribe.js +5 -6
  120. package/src/subscribe/CreateMoleculeSubscribe.js +5 -5
  121. package/src/subscribe/Subscribe.js +26 -26
  122. package/src/subscribe/WalletStatusSubscribe.js +5 -6
  123. package/src/versions/HashAtom.js +78 -0
  124. package/src/versions/Version4.js +34 -0
  125. package/src/versions/index.js +5 -0
  126. package/dist/client.umd.js +0 -453
  127. package/src/httpClient/ApolloClient.js +0 -245
  128. package/src/libraries/ApolloLink/CipherLink.js +0 -117
  129. package/src/libraries/ApolloLink/Client.js +0 -231
  130. package/src/libraries/ApolloLink/PusherLink.js +0 -234
  131. package/src/libraries/ApolloLink/handler.js +0 -106
  132. package/src/libraries/Base58.js +0 -71
  133. package/src/libraries/Base64.js +0 -40
  134. package/src/libraries/BaseX.js +0 -91
  135. package/src/libraries/Soda.js +0 -93
  136. package/src/query/QueryMetaInstance.js +0 -99
  137. package/src/test/Test.js +0 -670
  138. package/src/test/TestTokenUnit.js +0 -340
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import ResponseQueryActiveSession from '../response/ResponseQueryActiveSession';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseQueryActiveSession from '../response/ResponseQueryActiveSession'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Query for retrieving a list of active User Sessions
54
54
  */
55
55
  export default class QueryActiveSession extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param httpClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( httpClient ) {
62
- super( httpClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
65
64
  ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
@@ -70,18 +69,17 @@ export default class QueryActiveSession extends Query {
70
69
  createdAt,
71
70
  updatedAt
72
71
  }
73
- }`;
72
+ }`
74
73
  }
75
74
 
76
75
  /**
77
76
  * @param {object} json
78
77
  * @return {ResponseQueryActiveSession}
79
78
  */
80
- createResponse ( json ) {
81
- return new ResponseQueryActiveSession( {
79
+ createResponse (json) {
80
+ return new ResponseQueryActiveSession({
82
81
  query: this,
83
82
  json
84
- } );
83
+ })
85
84
  }
86
-
87
85
  }
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import { gql } from '@apollo/client/core';
50
- import ResponseAtom from '../response/ResponseAtom';
48
+ import Query from './Query'
49
+ import { gql } from '@apollo/client/core'
50
+ import ResponseAtom from '../response/ResponseAtom'
51
51
 
52
52
  /**
53
53
  * Query for getting the balance of a given wallet or token slug
54
54
  */
55
55
  export default class QueryAtom extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param apolloClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( apolloClient ) {
62
- super( apolloClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query(
65
64
  $molecularHashes: [String!],
@@ -117,20 +116,7 @@ export default class QueryAtom extends Query {
117
116
  total
118
117
  }
119
118
  }
120
- }`;
121
- }
122
-
123
- /**
124
- * Returns a Response object
125
- *
126
- * @param {object} json
127
- * @return {ResponseAtom}
128
- */
129
- createResponse ( json ) {
130
- return new ResponseAtom( {
131
- query: this,
132
- json
133
- } );
119
+ }`
134
120
  }
135
121
 
136
122
  /**
@@ -165,7 +151,7 @@ export default class QueryAtom extends Query {
165
151
  * @param {object} queryArgs
166
152
  * @return {object}
167
153
  */
168
- static createVariables ( {
154
+ static createVariables ({
169
155
  molecularHashes,
170
156
  molecularHash,
171
157
  bundleHashes,
@@ -193,83 +179,96 @@ export default class QueryAtom extends Query {
193
179
  filter,
194
180
  latest,
195
181
  queryArgs
196
- } ) {
197
- if ( molecularHash ) {
198
- molecularHashes = molecularHashes || [];
199
- molecularHashes.push( molecularHash );
182
+ }) {
183
+ if (molecularHash) {
184
+ molecularHashes = molecularHashes || []
185
+ molecularHashes.push(molecularHash)
200
186
  }
201
187
 
202
- if ( bundleHash ) {
203
- bundleHashes = bundleHashes || [];
204
- bundleHashes.push( bundleHash );
188
+ if (bundleHash) {
189
+ bundleHashes = bundleHashes || []
190
+ bundleHashes.push(bundleHash)
205
191
  }
206
192
 
207
- if ( position ) {
208
- positions = positions || [];
209
- positions.push( position );
193
+ if (position) {
194
+ positions = positions || []
195
+ positions.push(position)
210
196
  }
211
197
 
212
- if ( walletAddress ) {
213
- walletAddresses = walletAddresses || [];
214
- walletAddresses.push( walletAddress );
198
+ if (walletAddress) {
199
+ walletAddresses = walletAddresses || []
200
+ walletAddresses.push(walletAddress)
215
201
  }
216
202
 
217
- if ( isotope ) {
218
- isotopes = isotopes || [];
219
- isotopes.push( isotope );
203
+ if (isotope) {
204
+ isotopes = isotopes || []
205
+ isotopes.push(isotope)
220
206
  }
221
207
 
222
- if ( tokenSlug ) {
223
- tokenSlugs = tokenSlugs || [];
224
- tokenSlugs.push( tokenSlug );
208
+ if (tokenSlug) {
209
+ tokenSlugs = tokenSlugs || []
210
+ tokenSlugs.push(tokenSlug)
225
211
  }
226
212
 
227
- if ( cellSlug ) {
228
- cellSlugs = cellSlugs || [];
229
- cellSlugs.push( cellSlug );
213
+ if (cellSlug) {
214
+ cellSlugs = cellSlugs || []
215
+ cellSlugs.push(cellSlug)
230
216
  }
231
217
 
232
- if ( batchId ) {
233
- batchIds = batchIds || [];
234
- batchIds.push( batchId );
218
+ if (batchId) {
219
+ batchIds = batchIds || []
220
+ batchIds.push(batchId)
235
221
  }
236
222
 
237
- if ( value ) {
238
- values = values || [];
239
- values.push( value );
223
+ if (value) {
224
+ values = values || []
225
+ values.push(value)
240
226
  }
241
227
 
242
- if ( metaType ) {
243
- metaTypes = metaTypes || [];
244
- metaTypes.push( metaType );
228
+ if (metaType) {
229
+ metaTypes = metaTypes || []
230
+ metaTypes.push(metaType)
245
231
  }
246
232
 
247
- if ( metaId ) {
248
- metaIds = metaIds || [];
249
- metaIds.push( metaId );
233
+ if (metaId) {
234
+ metaIds = metaIds || []
235
+ metaIds.push(metaId)
250
236
  }
251
237
 
252
- if ( index ) {
253
- indexes = indexes || [];
254
- indexes.push( index );
238
+ if (index) {
239
+ indexes = indexes || []
240
+ indexes.push(index)
255
241
  }
256
242
 
257
243
  return {
258
- molecularHashes: molecularHashes,
259
- bundleHashes: bundleHashes,
260
- positions: positions,
261
- walletAddresses: walletAddresses,
262
- isotopes: isotopes,
263
- tokenSlugs: tokenSlugs,
264
- cellSlugs: cellSlugs,
265
- batchIds: batchIds,
266
- values: values,
267
- metaTypes: metaTypes,
268
- metaIds: metaIds,
269
- indexes: indexes,
270
- filter: filter,
271
- latest: latest,
272
- queryArgs: queryArgs
273
- };
244
+ molecularHashes,
245
+ bundleHashes,
246
+ positions,
247
+ walletAddresses,
248
+ isotopes,
249
+ tokenSlugs,
250
+ cellSlugs,
251
+ batchIds,
252
+ values,
253
+ metaTypes,
254
+ metaIds,
255
+ indexes,
256
+ filter,
257
+ latest,
258
+ queryArgs
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Returns a Response object
264
+ *
265
+ * @param {object} json
266
+ * @return {ResponseAtom}
267
+ */
268
+ createResponse (json) {
269
+ return new ResponseAtom({
270
+ query: this,
271
+ json
272
+ })
274
273
  }
275
274
  }
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import { gql } from '@apollo/client/core';
50
- import ResponseBalance from '../response/ResponseBalance';
48
+ import Query from './Query'
49
+ import { gql } from '@apollo/client/core'
50
+ import ResponseBalance from '../response/ResponseBalance'
51
51
 
52
52
  /**
53
53
  * Query for getting the balance of a given wallet or token slug
54
54
  */
55
55
  export default class QueryBalance extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param apolloClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( apolloClient ) {
62
- super( apolloClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
65
64
  Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
@@ -83,17 +82,17 @@ export default class QueryBalance extends Query {
83
82
  amount
84
83
  }
85
84
  }
86
- }`;
85
+ }`
87
86
  }
88
87
 
89
88
  /**
90
89
  * @param {object} json
91
90
  * @return {ResponseBalance}
92
91
  */
93
- createResponse ( json ) {
94
- return new ResponseBalance( {
92
+ createResponse (json) {
93
+ return new ResponseBalance({
95
94
  query: this,
96
95
  json
97
- } );
96
+ })
98
97
  }
99
98
  }
@@ -45,17 +45,21 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import Response from '../response/Response';
50
- import { gql } from '@apollo/client/core';
51
-
48
+ import Query from './Query'
49
+ import Response from '../response/Response'
50
+ import { gql } from '@apollo/client/core'
52
51
 
53
52
  /**
54
53
  * Query for retrieving Meta Asset information
55
54
  */
56
55
  export default class QueryBatch extends Query {
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
56
+ /**
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
62
+
59
63
  this.$__query = gql`query( $batchId: String ) {
60
64
  Batch( batchId: $batchId ) {
61
65
  ${ QueryBatch.getFields() },
@@ -63,7 +67,7 @@ export default class QueryBatch extends Query {
63
67
  ${ QueryBatch.getFields() }
64
68
  }
65
69
  }
66
- }`;
70
+ }`
67
71
  }
68
72
 
69
73
  static getFields () {
@@ -116,7 +120,7 @@ export default class QueryBatch extends Query {
116
120
  throughMetas {
117
121
  key,
118
122
  value
119
- }`;
123
+ }`
120
124
  }
121
125
 
122
126
  /**
@@ -125,13 +129,12 @@ export default class QueryBatch extends Query {
125
129
  * @param {object} json
126
130
  * @return {Response}
127
131
  */
128
- createResponse ( json ) {
129
- let responseObject = new Response( {
132
+ createResponse (json) {
133
+ const responseObject = new Response({
130
134
  query: this,
131
135
  json
132
- } );
133
- responseObject.dataKey = 'data.Batch';
134
- return responseObject;
136
+ })
137
+ responseObject.dataKey = 'data.Batch'
138
+ return responseObject
135
139
  }
136
-
137
140
  }
@@ -45,23 +45,27 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import QueryBatch from './QueryBatch';
50
- import Response from '../response/Response';
51
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import QueryBatch from './QueryBatch'
50
+ import Response from '../response/Response'
51
+ import { gql } from '@apollo/client/core'
52
52
 
53
53
  /**
54
54
  * Query for retrieving Meta Asset information
55
55
  */
56
56
  export default class QueryBatchHistory extends Query {
57
+ /**
58
+ * @param {ApolloClientWrapper} apolloClient
59
+ * @param {KnishIOClient} knishIOClient
60
+ */
61
+ constructor (apolloClient, knishIOClient) {
62
+ super(apolloClient, knishIOClient)
57
63
 
58
- constructor ( apolloClient ) {
59
- super( apolloClient );
60
64
  this.$__query = gql`query( $batchId: String ) {
61
65
  BatchHistory( batchId: $batchId ) {
62
66
  ${ QueryBatch.getFields() }
63
67
  }
64
- }`;
68
+ }`
65
69
  }
66
70
 
67
71
  /**
@@ -70,13 +74,12 @@ export default class QueryBatchHistory extends Query {
70
74
  * @param {object} json
71
75
  * @return {Response}
72
76
  */
73
- createResponse ( json ) {
74
- let responseObject = new Response( {
77
+ createResponse (json) {
78
+ const responseObject = new Response({
75
79
  query: this,
76
80
  json
77
- } );
78
- responseObject.dataKey = 'data.BatchHistory';
79
- return responseObject;
81
+ })
82
+ responseObject.dataKey = 'data.BatchHistory'
83
+ return responseObject
80
84
  }
81
-
82
85
  }
@@ -45,17 +45,21 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import ResponseContinuId from '../response/ResponseContinuId';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseContinuId from '../response/ResponseContinuId'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Queries the node for the next wallet to sign with for ContinuID
54
54
  */
55
55
  export default class QueryContinuId extends Query {
56
+ /**
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
56
62
 
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
59
63
  this.$__query = gql`query ($bundle: String!) {
60
64
  ContinuId(bundle: $bundle) {
61
65
  address,
@@ -68,7 +72,7 @@ export default class QueryContinuId extends Query {
68
72
  amount,
69
73
  createdAt
70
74
  }
71
- }`;
75
+ }`
72
76
  }
73
77
 
74
78
  /**
@@ -77,11 +81,10 @@ export default class QueryContinuId extends Query {
77
81
  * @param {object} json
78
82
  * @return {ResponseContinuId}
79
83
  */
80
- createResponse ( json ) {
81
- return new ResponseContinuId( {
84
+ createResponse (json) {
85
+ return new ResponseContinuId({
82
86
  query: this,
83
87
  json
84
- } );
88
+ })
85
89
  }
86
-
87
90
  }
@@ -45,24 +45,23 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import ResponseMetaType from '../response/ResponseMetaType';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseMetaType from '../response/ResponseMetaType'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Query for retrieving Meta Asset information
54
54
  */
55
55
  export default class QueryMetaType extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param apolloClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( apolloClient ) {
62
- super( apolloClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
63
62
 
64
- this.$__query = gql`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $latestMetas: Boolean, $queryArgs: QueryArgs, $countBy: String ) {
65
- MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, latestMetas: $latestMetas, queryArgs: $queryArgs, countBy: $countBy ) {
63
+ this.$__query = gql`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 ) {
64
+ 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 ) {
66
65
  metaType,
67
66
  instanceCount {
68
67
  key,
@@ -85,20 +84,7 @@ export default class QueryMetaType extends Query {
85
84
  total
86
85
  }
87
86
  }
88
- }`;
89
- }
90
-
91
- /**
92
- * Returns a Response object
93
- *
94
- * @param {object} json
95
- * @return {ResponseMetaType}
96
- */
97
- createResponse ( json ) {
98
- return new ResponseMetaType( {
99
- query: this,
100
- json
101
- } );
87
+ }`
102
88
  }
103
89
 
104
90
  /**
@@ -109,74 +95,76 @@ export default class QueryMetaType extends Query {
109
95
  * @param {string|array|null} key
110
96
  * @param {string|array|null} value
111
97
  * @param {boolean|null} latest
112
- * @param {boolean|null} latestMetas
113
98
  * @param {object|null} filter
114
99
  * @param {object|null} queryArgs
115
100
  * @param {string|null} count
116
101
  * @param {string|null} countBy
117
102
  * @return {{}}
118
103
  */
119
- static createVariables ( {
104
+ static createVariables ({
120
105
  metaType = null,
121
106
  metaId = null,
122
107
  key = null,
123
108
  value = null,
124
109
  latest = null,
125
- latestMetas = true,
126
110
  filter = null,
127
111
  queryArgs = null,
128
112
  count = null,
129
113
  countBy = null
130
- } ) {
131
-
132
- const variables = {};
114
+ }) {
115
+ const variables = {}
133
116
 
134
- if ( metaType ) {
135
- variables[ typeof metaType === 'string' ? 'metaType' : 'metaTypes' ] = metaType;
117
+ if (metaType) {
118
+ variables[typeof metaType === 'string' ? 'metaType' : 'metaTypes'] = metaType
136
119
  }
137
120
 
138
- if ( metaId ) {
139
- variables[ typeof metaId === 'string' ? 'metaId' : 'metaIds' ] = metaId;
121
+ if (metaId) {
122
+ variables[typeof metaId === 'string' ? 'metaId' : 'metaIds'] = metaId
140
123
  }
141
124
 
142
- if ( key ) {
143
- variables[ typeof key === 'string' ? 'key' : 'keys' ] = key;
125
+ if (key) {
126
+ variables[typeof key === 'string' ? 'key' : 'keys'] = key
144
127
  }
145
128
 
146
- if ( value ) {
147
- variables[ typeof value === 'string' ? 'value' : 'values' ] = value;
129
+ if (value) {
130
+ variables[typeof value === 'string' ? 'value' : 'values'] = value
148
131
  }
149
132
 
150
- if ( latest ) {
151
- variables[ 'latest' ] = !!latest;
152
- }
133
+ variables.latest = latest === true
153
134
 
154
- if ( latestMetas ) {
155
- variables[ 'latestMetas' ] = !!latestMetas;
135
+ if (filter) {
136
+ variables.filter = filter
156
137
  }
157
138
 
158
- if ( filter ) {
159
- variables[ 'filter' ] = filter;
160
- }
161
-
162
- if ( queryArgs ) {
163
-
164
- if ( typeof queryArgs.limit === 'undefined' || queryArgs.limit === 0 ) {
165
- queryArgs.limit = '*';
139
+ if (queryArgs) {
140
+ if (typeof queryArgs.limit === 'undefined' || queryArgs.limit === 0) {
141
+ queryArgs.limit = '*'
166
142
  }
167
143
 
168
- variables[ 'queryArgs' ] = queryArgs;
144
+ variables.queryArgs = queryArgs
169
145
  }
170
146
 
171
- if ( count ) {
172
- variables[ 'count' ] = count;
147
+ if (count) {
148
+ variables.count = count
173
149
  }
174
150
 
175
- if ( countBy ) {
176
- variables[ 'countBy' ] = countBy;
151
+ if (countBy) {
152
+ variables.countBy = countBy
177
153
  }
178
154
 
179
- return variables;
155
+ return variables
180
156
  }
181
157
 
158
+ /**
159
+ * Returns a Response object
160
+ *
161
+ * @param {object} json
162
+ * @return {ResponseMetaType}
163
+ */
164
+ createResponse (json) {
165
+ return new ResponseMetaType({
166
+ query: this,
167
+ json
168
+ })
169
+ }
182
170
  }