@aws-amplify/graphql-api-construct 1.1.3 → 1.2.0-amplify-table-preview.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/.jsii +153 -100
  2. package/API.md +4 -0
  3. package/CHANGELOG.md +16 -0
  4. package/README.md +9 -3
  5. package/lib/amplify-graphql-api.d.ts +9 -3
  6. package/lib/amplify-graphql-api.js +11 -5
  7. package/lib/amplify-graphql-definition.js +1 -1
  8. package/lib/internal/codegen-assets.js +6 -1
  9. package/lib/internal/construct-exports.js +7 -1
  10. package/lib/internal/default-parameters.js +2 -1
  11. package/lib/types.d.ts +15 -4
  12. package/lib/types.js +1 -1
  13. package/node_modules/@aws-amplify/graphql-auth-transformer/CHANGELOG.md +8 -0
  14. package/node_modules/@aws-amplify/graphql-auth-transformer/package.json +10 -10
  15. package/node_modules/@aws-amplify/graphql-default-value-transformer/CHANGELOG.md +8 -0
  16. package/node_modules/@aws-amplify/graphql-default-value-transformer/package.json +7 -7
  17. package/node_modules/@aws-amplify/graphql-function-transformer/CHANGELOG.md +8 -0
  18. package/node_modules/@aws-amplify/graphql-function-transformer/package.json +6 -6
  19. package/node_modules/@aws-amplify/graphql-http-transformer/CHANGELOG.md +8 -0
  20. package/node_modules/@aws-amplify/graphql-http-transformer/package.json +6 -6
  21. package/node_modules/@aws-amplify/graphql-index-transformer/API.md +3 -0
  22. package/node_modules/@aws-amplify/graphql-index-transformer/CHANGELOG.md +11 -0
  23. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.d.ts +1 -1
  24. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.d.ts.map +1 -1
  25. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.js +2 -1
  26. package/node_modules/@aws-amplify/graphql-index-transformer/lib/index.js.map +1 -1
  27. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.d.ts +1 -0
  28. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.d.ts.map +1 -1
  29. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.js +26 -7
  30. package/node_modules/@aws-amplify/graphql-index-transformer/lib/resolvers/resolvers.js.map +1 -1
  31. package/node_modules/@aws-amplify/graphql-index-transformer/package.json +7 -7
  32. package/node_modules/@aws-amplify/graphql-maps-to-transformer/CHANGELOG.md +8 -0
  33. package/node_modules/@aws-amplify/graphql-maps-to-transformer/lib/assets/mapping-lambda.zip +0 -0
  34. package/node_modules/@aws-amplify/graphql-maps-to-transformer/package.json +10 -10
  35. package/node_modules/@aws-amplify/graphql-model-transformer/CHANGELOG.md +12 -0
  36. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.d.ts.map +1 -1
  37. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.js +4 -0
  38. package/node_modules/@aws-amplify/graphql-model-transformer/lib/graphql-model-transformer.js.map +1 -1
  39. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-lambda.zip +0 -0
  40. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-notification-lambda.zip +0 -0
  41. package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-patching-lambda.zip +0 -0
  42. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.d.ts +13 -0
  43. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.d.ts.map +1 -0
  44. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.js +167 -0
  45. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamo-model-resource-generator.js.map +1 -0
  46. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.d.ts +40 -0
  47. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.d.ts.map +1 -0
  48. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.js +242 -0
  49. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-dynamodb-table-construct/index.js.map +1 -0
  50. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.d.ts +13 -0
  51. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.d.ts.map +1 -0
  52. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.js +665 -0
  53. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/amplify-dynamodb-table/amplify-table-manager-lambda/amplify-table-manager-handler.js.map +1 -0
  54. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.d.ts +5 -2
  55. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.d.ts.map +1 -1
  56. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.js +46 -60
  57. package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/dynamo-model-resource-generator.js.map +1 -1
  58. package/node_modules/@aws-amplify/graphql-model-transformer/package.json +7 -6
  59. package/node_modules/@aws-amplify/graphql-predictions-transformer/CHANGELOG.md +8 -0
  60. package/node_modules/@aws-amplify/graphql-predictions-transformer/lib/predictionsLambdaFunction.zip +0 -0
  61. package/node_modules/@aws-amplify/graphql-predictions-transformer/package.json +6 -6
  62. package/node_modules/@aws-amplify/graphql-relational-transformer/CHANGELOG.md +11 -0
  63. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.d.ts.map +1 -1
  64. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js +3 -10
  65. package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js.map +1 -1
  66. package/node_modules/@aws-amplify/graphql-relational-transformer/package.json +8 -8
  67. package/node_modules/@aws-amplify/graphql-searchable-transformer/CHANGELOG.md +8 -0
  68. package/node_modules/@aws-amplify/graphql-searchable-transformer/lib/streaming-lambda.zip +0 -0
  69. package/node_modules/@aws-amplify/graphql-searchable-transformer/package.json +7 -7
  70. package/node_modules/@aws-amplify/graphql-transformer/CHANGELOG.md +10 -0
  71. package/node_modules/@aws-amplify/graphql-transformer/package.json +14 -14
  72. package/node_modules/@aws-amplify/graphql-transformer-core/API.md +1 -0
  73. package/node_modules/@aws-amplify/graphql-transformer-core/CHANGELOG.md +12 -0
  74. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/output.d.ts +8 -1
  75. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/output.d.ts.map +1 -1
  76. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/output.js +60 -23
  77. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/output.js.map +1 -1
  78. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/transform-parameters.d.ts.map +1 -1
  79. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/transform-parameters.js +1 -0
  80. package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/transform-parameters.js.map +1 -1
  81. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/defaultSchema.d.ts +4 -1
  82. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/defaultSchema.d.ts.map +1 -1
  83. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/defaultSchema.js +35 -36
  84. package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/defaultSchema.js.map +1 -1
  85. package/node_modules/@aws-amplify/graphql-transformer-core/package.json +4 -4
  86. package/node_modules/@aws-amplify/graphql-transformer-interfaces/API.md +1 -0
  87. package/node_modules/@aws-amplify/graphql-transformer-interfaces/CHANGELOG.md +6 -0
  88. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transform-parameters.d.ts +1 -0
  89. package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transform-parameters.d.ts.map +1 -1
  90. package/node_modules/@aws-amplify/graphql-transformer-interfaces/package.json +2 -2
  91. package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/transform-parameters.ts +1 -0
  92. package/node_modules/@aws-amplify/graphql-transformer-interfaces/tsconfig.tsbuildinfo +1 -1
  93. package/node_modules/graphql-transformer-common/API.md +3 -0
  94. package/node_modules/graphql-transformer-common/CHANGELOG.md +6 -0
  95. package/node_modules/graphql-transformer-common/LICENSE +201 -0
  96. package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts +3 -0
  97. package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts.map +1 -1
  98. package/node_modules/graphql-transformer-common/lib/ResourceConstants.js +3 -0
  99. package/node_modules/graphql-transformer-common/lib/ResourceConstants.js.map +1 -1
  100. package/node_modules/graphql-transformer-common/package.json +3 -2
  101. package/node_modules/zod/README.md +215 -120
  102. package/node_modules/zod/lib/ZodError.js +8 -0
  103. package/node_modules/zod/lib/helpers/parseUtil.js +3 -2
  104. package/node_modules/zod/lib/helpers/util.js +4 -4
  105. package/node_modules/zod/lib/index.mjs +121 -57
  106. package/node_modules/zod/lib/index.umd.js +121 -56
  107. package/node_modules/zod/lib/types.d.ts +55 -10
  108. package/node_modules/zod/lib/types.js +301 -58
  109. package/node_modules/zod/package.json +29 -15
  110. package/package.json +17 -17
  111. package/src/amplify-graphql-api.ts +9 -3
  112. package/src/internal/codegen-assets.ts +5 -0
  113. package/src/internal/construct-exports.ts +6 -0
  114. package/src/internal/default-parameters.ts +1 -0
  115. package/src/types.ts +18 -4
