@wishknish/knishio-client-js 0.6.4 → 0.7.4

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 (119) hide show
  1. package/dist/client.cjs.js +513 -0
  2. package/dist/client.cjs.js.map +1 -0
  3. package/dist/client.es.mjs +8176 -0
  4. package/dist/client.es.mjs.map +1 -0
  5. package/dist/client.iife.js +30 -45
  6. package/dist/client.iife.js.map +1 -0
  7. package/package.json +48 -28
  8. package/src/Atom.js +132 -5
  9. package/src/AtomMeta.js +7 -8
  10. package/src/AuthToken.js +1 -1
  11. package/src/KnishIOClient.js +133 -76
  12. package/src/Meta.js +6 -2
  13. package/src/Molecule.js +289 -38
  14. package/src/PolicyMeta.js +1 -1
  15. package/src/Wallet.js +19 -11
  16. package/src/exception/AtomIndexException.js +1 -1
  17. package/src/exception/AtomsMissingException.js +1 -1
  18. package/src/exception/AuthorizationRejectedException.js +1 -1
  19. package/src/exception/BalanceInsufficientException.js +1 -1
  20. package/src/exception/BatchIdException.js +1 -1
  21. package/src/exception/CodeException.js +1 -1
  22. package/src/exception/DecryptionKeyException.js +1 -1
  23. package/src/exception/InvalidResponseException.js +1 -1
  24. package/src/exception/MetaMissingException.js +1 -1
  25. package/src/exception/MolecularHashMismatchException.js +1 -1
  26. package/src/exception/MolecularHashMissingException.js +1 -1
  27. package/src/exception/NegativeAmountException.js +1 -1
  28. package/src/exception/PolicyInvalidException.js +1 -1
  29. package/src/exception/SignatureMalformedException.js +1 -1
  30. package/src/exception/SignatureMismatchException.js +1 -1
  31. package/src/exception/StackableUnitAmountException.js +1 -1
  32. package/src/exception/StackableUnitDecimalsException.js +1 -1
  33. package/src/exception/TransferBalanceException.js +1 -1
  34. package/src/exception/TransferMalformedException.js +1 -1
  35. package/src/exception/TransferMismatchedException.js +1 -1
  36. package/src/exception/TransferRemainderException.js +1 -1
  37. package/src/exception/TransferToSelfException.js +1 -1
  38. package/src/exception/TransferUnbalancedException.js +1 -1
  39. package/src/exception/UnauthenticatedException.js +1 -1
  40. package/src/exception/WalletCredentialException.js +1 -1
  41. package/src/exception/WalletShadowException.js +1 -1
  42. package/src/exception/WrongTokenTypeException.js +1 -1
  43. package/src/exception/index.js +25 -25
  44. package/src/index.js +23 -9
  45. package/src/instance/Rules/Callback.js +5 -5
  46. package/src/instance/Rules/Condition.js +1 -1
  47. package/src/instance/Rules/Rule.js +4 -4
  48. package/src/instance/Rules/exception/RuleArgumentException.js +1 -1
  49. package/src/libraries/CheckMolecule.js +76 -24
  50. package/src/libraries/crypto.js +16 -2
  51. package/src/libraries/strings.js +1 -1
  52. package/src/libraries/urql/UrqlClientWrapper.js +3 -1
  53. package/src/mutation/Mutation.js +2 -2
  54. package/src/mutation/MutationActiveSession.js +2 -2
  55. package/src/mutation/MutationAppendRequest.js +91 -0
  56. package/src/mutation/MutationClaimShadowWallet.js +3 -3
  57. package/src/mutation/MutationCreateIdentifier.js +2 -2
  58. package/src/mutation/MutationCreateMeta.js +2 -2
  59. package/src/mutation/MutationCreateRule.js +2 -2
  60. package/src/mutation/MutationCreateToken.js +2 -2
  61. package/src/mutation/MutationCreateWallet.js +2 -2
  62. package/src/mutation/MutationDepositBufferToken.js +1 -1
  63. package/src/mutation/MutationLinkIdentifier.js +2 -2
  64. package/src/mutation/MutationPeering.js +82 -0
  65. package/src/mutation/MutationProposeMolecule.js +2 -2
  66. package/src/mutation/MutationRequestAuthorization.js +2 -2
  67. package/src/mutation/MutationRequestAuthorizationGuest.js +2 -2
  68. package/src/mutation/MutationRequestTokens.js +2 -2
  69. package/src/mutation/MutationTransferTokens.js +2 -2
  70. package/src/mutation/MutationWithdrawBufferToken.js +1 -1
  71. package/src/query/Query.js +2 -2
  72. package/src/query/QueryActiveSession.js +2 -2
  73. package/src/query/QueryAtom.js +2 -2
  74. package/src/query/QueryBalance.js +2 -2
  75. package/src/query/QueryBatch.js +2 -2
  76. package/src/query/QueryBatchHistory.js +3 -3
  77. package/src/query/QueryContinuId.js +2 -2
  78. package/src/query/QueryMetaType.js +11 -5
  79. package/src/query/QueryMetaTypeViaAtom.js +11 -4
  80. package/src/query/QueryPolicy.js +2 -2
  81. package/src/query/QueryToken.js +2 -2
  82. package/src/query/QueryUserActivity.js +2 -2
  83. package/src/query/QueryWalletBundle.js +2 -2
  84. package/src/query/QueryWalletList.js +2 -2
  85. package/src/response/Response.js +168 -4
  86. package/src/response/ResponseActiveSession.js +2 -2
  87. package/src/response/{ResponseMetaBatch.js → ResponseAppendRequest.js} +4 -21
  88. package/src/response/ResponseAtom.js +2 -2
  89. package/src/response/ResponseAuthorizationGuest.js +4 -4
  90. package/src/response/ResponseBalance.js +9 -4
  91. package/src/response/ResponseClaimShadowWallet.js +1 -1
  92. package/src/response/ResponseContinuId.js +3 -3
  93. package/src/response/ResponseCreateIdentifier.js +1 -1
  94. package/src/response/ResponseCreateMeta.js +1 -1
  95. package/src/response/ResponseCreateRule.js +1 -1
  96. package/src/response/ResponseCreateToken.js +1 -1
  97. package/src/response/ResponseCreateWallet.js +1 -1
  98. package/src/response/ResponseLinkIdentifier.js +3 -3
  99. package/src/response/ResponseMetaType.js +2 -2
  100. package/src/response/ResponseMetaTypeViaAtom.js +2 -2
  101. package/src/response/ResponsePeering.js +55 -0
  102. package/src/response/ResponsePolicy.js +2 -2
  103. package/src/response/ResponseProposeMolecule.js +3 -3
  104. package/src/response/ResponseQueryActiveSession.js +2 -2
  105. package/src/response/ResponseQueryUserActivity.js +2 -2
  106. package/src/response/ResponseRequestAuthorization.js +3 -3
  107. package/src/response/ResponseRequestAuthorizationGuest.js +3 -3
  108. package/src/response/ResponseRequestTokens.js +1 -1
  109. package/src/response/ResponseTransferTokens.js +1 -1
  110. package/src/response/ResponseWalletBundle.js +3 -3
  111. package/src/response/ResponseWalletList.js +4 -4
  112. package/src/subscribe/ActiveSessionSubscribe.js +1 -1
  113. package/src/subscribe/ActiveWalletSubscribe.js +1 -1
  114. package/src/subscribe/CreateMoleculeSubscribe.js +1 -1
  115. package/src/subscribe/Subscribe.js +1 -1
  116. package/src/subscribe/WalletStatusSubscribe.js +1 -1
  117. package/src/types/index.js +2 -2
  118. package/src/versions/Version4.js +1 -1
  119. package/src/versions/index.js +1 -1
