@wishknish/knishio-client-ts 0.9.3 → 0.9.5
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 +194 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.iife.js +20557 -4963
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +194 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +4 -1
- package/src/instance/rules/Callback.ts +1 -1
- package/src/libraries/CheckMolecule.ts +194 -4
- package/src/schemas/index.ts +30 -15
- package/src/validation/ValidationService.ts +1 -3
- package/src/validation/schemas.ts +40 -16
package/dist/index.cjs
CHANGED
|
@@ -3839,6 +3839,14 @@ var Wallet = class _Wallet {
|
|
|
3839
3839
|
};
|
|
3840
3840
|
var hexStringRegex = /^[0-9a-fA-F]+$/;
|
|
3841
3841
|
var base17HashRegex = /^[0-9a-g]+$/;
|
|
3842
|
+
var urlString = (message = "Invalid URL") => zod.z.string().refine((value) => {
|
|
3843
|
+
try {
|
|
3844
|
+
new URL(value);
|
|
3845
|
+
return true;
|
|
3846
|
+
} catch {
|
|
3847
|
+
return false;
|
|
3848
|
+
}
|
|
3849
|
+
}, message);
|
|
3842
3850
|
zod.z.string().regex(hexStringRegex, "Must be a valid hexadecimal string").brand();
|
|
3843
3851
|
var WalletAddressSchema = zod.z.string().regex(hexStringRegex, "Wallet address must be hexadecimal").length(64, "Wallet address must be exactly 64 characters").brand();
|
|
3844
3852
|
var BundleHashSchema = zod.z.string().regex(hexStringRegex, "Bundle hash must be hexadecimal").length(64, "Bundle hash must be exactly 64 characters").brand();
|
|
@@ -3850,7 +3858,7 @@ var MetaIdSchema = zod.z.string().min(1, "Meta ID cannot be empty").brand();
|
|
|
3850
3858
|
var BatchIdSchema = zod.z.string().min(1, "Batch ID cannot be empty").brand();
|
|
3851
3859
|
var CellSlugSchema = zod.z.string().min(1, "Cell slug cannot be empty").max(64, "Cell slug cannot exceed 64 characters").brand();
|
|
3852
3860
|
var AtomIsotopeSchema = zod.z.enum(["C", "V", "U", "T", "M", "I", "R", "B", "F"], {
|
|
3853
|
-
|
|
3861
|
+
error: "Invalid atom isotope. Must be one of: C, V, U, T, M, I, R, B, F"
|
|
3854
3862
|
});
|
|
3855
3863
|
var MetaDataValueSchema = zod.z.union([
|
|
3856
3864
|
zod.z.string(),
|
|
@@ -3863,7 +3871,7 @@ var AtomMetaDataSchema = zod.z.object({
|
|
|
3863
3871
|
value: MetaDataValueSchema
|
|
3864
3872
|
}).strict();
|
|
3865
3873
|
var MetaDataSchema = zod.z.lazy(
|
|
3866
|
-
() => zod.z.record(zod.z.union([
|
|
3874
|
+
() => zod.z.record(zod.z.string(), zod.z.union([
|
|
3867
3875
|
MetaDataValueSchema,
|
|
3868
3876
|
MetaDataSchema,
|
|
3869
3877
|
zod.z.array(MetaDataSchema)
|
|
@@ -3902,7 +3910,7 @@ zod.z.object({
|
|
|
3902
3910
|
version: zod.z.number().int().min(1).optional()
|
|
3903
3911
|
}).strict();
|
|
3904
3912
|
zod.z.object({
|
|
3905
|
-
uri: zod.z.union([
|
|
3913
|
+
uri: zod.z.union([urlString(), zod.z.array(urlString())]).optional(),
|
|
3906
3914
|
cellSlug: zod.z.union([CellSlugSchema, zod.z.string(), zod.z.null()]).optional(),
|
|
3907
3915
|
client: zod.z.unknown().optional(),
|
|
3908
3916
|
socket: zod.z.unknown().optional(),
|
|
@@ -3919,7 +3927,7 @@ zod.z.object({
|
|
|
3919
3927
|
zod.z.object({
|
|
3920
3928
|
cellSlug: zod.z.union([CellSlugSchema, zod.z.string(), zod.z.null()]).optional(),
|
|
3921
3929
|
encrypt: zod.z.boolean().optional(),
|
|
3922
|
-
callback: zod.z.
|
|
3930
|
+
callback: zod.z.custom((value) => typeof value === "function").optional()
|
|
3923
3931
|
}).strict();
|
|
3924
3932
|
zod.z.object({
|
|
3925
3933
|
cellSlug: zod.z.union([CellSlugSchema, zod.z.string(), zod.z.null()]).optional()
|
|
@@ -3928,7 +3936,7 @@ zod.z.object({
|
|
|
3928
3936
|
recipient: zod.z.union([WalletAddressSchema, zod.z.string()]),
|
|
3929
3937
|
amount: zod.z.union([zod.z.number().positive(), zod.z.string().min(1)]),
|
|
3930
3938
|
token: zod.z.union([TokenSlugSchema, zod.z.string()]).optional(),
|
|
3931
|
-
callbackUrl: zod.z.union([
|
|
3939
|
+
callbackUrl: zod.z.union([urlString(), zod.z.null()]).optional(),
|
|
3932
3940
|
metaType: zod.z.union([MetaTypeSchema, zod.z.string(), zod.z.null()]).optional(),
|
|
3933
3941
|
metaId: zod.z.union([MetaIdSchema, zod.z.string(), zod.z.null()]).optional(),
|
|
3934
3942
|
meta: zod.z.union([MetaDataSchema, zod.z.null()]).optional()
|
|
@@ -3969,7 +3977,7 @@ zod.z.object({
|
|
|
3969
3977
|
value: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
3970
3978
|
latest: zod.z.union([zod.z.boolean(), zod.z.null()]).optional(),
|
|
3971
3979
|
filter: zod.z.union([zod.z.array(MetaFilterSchema), zod.z.null()]).optional(),
|
|
3972
|
-
queryArgs: zod.z.union([zod.z.record(zod.z.unknown()), zod.z.null()]).optional(),
|
|
3980
|
+
queryArgs: zod.z.union([zod.z.record(zod.z.string(), zod.z.unknown()), zod.z.null()]).optional(),
|
|
3973
3981
|
count: zod.z.union([zod.z.number().int().min(1), zod.z.null()]).optional(),
|
|
3974
3982
|
countBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
3975
3983
|
cellSlug: zod.z.union([CellSlugSchema, zod.z.string(), zod.z.null()]).optional()
|
|
@@ -3994,7 +4002,7 @@ zod.z.object({
|
|
|
3994
4002
|
}).strict();
|
|
3995
4003
|
zod.z.object({
|
|
3996
4004
|
query: zod.z.string().min(1, "GraphQL query cannot be empty"),
|
|
3997
|
-
variables: zod.z.record(zod.z.unknown()).optional(),
|
|
4005
|
+
variables: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3998
4006
|
operationName: zod.z.union([zod.z.string(), zod.z.null()]).optional()
|
|
3999
4007
|
}).strict();
|
|
4000
4008
|
var GraphQLErrorSchema = zod.z.object({
|
|
@@ -4004,18 +4012,18 @@ var GraphQLErrorSchema = zod.z.object({
|
|
|
4004
4012
|
column: zod.z.number().int().min(1)
|
|
4005
4013
|
})).optional(),
|
|
4006
4014
|
path: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional(),
|
|
4007
|
-
extensions: zod.z.record(zod.z.unknown()).optional()
|
|
4015
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
4008
4016
|
}).strict();
|
|
4009
4017
|
zod.z.object({
|
|
4010
4018
|
data: zod.z.unknown().optional(),
|
|
4011
4019
|
errors: zod.z.array(GraphQLErrorSchema).nullable().optional(),
|
|
4012
|
-
extensions: zod.z.record(zod.z.unknown()).optional()
|
|
4020
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
4013
4021
|
}).strict();
|
|
4014
4022
|
zod.z.object({
|
|
4015
4023
|
operationName: zod.z.string().optional(),
|
|
4016
4024
|
query: zod.z.string().optional(),
|
|
4017
|
-
variables: zod.z.record(zod.z.unknown()).optional(),
|
|
4018
|
-
callback: zod.z.
|
|
4025
|
+
variables: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
4026
|
+
callback: zod.z.custom((value) => typeof value === "function").optional()
|
|
4019
4027
|
}).strict();
|
|
4020
4028
|
zod.z.object({
|
|
4021
4029
|
valid: zod.z.boolean(),
|
|
@@ -4025,7 +4033,7 @@ zod.z.object({
|
|
|
4025
4033
|
}).strict();
|
|
4026
4034
|
zod.z.object({
|
|
4027
4035
|
operation: zod.z.string().optional(),
|
|
4028
|
-
parameters: zod.z.record(zod.z.unknown()).optional(),
|
|
4036
|
+
parameters: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
4029
4037
|
timestamp: zod.z.number().int().min(0).optional(),
|
|
4030
4038
|
stack: zod.z.string().optional()
|
|
4031
4039
|
}).strict();
|
|
@@ -4229,7 +4237,7 @@ var CallbackParamsSchema = zod.z.object({
|
|
|
4229
4237
|
action: zod.z.string().min(1, "Action cannot be empty"),
|
|
4230
4238
|
metaType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
4231
4239
|
metaId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
4232
|
-
meta: zod.z.union([zod.z.instanceof(Meta2), zod.z.record(zod.z.unknown()), zod.z.null()]).optional(),
|
|
4240
|
+
meta: zod.z.union([zod.z.instanceof(Meta2), zod.z.record(zod.z.string(), zod.z.unknown()), zod.z.null()]).optional(),
|
|
4233
4241
|
address: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
4234
4242
|
token: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
4235
4243
|
amount: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
|
|
@@ -4493,7 +4501,7 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4493
4501
|
* @return True if all validations pass
|
|
4494
4502
|
*/
|
|
4495
4503
|
verify(senderWallet) {
|
|
4496
|
-
return this.molecularHash() && this.ots() && this.batchId() && this.continuId() && this.isotopeM() && this.isotopeT() && this.isotopeC() && this.isotopeU() && this.isotopeI() && this.isotopeR() && this.isotopeV(senderWallet || null);
|
|
4504
|
+
return this.molecularHash() && this.ots() && this.batchId() && this.continuId() && this.isotopeM() && this.isotopeT() && this.isotopeC() && this.isotopeU() && this.isotopeI() && this.isotopeR() && this.isotopeP() && this.isotopeA() && this.isotopeB() && this.isotopeF() && this.isotopeV(senderWallet || null);
|
|
4497
4505
|
}
|
|
4498
4506
|
/**
|
|
4499
4507
|
* Validate ContinuID requirement
|
|
@@ -4681,6 +4689,141 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4681
4689
|
}
|
|
4682
4690
|
return true;
|
|
4683
4691
|
}
|
|
4692
|
+
/**
|
|
4693
|
+
* Validate isotope P atoms (peering)
|
|
4694
|
+
* @return True if valid
|
|
4695
|
+
* @throws WrongTokenTypeException if the token slug is not USER
|
|
4696
|
+
* @throws MetaMissingException if the required peerHost meta field is absent
|
|
4697
|
+
*/
|
|
4698
|
+
isotopeP() {
|
|
4699
|
+
for (const atom of this.molecule.getIsotopes("P")) {
|
|
4700
|
+
if (atom.token !== "USER") {
|
|
4701
|
+
throw new WrongTokenTypeException(`Check::isotopeP() - "${atom.token}" is not a valid Token slug for "${atom.isotope}" isotope Atoms!`);
|
|
4702
|
+
}
|
|
4703
|
+
const metas = atom.aggregatedMeta();
|
|
4704
|
+
if (!Object.prototype.hasOwnProperty.call(metas, "peerHost") || !metas.peerHost) {
|
|
4705
|
+
throw new MetaMissingException('Check::isotopeP() - Required meta field "peerHost" is missing!');
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
return true;
|
|
4709
|
+
}
|
|
4710
|
+
/**
|
|
4711
|
+
* Validate isotope A atoms (append request)
|
|
4712
|
+
* @return True if valid
|
|
4713
|
+
* @throws WrongTokenTypeException if the token slug is not USER
|
|
4714
|
+
* @throws MetaMissingException if metaType, metaId or the action meta field is absent
|
|
4715
|
+
*/
|
|
4716
|
+
isotopeA() {
|
|
4717
|
+
for (const atom of this.molecule.getIsotopes("A")) {
|
|
4718
|
+
if (atom.token !== "USER") {
|
|
4719
|
+
throw new WrongTokenTypeException(`Check::isotopeA() - "${atom.token}" is not a valid Token slug for "${atom.isotope}" isotope Atoms!`);
|
|
4720
|
+
}
|
|
4721
|
+
if (!atom.metaType) {
|
|
4722
|
+
throw new MetaMissingException('Check::isotopeA() - Required field "metaType" is missing!');
|
|
4723
|
+
}
|
|
4724
|
+
if (!atom.metaId) {
|
|
4725
|
+
throw new MetaMissingException('Check::isotopeA() - Required field "metaId" is missing!');
|
|
4726
|
+
}
|
|
4727
|
+
const metas = atom.aggregatedMeta();
|
|
4728
|
+
if (!Object.prototype.hasOwnProperty.call(metas, "action") || !metas.action) {
|
|
4729
|
+
throw new MetaMissingException('Check::isotopeA() - Required meta field "action" is missing!');
|
|
4730
|
+
}
|
|
4731
|
+
}
|
|
4732
|
+
return true;
|
|
4733
|
+
}
|
|
4734
|
+
/**
|
|
4735
|
+
* Validate isotope B atoms (buffer/exchange)
|
|
4736
|
+
*
|
|
4737
|
+
* Buffer molecules are cross-isotope: their V atoms do not balance on their own
|
|
4738
|
+
* because a B atom absorbs the difference. isotopeV() therefore skips its V-only
|
|
4739
|
+
* conservation checks whenever B (or F) atoms are present, and conservation is
|
|
4740
|
+
* enforced here instead over the combined V+B set.
|
|
4741
|
+
*
|
|
4742
|
+
* @return True if valid
|
|
4743
|
+
* @throws MetaMissingException if metaType is not walletBundle, or metaId is absent
|
|
4744
|
+
* @throws TransferMalformedException if a B atom value is not a number
|
|
4745
|
+
* @throws TransferUnbalancedException if V+B atom values do not sum to zero
|
|
4746
|
+
*/
|
|
4747
|
+
isotopeB() {
|
|
4748
|
+
const isotopeB = this.molecule.getIsotopes("B");
|
|
4749
|
+
if (isotopeB.length === 0) {
|
|
4750
|
+
return true;
|
|
4751
|
+
}
|
|
4752
|
+
for (const atom of isotopeB) {
|
|
4753
|
+
if (!atom.metaType || atom.metaType !== "walletBundle") {
|
|
4754
|
+
throw new MetaMissingException('Check::isotopeB() - B-isotope atoms must have metaType "walletBundle"!');
|
|
4755
|
+
}
|
|
4756
|
+
if (!atom.metaId) {
|
|
4757
|
+
throw new MetaMissingException("Check::isotopeB() - B-isotope atoms must have a metaId!");
|
|
4758
|
+
}
|
|
4759
|
+
const value = atom.value !== null ? Number(atom.value) : Number.NaN;
|
|
4760
|
+
if (Number.isNaN(value)) {
|
|
4761
|
+
throw new TransferMalformedException("Check::isotopeB() - B-isotope atom value is not a valid number!");
|
|
4762
|
+
}
|
|
4763
|
+
}
|
|
4764
|
+
const vAtoms = this.molecule.getIsotopes("V");
|
|
4765
|
+
if (vAtoms.length > 0) {
|
|
4766
|
+
let sum = 0;
|
|
4767
|
+
for (const atom of [...vAtoms, ...isotopeB]) {
|
|
4768
|
+
const value = atom.value !== null ? Number(atom.value) : Number.NaN;
|
|
4769
|
+
if (!Number.isNaN(value)) {
|
|
4770
|
+
sum += value;
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
if (sum !== 0) {
|
|
4774
|
+
throw new TransferUnbalancedException("Check::isotopeB() - V+B atom values do not balance to zero!");
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
return true;
|
|
4778
|
+
}
|
|
4779
|
+
/**
|
|
4780
|
+
* Validate isotope F atoms (fusion/NFT)
|
|
4781
|
+
*
|
|
4782
|
+
* Mirrors isotopeB() and additionally forbids negative values. Must stay paired
|
|
4783
|
+
* with the hasCrossIsotope gate in isotopeV(), which is keyed on B *or* F: without
|
|
4784
|
+
* this check an F-isotope molecule would skip V-only conservation with nothing
|
|
4785
|
+
* validating V+F conservation in its place.
|
|
4786
|
+
*
|
|
4787
|
+
* @return True if valid
|
|
4788
|
+
* @throws MetaMissingException if metaType is not walletBundle, or metaId is absent
|
|
4789
|
+
* @throws TransferMalformedException if an F atom value is not a number, or is negative
|
|
4790
|
+
* @throws TransferUnbalancedException if V+F atom values do not sum to zero
|
|
4791
|
+
*/
|
|
4792
|
+
isotopeF() {
|
|
4793
|
+
const isotopeF = this.molecule.getIsotopes("F");
|
|
4794
|
+
if (isotopeF.length === 0) {
|
|
4795
|
+
return true;
|
|
4796
|
+
}
|
|
4797
|
+
for (const atom of isotopeF) {
|
|
4798
|
+
if (!atom.metaType || atom.metaType !== "walletBundle") {
|
|
4799
|
+
throw new MetaMissingException('Check::isotopeF() - F-isotope atoms must have metaType "walletBundle"!');
|
|
4800
|
+
}
|
|
4801
|
+
if (!atom.metaId) {
|
|
4802
|
+
throw new MetaMissingException("Check::isotopeF() - F-isotope atoms must have a metaId!");
|
|
4803
|
+
}
|
|
4804
|
+
const value = atom.value !== null ? Number(atom.value) : Number.NaN;
|
|
4805
|
+
if (Number.isNaN(value)) {
|
|
4806
|
+
throw new TransferMalformedException("Check::isotopeF() - F-isotope atom value is not a valid number!");
|
|
4807
|
+
}
|
|
4808
|
+
if (value < 0) {
|
|
4809
|
+
throw new TransferMalformedException("Check::isotopeF() - F-isotope atom value must not be negative!");
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4812
|
+
const vAtoms = this.molecule.getIsotopes("V");
|
|
4813
|
+
if (vAtoms.length > 0) {
|
|
4814
|
+
let sum = 0;
|
|
4815
|
+
for (const atom of [...vAtoms, ...isotopeF]) {
|
|
4816
|
+
const value = atom.value !== null ? Number(atom.value) : Number.NaN;
|
|
4817
|
+
if (!Number.isNaN(value)) {
|
|
4818
|
+
sum += value;
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4821
|
+
if (sum !== 0) {
|
|
4822
|
+
throw new TransferUnbalancedException("Check::isotopeF() - V+F atom values do not balance to zero!");
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
return true;
|
|
4826
|
+
}
|
|
4684
4827
|
/**
|
|
4685
4828
|
* Validate isotope V atoms (value transfers)
|
|
4686
4829
|
* @param senderWallet - Optional wallet for balance validation
|
|
@@ -4692,11 +4835,12 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4692
4835
|
if (isotopeV.length === 0) {
|
|
4693
4836
|
return true;
|
|
4694
4837
|
}
|
|
4838
|
+
const hasCrossIsotope = this.molecule.getIsotopes("B").length > 0 || this.molecule.getIsotopes("F").length > 0;
|
|
4695
4839
|
const firstAtom = this.molecule.atoms[0];
|
|
4696
4840
|
if (!firstAtom) {
|
|
4697
4841
|
throw new exports.AtomsMissingException("Check::isotopeV() - Missing first atom");
|
|
4698
4842
|
}
|
|
4699
|
-
if (firstAtom.isotope === "V" && isotopeV.length === 2) {
|
|
4843
|
+
if (!hasCrossIsotope && firstAtom.isotope === "V" && isotopeV.length === 2) {
|
|
4700
4844
|
const endAtom = isotopeV[isotopeV.length - 1];
|
|
4701
4845
|
if (!endAtom) {
|
|
4702
4846
|
throw new exports.AtomsMissingException("Check::isotopeV() - Missing end atom");
|
|
@@ -4708,6 +4852,10 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4708
4852
|
if (endValue < 0) {
|
|
4709
4853
|
throw new TransferMalformedException();
|
|
4710
4854
|
}
|
|
4855
|
+
const firstValueForPair = firstAtom.value !== null ? Number(firstAtom.value) : 0;
|
|
4856
|
+
if (firstValueForPair + endValue !== 0) {
|
|
4857
|
+
throw new TransferUnbalancedException();
|
|
4858
|
+
}
|
|
4711
4859
|
return true;
|
|
4712
4860
|
}
|
|
4713
4861
|
let sum = 0;
|
|
@@ -4736,7 +4884,7 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4736
4884
|
sum += value;
|
|
4737
4885
|
}
|
|
4738
4886
|
}
|
|
4739
|
-
if (sum !== 0) {
|
|
4887
|
+
if (!hasCrossIsotope && sum !== 0) {
|
|
4740
4888
|
throw new TransferUnbalancedException();
|
|
4741
4889
|
}
|
|
4742
4890
|
if (senderWallet) {
|
|
@@ -4748,7 +4896,7 @@ var CheckMolecule = class _CheckMolecule {
|
|
|
4748
4896
|
if (remainder < 0) {
|
|
4749
4897
|
throw new exports.TransferBalanceException();
|
|
4750
4898
|
}
|
|
4751
|
-
if (remainder !== sum) {
|
|
4899
|
+
if (!hasCrossIsotope && remainder !== sum) {
|
|
4752
4900
|
throw new TransferRemainderException();
|
|
4753
4901
|
}
|
|
4754
4902
|
} else if (sum !== 0) {
|
|
@@ -6436,6 +6584,14 @@ var Mutation = class extends Query {
|
|
|
6436
6584
|
}
|
|
6437
6585
|
}
|
|
6438
6586
|
};
|
|
6587
|
+
var urlString2 = (message = "Invalid URL") => zod.z.string().refine((value) => {
|
|
6588
|
+
try {
|
|
6589
|
+
new URL(value);
|
|
6590
|
+
return true;
|
|
6591
|
+
} catch {
|
|
6592
|
+
return false;
|
|
6593
|
+
}
|
|
6594
|
+
}, message);
|
|
6439
6595
|
function createBrandedSchema(name, baseSchema = zod.z.string()) {
|
|
6440
6596
|
return baseSchema.brand(name);
|
|
6441
6597
|
}
|
|
@@ -6461,7 +6617,12 @@ var TokenSlugSchema2 = createBrandedSchema(
|
|
|
6461
6617
|
);
|
|
6462
6618
|
var BatchIdSchema2 = createBrandedSchema(
|
|
6463
6619
|
"BatchId",
|
|
6464
|
-
|
|
6620
|
+
// v3's `.uuid()` regex, inlined verbatim. Zod 4's `z.uuid()` additionally enforces the
|
|
6621
|
+
// RFC 9562 version/variant nibbles and would reject batch IDs v3 accepted.
|
|
6622
|
+
zod.z.string().regex(
|
|
6623
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
6624
|
+
"Invalid batch ID format"
|
|
6625
|
+
)
|
|
6465
6626
|
);
|
|
6466
6627
|
var CellSlugSchema2 = createBrandedSchema(
|
|
6467
6628
|
"CellSlug",
|
|
@@ -6505,7 +6666,7 @@ var AtomMetaDataSchema2 = zod.z.object({
|
|
|
6505
6666
|
zod.z.object({
|
|
6506
6667
|
key: zod.z.string(),
|
|
6507
6668
|
value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean(), zod.z.null()])
|
|
6508
|
-
}).
|
|
6669
|
+
}).loose();
|
|
6509
6670
|
var AtomParamsSchema2 = zod.z.object({
|
|
6510
6671
|
position: zod.z.string().optional(),
|
|
6511
6672
|
walletAddress: zod.z.union([WalletAddressSchema2, zod.z.string()]).optional(),
|
|
@@ -6540,8 +6701,8 @@ var MoleculeParamsSchema2 = zod.z.object({
|
|
|
6540
6701
|
}).strict();
|
|
6541
6702
|
var KnishIOClientConfigSchema2 = zod.z.object({
|
|
6542
6703
|
uri: zod.z.union([
|
|
6543
|
-
|
|
6544
|
-
zod.z.array(
|
|
6704
|
+
urlString2("Invalid URI format"),
|
|
6705
|
+
zod.z.array(urlString2("Invalid URI format")).min(1)
|
|
6545
6706
|
]).optional(),
|
|
6546
6707
|
cellSlug: zod.z.union([CellSlugSchema2, zod.z.string()]).optional(),
|
|
6547
6708
|
client: zod.z.unknown().optional(),
|
|
@@ -6554,11 +6715,11 @@ var KnishIOClientConfigSchema2 = zod.z.object({
|
|
|
6554
6715
|
defaultRequestPolicy: zod.z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
6555
6716
|
}).strict();
|
|
6556
6717
|
var EnvironmentConfigSchema = zod.z.object({
|
|
6557
|
-
NODE_ENV: zod.z.enum(["development", "production", "test"]).
|
|
6558
|
-
KNISHIO_NODE_URI:
|
|
6718
|
+
NODE_ENV: zod.z.enum(["development", "production", "test"]).optional(),
|
|
6719
|
+
KNISHIO_NODE_URI: urlString2().optional(),
|
|
6559
6720
|
KNISHIO_CELL_SLUG: zod.z.string().optional(),
|
|
6560
|
-
KNISHIO_LOGGING: zod.z.string().transform((val) => val === "true").
|
|
6561
|
-
KNISHIO_SERVER_SDK_VERSION: zod.z.string().transform((val) => parseInt(val, 10)).
|
|
6721
|
+
KNISHIO_LOGGING: zod.z.string().transform((val) => val === "true").optional(),
|
|
6722
|
+
KNISHIO_SERVER_SDK_VERSION: zod.z.string().transform((val) => parseInt(val, 10)).optional()
|
|
6562
6723
|
}).partial();
|
|
6563
6724
|
var TransferParamsSchema2 = zod.z.object({
|
|
6564
6725
|
recipient: zod.z.union([WalletAddressSchema2, zod.z.string()]),
|
|
@@ -6567,7 +6728,7 @@ var TransferParamsSchema2 = zod.z.object({
|
|
|
6567
6728
|
"Amount must be positive"
|
|
6568
6729
|
),
|
|
6569
6730
|
token: zod.z.union([TokenSlugSchema2, zod.z.string()]).optional(),
|
|
6570
|
-
callbackUrl:
|
|
6731
|
+
callbackUrl: urlString2().optional(),
|
|
6571
6732
|
metaType: zod.z.string().optional(),
|
|
6572
6733
|
metaId: zod.z.string().optional(),
|
|
6573
6734
|
meta: MetaDataSchema2.optional()
|
|
@@ -6608,7 +6769,7 @@ var MetaQueryParamsSchema2 = zod.z.object({
|
|
|
6608
6769
|
value: zod.z.string().optional(),
|
|
6609
6770
|
latest: zod.z.boolean().optional(),
|
|
6610
6771
|
filter: zod.z.string().optional(),
|
|
6611
|
-
queryArgs: zod.z.record(zod.z.unknown()).optional(),
|
|
6772
|
+
queryArgs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
6612
6773
|
count: zod.z.number().int().min(0).optional(),
|
|
6613
6774
|
countBy: zod.z.string().optional(),
|
|
6614
6775
|
cellSlug: zod.z.union([CellSlugSchema2, zod.z.string()]).optional()
|
|
@@ -6627,14 +6788,14 @@ var AuthTokenParamsSchema2 = zod.z.object({
|
|
|
6627
6788
|
var AuthParamsSchema2 = zod.z.object({
|
|
6628
6789
|
cellSlug: zod.z.union([CellSlugSchema2, zod.z.string()]).optional(),
|
|
6629
6790
|
encrypt: zod.z.boolean().optional(),
|
|
6630
|
-
callback: zod.z.
|
|
6791
|
+
callback: zod.z.custom((value) => typeof value === "function").optional()
|
|
6631
6792
|
}).strict();
|
|
6632
6793
|
var GuestAuthParamsSchema2 = zod.z.object({
|
|
6633
6794
|
cellSlug: zod.z.union([CellSlugSchema2, zod.z.string()]).optional()
|
|
6634
6795
|
}).strict();
|
|
6635
6796
|
var GraphQLRequestSchema2 = zod.z.object({
|
|
6636
6797
|
query: zod.z.string().min(1),
|
|
6637
|
-
variables: zod.z.record(zod.z.unknown()).optional(),
|
|
6798
|
+
variables: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
6638
6799
|
operationName: zod.z.string().optional()
|
|
6639
6800
|
}).strict();
|
|
6640
6801
|
var GraphQLErrorSchema2 = zod.z.object({
|
|
@@ -6644,12 +6805,12 @@ var GraphQLErrorSchema2 = zod.z.object({
|
|
|
6644
6805
|
column: zod.z.number().int()
|
|
6645
6806
|
})).optional(),
|
|
6646
6807
|
path: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional(),
|
|
6647
|
-
extensions: zod.z.record(zod.z.unknown()).optional()
|
|
6808
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
6648
6809
|
}).strict();
|
|
6649
6810
|
var GraphQLResponseSchema2 = zod.z.object({
|
|
6650
6811
|
data: zod.z.unknown().optional(),
|
|
6651
6812
|
errors: zod.z.array(GraphQLErrorSchema2).optional(),
|
|
6652
|
-
extensions: zod.z.record(zod.z.unknown()).optional()
|
|
6813
|
+
extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
6653
6814
|
}).strict();
|
|
6654
6815
|
function safeParse(schema, data) {
|
|
6655
6816
|
const result = schema.safeParse(data);
|
|
@@ -6659,7 +6820,7 @@ function safeParse(schema, data) {
|
|
|
6659
6820
|
error: {
|
|
6660
6821
|
issues: result.error.issues,
|
|
6661
6822
|
message: result.error.message,
|
|
6662
|
-
formatted: result.error
|
|
6823
|
+
formatted: zod.z.treeifyError(result.error)
|
|
6663
6824
|
}
|
|
6664
6825
|
};
|
|
6665
6826
|
}
|
|
@@ -11920,7 +12081,7 @@ var PolicyMeta = class _PolicyMeta {
|
|
|
11920
12081
|
|
|
11921
12082
|
// src/index.ts
|
|
11922
12083
|
init_exception();
|
|
11923
|
-
var SDK_VERSION = "
|
|
12084
|
+
var SDK_VERSION = "0.9.5";
|
|
11924
12085
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
11925
12086
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
11926
12087
|
var SDK_INFO = {
|