@aws-amplify/graphql-model-transformer 1.3.5-agqlac.0 → 1.3.6

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 (267) hide show
  1. package/CHANGELOG.md +9 -4
  2. package/lib/rds-lambda.zip +0 -0
  3. package/lib/resources/dynamo-model-resource-generator.d.ts.map +1 -1
  4. package/lib/resources/dynamo-model-resource-generator.js.map +1 -1
  5. package/package.json +6 -6
  6. package/rds-lambda/node_modules/.package-lock.json +1514 -1505
  7. package/rds-lambda/node_modules/@aws-sdk/client-ssm/README.md +1 -1
  8. package/rds-lambda/node_modules/@aws-sdk/client-ssm/package.json +32 -31
  9. package/rds-lambda/node_modules/@aws-sdk/client-sso/package.json +28 -27
  10. package/rds-lambda/node_modules/@aws-sdk/client-sso-oidc/package.json +28 -27
  11. package/rds-lambda/node_modules/@aws-sdk/client-sts/package.json +33 -32
  12. package/rds-lambda/node_modules/@aws-sdk/credential-provider-env/package.json +3 -2
  13. package/rds-lambda/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -8
  14. package/rds-lambda/node_modules/@aws-sdk/credential-provider-node/package.json +10 -9
  15. package/rds-lambda/node_modules/@aws-sdk/credential-provider-process/package.json +4 -3
  16. package/rds-lambda/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -5
  17. package/rds-lambda/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -2
  18. package/rds-lambda/node_modules/@aws-sdk/middleware-host-header/package.json +3 -2
  19. package/rds-lambda/node_modules/@aws-sdk/middleware-logger/package.json +2 -1
  20. package/rds-lambda/node_modules/@aws-sdk/middleware-recursion-detection/package.json +3 -2
  21. package/rds-lambda/node_modules/@aws-sdk/middleware-sdk-sts/package.json +3 -2
  22. package/rds-lambda/node_modules/@aws-sdk/middleware-signing/package.json +6 -5
  23. package/rds-lambda/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -2
  24. package/rds-lambda/node_modules/@aws-sdk/token-providers/package.json +5 -4
  25. package/rds-lambda/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -1
  26. package/rds-lambda/node_modules/@aws-sdk/util-user-agent-node/package.json +3 -2
  27. package/rds-lambda/node_modules/@babel/compat-data/README.md +1 -1
  28. package/rds-lambda/node_modules/@babel/compat-data/data/corejs2-built-ins.json +146 -0
  29. package/rds-lambda/node_modules/@babel/compat-data/data/native-modules.json +1 -1
  30. package/rds-lambda/node_modules/@babel/compat-data/data/plugin-bugfixes.json +15 -0
  31. package/rds-lambda/node_modules/@babel/compat-data/data/plugins.json +68 -9
  32. package/rds-lambda/node_modules/@babel/compat-data/package.json +4 -4
  33. package/rds-lambda/node_modules/@babel/core/README.md +1 -1
  34. package/rds-lambda/node_modules/@babel/core/package.json +10 -10
  35. package/rds-lambda/node_modules/@babel/generator/README.md +1 -1
  36. package/rds-lambda/node_modules/@babel/generator/package.json +4 -3
  37. package/rds-lambda/node_modules/@babel/helper-compilation-targets/README.md +1 -1
  38. package/rds-lambda/node_modules/@babel/helper-compilation-targets/package.json +6 -6
  39. package/rds-lambda/node_modules/@babel/helper-split-export-declaration/README.md +1 -1
  40. package/rds-lambda/node_modules/@babel/helper-split-export-declaration/package.json +1 -1
  41. package/rds-lambda/node_modules/@babel/helpers/README.md +1 -1
  42. package/rds-lambda/node_modules/@babel/helpers/package.json +3 -3
  43. package/rds-lambda/node_modules/@babel/parser/README.md +1 -1
  44. package/rds-lambda/node_modules/@babel/parser/package.json +2 -2
  45. package/rds-lambda/node_modules/@babel/traverse/README.md +1 -1
  46. package/rds-lambda/node_modules/@babel/traverse/package.json +4 -4
  47. package/rds-lambda/node_modules/@jest/console/package.json +6 -6
  48. package/rds-lambda/node_modules/@jest/core/package.json +21 -21
  49. package/rds-lambda/node_modules/@jest/environment/package.json +5 -5
  50. package/rds-lambda/node_modules/@jest/expect/package.json +6 -6
  51. package/rds-lambda/node_modules/@jest/expect-utils/package.json +5 -5
  52. package/rds-lambda/node_modules/@jest/fake-timers/package.json +7 -7
  53. package/rds-lambda/node_modules/@jest/globals/package.json +6 -6
  54. package/rds-lambda/node_modules/@jest/reporters/package.json +14 -14
  55. package/rds-lambda/node_modules/@jest/schemas/package.json +3 -3
  56. package/rds-lambda/node_modules/@jest/source-map/package.json +3 -3
  57. package/rds-lambda/node_modules/@jest/test-result/package.json +6 -6
  58. package/rds-lambda/node_modules/@jest/test-sequencer/package.json +5 -5
  59. package/rds-lambda/node_modules/@jest/transform/package.json +7 -7
  60. package/rds-lambda/node_modules/@jest/types/package.json +5 -5
  61. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/CHANGELOG.md +70 -0
  62. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/LICENSE +15 -0
  63. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/README.md +454 -0
  64. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/package.json +28 -0
  65. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/range.bnf +16 -0
  66. package/rds-lambda/node_modules/@sinclair/typebox/package.json +3 -8
  67. package/rds-lambda/node_modules/@sinclair/typebox/readme.md +487 -300
  68. package/rds-lambda/node_modules/@smithy/abort-controller/README.md +4 -0
  69. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/abort-controller/package.json +14 -8
  70. package/rds-lambda/node_modules/@smithy/config-resolver/README.md +10 -0
  71. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/config-resolver/package.json +17 -11
  72. package/rds-lambda/node_modules/@smithy/credential-provider-imds/README.md +11 -0
  73. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/credential-provider-imds/package.json +17 -11
  74. package/rds-lambda/node_modules/@smithy/eventstream-codec/README.md +4 -0
  75. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/eventstream-codec/package.json +16 -10
  76. package/rds-lambda/node_modules/@smithy/fetch-http-handler/README.md +4 -0
  77. package/rds-lambda/node_modules/@smithy/fetch-http-handler/package.json +81 -0
  78. package/rds-lambda/node_modules/@smithy/hash-node/README.md +10 -0
  79. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/hash-node/package.json +16 -10
  80. package/rds-lambda/node_modules/@smithy/invalid-dependency/README.md +10 -0
  81. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/invalid-dependency/package.json +14 -8
  82. package/rds-lambda/node_modules/@smithy/is-array-buffer/README.md +10 -0
  83. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/is-array-buffer/package.json +13 -7
  84. package/rds-lambda/node_modules/@smithy/middleware-content-length/README.md +4 -0
  85. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-content-length/package.json +16 -11
  86. package/rds-lambda/node_modules/@smithy/middleware-endpoint/README.md +10 -0
  87. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-endpoint/package.json +18 -13
  88. package/rds-lambda/node_modules/@smithy/middleware-retry/README.md +4 -0
  89. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/package.json +20 -15
  90. package/rds-lambda/node_modules/@smithy/middleware-serde/README.md +4 -0
  91. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-serde/package.json +15 -10
  92. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-stack/README.md +3 -3
  93. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-stack/package.json +15 -10
  94. package/rds-lambda/node_modules/@smithy/node-config-provider/README.md +4 -0
  95. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/node-config-provider/package.json +16 -10
  96. package/rds-lambda/node_modules/@smithy/node-http-handler/README.md +4 -0
  97. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/node-http-handler/package.json +18 -12
  98. package/rds-lambda/node_modules/@smithy/property-provider/README.md +10 -0
  99. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/property-provider/package.json +14 -8
  100. package/rds-lambda/node_modules/@smithy/protocol-http/package.json +3 -3
  101. package/rds-lambda/node_modules/@smithy/querystring-builder/README.md +10 -0
  102. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/querystring-builder/package.json +15 -9
  103. package/rds-lambda/node_modules/@smithy/querystring-parser/README.md +10 -0
  104. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/querystring-parser/package.json +14 -8
  105. package/rds-lambda/node_modules/@smithy/service-error-classification/README.md +4 -0
  106. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/service-error-classification/package.json +14 -8
  107. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/shared-ini-file-loader/README.md +3 -3
  108. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/shared-ini-file-loader/package.json +14 -8
  109. package/rds-lambda/node_modules/@smithy/signature-v4/README.md +4 -0
  110. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/signature-v4/package.json +21 -15
  111. package/rds-lambda/node_modules/@smithy/smithy-client/README.md +10 -0
  112. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/smithy-client/package.json +16 -11
  113. package/rds-lambda/node_modules/@smithy/types/package.json +2 -2
  114. package/rds-lambda/node_modules/@smithy/url-parser/README.md +10 -0
  115. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/url-parser/package.json +15 -9
  116. package/rds-lambda/node_modules/@smithy/util-base64/README.md +4 -0
  117. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-base64/package.json +14 -8
  118. package/rds-lambda/node_modules/@smithy/util-body-length-browser/README.md +12 -0
  119. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-body-length-browser/package.json +13 -7
  120. package/rds-lambda/node_modules/@smithy/util-body-length-node/README.md +12 -0
  121. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-body-length-node/package.json +13 -7
  122. package/rds-lambda/node_modules/@smithy/util-buffer-from/README.md +10 -0
  123. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-buffer-from/package.json +14 -8
  124. package/rds-lambda/node_modules/@smithy/util-config-provider/README.md +4 -0
  125. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-config-provider/package.json +13 -7
  126. package/rds-lambda/node_modules/@smithy/util-defaults-mode-browser/README.md +10 -0
  127. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-defaults-mode-browser/package.json +17 -10
  128. package/rds-lambda/node_modules/@smithy/util-defaults-mode-node/README.md +10 -0
  129. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-defaults-mode-node/package.json +20 -13
  130. package/rds-lambda/node_modules/@smithy/util-hex-encoding/README.md +4 -0
  131. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-hex-encoding/package.json +13 -7
  132. package/rds-lambda/node_modules/@smithy/util-middleware/README.md +12 -0
  133. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-middleware/package.json +14 -8
  134. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-retry/README.md +7 -7
  135. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-retry/package.json +15 -9
  136. package/rds-lambda/node_modules/@smithy/util-stream/README.md +12 -0
  137. package/rds-lambda/node_modules/@smithy/util-stream/package.json +92 -0
  138. package/rds-lambda/node_modules/@smithy/util-uri-escape/README.md +10 -0
  139. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-uri-escape/package.json +13 -7
  140. package/rds-lambda/node_modules/@smithy/util-utf8/README.md +4 -0
  141. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-utf8/package.json +14 -8
  142. package/rds-lambda/node_modules/@smithy/util-waiter/README.md +10 -0
  143. package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-waiter/package.json +15 -9
  144. package/rds-lambda/node_modules/@types/node/README.md +1 -1
  145. package/rds-lambda/node_modules/@types/node/package.json +2 -2
  146. package/rds-lambda/node_modules/babel-jest/package.json +4 -4
  147. package/rds-lambda/node_modules/caniuse-lite/package.json +1 -1
  148. package/rds-lambda/node_modules/collect-v8-coverage/CHANGELOG.md +7 -0
  149. package/rds-lambda/node_modules/collect-v8-coverage/package.json +18 -20
  150. package/rds-lambda/node_modules/electron-to-chromium/full-chromium-versions.json +1 -1
  151. package/rds-lambda/node_modules/electron-to-chromium/full-versions.json +1 -1
  152. package/rds-lambda/node_modules/electron-to-chromium/package.json +1 -1
  153. package/rds-lambda/node_modules/expect/package.json +10 -9
  154. package/rds-lambda/node_modules/jest/package.json +7 -7
  155. package/rds-lambda/node_modules/jest-circus/package.json +15 -14
  156. package/rds-lambda/node_modules/jest-cli/package.json +10 -9
  157. package/rds-lambda/node_modules/jest-config/package.json +14 -14
  158. package/rds-lambda/node_modules/jest-diff/package.json +4 -4
  159. package/rds-lambda/node_modules/jest-each/package.json +5 -5
  160. package/rds-lambda/node_modules/jest-environment-node/package.json +8 -8
  161. package/rds-lambda/node_modules/jest-haste-map/package.json +5 -5
  162. package/rds-lambda/node_modules/jest-leak-detector/package.json +3 -3
  163. package/rds-lambda/node_modules/jest-matcher-utils/package.json +5 -5
  164. package/rds-lambda/node_modules/jest-message-util/package.json +4 -4
  165. package/rds-lambda/node_modules/jest-mock/package.json +6 -6
  166. package/rds-lambda/node_modules/jest-resolve/package.json +7 -7
  167. package/rds-lambda/node_modules/jest-resolve-dependencies/package.json +8 -8
  168. package/rds-lambda/node_modules/jest-runner/package.json +20 -20
  169. package/rds-lambda/node_modules/jest-runtime/package.json +17 -17
  170. package/rds-lambda/node_modules/jest-snapshot/package.json +15 -17
  171. package/rds-lambda/node_modules/jest-util/package.json +3 -3
  172. package/rds-lambda/node_modules/jest-validate/package.json +4 -4
  173. package/rds-lambda/node_modules/jest-watcher/package.json +5 -5
  174. package/rds-lambda/node_modules/jest-worker/package.json +6 -6
  175. package/rds-lambda/node_modules/node-releases/data/processed/envs.json +1 -1
  176. package/rds-lambda/node_modules/node-releases/package.json +1 -1
  177. package/rds-lambda/node_modules/pretty-format/package.json +5 -5
  178. package/rds-lambda/node_modules/ts-jest/.ts-jest-digest +1 -1
  179. package/rds-lambda/node_modules/ts-jest/CHANGELOG.md +9 -0
  180. package/rds-lambda/node_modules/ts-jest/package.json +12 -12
  181. package/rds-lambda/package-lock.json +1514 -1505
  182. package/src/index.ts +1 -0
  183. package/src/resources/dynamo-model-resource-generator.ts +0 -4
  184. package/tsconfig.tsbuildinfo +1 -1
  185. package/rds-lambda/node_modules/@aws-sdk/abort-controller/README.md +0 -4
  186. package/rds-lambda/node_modules/@aws-sdk/config-resolver/README.md +0 -10
  187. package/rds-lambda/node_modules/@aws-sdk/credential-provider-imds/README.md +0 -11
  188. package/rds-lambda/node_modules/@aws-sdk/eventstream-codec/README.md +0 -4
  189. package/rds-lambda/node_modules/@aws-sdk/fetch-http-handler/README.md +0 -4
  190. package/rds-lambda/node_modules/@aws-sdk/fetch-http-handler/package.json +0 -59
  191. package/rds-lambda/node_modules/@aws-sdk/hash-node/README.md +0 -10
  192. package/rds-lambda/node_modules/@aws-sdk/invalid-dependency/README.md +0 -10
  193. package/rds-lambda/node_modules/@aws-sdk/is-array-buffer/README.md +0 -10
  194. package/rds-lambda/node_modules/@aws-sdk/middleware-content-length/README.md +0 -4
  195. package/rds-lambda/node_modules/@aws-sdk/middleware-endpoint/README.md +0 -10
  196. package/rds-lambda/node_modules/@aws-sdk/middleware-retry/README.md +0 -4
  197. package/rds-lambda/node_modules/@aws-sdk/middleware-serde/README.md +0 -4
  198. package/rds-lambda/node_modules/@aws-sdk/node-config-provider/README.md +0 -4
  199. package/rds-lambda/node_modules/@aws-sdk/node-http-handler/README.md +0 -4
  200. package/rds-lambda/node_modules/@aws-sdk/property-provider/README.md +0 -10
  201. package/rds-lambda/node_modules/@aws-sdk/protocol-http/README.md +0 -4
  202. package/rds-lambda/node_modules/@aws-sdk/protocol-http/package.json +0 -57
  203. package/rds-lambda/node_modules/@aws-sdk/querystring-builder/README.md +0 -10
  204. package/rds-lambda/node_modules/@aws-sdk/querystring-parser/README.md +0 -10
  205. package/rds-lambda/node_modules/@aws-sdk/service-error-classification/README.md +0 -4
  206. package/rds-lambda/node_modules/@aws-sdk/signature-v4/README.md +0 -4
  207. package/rds-lambda/node_modules/@aws-sdk/smithy-client/LICENSE +0 -201
  208. package/rds-lambda/node_modules/@aws-sdk/smithy-client/README.md +0 -10
  209. package/rds-lambda/node_modules/@aws-sdk/url-parser/README.md +0 -10
  210. package/rds-lambda/node_modules/@aws-sdk/util-base64/README.md +0 -4
  211. package/rds-lambda/node_modules/@aws-sdk/util-body-length-browser/README.md +0 -12
  212. package/rds-lambda/node_modules/@aws-sdk/util-body-length-node/README.md +0 -12
  213. package/rds-lambda/node_modules/@aws-sdk/util-buffer-from/README.md +0 -10
  214. package/rds-lambda/node_modules/@aws-sdk/util-config-provider/README.md +0 -4
  215. package/rds-lambda/node_modules/@aws-sdk/util-defaults-mode-browser/README.md +0 -10
  216. package/rds-lambda/node_modules/@aws-sdk/util-defaults-mode-node/README.md +0 -10
  217. package/rds-lambda/node_modules/@aws-sdk/util-hex-encoding/README.md +0 -4
  218. package/rds-lambda/node_modules/@aws-sdk/util-middleware/README.md +0 -12
  219. package/rds-lambda/node_modules/@aws-sdk/util-stream/README.md +0 -12
  220. package/rds-lambda/node_modules/@aws-sdk/util-stream/package.json +0 -71
  221. package/rds-lambda/node_modules/@aws-sdk/util-uri-escape/README.md +0 -10
  222. package/rds-lambda/node_modules/@aws-sdk/util-utf8/README.md +0 -4
  223. package/rds-lambda/node_modules/@aws-sdk/util-waiter/README.md +0 -10
  224. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/abort-controller/LICENSE +0 -0
  225. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/config-resolver/LICENSE +0 -0
  226. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/credential-provider-imds/LICENSE +0 -0
  227. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/eventstream-codec/LICENSE +0 -0
  228. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/fetch-http-handler/LICENSE +0 -0
  229. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/hash-node/LICENSE +0 -0
  230. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/invalid-dependency/LICENSE +0 -0
  231. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/is-array-buffer/LICENSE +0 -0
  232. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-content-length/LICENSE +0 -0
  233. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-endpoint/LICENSE +0 -0
  234. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/LICENSE +0 -0
  235. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/CHANGELOG.md +0 -0
  236. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/CONTRIBUTING.md +0 -0
  237. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/LICENSE.md +0 -0
  238. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/README.md +0 -0
  239. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/dist/bin/uuid +0 -0
  240. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/package.json +0 -0
  241. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-retry/node_modules/uuid/wrapper.mjs +0 -0
  242. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-serde/LICENSE +0 -0
  243. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/middleware-stack/LICENSE +0 -0
  244. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/node-config-provider/LICENSE +0 -0
  245. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/node-http-handler/LICENSE +0 -0
  246. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/property-provider/LICENSE +0 -0
  247. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/querystring-builder/LICENSE +0 -0
  248. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/querystring-parser/LICENSE +0 -0
  249. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/service-error-classification/LICENSE +0 -0
  250. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/shared-ini-file-loader/LICENSE +0 -0
  251. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/signature-v4/LICENSE +0 -0
  252. /package/rds-lambda/node_modules/{@aws-sdk/protocol-http → @smithy/smithy-client}/LICENSE +0 -0
  253. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/url-parser/LICENSE +0 -0
  254. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-base64/LICENSE +0 -0
  255. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-body-length-browser/LICENSE +0 -0
  256. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-body-length-node/LICENSE +0 -0
  257. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-buffer-from/LICENSE +0 -0
  258. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-config-provider/LICENSE +0 -0
  259. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-defaults-mode-browser/LICENSE +0 -0
  260. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-defaults-mode-node/LICENSE +0 -0
  261. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-hex-encoding/LICENSE +0 -0
  262. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-middleware/LICENSE +0 -0
  263. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-retry/LICENSE +0 -0
  264. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-stream/LICENSE +0 -0
  265. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-uri-escape/LICENSE +0 -0
  266. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-utf8/LICENSE +0 -0
  267. /package/rds-lambda/node_modules/{@aws-sdk → @smithy}/util-waiter/LICENSE +0 -0
