@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,630 @@
|
|
|
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
|
+
/**
|
|
50
|
+
* GraphQL type definitions for KnishIO SDK
|
|
51
|
+
* Provides type safety for all GraphQL operations
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
import type {
|
|
55
|
+
WalletAddress,
|
|
56
|
+
BundleHash,
|
|
57
|
+
TokenSlug,
|
|
58
|
+
MetaType,
|
|
59
|
+
MetaId,
|
|
60
|
+
CellSlug,
|
|
61
|
+
AtomIsotope,
|
|
62
|
+
MetaData
|
|
63
|
+
} from './index'
|
|
64
|
+
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// BASE GRAPHQL TYPES
|
|
67
|
+
// =============================================================================
|
|
68
|
+
|
|
69
|
+
export interface GraphQLRequest {
|
|
70
|
+
query: string
|
|
71
|
+
variables?: Record<string, unknown>
|
|
72
|
+
operationName?: string | null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface GraphQLResponse<T = unknown> {
|
|
76
|
+
data?: T | null
|
|
77
|
+
errors?: GraphQLError[] | null
|
|
78
|
+
extensions?: Record<string, unknown> | null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface GraphQLError {
|
|
82
|
+
message: string
|
|
83
|
+
locations?: Array<{
|
|
84
|
+
line: number
|
|
85
|
+
column: number
|
|
86
|
+
}>
|
|
87
|
+
path?: Array<string | number>
|
|
88
|
+
extensions?: Record<string, unknown>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface GraphQLVariables {
|
|
92
|
+
[key: string]: unknown
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// =============================================================================
|
|
96
|
+
// QUERY OPERATION TYPES
|
|
97
|
+
// =============================================================================
|
|
98
|
+
|
|
99
|
+
export interface QueryOperation<TVariables = GraphQLVariables, TResult = unknown> {
|
|
100
|
+
query(): string
|
|
101
|
+
variables: TVariables
|
|
102
|
+
createResponse(data: unknown): TResult
|
|
103
|
+
getVariables(): TVariables
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface QueryContinuIdVariables {
|
|
107
|
+
bundle: BundleHash | string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface QueryContinuIdResult {
|
|
111
|
+
ContinuId: {
|
|
112
|
+
bundle: BundleHash
|
|
113
|
+
position: string
|
|
114
|
+
createdAt: string
|
|
115
|
+
} | null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface QueryWalletBundleVariables {
|
|
119
|
+
bundleHashes: Array<BundleHash | string>
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface QueryWalletBundleResult {
|
|
123
|
+
WalletBundle: Array<{
|
|
124
|
+
bundleHash: BundleHash
|
|
125
|
+
wallets: Array<{
|
|
126
|
+
address: WalletAddress
|
|
127
|
+
token: TokenSlug
|
|
128
|
+
balance: string
|
|
129
|
+
position: string
|
|
130
|
+
}>
|
|
131
|
+
}>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface QueryWalletListVariables {
|
|
135
|
+
bundleHash?: BundleHash | string | null
|
|
136
|
+
tokenSlug?: TokenSlug | string | null
|
|
137
|
+
unspent?: boolean | null
|
|
138
|
+
limit?: number | null
|
|
139
|
+
offset?: number | null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface QueryWalletListResult {
|
|
143
|
+
WalletList: Array<{
|
|
144
|
+
address: WalletAddress
|
|
145
|
+
token: TokenSlug
|
|
146
|
+
balance: string
|
|
147
|
+
position: string
|
|
148
|
+
createdAt: string
|
|
149
|
+
}>
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface QueryBalanceVariables {
|
|
153
|
+
bundleHash?: BundleHash | string | null
|
|
154
|
+
address?: WalletAddress | string | null
|
|
155
|
+
token?: TokenSlug | string | null
|
|
156
|
+
type?: 'token' | 'user' | null
|
|
157
|
+
unspent?: boolean | null
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface QueryBalanceResult {
|
|
161
|
+
Balance: Array<{
|
|
162
|
+
address: WalletAddress
|
|
163
|
+
position: string
|
|
164
|
+
amount: string
|
|
165
|
+
characters: string | null
|
|
166
|
+
token: TokenSlug
|
|
167
|
+
}>
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface QueryMetaTypeVariables {
|
|
171
|
+
metaType: MetaType | string
|
|
172
|
+
metaId?: MetaId | string | null
|
|
173
|
+
key?: string | null
|
|
174
|
+
value?: string | null
|
|
175
|
+
latest?: boolean | null
|
|
176
|
+
filter?: string | null
|
|
177
|
+
queryArgs?: Record<string, unknown> | null
|
|
178
|
+
count?: number | null
|
|
179
|
+
countBy?: string | null
|
|
180
|
+
cellSlug?: CellSlug | string | null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface QueryMetaTypeResult {
|
|
184
|
+
MetaType: Array<{
|
|
185
|
+
metaType: MetaType
|
|
186
|
+
metaId: MetaId
|
|
187
|
+
meta: MetaData
|
|
188
|
+
createdAt: string
|
|
189
|
+
}>
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface QueryBatchVariables {
|
|
193
|
+
batchId: string
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface QueryBatchResult {
|
|
197
|
+
Batch: {
|
|
198
|
+
batchId: string
|
|
199
|
+
molecularHash: string
|
|
200
|
+
height: number
|
|
201
|
+
atoms: Array<{
|
|
202
|
+
position: string
|
|
203
|
+
walletAddress: WalletAddress
|
|
204
|
+
isotope: AtomIsotope
|
|
205
|
+
token: TokenSlug
|
|
206
|
+
value: string | null
|
|
207
|
+
createdAt: string
|
|
208
|
+
}>
|
|
209
|
+
} | null
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface QueryActiveSessionVariables {
|
|
213
|
+
bundleHash?: BundleHash | string | null
|
|
214
|
+
metaType?: MetaType | string | null
|
|
215
|
+
metaId?: MetaId | string | null
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface QueryActiveSessionResult {
|
|
219
|
+
ActiveSession: {
|
|
220
|
+
sessionId: string
|
|
221
|
+
bundleHash: BundleHash
|
|
222
|
+
status: 'active' | 'expired' | 'inactive'
|
|
223
|
+
createdAt: string
|
|
224
|
+
expiresAt: string
|
|
225
|
+
} | null
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface QueryAtomVariables {
|
|
229
|
+
position?: string | null
|
|
230
|
+
isotope?: AtomIsotope | null
|
|
231
|
+
token?: TokenSlug | string | null
|
|
232
|
+
metaType?: MetaType | string | null
|
|
233
|
+
metaId?: MetaId | string | null
|
|
234
|
+
limit?: number | null
|
|
235
|
+
offset?: number | null
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface QueryAtomResult {
|
|
239
|
+
Atom: Array<{
|
|
240
|
+
position: string
|
|
241
|
+
walletAddress: WalletAddress
|
|
242
|
+
isotope: AtomIsotope
|
|
243
|
+
token: TokenSlug
|
|
244
|
+
value: string | null
|
|
245
|
+
batchId: string | null
|
|
246
|
+
metaType: MetaType | null
|
|
247
|
+
metaId: MetaId | null
|
|
248
|
+
meta: MetaData | null
|
|
249
|
+
createdAt: string
|
|
250
|
+
index: number
|
|
251
|
+
}>
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// =============================================================================
|
|
255
|
+
// MUTATION OPERATION TYPES
|
|
256
|
+
// =============================================================================
|
|
257
|
+
|
|
258
|
+
export interface MutationOperation<TVariables = GraphQLVariables, TResult = unknown> {
|
|
259
|
+
createRequest(variables: TVariables): GraphQLRequest
|
|
260
|
+
createResponse(data: unknown): TResult
|
|
261
|
+
fillMolecule?(variables: TVariables): Promise<void>
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface MutationProposeMoleculeVariables {
|
|
265
|
+
molecule: {
|
|
266
|
+
molecularHash: string
|
|
267
|
+
cellSlug: CellSlug | string | null
|
|
268
|
+
atoms: Array<{
|
|
269
|
+
position: string
|
|
270
|
+
walletAddress: WalletAddress
|
|
271
|
+
isotope: AtomIsotope
|
|
272
|
+
token: TokenSlug
|
|
273
|
+
value: string | null
|
|
274
|
+
batchId: string | null
|
|
275
|
+
metaType: MetaType | string | null
|
|
276
|
+
metaId: MetaId | string | null
|
|
277
|
+
meta: MetaData[] | null
|
|
278
|
+
otsFragment: string | null
|
|
279
|
+
index: number
|
|
280
|
+
createdAt: string
|
|
281
|
+
}>
|
|
282
|
+
createdAt: string
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface MutationProposeMoleculeResult {
|
|
287
|
+
ProposeMolecule: {
|
|
288
|
+
molecularHash: string
|
|
289
|
+
status: 'accepted' | 'rejected' | 'pending'
|
|
290
|
+
response: string | null
|
|
291
|
+
createdAt: string
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface MutationRequestAuthorizationVariables {
|
|
296
|
+
bundleHash?: BundleHash | string | null
|
|
297
|
+
metaType?: MetaType | string | null
|
|
298
|
+
metaId?: MetaId | string | null
|
|
299
|
+
cellSlug?: CellSlug | string | null
|
|
300
|
+
molecule: MutationProposeMoleculeVariables['molecule']
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface MutationRequestAuthorizationResult {
|
|
304
|
+
RequestAuthorization: {
|
|
305
|
+
authToken: string
|
|
306
|
+
expiresAt: number
|
|
307
|
+
pubkey: string
|
|
308
|
+
encrypt: boolean
|
|
309
|
+
molecularHash: string
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface MutationCreateTokenVariables {
|
|
314
|
+
token: TokenSlug | string
|
|
315
|
+
amount: string
|
|
316
|
+
fungible?: boolean
|
|
317
|
+
splittable?: number | null
|
|
318
|
+
supplyToken?: TokenSlug | string | null
|
|
319
|
+
metaType?: MetaType | string | null
|
|
320
|
+
metaId?: MetaId | string | null
|
|
321
|
+
meta?: MetaData | null
|
|
322
|
+
molecule: MutationProposeMoleculeVariables['molecule']
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface MutationCreateTokenResult {
|
|
326
|
+
CreateToken: {
|
|
327
|
+
token: TokenSlug
|
|
328
|
+
amount: string
|
|
329
|
+
fungible: boolean
|
|
330
|
+
molecularHash: string
|
|
331
|
+
createdAt: string
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface MutationTransferTokensVariables {
|
|
336
|
+
recipient: WalletAddress | string
|
|
337
|
+
amount: string
|
|
338
|
+
token?: TokenSlug | string
|
|
339
|
+
remainder?: boolean
|
|
340
|
+
metaType?: MetaType | string | null
|
|
341
|
+
metaId?: MetaId | string | null
|
|
342
|
+
meta?: MetaData | null
|
|
343
|
+
molecule: MutationProposeMoleculeVariables['molecule']
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface MutationTransferTokensResult {
|
|
347
|
+
TransferTokens: {
|
|
348
|
+
molecularHash: string
|
|
349
|
+
amount: string
|
|
350
|
+
recipient: WalletAddress
|
|
351
|
+
remainder: string | null
|
|
352
|
+
createdAt: string
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface MutationCreateMetaVariables {
|
|
357
|
+
metaType: MetaType | string
|
|
358
|
+
metaId: MetaId | string
|
|
359
|
+
meta: MetaData
|
|
360
|
+
molecule: MutationProposeMoleculeVariables['molecule']
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface MutationCreateMetaResult {
|
|
364
|
+
CreateMeta: {
|
|
365
|
+
metaType: MetaType
|
|
366
|
+
metaId: MetaId
|
|
367
|
+
meta: MetaData
|
|
368
|
+
molecularHash: string
|
|
369
|
+
createdAt: string
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface MutationActiveSessionVariables {
|
|
374
|
+
bundleHash: BundleHash | string
|
|
375
|
+
metaType?: MetaType | string | null
|
|
376
|
+
metaId?: MetaId | string | null
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface MutationActiveSessionResult {
|
|
380
|
+
ActiveSession: {
|
|
381
|
+
sessionId: string
|
|
382
|
+
bundleHash: BundleHash
|
|
383
|
+
status: 'active' | 'inactive'
|
|
384
|
+
expiresAt: string
|
|
385
|
+
createdAt: string
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface MutationRequestAuthorizationGuestVariables {
|
|
390
|
+
cellSlug?: CellSlug | string | null
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface MutationRequestAuthorizationGuestResult {
|
|
394
|
+
RequestAuthorizationGuest: {
|
|
395
|
+
authToken: string
|
|
396
|
+
expiresAt: number
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// =============================================================================
|
|
401
|
+
// SUBSCRIPTION OPERATION TYPES
|
|
402
|
+
// =============================================================================
|
|
403
|
+
|
|
404
|
+
export interface SubscriptionOperation<TVariables = GraphQLVariables, TResult = unknown> {
|
|
405
|
+
createRequest(variables: TVariables): GraphQLRequest
|
|
406
|
+
handleData(data: unknown): TResult
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface CreateMoleculeSubscribeVariables {
|
|
410
|
+
operationName?: string
|
|
411
|
+
bundleHash?: BundleHash | string | null
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export interface CreateMoleculeSubscribeResult {
|
|
415
|
+
CreateMolecule: {
|
|
416
|
+
molecularHash: string
|
|
417
|
+
status: 'accepted' | 'rejected' | 'pending'
|
|
418
|
+
bundleHash: BundleHash
|
|
419
|
+
atoms: Array<{
|
|
420
|
+
position: string
|
|
421
|
+
walletAddress: WalletAddress
|
|
422
|
+
isotope: AtomIsotope
|
|
423
|
+
token: TokenSlug
|
|
424
|
+
value: string | null
|
|
425
|
+
}>
|
|
426
|
+
createdAt: string
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface WalletStatusSubscribeVariables {
|
|
431
|
+
bundleHash: BundleHash | string
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface WalletStatusSubscribeResult {
|
|
435
|
+
WalletStatus: {
|
|
436
|
+
bundleHash: BundleHash
|
|
437
|
+
address: WalletAddress
|
|
438
|
+
token: TokenSlug
|
|
439
|
+
balance: string
|
|
440
|
+
status: 'active' | 'inactive' | 'depleted'
|
|
441
|
+
updatedAt: string
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface ActiveWalletSubscribeVariables {
|
|
446
|
+
bundleHash: BundleHash | string
|
|
447
|
+
token?: TokenSlug | string | null
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export interface ActiveWalletSubscribeResult {
|
|
451
|
+
ActiveWallet: {
|
|
452
|
+
bundleHash: BundleHash
|
|
453
|
+
address: WalletAddress
|
|
454
|
+
token: TokenSlug
|
|
455
|
+
balance: string
|
|
456
|
+
lastActivity: string
|
|
457
|
+
status: 'active' | 'inactive'
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// =============================================================================
|
|
462
|
+
// RESPONSE WRAPPER TYPES
|
|
463
|
+
// =============================================================================
|
|
464
|
+
|
|
465
|
+
export interface QueryResponse<T = unknown> {
|
|
466
|
+
success(): boolean
|
|
467
|
+
reason(): string | null
|
|
468
|
+
data(): T | null
|
|
469
|
+
payload(): Record<string, unknown> | null
|
|
470
|
+
errors(): GraphQLError[] | null
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface MutationResponse<T = unknown> extends QueryResponse<T> {
|
|
474
|
+
molecularHash(): string | null
|
|
475
|
+
status(): 'accepted' | 'rejected' | 'pending' | null
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// =============================================================================
|
|
479
|
+
// CLIENT WRAPPER TYPES
|
|
480
|
+
// =============================================================================
|
|
481
|
+
|
|
482
|
+
export interface GraphQLClient {
|
|
483
|
+
query<TResult = unknown, TVariables = GraphQLVariables>(
|
|
484
|
+
request: GraphQLRequest,
|
|
485
|
+
variables?: TVariables
|
|
486
|
+
): Promise<GraphQLResponse<TResult>>
|
|
487
|
+
|
|
488
|
+
mutation<TResult = unknown, TVariables = GraphQLVariables>(
|
|
489
|
+
request: GraphQLRequest,
|
|
490
|
+
variables?: TVariables
|
|
491
|
+
): Promise<GraphQLResponse<TResult>>
|
|
492
|
+
|
|
493
|
+
subscription<TResult = unknown, TVariables = GraphQLVariables>(
|
|
494
|
+
request: GraphQLRequest,
|
|
495
|
+
variables?: TVariables
|
|
496
|
+
): AsyncIterableIterator<GraphQLResponse<TResult>>
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export interface UrqlClientWrapper extends GraphQLClient {
|
|
500
|
+
uri: string
|
|
501
|
+
connected: boolean
|
|
502
|
+
|
|
503
|
+
connect(): Promise<void>
|
|
504
|
+
disconnect(): void
|
|
505
|
+
|
|
506
|
+
// WebSocket subscription management
|
|
507
|
+
subscribe<TResult = unknown>(
|
|
508
|
+
query: string,
|
|
509
|
+
variables?: GraphQLVariables,
|
|
510
|
+
callback?: (data: TResult) => void
|
|
511
|
+
): string // returns subscription ID
|
|
512
|
+
|
|
513
|
+
unsubscribe(subscriptionId: string): void
|
|
514
|
+
unsubscribeAll(): void
|
|
515
|
+
|
|
516
|
+
// Connection status
|
|
517
|
+
onConnect(callback: () => void): void
|
|
518
|
+
onDisconnect(callback: (reason: string) => void): void
|
|
519
|
+
onError(callback: (error: Error) => void): void
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// =============================================================================
|
|
523
|
+
// ERROR TYPES FOR GRAPHQL OPERATIONS
|
|
524
|
+
// =============================================================================
|
|
525
|
+
|
|
526
|
+
export type GraphQLErrorType =
|
|
527
|
+
| 'NETWORK_ERROR'
|
|
528
|
+
| 'TIMEOUT_ERROR'
|
|
529
|
+
| 'PARSE_ERROR'
|
|
530
|
+
| 'VALIDATION_ERROR'
|
|
531
|
+
| 'EXECUTION_ERROR'
|
|
532
|
+
| 'SUBSCRIPTION_ERROR'
|
|
533
|
+
| 'CONNECTION_ERROR'
|
|
534
|
+
| 'AUTHENTICATION_ERROR'
|
|
535
|
+
| 'AUTHORIZATION_ERROR'
|
|
536
|
+
| 'RATE_LIMIT_ERROR'
|
|
537
|
+
| 'SERVER_ERROR'
|
|
538
|
+
|
|
539
|
+
export interface KnishIOGraphQLError extends Error {
|
|
540
|
+
type: GraphQLErrorType
|
|
541
|
+
query?: string
|
|
542
|
+
variables?: GraphQLVariables
|
|
543
|
+
response?: GraphQLResponse
|
|
544
|
+
statusCode?: number
|
|
545
|
+
details?: Record<string, unknown>
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// =============================================================================
|
|
549
|
+
// OPERATION BUILDER TYPES
|
|
550
|
+
// =============================================================================
|
|
551
|
+
|
|
552
|
+
export interface QueryBuilder<TVariables = GraphQLVariables> {
|
|
553
|
+
setVariable<K extends keyof TVariables>(key: K, value: TVariables[K]): this
|
|
554
|
+
setVariables(variables: Partial<TVariables>): this
|
|
555
|
+
build(): GraphQLRequest
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface MutationBuilder<TVariables = GraphQLVariables> extends QueryBuilder<TVariables> {
|
|
559
|
+
withMolecule(molecule: MutationProposeMoleculeVariables['molecule']): this
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// =============================================================================
|
|
563
|
+
// CACHING TYPES
|
|
564
|
+
// =============================================================================
|
|
565
|
+
|
|
566
|
+
export interface CacheOptions {
|
|
567
|
+
ttl?: number // Time to live in seconds
|
|
568
|
+
key?: string // Custom cache key
|
|
569
|
+
tags?: string[] // Cache tags for invalidation
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export interface CachedQuery<T = unknown> {
|
|
573
|
+
data: T
|
|
574
|
+
timestamp: number
|
|
575
|
+
ttl: number
|
|
576
|
+
key: string
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export interface GraphQLCache {
|
|
580
|
+
get<T = unknown>(key: string): CachedQuery<T> | null
|
|
581
|
+
set<T = unknown>(key: string, data: T, options?: CacheOptions): void
|
|
582
|
+
invalidate(key: string): void
|
|
583
|
+
invalidateByTag(tag: string): void
|
|
584
|
+
clear(): void
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// =============================================================================
|
|
588
|
+
// BATCH OPERATIONS TYPES
|
|
589
|
+
// =============================================================================
|
|
590
|
+
|
|
591
|
+
export interface BatchedQuery {
|
|
592
|
+
id: string
|
|
593
|
+
query: string
|
|
594
|
+
variables?: GraphQLVariables
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export interface BatchedResponse<T = unknown> {
|
|
598
|
+
id: string
|
|
599
|
+
data?: T | null
|
|
600
|
+
errors?: GraphQLError[] | null
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface BatchExecutor {
|
|
604
|
+
add<T = unknown>(query: BatchedQuery): Promise<T>
|
|
605
|
+
execute(): Promise<BatchedResponse[]>
|
|
606
|
+
clear(): void
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// =============================================================================
|
|
610
|
+
// TYPE GUARDS FOR GRAPHQL TYPES
|
|
611
|
+
// =============================================================================
|
|
612
|
+
|
|
613
|
+
export function isGraphQLError(obj: unknown): obj is GraphQLError {
|
|
614
|
+
return typeof obj === 'object' &&
|
|
615
|
+
obj !== null &&
|
|
616
|
+
'message' in obj &&
|
|
617
|
+
typeof (obj as GraphQLError).message === 'string'
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export function isGraphQLResponse<T = unknown>(obj: unknown): obj is GraphQLResponse<T> {
|
|
621
|
+
return typeof obj === 'object' &&
|
|
622
|
+
obj !== null &&
|
|
623
|
+
('data' in obj || 'errors' in obj)
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export function hasGraphQLErrors(response: GraphQLResponse): boolean {
|
|
627
|
+
return Array.isArray(response.errors) && response.errors.length > 0
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// All types are already exported at their definitions above
|