@wishknish/knishio-client-ts 0.7.1 → 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.
- package/dist/index.cjs +83 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -38
- package/dist/index.d.ts +43 -38
- package/dist/index.iife.js +83 -81
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +84 -79
- package/dist/index.js.map +1 -1
- package/package.json +12 -7
- package/src/KnishIOClient.ts +64 -71
- package/src/index.ts +1 -10
- package/src/libraries/GraphQLClient.ts +17 -22
- package/src/query/Query.ts +6 -6
- package/src/query/QueryAtom.ts +27 -27
- package/src/query/QueryMetaType.ts +1 -1
- package/src/response/Response.ts +17 -1
- package/src/schemas/index.ts +12 -1
- package/src/types/client.ts +3 -2
- package/src/types/graphql.ts +3 -2
- package/src/types/index.ts +16 -1
package/dist/index.js
CHANGED
|
@@ -1587,6 +1587,13 @@ var init_Response = __esm({
|
|
|
1587
1587
|
}
|
|
1588
1588
|
throw new InvalidResponseException();
|
|
1589
1589
|
}
|
|
1590
|
+
if (this.$__response.errors && Array.isArray(this.$__response.errors) && this.$__response.errors.length > 0) {
|
|
1591
|
+
const errorMessage = this.$__response.errors[0].message || "Unknown GraphQL error";
|
|
1592
|
+
if (errorMessage.includes("Unauthenticated")) {
|
|
1593
|
+
throw new UnauthenticatedException("Unauthenticated request");
|
|
1594
|
+
}
|
|
1595
|
+
throw new InvalidResponseException(`GraphQL Error: ${errorMessage}`);
|
|
1596
|
+
}
|
|
1590
1597
|
this.init();
|
|
1591
1598
|
}
|
|
1592
1599
|
/**
|
|
@@ -1601,8 +1608,11 @@ var init_Response = __esm({
|
|
|
1601
1608
|
if (!this.dataKey) {
|
|
1602
1609
|
return this.response();
|
|
1603
1610
|
}
|
|
1611
|
+
if (!this.response().data) {
|
|
1612
|
+
throw new InvalidResponseException("Response has no data field");
|
|
1613
|
+
}
|
|
1604
1614
|
if (!Dot.has(this.response(), this.dataKey)) {
|
|
1605
|
-
throw new InvalidResponseException();
|
|
1615
|
+
throw new InvalidResponseException(`Missing expected field: ${this.dataKey}`);
|
|
1606
1616
|
}
|
|
1607
1617
|
return Dot.get(this.response(), this.dataKey);
|
|
1608
1618
|
}
|
|
@@ -4716,24 +4726,24 @@ var GraphQLClient = class {
|
|
|
4716
4726
|
encrypt: this.cipherLink
|
|
4717
4727
|
});
|
|
4718
4728
|
}
|
|
4719
|
-
async query(request
|
|
4720
|
-
const
|
|
4721
|
-
const result = await this.$__client.query(
|
|
4729
|
+
async query(request) {
|
|
4730
|
+
const { query, variables } = request;
|
|
4731
|
+
const result = await this.$__client.query(query, variables || {}).toPromise();
|
|
4722
4732
|
return this.formatResponse(result);
|
|
4723
4733
|
}
|
|
4724
|
-
async mutation(request
|
|
4725
|
-
const
|
|
4726
|
-
const mutationString = request.mutation ||
|
|
4727
|
-
const result = await this.$__client.mutation(mutationString,
|
|
4734
|
+
async mutation(request) {
|
|
4735
|
+
const { query, variables } = request;
|
|
4736
|
+
const mutationString = request.mutation || query;
|
|
4737
|
+
const result = await this.$__client.mutation(mutationString, variables || {}).toPromise();
|
|
4728
4738
|
return this.formatResponse(result);
|
|
4729
4739
|
}
|
|
4730
4740
|
// Alias for mutation() to match JS SDK interface
|
|
4731
|
-
async mutate(request
|
|
4732
|
-
return this.mutation(request
|
|
4741
|
+
async mutate(request) {
|
|
4742
|
+
return this.mutation(request);
|
|
4733
4743
|
}
|
|
4734
|
-
async *subscription(request
|
|
4735
|
-
const
|
|
4736
|
-
const subscription = this.$__client.subscription(
|
|
4744
|
+
async *subscription(request) {
|
|
4745
|
+
const { query, variables } = request;
|
|
4746
|
+
const subscription = this.$__client.subscription(query, variables || {});
|
|
4737
4747
|
const results = [];
|
|
4738
4748
|
const { unsubscribe } = pipe(
|
|
4739
4749
|
subscription,
|
|
@@ -4911,7 +4921,7 @@ var Query = class {
|
|
|
4911
4921
|
* Executes the Query and returns a Response
|
|
4912
4922
|
*/
|
|
4913
4923
|
async execute({
|
|
4914
|
-
variables =
|
|
4924
|
+
variables = null,
|
|
4915
4925
|
context = {}
|
|
4916
4926
|
} = {}) {
|
|
4917
4927
|
this.$__request = this.createQuery({ variables });
|
|
@@ -8865,51 +8875,44 @@ var KnishIOClient = class {
|
|
|
8865
8875
|
queryArgs = null,
|
|
8866
8876
|
count = null,
|
|
8867
8877
|
countBy = null,
|
|
8868
|
-
throughAtom =
|
|
8878
|
+
throughAtom = true,
|
|
8869
8879
|
values = null,
|
|
8870
8880
|
keys = null,
|
|
8871
8881
|
atomValues = null
|
|
8872
8882
|
}) {
|
|
8873
8883
|
this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${metaType}, metaId: ${metaId}...`);
|
|
8874
8884
|
let query;
|
|
8875
|
-
|
|
8885
|
+
let variables;
|
|
8886
|
+
if (throughAtom) {
|
|
8876
8887
|
query = this.createQuery(QueryMetaTypeViaAtom);
|
|
8888
|
+
variables = QueryMetaTypeViaAtom.createVariables({
|
|
8889
|
+
metaType,
|
|
8890
|
+
metaId,
|
|
8891
|
+
key,
|
|
8892
|
+
value,
|
|
8893
|
+
latest,
|
|
8894
|
+
filter,
|
|
8895
|
+
queryArgs,
|
|
8896
|
+
countBy,
|
|
8897
|
+
values,
|
|
8898
|
+
keys,
|
|
8899
|
+
atomValues,
|
|
8900
|
+
cellSlug: this.getCellSlug()
|
|
8901
|
+
});
|
|
8877
8902
|
} else {
|
|
8878
8903
|
query = this.createQuery(QueryMetaType);
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
variables.key = key;
|
|
8892
|
-
}
|
|
8893
|
-
if (value !== null) {
|
|
8894
|
-
variables.value = value;
|
|
8895
|
-
}
|
|
8896
|
-
if (queryArgs !== null) {
|
|
8897
|
-
variables.queryArgs = queryArgs;
|
|
8898
|
-
}
|
|
8899
|
-
if (count !== null) {
|
|
8900
|
-
variables.count = count;
|
|
8901
|
-
}
|
|
8902
|
-
if (countBy !== null) {
|
|
8903
|
-
variables.countBy = countBy;
|
|
8904
|
-
}
|
|
8905
|
-
if (values !== null) {
|
|
8906
|
-
variables.values = values;
|
|
8907
|
-
}
|
|
8908
|
-
if (keys !== null) {
|
|
8909
|
-
variables.keys = keys;
|
|
8910
|
-
}
|
|
8911
|
-
if (atomValues !== null) {
|
|
8912
|
-
variables.atomValues = atomValues;
|
|
8904
|
+
variables = QueryMetaType.createVariables({
|
|
8905
|
+
metaType,
|
|
8906
|
+
metaId,
|
|
8907
|
+
key,
|
|
8908
|
+
value,
|
|
8909
|
+
latest,
|
|
8910
|
+
filter,
|
|
8911
|
+
queryArgs,
|
|
8912
|
+
count,
|
|
8913
|
+
countBy,
|
|
8914
|
+
cellSlug: this.getCellSlug()
|
|
8915
|
+
});
|
|
8913
8916
|
}
|
|
8914
8917
|
return this.executeQuery(query, variables);
|
|
8915
8918
|
}
|
|
@@ -8969,35 +8972,37 @@ var KnishIOClient = class {
|
|
|
8969
8972
|
latest = null,
|
|
8970
8973
|
queryArgs = null
|
|
8971
8974
|
} = {}) {
|
|
8975
|
+
this.log("info", "KnishIOClient::queryAtom() - Querying atom instances");
|
|
8972
8976
|
const query = this.createQuery(QueryAtom);
|
|
8973
|
-
const variables = {
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
8977
|
+
const variables = QueryAtom.createVariables({
|
|
8978
|
+
molecularHashes,
|
|
8979
|
+
molecularHash,
|
|
8980
|
+
bundleHashes,
|
|
8981
|
+
bundleHash,
|
|
8982
|
+
positions,
|
|
8983
|
+
position,
|
|
8984
|
+
walletAddresses,
|
|
8985
|
+
walletAddress,
|
|
8986
|
+
isotopes,
|
|
8987
|
+
isotope,
|
|
8988
|
+
tokenSlugs,
|
|
8989
|
+
tokenSlug,
|
|
8990
|
+
cellSlugs,
|
|
8991
|
+
cellSlug,
|
|
8992
|
+
batchIds,
|
|
8993
|
+
batchId,
|
|
8994
|
+
values,
|
|
8995
|
+
value,
|
|
8996
|
+
metaTypes,
|
|
8997
|
+
metaType,
|
|
8998
|
+
metaIds,
|
|
8999
|
+
metaId,
|
|
9000
|
+
indexes,
|
|
9001
|
+
index,
|
|
9002
|
+
filter,
|
|
9003
|
+
latest,
|
|
9004
|
+
queryArgs
|
|
9005
|
+
});
|
|
9001
9006
|
return this.executeQuery(query, variables);
|
|
9002
9007
|
}
|
|
9003
9008
|
/**
|
|
@@ -9889,6 +9894,6 @@ var KnishIO = {
|
|
|
9889
9894
|
SDK_INFO
|
|
9890
9895
|
};
|
|
9891
9896
|
|
|
9892
|
-
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseMetaType, ResponseMetaTypeViaAtom, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning,
|
|
9897
|
+
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseMetaType, ResponseMetaTypeViaAtom, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition2 as isPosition, isWalletAddress2 as isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
|
|
9893
9898
|
//# sourceMappingURL=index.js.map
|
|
9894
9899
|
//# sourceMappingURL=index.js.map
|