@wishknish/knishio-client-ts 0.9.4 → 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 +50 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.iife.js +20400 -4950
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +50 -29
- 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/schemas/index.ts +30 -15
- package/src/validation/ValidationService.ts +1 -3
- package/src/validation/schemas.ts +40 -16
package/dist/index.js
CHANGED
|
@@ -3833,6 +3833,14 @@ var Wallet = class _Wallet {
|
|
|
3833
3833
|
};
|
|
3834
3834
|
var hexStringRegex = /^[0-9a-fA-F]+$/;
|
|
3835
3835
|
var base17HashRegex = /^[0-9a-g]+$/;
|
|
3836
|
+
var urlString = (message = "Invalid URL") => z.string().refine((value) => {
|
|
3837
|
+
try {
|
|
3838
|
+
new URL(value);
|
|
3839
|
+
return true;
|
|
3840
|
+
} catch {
|
|
3841
|
+
return false;
|
|
3842
|
+
}
|
|
3843
|
+
}, message);
|
|
3836
3844
|
z.string().regex(hexStringRegex, "Must be a valid hexadecimal string").brand();
|
|
3837
3845
|
var WalletAddressSchema = z.string().regex(hexStringRegex, "Wallet address must be hexadecimal").length(64, "Wallet address must be exactly 64 characters").brand();
|
|
3838
3846
|
var BundleHashSchema = z.string().regex(hexStringRegex, "Bundle hash must be hexadecimal").length(64, "Bundle hash must be exactly 64 characters").brand();
|
|
@@ -3844,7 +3852,7 @@ var MetaIdSchema = z.string().min(1, "Meta ID cannot be empty").brand();
|
|
|
3844
3852
|
var BatchIdSchema = z.string().min(1, "Batch ID cannot be empty").brand();
|
|
3845
3853
|
var CellSlugSchema = z.string().min(1, "Cell slug cannot be empty").max(64, "Cell slug cannot exceed 64 characters").brand();
|
|
3846
3854
|
var AtomIsotopeSchema = z.enum(["C", "V", "U", "T", "M", "I", "R", "B", "F"], {
|
|
3847
|
-
|
|
3855
|
+
error: "Invalid atom isotope. Must be one of: C, V, U, T, M, I, R, B, F"
|
|
3848
3856
|
});
|
|
3849
3857
|
var MetaDataValueSchema = z.union([
|
|
3850
3858
|
z.string(),
|
|
@@ -3857,7 +3865,7 @@ var AtomMetaDataSchema = z.object({
|
|
|
3857
3865
|
value: MetaDataValueSchema
|
|
3858
3866
|
}).strict();
|
|
3859
3867
|
var MetaDataSchema = z.lazy(
|
|
3860
|
-
() => z.record(z.union([
|
|
3868
|
+
() => z.record(z.string(), z.union([
|
|
3861
3869
|
MetaDataValueSchema,
|
|
3862
3870
|
MetaDataSchema,
|
|
3863
3871
|
z.array(MetaDataSchema)
|
|
@@ -3896,7 +3904,7 @@ z.object({
|
|
|
3896
3904
|
version: z.number().int().min(1).optional()
|
|
3897
3905
|
}).strict();
|
|
3898
3906
|
z.object({
|
|
3899
|
-
uri: z.union([
|
|
3907
|
+
uri: z.union([urlString(), z.array(urlString())]).optional(),
|
|
3900
3908
|
cellSlug: z.union([CellSlugSchema, z.string(), z.null()]).optional(),
|
|
3901
3909
|
client: z.unknown().optional(),
|
|
3902
3910
|
socket: z.unknown().optional(),
|
|
@@ -3913,7 +3921,7 @@ z.object({
|
|
|
3913
3921
|
z.object({
|
|
3914
3922
|
cellSlug: z.union([CellSlugSchema, z.string(), z.null()]).optional(),
|
|
3915
3923
|
encrypt: z.boolean().optional(),
|
|
3916
|
-
callback: z.
|
|
3924
|
+
callback: z.custom((value) => typeof value === "function").optional()
|
|
3917
3925
|
}).strict();
|
|
3918
3926
|
z.object({
|
|
3919
3927
|
cellSlug: z.union([CellSlugSchema, z.string(), z.null()]).optional()
|
|
@@ -3922,7 +3930,7 @@ z.object({
|
|
|
3922
3930
|
recipient: z.union([WalletAddressSchema, z.string()]),
|
|
3923
3931
|
amount: z.union([z.number().positive(), z.string().min(1)]),
|
|
3924
3932
|
token: z.union([TokenSlugSchema, z.string()]).optional(),
|
|
3925
|
-
callbackUrl: z.union([
|
|
3933
|
+
callbackUrl: z.union([urlString(), z.null()]).optional(),
|
|
3926
3934
|
metaType: z.union([MetaTypeSchema, z.string(), z.null()]).optional(),
|
|
3927
3935
|
metaId: z.union([MetaIdSchema, z.string(), z.null()]).optional(),
|
|
3928
3936
|
meta: z.union([MetaDataSchema, z.null()]).optional()
|
|
@@ -3963,7 +3971,7 @@ z.object({
|
|
|
3963
3971
|
value: z.union([z.string(), z.null()]).optional(),
|
|
3964
3972
|
latest: z.union([z.boolean(), z.null()]).optional(),
|
|
3965
3973
|
filter: z.union([z.array(MetaFilterSchema), z.null()]).optional(),
|
|
3966
|
-
queryArgs: z.union([z.record(z.unknown()), z.null()]).optional(),
|
|
3974
|
+
queryArgs: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
|
3967
3975
|
count: z.union([z.number().int().min(1), z.null()]).optional(),
|
|
3968
3976
|
countBy: z.union([z.string(), z.null()]).optional(),
|
|
3969
3977
|
cellSlug: z.union([CellSlugSchema, z.string(), z.null()]).optional()
|
|
@@ -3988,7 +3996,7 @@ z.object({
|
|
|
3988
3996
|
}).strict();
|
|
3989
3997
|
z.object({
|
|
3990
3998
|
query: z.string().min(1, "GraphQL query cannot be empty"),
|
|
3991
|
-
variables: z.record(z.unknown()).optional(),
|
|
3999
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
3992
4000
|
operationName: z.union([z.string(), z.null()]).optional()
|
|
3993
4001
|
}).strict();
|
|
3994
4002
|
var GraphQLErrorSchema = z.object({
|
|
@@ -3998,18 +4006,18 @@ var GraphQLErrorSchema = z.object({
|
|
|
3998
4006
|
column: z.number().int().min(1)
|
|
3999
4007
|
})).optional(),
|
|
4000
4008
|
path: z.array(z.union([z.string(), z.number()])).optional(),
|
|
4001
|
-
extensions: z.record(z.unknown()).optional()
|
|
4009
|
+
extensions: z.record(z.string(), z.unknown()).optional()
|
|
4002
4010
|
}).strict();
|
|
4003
4011
|
z.object({
|
|
4004
4012
|
data: z.unknown().optional(),
|
|
4005
4013
|
errors: z.array(GraphQLErrorSchema).nullable().optional(),
|
|
4006
|
-
extensions: z.record(z.unknown()).optional()
|
|
4014
|
+
extensions: z.record(z.string(), z.unknown()).optional()
|
|
4007
4015
|
}).strict();
|
|
4008
4016
|
z.object({
|
|
4009
4017
|
operationName: z.string().optional(),
|
|
4010
4018
|
query: z.string().optional(),
|
|
4011
|
-
variables: z.record(z.unknown()).optional(),
|
|
4012
|
-
callback: z.
|
|
4019
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
4020
|
+
callback: z.custom((value) => typeof value === "function").optional()
|
|
4013
4021
|
}).strict();
|
|
4014
4022
|
z.object({
|
|
4015
4023
|
valid: z.boolean(),
|
|
@@ -4019,7 +4027,7 @@ z.object({
|
|
|
4019
4027
|
}).strict();
|
|
4020
4028
|
z.object({
|
|
4021
4029
|
operation: z.string().optional(),
|
|
4022
|
-
parameters: z.record(z.unknown()).optional(),
|
|
4030
|
+
parameters: z.record(z.string(), z.unknown()).optional(),
|
|
4023
4031
|
timestamp: z.number().int().min(0).optional(),
|
|
4024
4032
|
stack: z.string().optional()
|
|
4025
4033
|
}).strict();
|
|
@@ -4223,7 +4231,7 @@ var CallbackParamsSchema = z.object({
|
|
|
4223
4231
|
action: z.string().min(1, "Action cannot be empty"),
|
|
4224
4232
|
metaType: z.union([z.string(), z.null()]).optional(),
|
|
4225
4233
|
metaId: z.union([z.string(), z.null()]).optional(),
|
|
4226
|
-
meta: z.union([z.instanceof(Meta2), z.record(z.unknown()), z.null()]).optional(),
|
|
4234
|
+
meta: z.union([z.instanceof(Meta2), z.record(z.string(), z.unknown()), z.null()]).optional(),
|
|
4227
4235
|
address: z.union([z.string(), z.null()]).optional(),
|
|
4228
4236
|
token: z.union([z.string(), z.null()]).optional(),
|
|
4229
4237
|
amount: z.union([z.string(), z.null()]).optional(),
|
|
@@ -6570,6 +6578,14 @@ var Mutation = class extends Query {
|
|
|
6570
6578
|
}
|
|
6571
6579
|
}
|
|
6572
6580
|
};
|
|
6581
|
+
var urlString2 = (message = "Invalid URL") => z.string().refine((value) => {
|
|
6582
|
+
try {
|
|
6583
|
+
new URL(value);
|
|
6584
|
+
return true;
|
|
6585
|
+
} catch {
|
|
6586
|
+
return false;
|
|
6587
|
+
}
|
|
6588
|
+
}, message);
|
|
6573
6589
|
function createBrandedSchema(name, baseSchema = z.string()) {
|
|
6574
6590
|
return baseSchema.brand(name);
|
|
6575
6591
|
}
|
|
@@ -6595,7 +6611,12 @@ var TokenSlugSchema2 = createBrandedSchema(
|
|
|
6595
6611
|
);
|
|
6596
6612
|
var BatchIdSchema2 = createBrandedSchema(
|
|
6597
6613
|
"BatchId",
|
|
6598
|
-
|
|
6614
|
+
// v3's `.uuid()` regex, inlined verbatim. Zod 4's `z.uuid()` additionally enforces the
|
|
6615
|
+
// RFC 9562 version/variant nibbles and would reject batch IDs v3 accepted.
|
|
6616
|
+
z.string().regex(
|
|
6617
|
+
/^[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}$/,
|
|
6618
|
+
"Invalid batch ID format"
|
|
6619
|
+
)
|
|
6599
6620
|
);
|
|
6600
6621
|
var CellSlugSchema2 = createBrandedSchema(
|
|
6601
6622
|
"CellSlug",
|
|
@@ -6639,7 +6660,7 @@ var AtomMetaDataSchema2 = z.object({
|
|
|
6639
6660
|
z.object({
|
|
6640
6661
|
key: z.string(),
|
|
6641
6662
|
value: z.union([z.string(), z.number(), z.boolean(), z.null()])
|
|
6642
|
-
}).
|
|
6663
|
+
}).loose();
|
|
6643
6664
|
var AtomParamsSchema2 = z.object({
|
|
6644
6665
|
position: z.string().optional(),
|
|
6645
6666
|
walletAddress: z.union([WalletAddressSchema2, z.string()]).optional(),
|
|
@@ -6674,8 +6695,8 @@ var MoleculeParamsSchema2 = z.object({
|
|
|
6674
6695
|
}).strict();
|
|
6675
6696
|
var KnishIOClientConfigSchema2 = z.object({
|
|
6676
6697
|
uri: z.union([
|
|
6677
|
-
|
|
6678
|
-
z.array(
|
|
6698
|
+
urlString2("Invalid URI format"),
|
|
6699
|
+
z.array(urlString2("Invalid URI format")).min(1)
|
|
6679
6700
|
]).optional(),
|
|
6680
6701
|
cellSlug: z.union([CellSlugSchema2, z.string()]).optional(),
|
|
6681
6702
|
client: z.unknown().optional(),
|
|
@@ -6688,11 +6709,11 @@ var KnishIOClientConfigSchema2 = z.object({
|
|
|
6688
6709
|
defaultRequestPolicy: z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
6689
6710
|
}).strict();
|
|
6690
6711
|
var EnvironmentConfigSchema = z.object({
|
|
6691
|
-
NODE_ENV: z.enum(["development", "production", "test"]).
|
|
6692
|
-
KNISHIO_NODE_URI:
|
|
6712
|
+
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
6713
|
+
KNISHIO_NODE_URI: urlString2().optional(),
|
|
6693
6714
|
KNISHIO_CELL_SLUG: z.string().optional(),
|
|
6694
|
-
KNISHIO_LOGGING: z.string().transform((val) => val === "true").
|
|
6695
|
-
KNISHIO_SERVER_SDK_VERSION: z.string().transform((val) => parseInt(val, 10)).
|
|
6715
|
+
KNISHIO_LOGGING: z.string().transform((val) => val === "true").optional(),
|
|
6716
|
+
KNISHIO_SERVER_SDK_VERSION: z.string().transform((val) => parseInt(val, 10)).optional()
|
|
6696
6717
|
}).partial();
|
|
6697
6718
|
var TransferParamsSchema2 = z.object({
|
|
6698
6719
|
recipient: z.union([WalletAddressSchema2, z.string()]),
|
|
@@ -6701,7 +6722,7 @@ var TransferParamsSchema2 = z.object({
|
|
|
6701
6722
|
"Amount must be positive"
|
|
6702
6723
|
),
|
|
6703
6724
|
token: z.union([TokenSlugSchema2, z.string()]).optional(),
|
|
6704
|
-
callbackUrl:
|
|
6725
|
+
callbackUrl: urlString2().optional(),
|
|
6705
6726
|
metaType: z.string().optional(),
|
|
6706
6727
|
metaId: z.string().optional(),
|
|
6707
6728
|
meta: MetaDataSchema2.optional()
|
|
@@ -6742,7 +6763,7 @@ var MetaQueryParamsSchema2 = z.object({
|
|
|
6742
6763
|
value: z.string().optional(),
|
|
6743
6764
|
latest: z.boolean().optional(),
|
|
6744
6765
|
filter: z.string().optional(),
|
|
6745
|
-
queryArgs: z.record(z.unknown()).optional(),
|
|
6766
|
+
queryArgs: z.record(z.string(), z.unknown()).optional(),
|
|
6746
6767
|
count: z.number().int().min(0).optional(),
|
|
6747
6768
|
countBy: z.string().optional(),
|
|
6748
6769
|
cellSlug: z.union([CellSlugSchema2, z.string()]).optional()
|
|
@@ -6761,14 +6782,14 @@ var AuthTokenParamsSchema2 = z.object({
|
|
|
6761
6782
|
var AuthParamsSchema2 = z.object({
|
|
6762
6783
|
cellSlug: z.union([CellSlugSchema2, z.string()]).optional(),
|
|
6763
6784
|
encrypt: z.boolean().optional(),
|
|
6764
|
-
callback: z.
|
|
6785
|
+
callback: z.custom((value) => typeof value === "function").optional()
|
|
6765
6786
|
}).strict();
|
|
6766
6787
|
var GuestAuthParamsSchema2 = z.object({
|
|
6767
6788
|
cellSlug: z.union([CellSlugSchema2, z.string()]).optional()
|
|
6768
6789
|
}).strict();
|
|
6769
6790
|
var GraphQLRequestSchema2 = z.object({
|
|
6770
6791
|
query: z.string().min(1),
|
|
6771
|
-
variables: z.record(z.unknown()).optional(),
|
|
6792
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
6772
6793
|
operationName: z.string().optional()
|
|
6773
6794
|
}).strict();
|
|
6774
6795
|
var GraphQLErrorSchema2 = z.object({
|
|
@@ -6778,12 +6799,12 @@ var GraphQLErrorSchema2 = z.object({
|
|
|
6778
6799
|
column: z.number().int()
|
|
6779
6800
|
})).optional(),
|
|
6780
6801
|
path: z.array(z.union([z.string(), z.number()])).optional(),
|
|
6781
|
-
extensions: z.record(z.unknown()).optional()
|
|
6802
|
+
extensions: z.record(z.string(), z.unknown()).optional()
|
|
6782
6803
|
}).strict();
|
|
6783
6804
|
var GraphQLResponseSchema2 = z.object({
|
|
6784
6805
|
data: z.unknown().optional(),
|
|
6785
6806
|
errors: z.array(GraphQLErrorSchema2).optional(),
|
|
6786
|
-
extensions: z.record(z.unknown()).optional()
|
|
6807
|
+
extensions: z.record(z.string(), z.unknown()).optional()
|
|
6787
6808
|
}).strict();
|
|
6788
6809
|
function safeParse(schema, data) {
|
|
6789
6810
|
const result = schema.safeParse(data);
|
|
@@ -6793,7 +6814,7 @@ function safeParse(schema, data) {
|
|
|
6793
6814
|
error: {
|
|
6794
6815
|
issues: result.error.issues,
|
|
6795
6816
|
message: result.error.message,
|
|
6796
|
-
formatted: result.error
|
|
6817
|
+
formatted: z.treeifyError(result.error)
|
|
6797
6818
|
}
|
|
6798
6819
|
};
|
|
6799
6820
|
}
|
|
@@ -12054,7 +12075,7 @@ var PolicyMeta = class _PolicyMeta {
|
|
|
12054
12075
|
|
|
12055
12076
|
// src/index.ts
|
|
12056
12077
|
init_exception();
|
|
12057
|
-
var SDK_VERSION = "
|
|
12078
|
+
var SDK_VERSION = "0.9.5";
|
|
12058
12079
|
var SDK_NAME = "KnishIO-Client-TS";
|
|
12059
12080
|
var COMPATIBLE_SERVER_VERSIONS = [4, 5];
|
|
12060
12081
|
var SDK_INFO = {
|