@nexeraid/identity-schemas 2.130.0-dev → 2.131.0-dev

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.
Files changed (64) hide show
  1. package/dist/{CoinMarketCap.schema-52c35587.cjs.prod.cjs → CoinMarketCap.schema-75a0f92b.cjs.prod.cjs} +2 -2
  2. package/dist/{CoinMarketCap.schema-3fa2dbfe.cjs.dev.cjs → CoinMarketCap.schema-e7a388f4.cjs.dev.cjs} +2 -2
  3. package/dist/{CoinMarketCap.schema-d51e69ae.esm.mjs → CoinMarketCap.schema-f8339199.esm.mjs} +2 -2
  4. package/dist/declarations/src/identity/app-requests.schema.d.ts +94 -94
  5. package/dist/declarations/src/identity/host-requests.schema.d.ts +16 -16
  6. package/dist/declarations/src/identity/identity-v2.schema.d.ts +76 -76
  7. package/dist/declarations/src/identity/kyc.schema.d.ts +74 -74
  8. package/dist/declarations/src/identity/query.schema.d.ts +84 -84
  9. package/dist/declarations/src/identity/query.schema.d.ts.map +1 -1
  10. package/dist/declarations/src/identity/scenario.schema.d.ts +156 -156
  11. package/dist/declarations/src/identity/txAuthData.schema.d.ts +28 -28
  12. package/dist/declarations/src/identity/zkps.schema.d.ts +46 -46
  13. package/dist/declarations/src/index.d.ts +1 -0
  14. package/dist/declarations/src/index.d.ts.map +1 -1
  15. package/dist/declarations/src/vault/data-links/data-links.schema.d.ts +4 -3
  16. package/dist/declarations/src/vault/data-links/data-links.schema.d.ts.map +1 -1
  17. package/dist/declarations/src/vault/data-links/metadata-links.schema.d.ts.map +1 -1
  18. package/dist/declarations/src/vault/data-links/object-path.d.ts +5 -2
  19. package/dist/declarations/src/vault/data-links/object-path.d.ts.map +1 -1
  20. package/dist/declarations/src/vault/data-links/type-util.d.ts +2 -2
  21. package/dist/declarations/src/vault/data-links/type-util.d.ts.map +1 -1
  22. package/dist/declarations/src/vault/data-links/zod-utils.d.ts.map +1 -1
  23. package/dist/declarations/src/vault/schemas/generated/Web3Transaction.schema.json.d.ts +31 -0
  24. package/dist/declarations/src/vault/schemas/generated/Web3Transaction.type.d.ts +13 -0
  25. package/dist/declarations/src/vault/schemas/generated/Web3Transaction.type.d.ts.map +1 -0
  26. package/dist/declarations/src/vault/vault.schema.d.ts +74 -23
  27. package/dist/declarations/src/vault/vault.schema.d.ts.map +1 -1
  28. package/dist/declarations/src/web3-transaction.schema.d.ts +24 -0
  29. package/dist/declarations/src/web3-transaction.schema.d.ts.map +1 -0
  30. package/dist/{identity-api.schema-ba16c8c3.cjs.prod.cjs → identity-api.schema-876b71fe.cjs.prod.cjs} +1 -1
  31. package/dist/{identity-api.schema-3f7334e3.esm.mjs → identity-api.schema-93648b2c.esm.mjs} +1 -1
  32. package/dist/{identity-api.schema-b2947339.cjs.dev.cjs → identity-api.schema-b195fc03.cjs.dev.cjs} +1 -1
  33. package/dist/nexeraid-identity-schemas.cjs.dev.cjs +11 -7
  34. package/dist/nexeraid-identity-schemas.cjs.prod.cjs +11 -7
  35. package/dist/nexeraid-identity-schemas.esm.mjs +6 -4
  36. package/dist/package.json +1 -1
  37. package/dist/{tfhe-utilities-7c18a426.cjs.prod.cjs → tfhe-utilities-1ce70999.cjs.prod.cjs} +2 -2
  38. package/dist/{tfhe-utilities-e3085d72.esm.mjs → tfhe-utilities-3731a30f.esm.mjs} +2 -2
  39. package/dist/{tfhe-utilities-aa85d5c3.cjs.dev.cjs → tfhe-utilities-cc4d4e53.cjs.dev.cjs} +2 -2
  40. package/dist/toArray-721f6561.cjs.prod.cjs +9 -0
  41. package/dist/toArray-aa653e1d.esm.mjs +7 -0
  42. package/dist/toArray-f13714a0.cjs.dev.cjs +9 -0
  43. package/dist/{vault.schema-e1eca1dd.esm.mjs → vault.schema-3aa96890.esm.mjs} +80 -217
  44. package/dist/{vault.schema-c797be4e.cjs.dev.cjs → vault.schema-60464fc5.cjs.dev.cjs} +85 -221
  45. package/dist/{vault.schema-d8294208.cjs.prod.cjs → vault.schema-9f88c87d.cjs.prod.cjs} +85 -221
  46. package/dist/zod-utils-5768518c.cjs.dev.cjs +222 -0
  47. package/dist/zod-utils-895d0829.esm.mjs +217 -0
  48. package/dist/zod-utils-dfe3037a.cjs.prod.cjs +222 -0
  49. package/identity/dist/nexeraid-identity-schemas-identity.cjs.dev.cjs +2 -2
  50. package/identity/dist/nexeraid-identity-schemas-identity.cjs.prod.cjs +2 -2
  51. package/identity/dist/nexeraid-identity-schemas-identity.esm.mjs +2 -2
  52. package/package.json +1 -1
  53. package/providers/dist/nexeraid-identity-schemas-providers.cjs.dev.cjs +3 -3
  54. package/providers/dist/nexeraid-identity-schemas-providers.cjs.prod.cjs +3 -3
  55. package/providers/dist/nexeraid-identity-schemas-providers.esm.mjs +3 -3
  56. package/vault/dist/nexeraid-identity-schemas-vault.cjs.dev.cjs +7 -5
  57. package/vault/dist/nexeraid-identity-schemas-vault.cjs.prod.cjs +7 -5
  58. package/vault/dist/nexeraid-identity-schemas-vault.esm.mjs +3 -1
  59. package/verifiable-credentials/dist/nexeraid-identity-schemas-verifiable-credentials.cjs.dev.cjs +3 -3
  60. package/verifiable-credentials/dist/nexeraid-identity-schemas-verifiable-credentials.cjs.prod.cjs +3 -3
  61. package/verifiable-credentials/dist/nexeraid-identity-schemas-verifiable-credentials.esm.mjs +3 -3
  62. package/webhooks/dist/nexeraid-identity-schemas-webhooks.cjs.dev.cjs +5 -4
  63. package/webhooks/dist/nexeraid-identity-schemas-webhooks.cjs.prod.cjs +5 -4
  64. package/webhooks/dist/nexeraid-identity-schemas-webhooks.esm.mjs +4 -3