@@ -35,7 +35,7 @@ import { Static, Type } from 'npm:@sinclair/typebox'
35
35
  import { Static, Type } from 'https://esm.sh/@sinclair/typebox'
36
36
  ```
37
37
 
38
- ## Usage
38
+ ## Example
39
39
 
40
40
  ```typescript
41
41
  import { Static, Type } from '@sinclair/typebox'
@@ -62,59 +62,62 @@ type T = Static<typeof T> // type T = {
62
62
 
63
63
  ## Overview
64
64
 
65
- TypeBox is a type builder library that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.
65
+ TypeBox is a runtime type builder that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type assertion rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.
66
66
 
67
- This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used either as a simple tool to build up complex schemas or integrated into REST and RPC services to help validate data received over the wire.
67
+ This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.
68
68
 
69
69
  License MIT
70
70
 
71
71
  ## Contents
72
72
  - [Install](#install)
73
73
  - [Overview](#overview)
74
- - [Example](#Example)
74
+ - [Usage](#usage)
75
75
  - [Types](#types)
76
76
  - [Standard](#types-standard)
77
77
  - [Extended](#types-extended)
78
78
  - [Modifiers](#types-modifiers)
79
79
  - [Options](#types-options)
80
- - [Reference](#types-reference)
80
+ - [Generics](#types-generics)
81
+ - [References](#types-references)
81
82
  - [Recursive](#types-recursive)
82
- - [Generic](#types-generic)
83
83
  - [Conditional](#types-conditional)
84
- - [Unsafe](#types-unsafe)
84
+ - [Template Literal](#types-template-literal)
85
85
  - [Guards](#types-guards)
86
+ - [Unsafe](#types-unsafe)
86
87
  - [Strict](#types-strict)
87
88
  - [Values](#values)
88
89
  - [Create](#values-create)
89
90
  - [Clone](#values-clone)
90
91
  - [Check](#values-check)
92
+ - [Convert](#values-convert)
91
93
  - [Cast](#values-cast)
92
94
  - [Equal](#values-equal)
93
95
  - [Hash](#values-hash)
94
96
  - [Diff](#values-diff)
95
97
  - [Patch](#values-patch)
96
98
  - [Errors](#values-errors)
99
+ - [Mutate](#values-mutate)
97
100
  - [Pointer](#values-pointer)
98
101
  - [TypeCheck](#typecheck)
99
102
  - [Ajv](#typecheck-ajv)
100
103
  - [TypeCompiler](#typecheck-typecompiler)
101
- - [TypeSystem](#typecheck)
104
+ - [TypeSystem](#typesystem)
102
105
  - [Types](#typesystem-types)
103
106
  - [Formats](#typesystem-formats)
107
+ - [Policies](#typesystem-policies)
104
108
  - [Benchmark](#benchmark)
105
109
  - [Compile](#benchmark-compile)
106
110
  - [Validate](#benchmark-validate)
107
111
  - [Compression](#benchmark-compression)
108
112
  - [Contribute](#contribute)
109
113
 
110
- <a name="Example"></a>
114
+ <a name="usage"></a>
111
115
 
112
- ## Example
116
+ ## Usage
113
117
 
114
- The following demonstrates TypeBox's general usage.
118
+ The following shows general usage.
115
119
 
116
120
  ```typescript
117
-
118
121
  import { Static, Type } from '@sinclair/typebox'
119
122
 
120
123
  //--------------------------------------------------------------------------------------------
@@ -173,9 +176,11 @@ type T = Static<typeof T> // type T = {
173
176
  //
174
177
  //--------------------------------------------------------------------------------------------
175
178
 
176
- function receive(value: T) { // ... as a Type
179
+ import { Value } from '@sinclair/typebox/value'
177
180
 
178
- if(JSON.validate(T, value)) { // ... as a Schema
181
+ function receive(value: T) { // ... as a Static Type
182
+
183
+ if(Value.Check(T, value)) { // ... as a JSON Schema
179
184
 
180
185
  // ok...
181
186
  }
@@ -186,13 +191,13 @@ function receive(value: T) { // ... as a Type
186
191
 
187
192
  ## Types
188
193
 
189
- TypeBox provides a set of functions that allow you to compose JSON Schema similar to how you would compose static types with TypeScript. Each function creates a JSON schema fragment which can compose into more complex types. The schemas produced by TypeBox can be passed directly to any JSON Schema compliant validator, or used to reflect runtime metadata for a type.
194
+ TypeBox types are JSON schema fragments that can be composed into more complex types. Each fragment is structured such that a JSON schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox provides a set of Standard types which are used create JSON schema compliant schematics as well as an Extended type set used to create schematics for constructs native to JavaScript.
190
195
 
191
196
  <a name='types-standard'></a>
192
197
 
193
- ### Standard
198
+ ### Standard Types
194
199
 
195
- The following table lists the Standard TypeBox types.
200
+ The following table lists the Standard TypeBox types. These types are fully compatible with the JSON Schema Draft 6 specification.
196
201
 
197
202
  ```typescript
198
203
  ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
@@ -226,19 +231,13 @@ The following table lists the Standard TypeBox types.
226
231
  │ │ │ │
227
232
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
228
233
  │ const T = Type.Null() │ type T = null │ const T = { │
229
- │ │ │ type: 'null'
230
- │ │ │ } │
231
- │ │ │ │
232
- ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
233
- │ const T = Type.RegEx(/foo/) │ type T = string │ const T = { │
234
- │ │ │ type: 'string', │
235
- │ │ │ pattern: 'foo' │
234
+ │ │ │ type: 'null'
236
235
  │ │ │ } │
237
236
  │ │ │ │
238
237
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
239
238
  │ const T = Type.Literal(42) │ type T = 42 │ const T = { │
240
- │ │ │ const: 42,
241
- │ │ │ type: 'number'
239
+ │ │ │ const: 42,
240
+ │ │ │ type: 'number'
242
241
  │ │ │ } │
243
242
  │ │ │ │
244
243
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
@@ -252,15 +251,14 @@ The following table lists the Standard TypeBox types.
252
251
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
253
252
  │ const T = Type.Object({ │ type T = { │ const T = { │
254
253
  │ x: Type.Number(), │ x: number, │ type: 'object', │
255
- │ y: Type.Number() │ y: number │ properties: {
256
- │ }) │ } │ x: {
257
- │ │ │ type: 'number'
258
- │ │ │ },
259
- │ │ │ y: {
260
- │ │ │ type: 'number'
261
- │ │ │ }
262
- │ │ │ },
263
- │ │ │ required: ['x', 'y'] │
254
+ │ y: Type.Number() │ y: number │ required: ['x', 'y'],
255
+ │ }) │ } │ properties: {
256
+ │ │ │ x: {
257
+ │ │ │ type: 'number'
258
+ │ │ │ }, {
259
+ │ │ │ type: 'number'
260
+ │ │ │ }
261
+ │ │ │ }
264
262
  │ │ │ } │
265
263
  │ │ │ │
266
264
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
@@ -268,12 +266,12 @@ The following table lists the Standard TypeBox types.
268
266
  │ Type.Number(), │ │ type: 'array', │
269
267
  │ Type.Number() │ │ items: [{ │
270
268
  │ ]) │ │ type: 'number' │
271
- │ │ │ }, {
272
- │ │ │ type: 'number'
273
- │ │ │ }],
274
- │ │ │ additionalItems: false,
275
- │ │ │ minItems: 2,
276
- │ │ │ maxItems: 2
269
+ │ │ │ }, {
270
+ │ │ │ type: 'number'
271
+ │ │ │ }],
272
+ │ │ │ additionalItems: false,
273
+ │ │ │ minItems: 2,
274
+ │ │ │ maxItems: 2
277
275
  │ │ │ } │
278
276
  │ │ │ │
279
277
  │ │ │ │
@@ -310,33 +308,101 @@ The following table lists the Standard TypeBox types.
310
308
  │ │ │ │
311
309
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
312
310
  │ const T = Type.Intersect([ │ type T = { │ const T = { │
311
+ │ Type.Object({ │ x: number │ allOf: [{ │
312
+ │ x: Type.Number() │ } & { │ type: 'object', │
313
+ │ }), │ y: number │ required: ['x'], │
314
+ │ Type.Object({ │ } │ properties: { │
315
+ │ y: Type.Number() │ │ x: { │
316
+ │ ]) │ │ type: 'number' │
317
+ │ ]) │ │ } │
318
+ │ │ │ } │
319
+ │ │ │ }, { │
320
+ │ │ │ type: 'object', |
321
+ │ │ │ required: ['y'], │
322
+ │ │ │ properties: { │
323
+ │ │ │ y: { │
324
+ │ │ │ type: 'number' │
325
+ │ │ │ } │
326
+ │ │ │ } │
327
+ │ │ │ }] │
328
+ │ │ │ } │
329
+ │ │ │ │
330
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
331
+ │ const T = Type.Composite([ │ type I = { │ const T = { │
313
332
  │ Type.Object({ │ x: number │ type: 'object', │
314
- │ x: Type.Number() │ } & { │ properties: {
315
- │ }), │ y: number │ x: {
316
- │ Type.Object({ │ } │ type: 'number'
317
- │ y: Type.Number() │ │ },
318
- │ }) │ │ y: {
319
- │ ]) │ type: 'number'
333
+ │ x: Type.Number() │ } & { │ required: ['x', 'y'],
334
+ │ }), │ y: number │ properties: {
335
+ │ Type.Object({ │ } │ x: {
336
+ │ y: Type.Number() │ │ type: 'number'
337
+ │ }) │ type T = { }, │
338
+ │ ]) │ [K in keyof I]: I[K] y: {
339
+ │ │ } │ type: 'number' │
320
340
  │ │ │ } │
321
- │ │ │ },
322
- │ │ │ required: ['x', 'y'] │
341
+ │ │ │ }
323
342
  │ │ │ } │
324
343
  │ │ │ │
325
344
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
326
345
  │ const T = Type.Never() │ type T = never │ const T = { │
327
- │ │ │ allOf: [{
328
- │ │ │ type: 'boolean',
329
- │ │ │ const: false
346
+ │ │ │ not: {}
347
+ │ │ │ }
348
+ │ │ │
349
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
350
+ │ const T = Type.Not( | type T = string │ const T = { │
351
+ | Type.Union([ │ │ allOf: [{ │
352
+ │ Type.Literal('x'), │ │ not: { │
353
+ │ Type.Literal('y'), │ │ anyOf: [ │
354
+ │ Type.Literal('z') │ │ { const: 'x' }, │
355
+ │ ]), │ │ { const: 'y' }, │
356
+ │ Type.String() │ │ { const: 'z' } │
357
+ │ ) │ │ ] │
358
+ │ │ │ } │
330
359
  │ │ │ }, { │
331
- │ │ │ type: 'boolean',
332
- │ │ │ const: true │
360
+ │ │ │ type: 'string'
333
361
  │ │ │ }] │
334
362
  │ │ │ } │
335
363
  │ │ │ │
336
364
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
365
+ │ const T = Type.Extends( │ type T = │ const T = { │
366
+ │ Type.String(), │ string extends number │ const: false, │
367
+ │ Type.Number(), │ true : false │ type: 'boolean' │
368
+ │ Type.Literal(true), │ │ } │
369
+ │ Type.Literal(false) │ │ │
370
+ │ ) │ │ │
371
+ │ │ │ │
372
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
373
+ │ const T = Type.Extract( │ type T = Extract< │ const T = { │
374
+ │ Type.Union([ │ string | number, │ type: 'string' │
375
+ │ Type.String(), │ string │ } │
376
+ │ Type.Number(), │ > │ │
377
+ │ ]), │ │ │
378
+ │ Type.String() │ │ │
379
+ │ ) │ │ │
380
+ │ │ │ │
381
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
382
+ │ const T = Type.Exclude( │ type T = Exclude< │ const T = { │
383
+ │ Type.Union([ │ string | number, │ type: 'number' │
384
+ │ Type.String(), │ string │ } │
385
+ │ Type.Number(), │ > │ │
386
+ │ ]), │ │ │
387
+ │ Type.String() │ │ │
388
+ │ ) │ │ │
389
+ │ │ │ │
390
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
391
+ │ const U = Type.Union([ │ type U = 'open' | 'close' │ const T = { │
392
+ │ Type.Literal('open'), │ │ type: 'string', │
393
+ │ Type.Literal('close') │ type T = `on${U}` │ pattern: '^on(open|close)$' │
394
+ │ ]) │ │ } │
395
+ │ │ │ │
396
+ │ const T = Type │ │ │
397
+ │ .TemplateLiteral([ │ │ │
398
+ │ Type.Literal('on'), │ │ │
399
+ │ U │ │ │
400
+ │ ]) │ │ │
401
+ │ │ │ │
402
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
337
403
  │ const T = Type.Record( │ type T = Record< │ const T = { │
338
404
  │ Type.String(), │ string, │ type: 'object', │
339
- │ Type.Number() │ number, │ patternProperties: { │
405
+ │ Type.Number() │ number │ patternProperties: { │
340
406
  │ ) │ > │ '^.*$': { │
341
407
  │ │ │ type: 'number' │
342
408
  │ │ │ } │
@@ -359,47 +425,58 @@ The following table lists the Standard TypeBox types.
359
425
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
360
426
  │ const T = Type.Required( │ type T = Required<{ │ const T = { │
361
427
  │ Type.Object({ │ x?: number, │ type: 'object', │
362
- │ x: Type.Optional( │ y?: number │ properties: {
363
- │ Type.Number() | }> │ x: {
364
- │ ), │ │ type: 'number'
365
- │ y: Type.Optional( │ │ },
366
- │ Type.Number() │ │ y: {
367
- │ ) │ │ type: 'number'
368
- │ }) │ │ }
369
- │ ) │ │ },
370
- │ │ │ required: ['x', 'y']
428
+ │ x: Type.Optional( │ y?: number │ required: ['x', 'y'],
429
+ │ Type.Number() | }> │ properties: {
430
+ │ ), │ │ x: {
431
+ │ y: Type.Optional( │ │ type: 'number'
432
+ │ Type.Number() │ │ },
433
+ │ ) │ │ y: {
434
+ │ }) │ │ type: 'number'
435
+ │ ) │ │ }
436
+ │ │ │ }
371
437
  │ │ │ } │
372
438
  │ │ │ │
373
439
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
374
440
  │ const T = Type.Pick( │ type T = Pick<{ │ const T = { │
375
441
  │ Type.Object({ │ x: number, │ type: 'object', │
376
- │ x: Type.Number(), │ y: number │ properties: {
377
- │ y: Type.Number() | }, 'x'> │ x: {
378
- │ }), ['x'] type: 'number'
379
- │ ) │ │ }
380
- │ │ │ },
381
- │ │ │ required: ['x']
442
+ │ x: Type.Number(), │ y: number │ required: ['x'],
443
+ │ y: Type.Number() }, 'x'> │ properties: {
444
+ │ }), ['x'] | x: {
445
+ │ ) │ │ type: 'number'
446
+ │ │ │ }
447
+ │ │ │ }
382
448
  │ │ │ } │
383
449
  │ │ │ │
384
450
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
385
451
  │ const T = Type.Omit( │ type T = Omit<{ │ const T = { │
386
452
  │ Type.Object({ │ x: number, │ type: 'object', │
387
- │ x: Type.Number(), │ y: number │ properties: {
388
- │ y: Type.Number() | }, 'x'> │ y: {
389
- │ }), ['x'] type: 'number'
390
- │ ) │ │ }
391
- │ │ │ },
392
- │ │ │ required: ['y']
453
+ │ x: Type.Number(), │ y: number │ required: ['y'],
454
+ │ y: Type.Number() }, 'x'> │ properties: {
455
+ │ }), ['x'] | y: {
456
+ │ ) │ │ type: 'number'
457
+ │ │ │ }
458
+ │ │ │ }
393
459
  │ │ │ } │
394
460
  │ │ │ │
461
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
462
+ │ const T = Type.Object({ │ type T = { │ const R = { │
463
+ │ x: Type.Number(), │ x: number, │ $ref: 'T' │
464
+ │ y: Type.Number() │ y: number │ } │
465
+ │ }, { $id: 'T' }) | } │ │
466
+ │ │ │ │
467
+ │ const R = Type.Ref(T) │ type R = T │ │
468
+ │ │ │ │
469
+ │ │ │ │
470
+ │ │ │ │
471
+ │ │ │ │
395
472
  └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
396
473
  ```
397
474
 
398
475
  <a name='types-extended'></a>
399
476
 
400
- ### Extended
477
+ ### Extended Types
401
478
 
402
- TypeBox provides a set of extended types that can be used to express schematics for core JavaScript constructs and primitives. Extended types are not valid JSON Schema and will not validate using typical validation. These types however can be used to frame JSON schema and describe callable RPC interfaces that may receive JSON validated data.
479
+ TypeBox provides several extended types that can be used to produce schematics for common JavaScript constructs. These types can not be used with standard JSON schema validators; but are useful to help frame schematics for RPC interfaces that may receive JSON validated data. Extended types are prefixed with the `[Extended]` doc comment for convenience. The following table lists the supported types.
403
480
 
404
481
  ```typescript
405
482
  ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
@@ -462,6 +539,24 @@ TypeBox provides a set of extended types that can be used to express schematics
462
539
  │ │ │ } │
463
540
  │ │ │ │
464
541
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
542
+ │ const T = Type.RegEx(/foo/) │ type T = string │ const T = { │
543
+ │ │ │ type: 'string', │
544
+ │ │ │ pattern: 'foo' │
545
+ │ │ │ } │
546
+ │ │ │ │
547
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
548
+ │ const T = Type.Symbol() │ type T = symbol │ const T = { │
549
+ │ │ │ type: 'null', │
550
+ │ │ │ typeOf: 'Symbol' │
551
+ │ │ │ } │
552
+ │ │ │ │
553
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
554
+ │ const T = Type.BigInt() │ type T = bigint │ const T = { │
555
+ │ │ │ type: 'null', │
556
+ │ │ │ typeOf: 'BigInt' │
557
+ │ │ │ } │
558
+ │ │ │ │
559
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
465
560
  │ const T = Type.Void() │ type T = void │ const T = { │
466
561
  │ │ │ type: 'null' │
467
562
  │ │ │ typeOf: 'Void' │
@@ -474,7 +569,7 @@ TypeBox provides a set of extended types that can be used to express schematics
474
569
 
475
570
  ### Modifiers
476
571
 
477
- TypeBox provides modifiers that can be applied to an objects properties. This allows for `optional` and `readonly` to be applied to that property. The following table illustates how they map between TypeScript and JSON Schema.
572
+ TypeBox provides modifiers that allow schema properties to be statically inferred as `readonly` or `optional`. The following table shows the supported modifiers and how they map between TypeScript and JSON Schema.
478
573
 
479
574
  ```typescript
480
575
  ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
@@ -484,9 +579,9 @@ TypeBox provides modifiers that can be applied to an objects properties. This al
484
579
  │ const T = Type.Object({ │ type T = { │ const T = { │
485
580
  │ name: Type.Optional( │ name?: string │ type: 'object', │
486
581
  │ Type.String() │ } │ properties: { │
487
- │ ) │ │ name: {
488
- │ }) │ │ type: 'string'
489
- │ │ │ }
582
+ │ ) │ │ name: {
583
+ │ }) │ │ type: 'string'
584
+ │ │ │ }
490
585
  │ │ │ } │
491
586
  │ │ │ } │
492
587
  │ │ │ │
@@ -518,24 +613,96 @@ TypeBox provides modifiers that can be applied to an objects properties. This al
518
613
 
519
614
  ### Options
520
615
 
521
- You can pass additional JSON schema options on the last argument of any given type. The following are some examples.
616
+ You can pass JSON Schema options on the last argument of any type. Option hints specific to each type are provided for convenience.
617
+
618
+ ```typescript
619
+ // String must be an email
620
+ const T = Type.String({ // const T = {
621
+ format: 'email' // type: 'string',
622
+ }) // format: 'email'
623
+ // }
624
+
625
+ // Mumber must be a multiple of 2
626
+ const T = Type.Number({ // const T = {
627
+ multipleOf: 2 // type: 'number',
628
+ }) // multipleOf: 2
629
+ // }
630
+
631
+ // Array must have at least 5 integer values
632
+ const T = Type.Array(Type.Integer(), { // const T = {
633
+ minItems: 5 // type: 'array',
634
+ }) // minItems: 5,
635
+ // items: {
636
+ // type: 'integer'
637
+ // }
638
+ // }
639
+
640
+ ```
641
+
642
+ <a name='types-generics'></a>
643
+
644
+ ### Generic Types
645
+
646
+ Generic types can be created with generic functions constrained to type `TSchema`. The following creates a generic `Vector<T>` type.
647
+
648
+ ```typescript
649
+ import { Type, Static, TSchema } from '@sinclair/typebox'
650
+
651
+ const Vector = <T extends TSchema>(t: T) => Type.Object({ x: t, y: t, z: t })
652
+
653
+ const NumberVector = Vector(Type.Number()) // const NumberVector = {
654
+ // type: 'object',
655
+ // required: ['x', 'y', 'z'],
656
+ // properties: {
657
+ // x: { type: 'number' },
658
+ // y: { type: 'number' },
659
+ // z: { type: 'number' }
660
+ // }
661
+ // }
662
+
663
+ type NumberVector = Static<typeof NumberVector> // type NumberVector = {
664
+ // x: number,
665
+ // y: number,
666
+ // z: number
667
+ // }
668
+
669
+ const BooleanVector = Vector(Type.Boolean()) // const BooleanVector = {
670
+ // type: 'object',
671
+ // required: ['x', 'y', 'z'],
672
+ // properties: {
673
+ // x: { type: 'boolean' },
674
+ // y: { type: 'boolean' },
675
+ // z: { type: 'boolean' }
676
+ // }
677
+ // }
678
+
679
+ type BooleanVector = Static<typeof BooleanVector> // type BooleanVector = {
680
+ // x: boolean,
681
+ // y: boolean,
682
+ // z: boolean
683
+ // }
684
+ ```
685
+
686
+ The following creates a generic `Nullable<T>` type.
522
687
 
523
688
  ```typescript
524
- // string must be an email
525
- const T = Type.String({ format: 'email' })
689
+ const Nullable = <T extends TSchema>(schema: T) => Type.Union([schema, Type.Null()])
526
690
 
527
- // number must be a multiple of 2
528
- const T = Type.Number({ multipleOf: 2 })
691
+ const T = Nullable(Type.String()) // const T = {
692
+ // anyOf: [
693
+ // { type: 'string' },
694
+ // { type: 'null' }
695
+ // ]
696
+ // }
529
697
 
530
- // array must have at least 5 integer values
531
- const T = Type.Array(Type.Integer(), { minItems: 5 })
698
+ type T = Static<typeof T> // type T = string | null
532
699
  ```
533
700
 
534
- <a name='types-reference'></a>
701
+ <a name='types-references'></a>
535
702
 
536
- ### Reference
703
+ ### Reference Types
537
704
 
538
- Use `Type.Ref(...)` to create referenced types. The target type must specify an `$id`.
705
+ Reference types are supported with `Type.Ref`. The target type must specify a valid `$id`.
539
706
 
540
707
  ```typescript
541
708
  const T = Type.String({ $id: 'T' }) // const T = {
@@ -550,9 +717,9 @@ const R = Type.Ref(T) // const R = {
550
717
 
551
718
  <a name='types-recursive'></a>
552
719
 
553
- ### Recursive
720
+ ### Recursive Types
554
721
 
555
- Use `Type.Recursive(...)` to create recursive types.
722
+ Recursive types are supported with `Type.Recursive`
556
723
 
557
724
  ```typescript
558
725
  const Node = Type.Recursive(Node => Type.Object({ // const Node = {
@@ -581,102 +748,93 @@ type Node = Static<typeof Node> // type Node = {
581
748
  // }
582
749
 
583
750
  function test(node: Node) {
584
- const id = node.nodes[0].nodes[0] // id is string
585
- .nodes[0].nodes[0]
586
- .id
751
+ const id = node.nodes[0].nodes[0].id // id is string
587
752
  }
588
753
  ```
589
754
 
590
- <a name='types-generic'></a>
755
+ <a name='types-conditional'></a>
591
756
 
592
- ### Generic
757
+ ### Conditional Types
593
758
 
594
- Use functions to create generic types. The following creates a generic `Nullable<T>` type.
759
+ Conditional types are supported with `Type.Extends`, `Type.Exclude` and `Type.Extract`
595
760
 
596
761
  ```typescript
597
- import { Type, Static, TSchema } from '@sinclair/typebox'
762
+ // TypeScript
598
763
 
599
- const Nullable = <T extends TSchema>(type: T) => Type.Union([type, Type.Null()])
764
+ type T0 = string extends number ? true : false // type T0 = false
600
765
 
601
- const T = Nullable(Type.String()) // const T = {
602
- // anyOf: [{
603
- // type: 'string'
604
- // }, {
605
- // type: 'null'
606
- // }]
607
- // }
766
+ type T1 = Extract<string | number, number> // type T1 = number
608
767
 
609
- type T = Static<typeof T> // type T = string | null
768
+ type T2 = Exclude<string | number, number> // type T2 = string
610
769
 
611
- const U = Nullable(Type.Number()) // const U = {
612
- // anyOf: [{
613
- // type: 'number'
614
- // }, {
615
- // type: 'null'
616
- // }]
617
- // }
770
+ // TypeBox
618
771
 
619
- type U = Static<typeof U> // type U = number | null
620
- ```
772
+ const T0 = Type.Extends(Type.String(), Type.Number(), Type.Literal(true), Type.Literal(false))
621
773
 
622
- <a name='types-conditional'></a>
774
+ const T1 = Type.Extract(Type.Union([Type.String(), Type.Number()]), Type.Number())
623
775
 
624
- ### Conditional
776
+ const T2 = Type.Exclude(Type.Union([Type.String(), Type.Number()]), Type.Number())
625
777
 
626
- Use the conditional module to create [Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html). This module implements TypeScript's structural equivalence checks to enable TypeBox types to be conditionally inferred at runtime. This module also provides the [Extract](https://www.typescriptlang.org/docs/handbook/utility-types.html#extracttype-union) and [Exclude](https://www.typescriptlang.org/docs/handbook/utility-types.html#excludeuniontype-excludedmembers) utility types which are expressed as conditional types in TypeScript.
627
778
 
628
- The conditional module is provided as an optional import.
779
+ type T0 = Static<typeof T0> // type T0 = false
629
780
 
630
- ```typescript
631
- import { Conditional } from '@sinclair/typebox/conditional'
781
+ type T1 = Static<typeof T1> // type T1 = number
782
+
783
+ type T2 = Static<typeof T2> // type T2 = string
632
784
  ```
633
- The following table shows the TypeBox mappings between TypeScript and JSON schema.
785
+
786
+ <a name='types-template-literal'></a>
787
+
788
+ ### Template Literal Types
789
+
790
+ Template Literal types are supported with `Type.TemplateLiteral`
634
791
 
635
792
  ```typescript
636
- ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
637
- │ TypeBox │ TypeScript │ JSON Schema │
638
- │ │ │ │
639
- ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
640
- const T = Conditional.Extends( type T = const T = {
641
- Type.String(), │ string extends number │ const: false, │
642
- Type.Number(), │ true : false │ type: 'boolean' │
643
- │ Type.Literal(true), │ │ }
644
- │ Type.Literal(false) │ │ │
645
- ) │ │ │
646
- │ │ │ │
647
- ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
648
- │ const T = Conditional.Extract( │ type T = Extract< │ const T = { │
649
- Type.Union([ 'a' | 'b' | 'c', │ anyOf: [{ │
650
- Type.Literal('a'), │ 'a' | 'f' │ const: 'a' │
651
- Type.Literal('b'), │ > │ type: 'string' │
652
- │ Type.Literal('c') │ │ }] │
653
- ]), │ │ } │
654
- │ Type.Union([ │ │ │
655
- Type.Literal('a'), │ │ │
656
- │ Type.Literal('f') │ │ │
657
- ]) │ │ │
658
- ) │ │ │
659
- │ │ │ │
660
- ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
661
- │ const T = Conditional.Exclude( │ type T = Exclude< │ const T = { │
662
- │ Type.Union([ │ 'a' | 'b' | 'c', │ anyOf: [{
663
- │ Type.Literal('a'), │ 'a' │ const: 'b', │
664
- Type.Literal('b'), │ > │ type: 'string' │
665
- │ Type.Literal('c') │ │ }, { │
666
- │ ]), │ │ const: 'c', │
667
- │ Type.Union([ │ │ type: 'string' │
668
- │ Type.Literal('a') │ │ }] │
669
- │ ]) │ │ } │
670
- ) │ │ │
671
- │ │ │ │
672
- └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
793
+ // TypeScript
794
+
795
+ type T = `option${'A'|'B'}` // type T = 'optionA' | 'optionB'
796
+
797
+ type R = Record<T, string> // type R = {
798
+ // optionA: string
799
+ // optionB: string
800
+ // }
801
+
802
+ // TypeBox
803
+
804
+ const T = Type.TemplateLiteral([ // const T = {
805
+ Type.Literal('option'), // pattern: '^option(A|B)$',
806
+ Type.Union([ // type: 'string'
807
+ Type.Literal('A'), // }
808
+ Type.Literal('B')
809
+ ])
810
+ ])
811
+
812
+ const R = Type.Record(T, Type.String()) // const R = {
813
+ // type: 'object',
814
+ // required: ['optionA', 'optionB'],
815
+ // properties: {
816
+ // optionA: {
817
+ // type: 'string'
818
+ // },
819
+ // optionB: {
820
+ // type: 'string'
821
+ // }
822
+ // }
823
+ // }
824
+
825
+ type T = Static<typeof T> // type T = 'optionA' | 'optionB'
826
+
827
+ type R = Static<typeof R> // type R = {
828
+ // optionA: string
829
+ // optionB: string
830
+ // }
673
831
  ```
674
832
 
675
833
  <a name='types-unsafe'></a>
676
834
 
677
835
  ### Unsafe
678
836
 
679
- Use `Type.Unsafe(...)` to create custom schemas with user defined inference rules.
837
+ Use `Type.Unsafe` to create custom schematics with user defined inference rules.
680
838
 
681
839
  ```typescript
682
840
  const T = Type.Unsafe<string>({ type: 'number' }) // const T = {
@@ -686,16 +844,12 @@ const T = Type.Unsafe<string>({ type: 'number' }) // const T = {
686
844
  type T = Static<typeof T> // type T = string
687
845
  ```
688
846
 
689
- This function can be used to create custom schemas for validators that require specific schema representations. An example of this might be OpenAPI's `nullable` and `enum` schemas which are not provided by TypeBox. The following demonstrates using `Type.Unsafe(...)` to create these types.
847
+ The `Type.Unsafe` type can be useful to express specific OpenAPI schema representations.
690
848
 
691
849
  ```typescript
692
850
  import { Type, Static, TSchema } from '@sinclair/typebox'
693
851
 
694
- //--------------------------------------------------------------------------------------------
695
- //
696
852
  // Nullable<T>
697
- //
698
- //--------------------------------------------------------------------------------------------
699
853
 
700
854
  function Nullable<T extends TSchema>(schema: T) {
701
855
  return Type.Unsafe<Static<T> | null>({ ...schema, nullable: true })
@@ -708,12 +862,7 @@ const T = Nullable(Type.String()) // const T = {
708
862
 
709
863
  type T = Static<typeof T> // type T = string | null
710
864
 
711
-
712
- //--------------------------------------------------------------------------------------------
713
- //
714
865
  // StringEnum<string[]>
715
- //
716
- //--------------------------------------------------------------------------------------------
717
866
 
718
867
  function StringEnum<T extends string[]>(values: [...T]) {
719
868
  return Type.Unsafe<T[number]>({ type: 'string', enum: values })
@@ -730,10 +879,10 @@ type T = Static<typeof T> // type T = 'A' | 'B' | 'C'
730
879
 
731
880
  ### Guards
732
881
 
733
- Use the guard module to test if values are TypeBox types.
882
+ TypeBox provides a `TypeGuard` module that can be used for reflection and asserting values as types.
734
883
 
735
884
  ```typescript
736
- import { TypeGuard } from '@sinclair/typebox/guard'
885
+ import { Type, TypeGuard } from '@sinclair/typebox'
737
886
 
738
887
  const T = Type.String()
739
888
 
@@ -747,7 +896,7 @@ if(TypeGuard.TString(T)) {
747
896
 
748
897
  ### Strict
749
898
 
750
- TypeBox schemas contain the `Kind` and `Modifier` symbol properties. These properties are provided to enable runtime type reflection on schemas, as well as helping TypeBox internally compose types. These properties are not strictly valid JSON schema; so in some cases it may be desirable to omit them. TypeBox provides a `Type.Strict()` function that will omit these properties if necessary.
899
+ TypeBox schemas contain the `Kind` and `Modifier` symbol properties. These properties are used for type composition and reflection. These properties are not strictly valid JSON schema; so in some cases it may be desirable to omit them. TypeBox provides a `Type.Strict` function that will omit these properties if necessary.
751
900
 
752
901
  ```typescript
753
902
  const T = Type.Object({ // const T = {
@@ -776,7 +925,7 @@ const U = Type.Strict(T) // const U = {
776
925
 
777
926
  ## Values
778
927
 
779
- TypeBox includes an optional values module that can be used to perform common operations on JavaScript values. This module enables one to create, check and cast values from types. It also provides functionality to check equality, clone and diff and patch JavaScript values. The value module is provided as an optional import.
928
+ TypeBox provides an optional utility module that can be used to perform common operations on JavaScript values. This module includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This module is provided via optional import.
780
929
 
781
930
  ```typescript
782
931
  import { Value } from '@sinclair/typebox/value'
@@ -786,7 +935,7 @@ import { Value } from '@sinclair/typebox/value'
786
935
 
787
936
  ### Create
788
937
 
789
- Use the Create function to create a value from a TypeBox type. TypeBox will use default values if specified.
938
+ Use the Create function to create a value from a type. TypeBox will use default values if specified.
790
939
 
791
940
  ```typescript
792
941
  const T = Type.Object({ x: Type.Number(), y: Type.Number({ default: 42 }) })
@@ -816,6 +965,20 @@ const T = Type.Object({ x: Type.Number() })
816
965
  const R = Value.Check(T, { x: 1 }) // const R = true
817
966
  ```
818
967
 
968
+ <a name='values-convert'></a>
969
+
970
+ ### Convert
971
+
972
+ Use the Convert function to convert a value into its target type if a reasonable conversion is possible.
973
+
974
+ ```typescript
975
+ const T = Type.Object({ x: Type.Number() })
976
+
977
+ const R1 = Value.Convert(T, { x: '3.14' }) // const R1 = { x: 3.14 }
978
+
979
+ const R2 = Value.Convert(T, { x: 'not a number' }) // const R2 = { x: 'not a number' }
980
+ ```
981
+
819
982
  <a name='values-cast'></a>
820
983
 
821
984
  ### Cast
@@ -891,7 +1054,6 @@ const E = Value.Diff(A, B) // const E = [
891
1054
  const C = Value.Patch<typeof B>(A, E) // const C = { x: 3 }
892
1055
  ```
893
1056
 
894
-
895
1057
  <a name='values-errors'></a>
896
1058
 
897
1059
  ### Errors
@@ -914,34 +1076,60 @@ const R = [...Value.Errors(T, { x: '42' })] // const R = [{
914
1076
  // }]
915
1077
  ```
916
1078
 
1079
+ <a name='values-mutate'></a>
1080
+
1081
+ ### Mutate
1082
+
1083
+ Use the Mutate function to perform a deep mutable value assignment while retaining internal references.
1084
+
1085
+ ```typescript
1086
+ const Y = { z: 1 } // const Y = { z: 1 }
1087
+
1088
+ const X = { y: Y } // const X = { y: { z: 1 } }
1089
+
1090
+ const A = { x: X } // const A = { x: { y: { z: 1 } } }
1091
+
1092
+
1093
+ Value.Mutate(A, { x: { y: { z: 2 } } }) // const A' = { x: { y: { z: 2 } } }
1094
+
1095
+ const R0 = A.x.y.z === 2 // const R0 = 2
1096
+
1097
+ const R1 = A.x.y === Y // const R1 = true
1098
+
1099
+ const R2 = A.x === X // const R2 = true
1100
+ ```
1101
+
917
1102
  <a name='values-pointer'></a>
918
1103
 
919
1104
  ### Pointer
920
1105
 
921
- Use ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) Json Pointers.
1106
+ Use ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) JSON Pointers.
922
1107
 
923
1108
  ```typescript
924
1109
  import { ValuePointer } from '@sinclair/typebox/value'
925
1110
 
926
1111
  const A = { x: 0, y: 0, z: 0 }
927
1112
 
928
- ValuePointer.Set(A, '/x', 1) // const A = { x: 1, y: 0, z: 0 }
929
- ValuePointer.Set(A, '/y', 1) // const A = { x: 1, y: 1, z: 0 }
930
- ValuePointer.Set(A, '/z', 1) // const A = { x: 1, y: 1, z: 1 }
1113
+ ValuePointer.Set(A, '/x', 1) // const A' = { x: 1, y: 0, z: 0 }
1114
+
1115
+ ValuePointer.Set(A, '/y', 1) // const A' = { x: 1, y: 1, z: 0 }
1116
+
1117
+ ValuePointer.Set(A, '/z', 1) // const A' = { x: 1, y: 1, z: 1 }
931
1118
  ```
1119
+
932
1120
  <a name='typecheck'></a>
933
1121
 
934
1122
  ## TypeCheck
935
1123
 
936
- TypeBox constructs JSON Schema draft 6 compliant schematics and can be used with any validator that supports this specification. In JavaScript, an ideal validator to use is Ajv which supports draft 6 as well as more recent revisions to the specification. In addition to Ajv, TypeBox provides an optional built in type compiler which can offer faster runtime type compilation, as well as providing high performance data validation for TypeBox types only.
1124
+ TypeBox types target JSON Schema draft 6 so are compatible with any validator that supports this specification. TypeBox also provides a built in type checking compiler designed specifically for high performance compilation and value assertion.
937
1125
 
938
- The following sections detail using these validators.
1126
+ The following sections detail using Ajv and TypeBox's compiler infrastructure.
939
1127
 
940
1128
  <a name='typecheck-ajv'></a>
941
1129
 
942
1130
  ## Ajv
943
1131
 
944
- The following shows the recommended setup for Ajv.
1132
+ The following shows the recommended setup for Ajv.
945
1133
 
946
1134
  ```bash
947
1135
  $ npm install ajv ajv-formats --save
@@ -982,7 +1170,7 @@ const R = C({ x: 1, y: 2, z: 3 }) // const R = true
982
1170
 
983
1171
  ### TypeCompiler
984
1172
 
985
- The TypeCompiler is a Just-In-Time (JIT) runtime compiler that can be used to convert TypeBox types into fast validation routines. This compiler is specifically tuned for fast compilation and validation for TypeBox types only.
1173
+ The TypeBox TypeCompiler is a high performance JIT compiler that transforms TypeBox types into optimized JavaScript validation routines. The compiler is tuned for fast compilation as well as fast value assertion. It is designed to serve as a validation backend that can be integrated into larger applications; but can also be used as a general purpose validator.
986
1174
 
987
1175
  The TypeCompiler is provided as an optional import.
988
1176
 
@@ -1002,7 +1190,7 @@ const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObje
1002
1190
  const R = C.Check({ x: 1, y: 2, z: 3 }) // const R = true
1003
1191
  ```
1004
1192
 
1005
- Use `Errors(...)` to generate diagnostics for a value. The `Errors(...)` function will run an exhaustive check across the value and yield any error found. For performance, this function should only be called after failed `Check(...)`.
1193
+ Use the `Errors(...)` function to produce diagnostic errors for a value. The `Errors(...)` function will return an iterator that if enumerated; will perform an exhaustive check across the entire value and yield any error found. For performance, this function should only be called after failed `Check(...)`. Applications may also choose to yield only the first value to avoid exhaustive error generation.
1006
1194
 
1007
1195
  ```typescript
1008
1196
  const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
@@ -1047,7 +1235,7 @@ console.log(C.Code()) // return function check(va
1047
1235
 
1048
1236
  ## TypeSystem
1049
1237
 
1050
- TypeBox provides an extensible TypeSystem module that enables developers to define additional types above and beyond the built in type set. This module also allows developers to define custom string formats as well as override certain type checking behaviours.
1238
+ The TypeBox TypeSystem module provides functionality to define types above and beyond the Standard and Extended type sets as well as control various assertion polices. Configurations made to the TypeSystem module are observed by both `TypeCompiler` and `Value` modules.
1051
1239
 
1052
1240
  The TypeSystem module is provided as an optional import.
1053
1241
 
@@ -1059,78 +1247,69 @@ import { TypeSystem } from '@sinclair/typebox/system'
1059
1247
 
1060
1248
  ### Types
1061
1249
 
1062
- Use the `CreateType(...)` function to specify custom type. This function will return a type factory function that can be used to construct the type. The following creates and registers a BigNumber type which will statically infer as `bigint`.
1250
+ Use the `Type(...)` function to create a custom type. This function will return a type factory function that can be used to construct the type. The following creates a Point type.
1063
1251
 
1064
1252
  ```typescript
1065
- //--------------------------------------------------------------------------------------------
1066
- //
1067
- // Use TypeSystem.CreateType(...) to define and return a type factory function
1068
- //
1069
- //--------------------------------------------------------------------------------------------
1253
+ type PointOptions = { } // The Type Options
1070
1254
 
1071
- type BigNumberOptions = { minimum?: bigint; maximum?: bigint }
1255
+ type PointType = { x: number, y: number } // The Static<T> Type
1072
1256
 
1073
- const BigNumber = TypeSystem.CreateType<bigint, BigNumberOptions>(
1074
- 'BigNumber',
1075
- (options, value) => {
1076
- if (typeof value !== 'bigint') return false
1077
- if (options.maximum !== undefined && value > options.maximum) return false
1078
- if (options.minimum !== undefined && value < options.minimum) return false
1079
- return true
1080
- }
1081
- )
1257
+ const Point = TypeSystem.Type<PointType, PointOptions>('Point', (options, value) => {
1258
+ return (
1259
+ typeof value === 'object' && value !== null &&
1260
+ typeof value.x === 'number' &&
1261
+ typeof value.y === 'number'
1262
+ )
1263
+ })
1082
1264
 
1083
- //--------------------------------------------------------------------------------------------
1084
- //
1085
- // Use the custom type like any other type
1086
- //
1087
- //--------------------------------------------------------------------------------------------
1265
+ const T = Point()
1088
1266
 
1089
- const T = BigNumber({ minimum: 10n, maximum: 20n }) // const T = {
1090
- // minimum: 10n,
1091
- // maximum: 20n,
1092
- // [Symbol(TypeBox.Kind)]: 'BigNumber'
1093
- // }
1267
+ type T = Static<typeof T> // type T = { x: number, y: number }
1094
1268
 
1095
- const C = TypeCompiler.Compile(T)
1096
- const X = C.Check(15n) // const X = true
1097
- const Y = C.Check(5n) // const Y = false
1098
- const Z = C.Check(25n) // const Z = false
1269
+ const R = Value.Check(T, { x: 1, y: 2 }) // const R = true
1099
1270
  ```
1100
1271
 
1101
1272
  <a name='typesystem-formats'></a>
1102
1273
 
1103
1274
  ### Formats
1104
1275
 
1105
- Use the `CreateFormat(...)` function to specify user defined string formats. The following creates a custom string format that checks for lowercase.
1276
+ Use the `Format(...)` function to create a custom string format. The following creates a format that checks for lowercase strings.
1106
1277
 
1107
1278
  ```typescript
1108
- //--------------------------------------------------------------------------------------------
1109
- //
1110
- // Use TypeSystem.CreateFormat(...) to define a custom string format
1111
- //
1112
- //--------------------------------------------------------------------------------------------
1279
+ TypeSystem.Format('lowercase', value => value === value.toLowerCase()) // format should be lowercase
1113
1280
 
1114
- TypeSystem.CreateFormat('lowercase', value => value === value.toLowerCase())
1281
+ const T = Type.String({ format: 'lowercase' })
1115
1282
 
1116
- //--------------------------------------------------------------------------------------------
1117
- //
1118
- // Use the format by creating string types with the 'format' option
1283
+ const A = Value.Check(T, 'Hello') // const A = false
1284
+
1285
+ const B = Value.Check(T, 'hello') // const B = true
1286
+ ```
1287
+
1288
+ <a name='typesystem-policies'></a>
1289
+
1290
+ ### Policies
1291
+
1292
+ TypeBox validates using JSON Schema assertion policies by default. It is possible to override these policies and have TypeBox assert using TypeScript policies. The following overrides are available.
1293
+
1294
+ ```typescript
1295
+ // Allow arrays to validate as object types (default is false)
1119
1296
  //
1120
- //--------------------------------------------------------------------------------------------
1297
+ // const A: {} = [] - allowed in TS
1121
1298
 
1122
- const T = Type.String({ format: 'lowercase' })
1299
+ TypeSystem.AllowArrayObjects = true
1123
1300
 
1124
- const A = Value.Check(T, 'action') // const A = true
1301
+ // Allow numeric values to be NaN or + or - Infinity (default is false)
1302
+ //
1303
+ // const A: number = NaN - allowed in TS
1125
1304
 
1126
- const B = Value.Check(T, 'ACTION') // const B = false
1305
+ TypeSystem.AllowNaN = true
1127
1306
  ```
1128
1307
 
1129
1308
  <a name='benchmark'></a>
1130
1309
 
1131
1310
  ## Benchmark
1132
1311
 
1133
- This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.11.2.
1312
+ This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.12.0.
1134
1313
 
1135
1314
  For additional comparative benchmarks, please refer to [typescript-runtime-type-benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/).
1136
1315
 
@@ -1141,33 +1320,39 @@ For additional comparative benchmarks, please refer to [typescript-runtime-type-
1141
1320
  This benchmark measures compilation performance for varying types. You can review this benchmark [here](https://github.com/sinclairzx81/typebox/blob/master/benchmark/measurement/module/compile.ts).
1142
1321
 
1143
1322
  ```typescript
1144
- ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1145
- (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1146
- ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1147
- Number2000 │ ' 451 ms' │ ' 16 ms' │ ' 28.19 x' │
1148
- String2000 │ ' 338 ms' │ ' 14 ms' │ ' 24.14 x' │
1149
- Boolean2000 │ ' 297 ms' │ ' 13 ms' │ ' 22.85 x' │
1150
- Null2000 │ ' 265 ms' │ ' 8 ms' │ ' 33.13 x' │
1151
- RegEx2000 │ ' 492 ms' │ ' 18 ms' │ ' 27.33 x' │
1152
- ObjectA2000 │ ' 2744 ms' │ ' 55 ms' │ ' 49.89 x' │
1153
- ObjectB 2000 │ ' 3005 ms' │ ' 44 ms' │ ' 68.30 x' │
1154
- Tuple2000 │ ' 1283 ms' │ ' 26 ms' │ ' 49.35 x' │
1155
- Union2000 │ ' 1263 ms' │ ' 27 ms' │ ' 46.78 x' │
1156
- Vector42000 │ ' 1622 ms' │ ' 23 ms' │ ' 70.52 x' │
1157
- Matrix42000 │ ' 888 ms' │ ' 12 ms' │ ' 74.00 x' │
1158
- Literal_String2000 │ ' 344 ms' │ ' 14 ms' │ ' 24.57 x' │
1159
- Literal_Number2000 │ ' 389 ms' │ ' 8 ms' │ ' 48.63 x' │
1160
- Literal_Boolean2000 │ ' 374 ms' │ ' 9 ms' │ ' 41.56 x' │
1161
- Array_Number2000 │ ' 710 ms' │ ' 12 ms' │ ' 59.17 x' │
1162
- Array_String2000 │ ' 739 ms' │ ' 9 ms' │ ' 82.11 x' │
1163
- Array_Boolean2000 │ ' 732 ms' │ ' 7 ms' │ ' 104.57 x' │
1164
- Array_ObjectA2000 │ ' 3733 ms' │ ' 42 ms' │ ' 88.88 x' │
1165
- Array_ObjectB2000 │ ' 3602 ms' │ ' 42 ms' │ ' 85.76 x' │
1166
- Array_Tuple2000 │ ' 2204 ms' │ ' 20 ms' │ ' 110.20 x' │
1167
- Array_Union2000 │ ' 1533 ms' │ ' 24 ms' │ ' 63.88 x' │
1168
- Array_Vector42000 │ ' 2263 ms' │ ' 21 ms' │ ' 107.76 x' │
1169
- Array_Matrix42000 │ ' 1576 ms' │ ' 14 ms' │ ' 112.57 x' │
1170
- └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1323
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1324
+ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1325
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1326
+ Literal_String 1000 │ ' 257 ms' │ ' 8 ms' │ ' 32.13 x' │
1327
+ Literal_Number 1000 │ ' 203 ms' │ ' 4 ms' │ ' 50.75 x' │
1328
+ Literal_Boolean 1000 │ ' 183 ms' │ ' 4 ms' │ ' 45.75 x' │
1329
+ Primitive_Number 1000 │ ' 174 ms' │ ' 8 ms' │ ' 21.75 x' │
1330
+ Primitive_String 1000 │ ' 158 ms' │ ' 9 ms' │ ' 17.56 x' │
1331
+ Primitive_String_Pattern 1000 │ ' 213 ms' │ ' 13 ms' │ ' 16.38 x' │
1332
+ Primitive_Boolean1000 │ ' 136 ms' │ ' 6 ms' │ ' 22.67 x' │
1333
+ Primitive_Null 1000 │ ' 144 ms' │ ' 6 ms' │ ' 24.00 x' │
1334
+ Object_Unconstrained 1000 │ ' 1176 ms' │ ' 38 ms' │ ' 30.95 x' │
1335
+ Object_Constrained 1000 │ ' 1181 ms' │ ' 31 ms' │ ' 38.10 x' │
1336
+ Object_Vector3 1000 │ ' 387 ms' │ ' 8 ms' │ ' 48.38 x' │
1337
+ Object_Box3D 1000 │ ' 1693 ms' │ ' 25 ms' │ ' 67.72 x' │
1338
+ Tuple_Primitive 1000 │ ' 470 ms' │ ' 15 ms' │ ' 31.33 x' │
1339
+ Tuple_Object 1000 │ ' 1206 ms' │ ' 17 ms' │ ' 70.94 x' │
1340
+ Composite_Intersect 1000 │ ' 567 ms' │ ' 20 ms' │ ' 28.35 x' │
1341
+ Composite_Union 1000 │ ' 515 ms' │ ' 21 ms' │ ' 24.52 x' │
1342
+ Math_Vector4 1000 │ ' 787 ms' │ ' 10 ms' │ ' 78.70 x' │
1343
+ Math_Matrix4 1000 │ ' 386 ms' │ ' 8 ms' │ ' 48.25 x' │
1344
+ Array_Primitive_Number 1000 │ ' 349 ms' │ ' 7 ms' │ ' 49.86 x' │
1345
+ Array_Primitive_String 1000 │ ' 336 ms' │ ' 4 ms' │ ' 84.00 x' │
1346
+ Array_Primitive_Boolean 1000 │ ' 284 ms' │ ' 3 ms' │ ' 94.67 x' │
1347
+ Array_Object_Unconstrained 1000 │ ' 1704 ms' │ ' 19 ms' │ ' 89.68 x' │
1348
+ Array_Object_Constrained 1000 │ ' 1456 ms' │ ' 18 ms' │ ' 80.89 x' │
1349
+ │ Array_Tuple_Primitive │ 1000 │ ' 792 ms' │ ' 15 ms' │ ' 52.80 x' │
1350
+ │ Array_Tuple_Object │ 1000 │ ' 1552 ms' │ ' 17 ms' │ ' 91.29 x' │
1351
+ │ Array_Composite_Intersect │ 1000 │ ' 744 ms' │ ' 18 ms' │ ' 41.33 x' │
1352
+ │ Array_Composite_Union │ 1000 │ ' 783 ms' │ ' 15 ms' │ ' 52.20 x' │
1353
+ │ Array_Math_Vector4 │ 1000 │ ' 1093 ms' │ ' 14 ms' │ ' 78.07 x' │
1354
+ │ Array_Math_Matrix4 │ 1000 │ ' 684 ms' │ ' 6 ms' │ ' 114.00 x' │
1355
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1171
1356
  ```
1172
1357
 
1173
1358
  <a name='benchmark-validate'></a>
@@ -1177,35 +1362,41 @@ This benchmark measures compilation performance for varying types. You can revie
1177
1362
  This benchmark measures validation performance for varying types. You can review this benchmark [here](https://github.com/sinclairzx81/typebox/blob/master/benchmark/measurement/module/check.ts).
1178
1363
 
1179
1364
  ```typescript
1180
- ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1181
- (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1182
- ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1183
- Number │ 1000000 │ ' 30 ms' │ ' 7 ms' │ ' 6 ms' │ ' 1.17 x' │
1184
- String │ 1000000 │ ' 23 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1185
- Boolean │ 1000000 │ ' 22 ms' │ ' 21 ms' │ ' 10 ms' │ ' 2.10 x' │
1186
- Null │ 1000000 │ ' 27 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1187
- RegEx │ 1000000 │ ' 163 ms' │ ' 47 ms' │ ' 38 ms' │ ' 1.24 x' │
1188
- ObjectA │ 1000000 │ ' 654 ms' │ ' 41 ms' │ ' 24 ms' │ ' 1.71 x' │
1189
- ObjectB │ 1000000 │ ' 1173 ms' │ ' 59 ms' │ ' 41 ms' │ ' 1.44 x' │
1190
- Tuple │ 1000000 │ ' 124 ms' │ ' 24 ms' │ ' 17 ms' │ ' 1.41 x' │
1191
- Union │ 1000000 │ ' 332 ms' │ ' 26 ms' │ ' 16 ms' │ ' 1.63 x' │
1192
- Recursive │ 1000000 │ ' 3129 ms' │ ' 412 ms' │ ' 102 ms' │ ' 4.04 x' │
1193
- Vector4 │ 1000000 │ ' 147 ms' │ ' 26 ms' │ ' 13 ms' │ ' 2.00 x' │
1194
- Matrix4 │ 1000000 │ ' 576 ms' │ ' 41 ms' │ ' 28 ms' │ ' 1.46 x' │
1195
- Literal_String │ 1000000 │ ' 51 ms' │ ' 21 ms' │ ' 10 ms' │ ' 2.10 x' │
1196
- Literal_Number │ 1000000 │ ' 47 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1197
- Literal_Boolean │ 1000000 │ ' 47 ms' │ ' 21 ms' │ ' 10 ms' │ ' 2.10 x' │
1198
- Array_Number │ 1000000 │ ' 490 ms' │ ' 33 ms' │ ' 18 ms' │ ' 1.83 x' │
1199
- Array_String │ 1000000 │ ' 502 ms' │ ' 31 ms' │ ' 25 ms' │ ' 1.24 x' │
1200
- Array_Boolean │ 1000000 │ ' 465 ms' │ ' 33 ms' │ ' 27 ms' │ ' 1.22 x' │
1201
- Array_ObjectA │ 1000000 │ ' 15463 ms' │ ' 2470 ms' │ ' 2052 ms' │ ' 1.20 x' │
1202
- Array_ObjectB │ 1000000 │ ' 18047 ms' │ ' 2497 ms' │ ' 2348 ms' │ ' 1.06 x' │
1203
- Array_Tuple │ 1000000 │ ' 1958 ms' │ ' 99 ms' │ ' 77 ms' │ ' 1.29 x' │
1204
- Array_Union │ 1000000 │ ' 5348 ms' │ ' 254 ms' │ ' 89 ms' │ ' 2.85 x' │
1205
- Array_Recursive │ 1000000 │ ' 54643 ms' │ ' 8870 ms' │ ' 1158 ms' │ ' 7.66 x' │
1206
- Array_Vector4 │ 1000000 │ ' 2724 ms' │ ' 105 ms' │ ' 48 ms' │ ' 2.19 x' │
1207
- Array_Matrix4 │ 1000000 │ ' 13821 ms' │ ' 437 ms' │ ' 266 ms' │ ' 1.64 x' │
1208
- └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1365
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1366
+ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1367
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1368
+ Literal_String │ 1000000 │ ' 27 ms' │ ' 6 ms' │ ' 5 ms' │ ' 1.20 x' │
1369
+ Literal_Number │ 1000000 │ ' 23 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1370
+ Literal_Boolean │ 1000000 │ ' 21 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1371
+ Primitive_Number │ 1000000 │ ' 26 ms' │ ' 19 ms' │ ' 11 ms' │ ' 1.73 x' │
1372
+ Primitive_String │ 1000000 │ ' 25 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1373
+ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 49 ms' │ ' 43 ms' │ ' 1.14 x' │
1374
+ Primitive_Boolean │ 1000000 │ ' 23 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1375
+ Primitive_Null │ 1000000 │ ' 24 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1376
+ Object_Unconstrained │ 1000000 │ ' 804 ms' │ ' 35 ms' │ ' 28 ms' │ ' 1.25 x' │
1377
+ Object_Constrained │ 1000000 │ ' 1041 ms' │ ' 55 ms' │ ' 41 ms' │ ' 1.34 x' │
1378
+ Object_Vector3 │ 1000000 │ ' 380 ms' │ ' 26 ms' │ ' 20 ms' │ ' 1.30 x' │
1379
+ Object_Box3D │ 1000000 │ ' 1785 ms' │ ' 65 ms' │ ' 52 ms' │ ' 1.25 x' │
1380
+ Object_Recursive │ 1000000 │ ' 4984 ms' │ ' 396 ms' │ ' 114 ms' │ ' 3.47 x' │
1381
+ Tuple_Primitive │ 1000000 │ ' 168 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1382
+ Tuple_Object │ 1000000 │ ' 673 ms' │ ' 30 ms' │ ' 26 ms' │ ' 1.15 x' │
1383
+ Composite_Intersect │ 1000000 │ ' 751 ms' │ ' 28 ms' │ ' 20 ms' │ ' 1.40 x' │
1384
+ Composite_Union │ 1000000 │ ' 489 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1385
+ Math_Vector4 │ 1000000 │ ' 259 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1386
+ Math_Matrix4 │ 1000000 │ ' 1002 ms' │ ' 40 ms' │ ' 30 ms' │ ' 1.33 x' │
1387
+ Array_Primitive_Number │ 1000000 │ ' 252 ms' │ ' 22 ms' │ ' 15 ms' │ ' 1.47 x' │
1388
+ Array_Primitive_String │ 1000000 │ ' 227 ms' │ ' 22 ms' │ ' 18 ms' │ ' 1.22 x' │
1389
+ Array_Primitive_Boolean │ 1000000 │ ' 150 ms' │ ' 23 ms' │ ' 22 ms' │ ' 1.05 x' │
1390
+ Array_Object_Unconstrained │ 1000000 │ ' 4754 ms' │ ' 71 ms' │ ' 64 ms' │ ' 1.11 x' │
1391
+ Array_Object_Constrained │ 1000000 │ ' 4787 ms' │ ' 142 ms' │ ' 123 ms' │ ' 1.15 x' │
1392
+ Array_Object_Recursive │ 1000000 │ ' 19088 ms' │ ' 1735 ms' │ ' 314 ms' │ ' 5.53 x' │
1393
+ │ Array_Tuple_Primitive │ 1000000 │ ' 650 ms' │ ' 41 ms' │ ' 31 ms' │ ' 1.32 x' │
1394
+ │ Array_Tuple_Object │ 1000000 │ ' 2770 ms' │ ' 67 ms' │ ' 55 ms' │ ' 1.22 x' │
1395
+ │ Array_Composite_Intersect │ 1000000 │ ' 2693 ms' │ ' 50 ms' │ ' 39 ms' │ ' 1.28 x' │
1396
+ │ Array_Composite_Union │ 1000000 │ ' 1982 ms' │ ' 72 ms' │ ' 33 ms' │ ' 2.18 x' │
1397
+ │ Array_Math_Vector4 │ 1000000 │ ' 1068 ms' │ ' 40 ms' │ ' 26 ms' │ ' 1.54 x' │
1398
+ │ Array_Math_Matrix4 │ 1000000 │ ' 4609 ms' │ ' 115 ms' │ ' 88 ms' │ ' 1.31 x' │
1399
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1209
1400
  ```
1210
1401
 
1211
1402
  <a name='benchmark-compression'></a>
@@ -1218,15 +1409,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1218
1409
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1219
1410
  │ (index) │ Compiled │ Minified │ Compression │
1220
1411
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1221
- │ typebox/compiler │ ' 65.4 kb' │ ' 32.2 kb' │ '2.03 x' │
1222
- │ typebox/conditional │ ' 45.5 kb' │ ' 18.6 kb' │ '2.45 x' │
1223
- │ typebox/custom │ ' 0.6 kb' │ ' 0.2 kb' │ '2.61 x' │
1224
- │ typebox/format │ ' 0.6 kb' │ ' 0.2 kb' │ '2.66 x' │
1225
- │ typebox/guard │ ' 23.8 kb' │ ' 11.4 kb' │ '2.08 x' │
1226
- │ typebox/hash │ ' 4.2 kb' │ ' 1.8 kb' │ '2.30 x' │
1227
- │ typebox/system │ ' 14.0 kb' │ ' 7.1 kb' │ '1.96 x' │
1228
- │ typebox/value │ ' 90.0 kb' │ ' 41.8 kb' │ '2.15 x' │
1229
- │ typebox │ ' 12.0 kb' │ ' 6.4 kb' │ '1.89 x' │
1412
+ │ typebox/compiler │ '124.3 kb' │ ' 55.7 kb' │ '2.23 x' │
1413
+ │ typebox/errors │ '107.8 kb' │ ' 47.9 kb' │ '2.25 x' │
1414
+ │ typebox/system │ ' 73.3 kb' │ ' 30.2 kb' │ '2.43 x' │
1415
+ │ typebox/value │ '170.7 kb' │ ' 74.2 kb' │ '2.30 x' │
1416
+ │ typebox │ ' 72.0 kb' │ ' 29.7 kb' │ '2.43 x' │
1230
1417
  └──────────────────────┴────────────┴────────────┴─────────────┘
1231
1418
  ```
1232
1419