@@ -38,7 +38,7 @@ function addIssueToContext(ctx, issueData) {
38
38
  ctx.common.contextualErrorMap,
39
39
  ctx.schemaErrorMap,
40
40
  (0, errors_1.getErrorMap)(),
41
- en_1.default,
41
+ en_1.default, // then global default map
42
42
  ].filter((x) => !!x),
43
43
  });
44
44
  ctx.common.issues.push(issue);
@@ -89,7 +89,8 @@ class ParseStatus {
89
89
  status.dirty();
90
90
  if (value.status === "dirty")
91
91
  status.dirty();
92
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
92
+ if (key.value !== "__proto__" &&
93
+ (typeof value.value !== "undefined" || pair.alwaysSet)) {
93
94
  finalObject[key.value] = value.value;
94
95
  }
95
96
  }
@@ -30,8 +30,8 @@ var util;
30
30
  return obj[e];
31
31
  });
32
32
  };
33
- util.objectKeys = typeof Object.keys === "function"
34
- ? (obj) => Object.keys(obj)
33
+ util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
34
+ ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
35
35
  : (object) => {
36
36
  const keys = [];
37
37
  for (const key in object) {
@@ -49,7 +49,7 @@ var util;
49
49
  return undefined;
50
50
  };
51
51
  util.isInteger = typeof Number.isInteger === "function"
52
- ? (val) => Number.isInteger(val)
52
+ ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
53
53
  : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
54
54
  function joinValues(array, separator = " | ") {
55
55
  return array
@@ -69,7 +69,7 @@ var objectUtil;
69
69
  objectUtil.mergeShapes = (first, second) => {
70
70
  return {
71
71
  ...first,
72
- ...second,
72
+ ...second, // second overwrites first
73
73
  };
74
74
  };
75
75
  })(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
@@ -478,7 +478,8 @@ class ParseStatus {
478
478
  status.dirty();
479
479
  if (value.status === "dirty")
480
480
  status.dirty();
481
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
481
+ if (key.value !== "__proto__" &&
482
+ (typeof value.value !== "undefined" || pair.alwaysSet)) {
482
483
  finalObject[key.value] = value.value;
483
484
  }
484
485
  }
@@ -586,6 +587,7 @@ class ZodType {
586
587
  this.catch = this.catch.bind(this);
587
588
  this.describe = this.describe.bind(this);
588
589
  this.pipe = this.pipe.bind(this);
590
+ this.readonly = this.readonly.bind(this);
589
591
  this.isNullable = this.isNullable.bind(this);
590
592
  this.isOptional = this.isOptional.bind(this);
591
593
  }
@@ -802,6 +804,9 @@ class ZodType {
802
804
  pipe(target) {
803
805
  return ZodPipeline.create(this, target);
804
806
  }
807
+ readonly() {
808
+ return ZodReadonly.create(this);
809
+ }
805
810
  isOptional() {
806
811
  return this.safeParse(undefined).success;
807
812
  }
@@ -811,17 +816,28 @@ class ZodType {
811
816
  }
812
817
  const cuidRegex = /^c[^\s-]{8,}$/i;
813
818
  const cuid2Regex = /^[a-z][a-z0-9]*$/;
814
- const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
815
- const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
819
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
820
+ // const uuidRegex =
821
+ // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
822
+ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
816
823
  // from https://stackoverflow.com/a/46181/1550155
817
824
  // old version: too slow, didn't support unicode
818
825
  // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
819
826
  //old email regex
820
827
  // const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
821
828
  // eslint-disable-next-line
822
- const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
829
+ // const emailRegex =
830
+ // /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
831
+ // const emailRegex =
832
+ // /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
833
+ // const emailRegex =
834
+ // /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
835
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
836
+ // const emailRegex =
837
+ // /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
823
838
  // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
824
- const emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
839
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
840
+ let emojiRegex;
825
841
  const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
826
842
  const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
827
843
  // Adapted from https://stackoverflow.com/a/3143231
@@ -861,31 +877,6 @@ function isValidIP(ip, version) {
861
877
  return false;
862
878
  }
863
879
  class ZodString extends ZodType {
864
- constructor() {
865
- super(...arguments);
866
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
867
- validation,
868
- code: ZodIssueCode.invalid_string,
869
- ...errorUtil.errToObj(message),
870
- });
871
- /**
872
- * @deprecated Use z.string().min(1) instead.
873
- * @see {@link ZodString.min}
874
- */
875
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
876
- this.trim = () => new ZodString({
877
- ...this._def,
878
- checks: [...this._def.checks, { kind: "trim" }],
879
- });
880
- this.toLowerCase = () => new ZodString({
881
- ...this._def,
882
- checks: [...this._def.checks, { kind: "toLowerCase" }],
883
- });
884
- this.toUpperCase = () => new ZodString({
885
- ...this._def,
886
- checks: [...this._def.checks, { kind: "toUpperCase" }],
887
- });
888
- }
889
880
  _parse(input) {
890
881
  if (this._def.coerce) {
891
882
  input.data = String(input.data);
@@ -973,6 +964,9 @@ class ZodString extends ZodType {
973
964
  }
974
965
  }
975
966
  else if (check.kind === "emoji") {
967
+ if (!emojiRegex) {
968
+ emojiRegex = new RegExp(_emojiRegex, "u");
969
+ }
976
970
  if (!emojiRegex.test(input.data)) {
977
971
  ctx = this._getOrReturnCtx(input, ctx);
978
972
  addIssueToContext(ctx, {
@@ -1125,6 +1119,13 @@ class ZodString extends ZodType {
1125
1119
  }
1126
1120
  return { status: status.value, value: input.data };
1127
1121
  }
1122
+ _regex(regex, validation, message) {
1123
+ return this.refinement((data) => regex.test(data), {
1124
+ validation,
1125
+ code: ZodIssueCode.invalid_string,
1126
+ ...errorUtil.errToObj(message),
1127
+ });
1128
+ }
1128
1129
  _addCheck(check) {
1129
1130
  return new ZodString({
1130
1131
  ...this._def,
@@ -1222,6 +1223,31 @@ class ZodString extends ZodType {
1222
1223
  ...errorUtil.errToObj(message),
1223
1224
  });
1224
1225
  }
1226
+ /**
1227
+ * @deprecated Use z.string().min(1) instead.
1228
+ * @see {@link ZodString.min}
1229
+ */
1230
+ nonempty(message) {
1231
+ return this.min(1, errorUtil.errToObj(message));
1232
+ }
1233
+ trim() {
1234
+ return new ZodString({
1235
+ ...this._def,
1236
+ checks: [...this._def.checks, { kind: "trim" }],
1237
+ });
1238
+ }
1239
+ toLowerCase() {
1240
+ return new ZodString({
1241
+ ...this._def,
1242
+ checks: [...this._def.checks, { kind: "toLowerCase" }],
1243
+ });
1244
+ }
1245
+ toUpperCase() {
1246
+ return new ZodString({
1247
+ ...this._def,
1248
+ checks: [...this._def.checks, { kind: "toUpperCase" }],
1249
+ });
1250
+ }
1225
1251
  get isDatetime() {
1226
1252
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1227
1253
  }
@@ -2930,6 +2956,12 @@ class ZodRecord extends ZodType {
2930
2956
  }
2931
2957
  }
2932
2958
  class ZodMap extends ZodType {
2959
+ get keySchema() {
2960
+ return this._def.keyType;
2961
+ }
2962
+ get valueSchema() {
2963
+ return this._def.valueType;
2964
+ }
2933
2965
  _parse(input) {
2934
2966
  const { status, ctx } = this._processInputParams(input);
2935
2967
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -3126,16 +3158,20 @@ class ZodFunction extends ZodType {
3126
3158
  const params = { errorMap: ctx.common.contextualErrorMap };
3127
3159
  const fn = ctx.data;
3128
3160
  if (this._def.returns instanceof ZodPromise) {
3129
- return OK(async (...args) => {
3161
+ // Would love a way to avoid disabling this rule, but we need
3162
+ // an alias (using an arrow function was what caused 2651).
3163
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
3164
+ const me = this;
3165
+ return OK(async function (...args) {
3130
3166
  const error = new ZodError([]);
3131
- const parsedArgs = await this._def.args
3167
+ const parsedArgs = await me._def.args
3132
3168
  .parseAsync(args, params)
3133
3169
  .catch((e) => {
3134
3170
  error.addIssue(makeArgsIssue(args, e));
3135
3171
  throw error;
3136
3172
  });
3137
- const result = await fn(...parsedArgs);
3138
- const parsedReturns = await this._def.returns._def.type
3173
+ const result = await Reflect.apply(fn, this, parsedArgs);
3174
+ const parsedReturns = await me._def.returns._def.type
3139
3175
  .parseAsync(result, params)
3140
3176
  .catch((e) => {
3141
3177
  error.addIssue(makeReturnsIssue(result, e));
@@ -3145,13 +3181,17 @@ class ZodFunction extends ZodType {
3145
3181
  });
3146
3182
  }
3147
3183
  else {
3148
- return OK((...args) => {
3149
- const parsedArgs = this._def.args.safeParse(args, params);
3184
+ // Would love a way to avoid disabling this rule, but we need
3185
+ // an alias (using an arrow function was what caused 2651).
3186
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
3187
+ const me = this;
3188
+ return OK(function (...args) {
3189
+ const parsedArgs = me._def.args.safeParse(args, params);
3150
3190
  if (!parsedArgs.success) {
3151
3191
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3152
3192
  }
3153
- const result = fn(...parsedArgs.data);
3154
- const parsedReturns = this._def.returns.safeParse(result, params);
3193
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3194
+ const parsedReturns = me._def.returns.safeParse(result, params);
3155
3195
  if (!parsedReturns.success) {
3156
3196
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3157
3197
  }
@@ -3239,7 +3279,7 @@ ZodLiteral.create = (value, params) => {
3239
3279
  };
3240
3280
  function createZodEnum(values, params) {
3241
3281
  return new ZodEnum({
3242
- values: values,
3282
+ values,
3243
3283
  typeName: ZodFirstPartyTypeKind.ZodEnum,
3244
3284
  ...processCreateParams(params),
3245
3285
  });
@@ -3381,8 +3421,29 @@ class ZodEffects extends ZodType {
3381
3421
  _parse(input) {
3382
3422
  const { status, ctx } = this._processInputParams(input);
3383
3423
  const effect = this._def.effect || null;
3424
+ const checkCtx = {
3425
+ addIssue: (arg) => {
3426
+ addIssueToContext(ctx, arg);
3427
+ if (arg.fatal) {
3428
+ status.abort();
3429
+ }
3430
+ else {
3431
+ status.dirty();
3432
+ }
3433
+ },
3434
+ get path() {
3435
+ return ctx.path;
3436
+ },
3437
+ };
3438
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3384
3439
  if (effect.type === "preprocess") {
3385
- const processed = effect.transform(ctx.data);
3440
+ const processed = effect.transform(ctx.data, checkCtx);
3441
+ if (ctx.common.issues.length) {
3442
+ return {
3443
+ status: "dirty",
3444
+ value: ctx.data,
3445
+ };
3446
+ }
3386
3447
  if (ctx.common.async) {
3387
3448
  return Promise.resolve(processed).then((processed) => {
3388
3449
  return this._def.schema._parseAsync({
@@ -3400,21 +3461,6 @@ class ZodEffects extends ZodType {
3400
3461
  });
3401
3462
  }
3402
3463
  }
3403
- const checkCtx = {
3404
- addIssue: (arg) => {
3405
- addIssueToContext(ctx, arg);
3406
- if (arg.fatal) {
3407
- status.abort();
3408
- }
3409
- else {
3410
- status.dirty();
3411
- }
3412
- },
3413
- get path() {
3414
- return ctx.path;
3415
- },
3416
- };
3417
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3418
3464
  if (effect.type === "refinement") {
3419
3465
  const executeRefinement = (acc
3420
3466
  // effect: RefinementEffect<any>
@@ -3718,8 +3764,24 @@ class ZodPipeline extends ZodType {
3718
3764
  });
3719
3765
  }
3720
3766
  }
3767
+ class ZodReadonly extends ZodType {
3768
+ _parse(input) {
3769
+ const result = this._def.innerType._parse(input);
3770
+ if (isValid(result)) {
3771
+ result.value = Object.freeze(result.value);
3772
+ }
3773
+ return result;
3774
+ }
3775
+ }
3776
+ ZodReadonly.create = (type, params) => {
3777
+ return new ZodReadonly({
3778
+ innerType: type,
3779
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3780
+ ...processCreateParams(params),
3781
+ });
3782
+ };
3721
3783
  const custom = (check, params = {},
3722
- /*
3784
+ /**
3723
3785
  * @deprecated
3724
3786
  *
3725
3787
  * Pass `fatal` into the params object instead:
@@ -3786,6 +3848,7 @@ var ZodFirstPartyTypeKind;
3786
3848
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
3787
3849
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3788
3850
  ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
3851
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
3789
3852
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3790
3853
  const instanceOfType = (
3791
3854
  // const instanceOfType = <T extends new (...args: any[]) => any>(
@@ -3899,6 +3962,7 @@ var z = /*#__PURE__*/Object.freeze({
3899
3962
  BRAND: BRAND,
3900
3963
  ZodBranded: ZodBranded,
3901
3964
  ZodPipeline: ZodPipeline,
3965
+ ZodReadonly: ZodReadonly,
3902
3966
  custom: custom,
3903
3967
  Schema: ZodType,
3904
3968
  ZodSchema: ZodType,
@@ -3950,4 +4014,4 @@ var z = /*#__PURE__*/Object.freeze({
3950
4014
  ZodError: ZodError
3951
4015
  });
3952
4016
 
3953
- export { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodSymbol, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, z as default, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void, z };
4017
+ export { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodSymbol, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, z as default, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void, z };