@@ -2822,6 +2822,10 @@ zod.z["enum"](allDataLinkTypes$1);
2822
2822
  * A link to a specific property in the schema
2823
2823
  */
2824
2824
 
2825
+ // set to unknown to avoid type errors
2826
+ // because now path is string because we have dynamic path
2827
+ // due to Web3TransactionData/functionArgs
2828
+
2825
2829
  /**
2826
2830
  * SearchLink
2827
2831
  *
@@ -2834,218 +2838,14 @@ zod.z["enum"](allDataLinkTypes$1);
2834
2838
  * A link that contains a specific object
2835
2839
  */
2836
2840
 
2837
- // tools to work with object paths in TypeScript
2838
-
2839
- var Separator = "/";
2840
-
2841
- // recursively get the type of a nested object property
2842
- // TODO: support unions: {a: {b: string } | {c: number}} + "a/b" -> string | undefined
2843
-
2844
- function _toArray(r) {
2845
- return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();
2846
- }
2847
-
2848
- function _createForOfIteratorHelper(r, e) {
2849
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2850
- if (!t) {
2851
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
2852
- t && (r = t);
2853
- var n = 0,
2854
- F = function () {};
2855
- return {
2856
- s: F,
2857
- n: function () {
2858
- return n >= r.length ? {
2859
- done: !0
2860
- } : {
2861
- done: !1,
2862
- value: r[n++]
2863
- };
2864
- },
2865
- e: function (r) {
2866
- throw r;
2867
- },
2868
- f: F
2869
- };
2870
- }
2871
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2872
- }
2873
- var o,
2874
- a = !0,
2875
- u = !1;
2876
- return {
2877
- s: function () {
2878
- t = t.call(r);
2879
- },
2880
- n: function () {
2881
- var r = t.next();
2882
- return a = r.done, r;
2883
- },
2884
- e: function (r) {
2885
- u = !0, o = r;
2886
- },
2887
- f: function () {
2888
- try {
2889
- a || null == t.return || t.return();
2890
- } finally {
2891
- if (u) throw o;
2892
- }
2893
- }
2894
- };
2895
- }
2896
-
2897
- // this lib is too generic to follow the linting rules, a lot of types end up resolved to any
2898
- /* eslint-disable @typescript-eslint/no-explicit-any */
2899
- /* eslint-disable @typescript-eslint/no-unsafe-return */
2900
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2901
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
2902
-
2903
- var generateZodObjectPaths = function generateZodObjectPaths(schema) {
2904
- function traverse(schema, pathToHere) {
2905
- var paths = [];
2906
- if (schema.shape) {
2907
- for (var _i = 0, _Object$entries = Object.entries(schema.shape); _i < _Object$entries.length; _i++) {
2908
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2909
- key = _Object$entries$_i[0],
2910
- value = _Object$entries$_i[1];
2911
- var newPath = [].concat(_toConsumableArray(pathToHere), [key]);
2912
- var deep = traverse(value, newPath);
2913
- paths = [].concat(_toConsumableArray(paths), [newPath.join(Separator)], _toConsumableArray(deep));
2914
- }
2915
- } else if (schema instanceof zod.z.ZodOptional) {
2916
- var _deep = traverse(schema.unwrap(), pathToHere);
2917
- paths = [].concat(_toConsumableArray(paths), _toConsumableArray(_deep));
2918
- } else if (schema instanceof zod.z.ZodArray) {
2919
- var _deep2 = traverse(schema.element, pathToHere);
2920
- paths = [].concat(_toConsumableArray(paths), _toConsumableArray(_deep2));
2921
- } else if (schema instanceof zod.z.ZodIntersection) {
2922
- // @ts-expect-error -- TODO: fix this
2923
- var deepLeft = traverse(schema._def.left, pathToHere);
2924
- paths = [].concat(_toConsumableArray(paths), _toConsumableArray(deepLeft));
2925
- // @ts-expect-error -- TODO: fix this
2926
- var deepRight = traverse(schema._def.right, pathToHere);
2927
- paths = [].concat(_toConsumableArray(paths), _toConsumableArray(deepRight));
2928
- } else if (schema instanceof zod.z.ZodUnion) {
2929
- var _iterator = _createForOfIteratorHelper(schema.options),
2930
- _step;
2931
- try {
2932
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2933
- var option = _step.value;
2934
- var _deep3 = traverse(option, pathToHere);
2935
- paths = [].concat(_toConsumableArray(paths), _toConsumableArray(_deep3));
2936
- }
2937
- } catch (err) {
2938
- _iterator.e(err);
2939
- } finally {
2940
- _iterator.f();
2941
- }
2942
- } else if (schema instanceof zod.z.ZodType) {
2943
- paths.push(pathToHere.join(Separator));
2944
- }
2945
- return Array.from(new Set(paths));
2946
- }
2947
- return traverse(schema, []);
2948
- };
2949
-
2950
- // avoid circular dependency with logger
2951
-
2952
- var resolvePathOnDataSchema = function resolvePathOnDataSchema(_ref) {
2953
- var logger = _ref.logger,
2954
- dataSchema = _ref.dataSchema,
2955
- path = _ref.path;
2956
- function traverse(schema, path) {
2957
- if (path.length === 0) {
2958
- return schema;
2959
- }
2960
- var _path = _toArray(path),
2961
- part = _path[0],
2962
- rest = _path.slice(1);
2963
- if (!part) {
2964
- return null; // unreachable due to previous check
2965
- }
2966
- if (schema.shape) {
2967
- if (!(part in schema.shape)) {
2968
- logger.error({
2969
- msg: "part not found in schema.shape",
2970
- data: {
2971
- path: path,
2972
- dataSchema: dataSchema
2973
- }
2974
- });
2975
- return null;
2976
- }
2977
- return traverse(schema.shape[part], rest);
2978
- } else if (schema instanceof zod.z.ZodOptional) {
2979
- return traverse(schema.unwrap(), path);
2980
- } else if (schema instanceof zod.z.ZodArray) {
2981
- return traverse(schema.element, path);
2982
- } else if (schema instanceof zod.z.ZodIntersection) {
2983
- // @ts-expect-error -- TODO: fix this
2984
- var right = schema._def.right;
2985
- if (!right) {
2986
- logger.error({
2987
- msg: "Intersection has no .right field",
2988
- data: {
2989
- path: path,
2990
- dataSchema: dataSchema
2991
- }
2992
- });
2993
- return null;
2994
- }
2995
- return traverse(right, path);
2996
- } else if (schema instanceof zod.z.ZodUnion) {
2997
- var options = schema.options;
2998
- var _iterator2 = _createForOfIteratorHelper(options),
2999
- _step2;
3000
- try {
3001
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3002
- var option = _step2.value;
3003
- var _result = traverse(option, path);
3004
- if (_result) {
3005
- return _result;
3006
- }
3007
- }
3008
- } catch (err) {
3009
- _iterator2.e(err);
3010
- } finally {
3011
- _iterator2.f();
3012
- }
3013
- }
3014
- return null;
3015
- }
3016
- var parts = path.split(Separator);
3017
- var result = traverse(dataSchema, parts);
3018
- if (!result) {
3019
- logger.error({
3020
- msg: "path not found",
3021
- data: {
3022
- path: path,
3023
- dataSchema: dataSchema
3024
- }
3025
- });
3026
- return null;
3027
- }
3028
- return result;
3029
- };
3030
- var resolvePathOnMapSchema = function resolvePathOnMapSchema(_ref2) {
3031
- var logger = _ref2.logger,
3032
- mapSchema = _ref2.mapSchema,
3033
- path = _ref2.path;
3034
- var rest = path;
3035
- while (rest.length > 0) {
3036
- if (rest in mapSchema.shape) {
3037
- return mapSchema.shape[rest];
3038
- }
3039
- rest = rest.slice(0, rest.lastIndexOf(Separator));
3040
- }
3041
- logger.error({
3042
- msg: "path not found",
3043
- data: {
3044
- path: path
3045
- }
3046
- });
3047
- return null;
3048
- };
2841
+ var Web3ArgsType = zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"]()]);
2842
+ var Web3TransactionData = zod.z.object({
2843
+ senderAddress: EvmAddress,
2844
+ contractAddress: EvmAddress,
2845
+ functionName: zod.z.string().optional(),
2846
+ functionArgs: zod.z.record(zod.z.string(), Web3ArgsType).optional(),
2847
+ transactionRequestDate: zod.z.coerce.date().optional()
2848
+ });
3049
2849
 