@@ -45,8 +45,8 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseCreateWallet from '../response/ResponseCreateWallet'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseCreateWallet from '../response/ResponseCreateWallet.js'
50
50
 
51
51
  /**
52
52
  * Query for creating new Wallets
@@ -45,7 +45,7 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
49
 
50
50
  /**
51
51
  *
@@ -45,8 +45,8 @@ 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 Mutation from '../mutation/Mutation'
49
- import ResponseLinkIdentifier from '../response/ResponseLinkIdentifier'
48
+ import Mutation from '../mutation/Mutation.js'
49
+ import ResponseLinkIdentifier from '../response/ResponseLinkIdentifier.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -0,0 +1,82 @@
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-JS for information.
45
+
46
+ License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
+ */
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponsePeering from '../response/ResponsePeering.js'
50
+
51
+ /**
52
+ * Mutation for registering a peer node via the P-isotope
53
+ */
54
+ export default class MutationPeering extends MutationProposeMolecule {
55
+ /**
56
+ * Fills a molecule with a P-isotope peering atom
57
+ *
58
+ * @param {string} host
59
+ */
60
+ fillMolecule ({
61
+ host
62
+ }) {
63
+ this.$__molecule.initPeering({
64
+ host
65
+ })
66
+ this.$__molecule.sign({})
67
+ this.$__molecule.check()
68
+ }
69
+
70
+ /**
71
+ * Builds a new Response object from a JSON string
72
+ *
73
+ * @param {object} json
74
+ * @return {ResponsePeering}
75
+ */
76
+ createResponse (json) {
77
+ return new ResponsePeering({
78
+ query: this,
79
+ json
80
+ })
81
+ }
82
+ }
@@ -45,8 +45,8 @@ 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 ResponseProposeMolecule from '../response/ResponseProposeMolecule'
49
- import Mutation from './Mutation'
48
+ import ResponseProposeMolecule from '../response/ResponseProposeMolecule.js'
49
+ import Mutation from './Mutation.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  export default class MutationProposeMolecule extends Mutation {
@@ -45,8 +45,8 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseRequestAuthorization from '../response/ResponseRequestAuthorization'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseRequestAuthorization from '../response/ResponseRequestAuthorization.js'
50
50
 
