@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.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var zod = require('zod');
|
|
6
4
|
var JsSHA = require('jssha');
|
|
7
5
|
var mlKem_js = require('@noble/post-quantum/ml-kem.js');
|
|
@@ -1595,6 +1593,13 @@ var init_Response = __esm({
|
|
|
1595
1593
|
}
|
|
1596
1594
|
throw new exports.InvalidResponseException();
|
|
1597
1595
|
}
|
|
1596
|
+
if (this.$__response.errors && Array.isArray(this.$__response.errors) && this.$__response.errors.length > 0) {
|
|
1597
|
+
const errorMessage = this.$__response.errors[0].message || "Unknown GraphQL error";
|
|
1598
|
+
if (errorMessage.includes("Unauthenticated")) {
|
|
1599
|
+
throw new UnauthenticatedException("Unauthenticated request");
|
|
1600
|
+
}
|
|
1601
|
+
throw new exports.InvalidResponseException(`GraphQL Error: ${errorMessage}`);
|
|
1602
|
+
}
|
|
1598
1603
|
this.init();
|
|
1599
1604
|
}
|
|
1600
1605
|
/**
|
|
@@ -1609,8 +1614,11 @@ var init_Response = __esm({
|
|
|
1609
1614
|
if (!this.dataKey) {
|
|
1610
1615
|
return this.response();
|
|
1611
1616
|
}
|
|
1617
|
+
if (!this.response().data) {
|
|
1618
|
+
throw new exports.InvalidResponseException("Response has no data field");
|
|
1619
|
+
}
|
|
1612
1620
|
if (!exports.Dot.has(this.response(), this.dataKey)) {
|
|
1613
|
-
throw new exports.InvalidResponseException();
|
|
1621
|
+
throw new exports.InvalidResponseException(`Missing expected field: ${this.dataKey}`);
|
|
1614
1622
|
}
|
|
1615
1623
|
return exports.Dot.get(this.response(), this.dataKey);
|
|
1616
1624
|
}
|
|
@@ -4724,24 +4732,24 @@ var GraphQLClient = class {
|
|
|
4724
4732
|
encrypt: this.cipherLink
|
|
4725
4733
|
});
|
|
4726
4734
|
}
|
|
4727
|
-
async query(request
|
|
4728
|
-
const
|
|
4729
|
-
const result = await this.$__client.query(
|
|
4735
|
+
async query(request) {
|
|
4736
|
+
const { query, variables } = request;
|
|
4737
|
+
const result = await this.$__client.query(query, variables || {}).toPromise();
|
|
4730
4738
|
return this.formatResponse(result);
|
|
4731
4739
|
}
|
|
4732
|
-
async mutation(request
|
|
4733
|
-
const
|
|
4734
|
-
const mutationString = request.mutation ||
|
|
4735
|
-
const result = await this.$__client.mutation(mutationString,
|
|
4740
|
+
async mutation(request) {
|
|
4741
|
+
const { query, variables } = request;
|
|
4742
|
+
const mutationString = request.mutation || query;
|
|
4743
|
+
const result = await this.$__client.mutation(mutationString, variables || {}).toPromise();
|
|
4736
4744
|
return this.formatResponse(result);
|
|
4737
4745
|
}
|
|
4738
4746
|
// Alias for mutation() to match JS SDK interface
|
|
4739
|
-
async mutate(request
|
|
4740
|
-
return this.mutation(request
|
|
4747
|
+
async mutate(request) {
|
|
4748
|
+
return this.mutation(request);
|
|
4741
4749
|
}
|
|
4742
|
-
async *subscription(request
|
|
4743
|
-
const
|
|
4744
|
-
const subscription = this.$__client.subscription(
|
|
4750
|
+
async *subscription(request) {
|
|
4751
|
+
const { query, variables } = request;
|
|
4752
|
+
const subscription = this.$__client.subscription(query, variables || {});
|
|
4745
4753
|
const results = [];
|
|
4746
4754
|
const { unsubscribe } = wonka.pipe(
|
|
4747
4755
|
subscription,
|
|
@@ -4919,7 +4927,7 @@ var Query = class {
|
|
|
4919
4927
|
* Executes the Query and returns a Response
|
|
4920
4928
|
*/
|
|
4921
4929
|
async execute({
|
|
4922
|
-
variables =
|
|
4930
|
+
variables = null,
|
|
4923
4931
|
context = {}
|
|
4924
4932
|
} = {}) {
|
|
4925
4933
|
this.$__request = this.createQuery({ variables });
|
|
@@ -8873,51 +8881,44 @@ var KnishIOClient = class {
|
|
|
8873
8881
|
queryArgs = null,
|
|
8874
8882
|
count = null,
|
|
8875
8883
|
countBy = null,
|
|
8876
|
-
throughAtom =
|
|
8884
|
+
throughAtom = true,
|
|
8877
8885
|
values = null,
|
|
8878
8886
|
keys = null,
|
|
8879
8887
|
atomValues = null
|
|
8880
8888
|
}) {
|
|
8881
8889
|
this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${metaType}, metaId: ${metaId}...`);
|
|
8882
8890
|
let query;
|
|
8883
|
-
|
|
8891
|
+
let variables;
|
|
8892
|
+
if (throughAtom) {
|
|
8884
8893
|
query = this.createQuery(QueryMetaTypeViaAtom);
|
|
8894
|
+
variables = QueryMetaTypeViaAtom.createVariables({
|
|
8895
|
+
metaType,
|
|
8896
|
+
metaId,
|
|
8897
|
+
key,
|
|
8898
|
+
value,
|
|
8899
|
+
latest,
|
|
8900
|
+
filter,
|
|
8901
|
+
queryArgs,
|
|
8902
|
+
countBy,
|
|
8903
|
+
values,
|
|
8904
|
+
keys,
|
|
8905
|
+
atomValues,
|
|
8906
|
+
cellSlug: this.getCellSlug()
|
|
8907
|
+
});
|
|
8885
8908
|
} else {
|
|
8886
8909
|
query = this.createQuery(QueryMetaType);
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
variables.key = key;
|
|
8900
|
-
}
|
|
8901
|
-
if (value !== null) {
|
|
8902
|
-
variables.value = value;
|
|
8903
|
-
}
|
|
8904
|
-
if (queryArgs !== null) {
|
|
8905
|
-
variables.queryArgs = queryArgs;
|
|
8906
|
-
}
|
|
8907
|
-
if (count !== null) {
|
|
8908
|
-
variables.count = count;
|
|
8909
|
-
}
|
|
8910
|
-
if (countBy !== null) {
|
|
8911
|
-
variables.countBy = countBy;
|
|
8912
|
-
}
|
|
8913
|
-
if (values !== null) {
|
|
8914
|
-
variables.values = values;
|
|
8915
|
-
}
|
|
8916
|
-
if (keys !== null) {
|
|
8917
|
-
variables.keys = keys;
|
|
8918
|
-
}
|
|
8919
|
-
if (atomValues !== null) {
|
|
8920
|
-
variables.atomValues = atomValues;
|
|
8910
|
+
variables = QueryMetaType.createVariables({
|
|
8911
|
+
metaType,
|
|
8912
|
+
metaId,
|
|
8913
|
+
key,
|
|
8914
|
+
value,
|
|
8915
|
+
latest,
|
|
8916
|
+
filter,
|
|
8917
|
+
queryArgs,
|
|
8918
|
+
count,
|
|
8919
|
+
countBy,
|
|
8920
|
+
cellSlug: this.getCellSlug()
|
|
8921
|
+
});
|
|
8921
8922
|
}
|
|
8922
8923
|
return this.executeQuery(query, variables);
|
|
8923
8924
|
}
|
|
@@ -8977,35 +8978,37 @@ var KnishIOClient = class {
|
|
|
8977
8978
|
latest = null,
|
|
8978
8979
|
queryArgs = null
|
|
8979
8980
|
} = {}) {
|
|
8981
|
+
this.log("info", "KnishIOClient::queryAtom() - Querying atom instances");
|
|
8980
8982
|
const query = this.createQuery(QueryAtom);
|
|
8981
|
-
const variables = {
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
8983
|
+
const variables = QueryAtom.createVariables({
|
|
8984
|
+
molecularHashes,
|
|
8985
|
+
molecularHash,
|
|
8986
|
+
bundleHashes,
|
|
8987
|
+
bundleHash,
|
|
8988
|
+
positions,
|
|
8989
|
+
position,
|
|
8990
|
+
walletAddresses,
|
|
8991
|
+
walletAddress,
|
|
8992
|
+
isotopes,
|
|
8993
|
+
isotope,
|
|
8994
|
+
tokenSlugs,
|
|
8995
|
+
tokenSlug,
|
|
8996
|
+
cellSlugs,
|
|
8997
|
+
cellSlug,
|
|
8998
|
+
batchIds,
|
|
8999
|
+
batchId,
|
|
9000
|
+
values,
|
|
9001
|
+
value,
|
|
9002
|
+
metaTypes,
|
|
9003
|
+
metaType,
|
|
9004
|
+
metaIds,
|
|
9005
|
+
metaId,
|
|
9006
|
+
indexes,
|
|
9007
|
+
index,
|
|
9008
|
+
filter,
|
|
9009
|
+
latest,
|
|
9010
|
+
queryArgs
|
|
9011
|
+
});
|
|
9009
9012
|
return this.executeQuery(query, variables);
|
|
9010
9013
|
}
|
|
9011
9014
|
/**
|
|
@@ -9961,7 +9964,6 @@ exports.createPosition = createPosition;
|
|
|
9961
9964
|
exports.createTokenSlug = createTokenSlug;
|
|
9962
9965
|
exports.createWalletAddress = createWalletAddress;
|
|
9963
9966
|
exports.deepCloning = deepCloning;
|
|
9964
|
-
exports.default = shake256;
|
|
9965
9967
|
exports.diff = diff;
|
|
9966
9968
|
exports.enumerateMolecularHash = enumerateMolecularHash;
|
|
9967
9969
|
exports.generateBatchId = generateBatchId;
|