3050
2850
  var allDataLinkVersions = ["v1"];
3051
2851
  var DataLinkVersionZodSchema = zod.z["enum"](allDataLinkVersions);
@@ -10891,6 +10691,48 @@ var TransactionJsonSchema = {
10891
10691
  $schema: "http://json-schema.org/draft-07/schema#"
10892
10692
  };
10893
10693
 
10694
+ var Web3TransactionJsonSchema = {
10695
+ $ref: "#/definitions/Web3Transaction",
10696
+ definitions: {
10697
+ Web3Transaction: {
10698
+ type: "object",
10699
+ properties: {
10700
+ senderAddress: {
10701
+ type: "string",
10702
+ description: "String value that identifies the address of a specific user. Normally tied to an EOA that includes the Smart Wallet."
10703
+ },
10704
+ contractAddress: {
10705
+ type: "string",
10706
+ description: "String value that identifies the address of a specific user. Normally tied to an EOA that includes the Smart Wallet."
10707
+ },
10708
+ functionName: {
10709
+ type: "string"
10710
+ },
10711
+ functionArgs: {
10712
+ type: "object",
10713
+ additionalProperties: {
10714
+ type: [
10715
+ "string",
10716
+ "number",
10717
+ "boolean"
10718
+ ]
10719
+ }
10720
+ },
10721
+ transactionRequestDate: {
10722
+ type: "string",
10723
+ format: "date-time"
10724
+ }
10725
+ },
10726
+ required: [
10727
+ "senderAddress",
10728
+ "contractAddress"
10729
+ ],
10730
+ additionalProperties: false
10731
+ }
10732
+ },
10733
+ $schema: "http://json-schema.org/draft-07/schema#"
10734
+ };
10735
+
10894
10736
  var KycSessionZodSchema = zod.z.object({
10895
10737
  vcs: zod.z.object({
10896
10738
  // "v1" here refers the version of the credential schema
@@ -11473,22 +11315,40 @@ var TransactionZodSchema = zod.z.object({
11473
11315
  }).optional()
11474
11316
  });
11475
11317
 
11318
+ var Web3TransactionZodSchema = zod.z.object({
11319
+ senderAddress: EvmAddress,
11320
+ contractAddress: EvmAddress,
11321
+ functionName: zod.z.string().optional(),
11322
+ functionArgs: zod.z.record(zod.z.string(), Web3ArgsType).optional(),
11323
+ transactionRequestDate: zod.z.coerce.date().optional()
11324
+ });
11325
+
11476
11326
  var VaultJsonSchemas = {
11477
11327
  Customer: CustomerJsonSchema,
11478
11328
  KycSession: KycSessionJsonSchema,
11479
11329
  Transaction: TransactionJsonSchema,
11480
11330
  TfheKycSession: TfheKycSessionJsonSchema,
11481
- Tfhe: TfheJsonSchema
11331
+ Tfhe: TfheJsonSchema,
11332
+ Web3Transaction: Web3TransactionJsonSchema
11482
11333
  };
11483
11334
  var VaultZodSchema = zod.z.object({
11484
11335
  Customer: CustomerZodSchema,
11485
11336
  KycSession: KycSessionZodSchema,
11486
11337
  Transaction: TransactionZodSchema,
11487
11338
  TfheKycSession: TfheKycSessionZodSchema,
11488
- Tfhe: TfheZodSchema
11339
+ Tfhe: TfheZodSchema,
11340
+ Web3Transaction: Web3TransactionZodSchema
11489
11341
  });
11490
11342
  var VaultSchemaIdZodSchema = zod.z["enum"](Object.keys(VaultZodSchema.shape));
11491
- var VaultSchemaPathsZodSchema = zod.z["enum"](generateZodObjectPaths(VaultZodSchema));
11343
+ // Paths<VaultSchema>;
11344
+ var VaultSchemaPathsZodSchema = zod.z.string();
11345
+ // z.enum(
11346
+ // generateZodObjectPaths(VaultZodSchema) as [
11347
+ // VaultSchemaPaths,
11348
+ // ...VaultSchemaPaths[],
11349
+ // ],
11350
+ // );
11351
+
11492
11352
  var VaultPointerKeyMapZodSchema = zod.z.object({
11493
11353
  Customer: zod.z.object({
11494
11354
  customerId: CustomerId,
@@ -11515,7 +11375,10 @@ var VaultPointerKeyMapZodSchema = zod.z.object({
11515
11375
  workflowId: WorkflowId,
11516
11376
  identityId: IdentityId,
11517
11377
  workflowSessionId: WorkflowSessionId
11518
- }).strict()
11378
+ }).strict(),
11379
+ Web3Transaction: zod.z.object({
11380
+ workflowSessionId: WorkflowSessionId
11381
+ })
11519
11382
  });
11520
11383
  var VaultQueryMapZodSchema = zod.z.object({
11521
11384
  KycSession: zod.z.object({
@@ -11867,7 +11730,6 @@ exports.ScoringAnalysisRequest = ScoringAnalysisRequest;
11867
11730
  exports.ScoringAnalysisResponse = ScoringAnalysisResponse;
11868
11731
  exports.SelfieImageCredentialSchema = SelfieImageCredentialSchema;
11869
11732
  exports.SelfieImageCredentialSubjectSchema = SelfieImageCredentialSubjectSchema;
11870
- exports.Separator = Separator;
11871
11733
  exports.SigGatingId = SigGatingId;
11872
11734
  exports.SigGatingPrefix = SigGatingPrefix;
11873
11735
  exports.SolanaChainId = SolanaChainId;
@@ -11969,16 +11831,21 @@ exports.WalletScreeningData = WalletScreeningData;
11969
11831
  exports.WalletScreeningProvider = WalletScreeningProvider;
11970
11832
  exports.WalletScreeningProviders = WalletScreeningProviders;
11971
11833
  exports.Web2CreateSessionParams = Web2CreateSessionParams;
11834
+ exports.Web3ArgsType = Web3ArgsType;
11835
+ exports.Web3TransactionData = Web3TransactionData;
11972
11836
  exports.WorkflowId = WorkflowId;
11973
11837
  exports.WorkflowSessionAttributeId = WorkflowSessionAttributeId;
11974
11838
  exports.WorkflowSessionAttributePrefix = WorkflowSessionAttributePrefix;
11975
11839
  exports.WorkflowSessionId = WorkflowSessionId;
11976
11840
  exports.WorkflowsScoringAnalysisRequest = WorkflowsScoringAnalysisRequest;
11977
11841
  exports.WorkspaceId = WorkspaceId;
11842
+ exports._arrayWithHoles = _arrayWithHoles;
11978
11843
  exports._defineProperty = _defineProperty;
11844
+ exports._iterableToArray = _iterableToArray;
11845
+ exports._nonIterableRest = _nonIterableRest;
11979
11846
  exports._slicedToArray = _slicedToArray;
11980
- exports._toArray = _toArray;
11981
11847
  exports._toConsumableArray = _toConsumableArray;
11848
+ exports._unsupportedIterableToArray = _unsupportedIterableToArray;
11982
11849
  exports.allDataLinkTypes = allDataLinkTypes;
11983
11850
  exports.allDataLinkVersions = allDataLinkVersions;
11984
11851
  exports.compareRiskLevels = compareRiskLevels;
@@ -11987,7 +11854,6 @@ exports.countryISO3toISO2Mapping = countryISO3toISO2Mapping;
11987
11854
  exports.createBrandedSchemaId = createBrandedSchemaId;
11988
11855
  exports.createBrandedSchemaIdWithParams = createBrandedSchemaIdWithParams;
11989
11856
  exports.generateId = generateId;
11990
- exports.generateZodObjectPaths = generateZodObjectPaths;
11991
11857
  exports.getRiskLevelByRiskScore = getRiskLevelByRiskScore;
11992
11858
  exports.getTagTypeFromEntityType = getTagTypeFromEntityType;
11993
11859
  exports.initializeStatistics = initializeStatistics;
@@ -11995,7 +11861,5 @@ exports.isValidAddress = isValidAddress;
11995
11861
  exports.isoCountriesNameFromISO2 = isoCountriesNameFromISO2;
11996
11862
  exports.isoCountriesNameFromISO3 = isoCountriesNameFromISO3;
11997
11863
  exports.parseISO3CountryCode = parseISO3CountryCode;
11998
- exports.resolvePathOnDataSchema = resolvePathOnDataSchema;
11999
- exports.resolvePathOnMapSchema = resolvePathOnMapSchema;
12000
11864
  exports.scorechainCountriesNameFromISO2 = scorechainCountriesNameFromISO2;
12001
11865
  exports.shortBlockchainAddress = shortBlockchainAddress;
@@ -0,0 +1,222 @@
1
+ 'use strict';
2
+
3
+ var toArray = require('./toArray-f13714a0.cjs.dev.cjs');
4
+ var vault_schema = require('./vault.schema-60464fc5.cjs.dev.cjs');
5
+ var zod = require('zod');
6
+
7
+ // tools to work with object paths in TypeScript
8
+
9
+ var Separator = "/";
10
+
11
+ // recursively get the type of a nested object property
12
+ // TODO: support unions: {a: {b: string } | {c: number}} + "a/b" -> string | undefined
13
+
14
+ function _createForOfIteratorHelper(r, e) {
15
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
16
+ if (!t) {
17
+ if (Array.isArray(r) || (t = vault_schema._unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
18
+ t && (r = t);
19
+ var n = 0,
20
+ F = function () {};
21
+ return {
22
+ s: F,
23
+ n: function () {
24
+ return n >= r.length ? {
25
+ done: !0
26
+ } : {
27
+ done: !1,
28
+ value: r[n++]
29
+ };
30
+ },
31
+ e: function (r) {
32
+ throw r;
33
+ },
34
+ f: F
35
+ };
36
+ }
37
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
38
+ }
39
+ var o,
40
+ a = !0,
41
+ u = !1;
42
+ return {
43
+ s: function () {
44
+ t = t.call(r);
45
+ },
46
+ n: function () {
47
+ var r = t.next();
48
+ return a = r.done, r;
49
+ },
50
+ e: function (r) {
51
+ u = !0, o = r;
52
+ },
53
+ f: function () {
54
+ try {
55
+ a || null == t.return || t.return();
56
+ } finally {
57
+ if (u) throw o;
58
+ }
59
+ }
60
+ };
61
+ }
62
+
63
+ // this lib is too generic to follow the linting rules, a lot of types end up resolved to any
64
+ /* eslint-disable @typescript-eslint/no-explicit-any */
65
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
66
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
67
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
68
+
69
+ var generateZodObjectPaths = function generateZodObjectPaths(schema) {
70
+ function traverse(schema, pathToHere) {
71
+ var paths = [];
72
+ if (schema.shape) {
73
+ for (var _i = 0, _Object$entries = Object.entries(schema.shape); _i < _Object$entries.length; _i++) {
74
+ var _Object$entries$_i = vault_schema._slicedToArray(_Object$entries[_i], 2),
75
+ key = _Object$entries$_i[0],
76
+ value = _Object$entries$_i[1];
77
+ var newPath = [].concat(vault_schema._toConsumableArray(pathToHere), [key]);
78
+ var deep = traverse(value, newPath);
79
+ paths = [].concat(vault_schema._toConsumableArray(paths), [newPath.join(Separator)], vault_schema._toConsumableArray(deep));
80
+ }
81
+ } else if (schema instanceof zod.z.ZodOptional) {
82
+ var _deep = traverse(schema.unwrap(), pathToHere);
83
+ paths = [].concat(vault_schema._toConsumableArray(paths), vault_schema._toConsumableArray(_deep));
84
+ } else if (schema instanceof zod.z.ZodArray) {
85
+ var _deep2 = traverse(schema.element, pathToHere);
86
+ paths = [].concat(vault_schema._toConsumableArray(paths), vault_schema._toConsumableArray(_deep2));
87
+ } else if (schema instanceof zod.z.ZodIntersection) {
88
+ // @ts-expect-error -- TODO: fix this
89
+ var deepLeft = traverse(schema._def.left, pathToHere);
90
+ paths = [].concat(vault_schema._toConsumableArray(paths), vault_schema._toConsumableArray(deepLeft));
91
+ // @ts-expect-error -- TODO: fix this
92
+ var deepRight = traverse(schema._def.right, pathToHere);
93
+ paths = [].concat(vault_schema._toConsumableArray(paths), vault_schema._toConsumableArray(deepRight));
94
+ } else if (schema instanceof zod.z.ZodUnion) {
95
+ var _iterator = _createForOfIteratorHelper(schema.options),
96
+ _step;
97
+ try {
98
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
+ var option = _step.value;
100
+ var _deep3 = traverse(option, pathToHere);
101
+ paths = [].concat(vault_schema._toConsumableArray(paths), vault_schema._toConsumableArray(_deep3));
102
+ }
103
+ } catch (err) {
104
+ _iterator.e(err);
105
+ } finally {
106
+ _iterator.f();
107
+ }
108
+ } else if (schema instanceof zod.z.ZodType) {
109
+ paths.push(pathToHere.join(Separator));
110
+ }
111
+ return Array.from(new Set(paths));
112
+ }
113
+ return traverse(schema, []);
114
+ };
115
+
116
+ // avoid circular dependency with logger
117
+
118
+ var resolvePathOnDataSchema = function resolvePathOnDataSchema(_ref) {
119
+ var logger = _ref.logger,
120
+ dataSchema = _ref.dataSchema,
121
+ path = _ref.path;
122
+ if (path.startsWith("Web3Transaction/functionArgs/")) {
123
+ return vault_schema.Web3ArgsType;
124
+ }
125
+ function traverse(schema, path) {
126
+ if (path.length === 0) {
127
+ return schema;
128
+ }
129
+ var _path = toArray._toArray(path),
130
+ part = _path[0],
131
+ rest = _path.slice(1);
132
+ if (!part) {
133
+ return null; // unreachable due to previous check
134
+ }
135
+ if (schema.shape) {
136
+ if (!(part in schema.shape)) {
137
+ logger.error({
138
+ msg: "part not found in schema.shape",
139
+ data: {
140
+ path: path,
141
+ dataSchema: dataSchema
142
+ }
143
+ });
144
+ return null;
145
+ }
146
+ return traverse(schema.shape[part], rest);
147
+ } else if (schema instanceof zod.z.ZodOptional) {
148
+ return traverse(schema.unwrap(), path);
149
+ } else if (schema instanceof zod.z.ZodArray) {
150
+ return traverse(schema.element, path);
151
+ } else if (schema instanceof zod.z.ZodIntersection) {
152
+ // @ts-expect-error -- TODO: fix this
153
+ var right = schema._def.right;
154
+ if (!right) {
155
+ logger.error({
156
+ msg: "Intersection has no .right field",
157
+ data: {
158
+ path: path,
159
+ dataSchema: dataSchema
160
+ }
161
+ });
162
+ return null;
163
+ }
164
+ return traverse(right, path);
165
+ } else if (schema instanceof zod.z.ZodUnion) {
166
+ var options = schema.options;
167
+ var _iterator2 = _createForOfIteratorHelper(options),
168
+ _step2;
169
+ try {
170
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
171
+ var option = _step2.value;
172
+ var _result = traverse(option, path);
173
+ if (_result) {
174
+ return _result;
175
+ }
176
+ }
177
+ } catch (err) {
178
+ _iterator2.e(err);
179
+ } finally {
180
+ _iterator2.f();
181
+ }
182
+ }
183
+ return null;
184
+ }
185
+ var parts = path.split(Separator);
186
+ var result = traverse(dataSchema, parts);
187
+ if (!result) {
188
+ logger.error({
189
+ msg: "path not found",
190
+ data: {
191
+ path: path,
192
+ dataSchema: dataSchema
193
+ }
194
+ });
195
+ return null;
196
+ }
197
+ return result;
198
+ };
199
+ var resolvePathOnMapSchema = function resolvePathOnMapSchema(_ref2) {
200
+ var logger = _ref2.logger,
201
+ mapSchema = _ref2.mapSchema,
202
+ path = _ref2.path;
203
+ var rest = path;
204
+ while (rest.length > 0) {
205
+ if (rest in mapSchema.shape) {
206
+ return mapSchema.shape[rest];
207
+ }
208
+ rest = rest.slice(0, rest.lastIndexOf(Separator));
209
+ }
210
+ logger.error({
211
+ msg: "path not found",
212
+ data: {
213
+ path: path
214
+ }
215
+ });
216
+ return null;
217
+ };
218
+
219
+ exports.Separator = Separator;
220
+ exports.generateZodObjectPaths = generateZodObjectPaths;
221
+ exports.resolvePathOnDataSchema = resolvePathOnDataSchema;
222
+ exports.resolvePathOnMapSchema = resolvePathOnMapSchema;