51
51
  /**
52
52
  * Query for requesting an authorization token from the node
@@ -45,8 +45,8 @@ 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 Mutation from '../mutation/Mutation'
49
- import ResponseRequestAuthorizationGuest from '../response/ResponseRequestAuthorizationGuest'
48
+ import Mutation from '../mutation/Mutation.js'
49
+ import ResponseRequestAuthorizationGuest from '../response/ResponseRequestAuthorizationGuest.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  export default class MutationRequestAuthorizationGuest extends Mutation {
@@ -45,8 +45,8 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseRequestTokens from '../response/ResponseRequestTokens'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseRequestTokens from '../response/ResponseRequestTokens.js'
50
50
 
51
51
  export default class MutationRequestTokens extends MutationProposeMolecule {
52
52
  /**
@@ -45,8 +45,8 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
49
- import ResponseTransferTokens from '../response/ResponseTransferTokens'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
+ import ResponseTransferTokens from '../response/ResponseTransferTokens.js'
50
50
 
51
51
  /**
52
52
  * Query for moving tokens between wallets
@@ -45,7 +45,7 @@ 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 MutationProposeMolecule from './MutationProposeMolecule'
48
+ import MutationProposeMolecule from './MutationProposeMolecule.js'
49
49
 
50
50
  /**
51
51
  *
@@ -45,8 +45,8 @@ 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 CodeException from '../exception/CodeException'
49
- import Response from '../response/Response'
48
+ import CodeException from '../exception/CodeException.js'
49
+ import Response from '../response/Response.js'
50
50
 
51
51
  export default class Query {
52
52
  /**
@@ -45,8 +45,8 @@ 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'
48
+ import Query from './Query.js'
49
+ import ResponseQueryActiveSession from '../response/ResponseQueryActiveSession.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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 ResponseAtom from '../response/ResponseAtom'
48
+ import Query from './Query.js'
49
+ import ResponseAtom from '../response/ResponseAtom.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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 ResponseBalance from '../response/ResponseBalance'
48
+ import Query from './Query.js'
49
+ import ResponseBalance from '../response/ResponseBalance.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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'
48
+ import Query from './Query.js'
49
+ import Response from '../response/Response.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,9 +45,9 @@ 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'
48
+ import Query from './Query.js'
49
+ import QueryBatch from './QueryBatch.js'
50
+ import Response from '../response/Response.js'
51
51
  import { gql } from '@urql/core'
52
52
 
53
53
  /**
@@ -45,8 +45,8 @@ 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'
48
+ import Query from './Query.js'
49
+ import ResponseContinuId from '../response/ResponseContinuId.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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'
48
+ import Query from './Query.js'
49
+ import ResponseMetaType from '../response/ResponseMetaType.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -60,8 +60,8 @@ export default class QueryMetaType extends Query {
60
60
  constructor (graphQLClient, knishIOClient) {
61
61
  super(graphQLClient, knishIOClient)
62
62
 
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 ) {
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, $cellSlug: 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, cellSlug: $cellSlug ) {
65
65
  metaType,
66
66
  instanceCount {
67
67
  key,
@@ -99,6 +99,7 @@ export default class QueryMetaType extends Query {
99
99
  * @param {object|null} queryArgs
100
100
  * @param {string|null} count
101
101
  * @param {string|null} countBy
102
+ * @param {string|null} cellSlug
102
103
  * @return {{}}
103
104
  */
104
105
  static createVariables ({
@@ -110,7 +111,8 @@ export default class QueryMetaType extends Query {
110
111
  filter = null,
111
112
  queryArgs = null,
112
113
  count = null,
113
- countBy = null
114
+ countBy = null,
115
+ cellSlug = null
114
116
  }) {
115
117
  const variables = {}
116
118
 
@@ -152,6 +154,10 @@ export default class QueryMetaType extends Query {
152
154
  variables.countBy = countBy
153
155
  }
154
156
 
157
+ if (cellSlug) {
158
+ variables.cellSlug = cellSlug
159
+ }
160
+
155
161
  return variables
156
162
  }
157
163
 
@@ -45,8 +45,8 @@ 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 ResponseMetaTypeViaAtom from '../response/ResponseMetaTypeViaAtom'
48
+ import Query from './Query.js'
49
+ import ResponseMetaTypeViaAtom from '../response/ResponseMetaTypeViaAtom.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  export default class QueryMetaTypeViaAtom extends Query {
@@ -57,11 +57,12 @@ export default class QueryMetaTypeViaAtom extends Query {
57
57
  constructor (graphQLClient, knishIOClient) {
58
58
  super(graphQLClient, knishIOClient)
59
59
 
60
- this.$__query = gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
60
+ this.$__query = gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
61
61
  MetaTypeViaAtom(
62
62
  metaTypes: $metaTypes
63
63
  metaIds: $metaIds
64
64
  atomValues: $atomValues
65
+ cellSlugs: $cellSlugs
65
66
  filter: $filter,
66
67
  latest: $latest,
67
68
  queryArgs: $queryArgs
@@ -106,6 +107,7 @@ export default class QueryMetaTypeViaAtom extends Query {
106
107
  * @param {array|null} filter
107
108
  * @param {object|null} queryArgs
108
109
  * @param {string|null} countBy
110
+ * @param {string|null} cellSlug
109
111
  * @return {{}}
110
112
  */
111
113
  static createVariables ({
@@ -119,7 +121,8 @@ export default class QueryMetaTypeViaAtom extends Query {
119
121
  latest = null,
120
122
  filter = null,
121
123
  queryArgs = null,
122
- countBy = null
124
+ countBy = null,
125
+ cellSlug = null
123
126
  }) {
124
127
  const variables = {}
125
128
 
@@ -143,6 +146,10 @@ export default class QueryMetaTypeViaAtom extends Query {
143
146
  variables.metaIds = typeof metaId === 'string' ? [metaId] : metaId
144
147
  }
145
148
 
149
+ if (cellSlug) {
150
+ variables.cellSlugs = typeof cellSlug === 'string' ? [cellSlug] : cellSlug
151
+ }
152
+
146
153
  if (countBy) {
147
154
  variables.countBy = countBy
148
155
  }
@@ -46,8 +46,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
48
 
49
- import Query from './Query'
50
- import ResponsePolicy from '../response/ResponsePolicy'
49
+ import Query from './Query.js'
50
+ import ResponsePolicy from '../response/ResponsePolicy.js'
51
51
  import { gql } from "@urql/core";
52
52
 
53
53
  export default class QueryPolicy extends Query {
@@ -45,8 +45,8 @@ 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'
48
+ import Query from './Query.js'
49
+ import Response from '../response/Response.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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 ResponseQueryUserActivity from '../response/ResponseQueryUserActivity'
48
+ import Query from './Query.js'
49
+ import ResponseQueryUserActivity from '../response/ResponseQueryUserActivity.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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 ResponseWalletBundle from '../response/ResponseWalletBundle'
48
+ import Query from './Query.js'
49
+ import ResponseWalletBundle from '../response/ResponseWalletBundle.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,8 +45,8 @@ 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 ResponseWalletList from '../response/ResponseWalletList'
48
+ import Query from './Query.js'
49
+ import ResponseWalletList from '../response/ResponseWalletList.js'
50
50
  import { gql } from '@urql/core'
51
51
 
52
52
  /**
@@ -45,9 +45,9 @@ 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 InvalidResponseException from '../exception/InvalidResponseException'
49
- import UnauthenticatedException from '../exception/UnauthenticatedException'
50
- import Dot from '../libraries/Dot'
48
+ import InvalidResponseException from '../exception/InvalidResponseException.js'
49
+ import UnauthenticatedException from '../exception/UnauthenticatedException.js'
50
+ import Dot from '../libraries/Dot.js'
51
51
 
52
52
  /**
53
53
  * Base Response class for processing node responses
@@ -86,6 +86,17 @@ export default class Response {
86
86
  throw new InvalidResponseException()
87
87
  }
88
88
 
89
+ // Check for GraphQL errors array
90
+ if (this.$__response.errors && Array.isArray(this.$__response.errors) && this.$__response.errors.length > 0) {
91
+ const errorMessage = this.$__response.errors[0].message || 'Unknown GraphQL error'
92
+
93
+ if (errorMessage.includes('Unauthenticated')) {
94
+ throw new UnauthenticatedException()
95
+ }
96
+
97
+ throw new InvalidResponseException(`GraphQL Error: ${errorMessage}`)
98
+ }
99
+
89
100
  this.init()
90
101
  }
91
102
 
@@ -103,9 +114,14 @@ export default class Response {
103
114
  return this.response()
104
115
  }
105
116
 
117
+ // Check if response has data field
118
+ if (!this.response().data) {
119
+ throw new InvalidResponseException('Response has no data field')
120
+ }
121
+
106
122
  // Check key & return custom data from the response
107
123
  if (!Dot.has(this.response(), this.dataKey)) {
108
- throw new InvalidResponseException()
124
+ throw new InvalidResponseException(`Missing expected field: ${this.dataKey}`)
109
125
  }
110
126
 
111
127
  return Dot.get(this.response(), this.dataKey)
@@ -138,4 +154,152 @@ export default class Response {
138
154
  status () {
139
155
  return null
140
156
  }
157
+
158
+ /**
159
+ * Check if response was successful
160
+ * @return {boolean}
161
+ */
162
+ success () {
163
+ // Default implementation - can be overridden by subclasses
164
+ return !this.$__response?.errors?.length
165
+ }
166
+
167
+ /**
168
+ * Get error message if any
169
+ *
170
+ * @return {string|null}
171
+ */
172
+ error () {
173
+ return this.$__response?.errors?.length ? this.$__response.errors[0].message || 'Unknown error' : null
174
+ }
175
+
176
+ /**
177
+ * Enhanced interface methods for standardized response handling
178
+ */
179
+
180
+ /**
181
+ * Get error reason (alias for error() to match standardized interface)
182
+ * @return {string|null}
183
+ */
184
+ reason () {
185
+ return this.error()
186
+ }
187
+
188
+ /**
189
+ * Convert to ValidationResult for enhanced error handling
190
+ * @return {object}
191
+ */
192
+ toValidationResult () {
193
+ if (this.success() && this.payload() !== null) {
194
+ return {
195
+ success: true,
196
+ data: this.payload(),
197
+ warnings: []
198
+ }
199
+ } else {
200
+ return {
201
+ success: false,
202
+ error: {
203
+ message: this.reason() || 'Unknown error',
204
+ context: this.constructor.name,
205
+ details: this.$__response?.errors || []
206
+ }
207
+ }
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Enhanced error handling with callbacks
213
+ * @param {function} callback
214
+ * @return {Response}
215
+ */
216
+ onSuccess (callback) {
217
+ if (this.success() && this.payload() !== null) {
218
+ try {
219
+ callback(this.payload())
220
+ } catch (error) {
221
+ console.warn('Response.onSuccess callback failed:', error)
222
+ }
223
+ }
224
+ return this
225
+ }
226
+
227
+ /**
228
+ * Enhanced failure handling with callbacks
229
+ * @param {function} callback
230
+ * @return {Response}
231
+ */
232
+ onFailure (callback) {
233
+ if (!this.success()) {
234
+ try {
235
+ callback(this.reason() || 'Unknown error')
236
+ } catch (error) {
237
+ console.warn('Response.onFailure callback failed:', error)
238
+ }
239
+ }
240
+ return this
241
+ }
242
+
243
+ /**
244
+ * Debug logging with enhanced context
245
+ * @param {string|null} label
246
+ * @return {Response}
247
+ */
248
+ debug (label = null) {
249
+ const debugPrefix = label ? `[${label}]` : `[${this.constructor.name}]`
250
+
251
+ if (this.success()) {
252
+ console.debug(`${debugPrefix} Success:`, {
253
+ payload: this.payload(),
254
+ query: this.$__query?.constructor?.name,
255
+ dataKey: this.dataKey
256
+ })
257
+ } else {
258
+ console.debug(`${debugPrefix} Failure:`, {
259
+ error: this.reason(),
260
+ errors: this.$__response?.errors,
261
+ rawData: this.$__response
262
+ })
263
+ }
264
+
265
+ return this
266
+ }
267
+
268
+ /**
269
+ * Promise conversion for enhanced async patterns
270
+ * @return {Promise}
271
+ */
272
+ toPromise () {
273
+ if (this.success() && this.payload() !== null) {
274
+ return Promise.resolve(this.payload())
275
+ } else {
276
+ return Promise.reject(new Error(this.reason() || 'Unknown error'))
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Functional programming map operation
282
+ * @param {function} mapper
283
+ * @return {Response}
284
+ */
285
+ map (mapper) {
286
+ if (this.success() && this.payload() !== null) {
287
+ try {
288
+ const mappedPayload = mapper(this.payload())
289
+ // Create new response with mapped payload
290
+ const newResponse = Object.create(Object.getPrototypeOf(this))
291
+ Object.assign(newResponse, this)
292
+ newResponse.$__payload = mappedPayload
293
+ return newResponse
294
+ } catch (error) {
295
+ // Create error response
296
+ const errorResponse = Object.create(Object.getPrototypeOf(this))
297
+ Object.assign(errorResponse, this)
298
+ errorResponse.$__response = { errors: [{ message: `Mapping failed: ${error.message}` }] }
299
+ return errorResponse
300
+ }
301
+ } else {
302
+ return this
303
+ }
304
+ }
141
305
  }
@@ -46,8 +46,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
48
 
49
- import Query from '../query/Query'
50
- import Response from './Response'
49
+ import Query from '../query/Query.js'
50
+ import Response from './Response.js'
51
51
 
52
52
  export default class ResponseActiveSession extends Response {
53
53
  /**