@contember/schema-utils 2.1.0-alpha.37 → 2.1.0-alpha.39

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 (399) hide show
  1. package/dist/development/index.cjs +110 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +94 -0
  4. package/dist/development/index.js.map +1 -0
  5. package/dist/development/src/acl/AllowAllPermissionFactory.cjs +42 -0
  6. package/dist/development/src/acl/AllowAllPermissionFactory.cjs.map +1 -0
  7. package/dist/development/src/acl/AllowAllPermissionFactory.js +42 -0
  8. package/dist/development/src/acl/AllowAllPermissionFactory.js.map +1 -0
  9. package/dist/development/src/acl/PredicateDefinitionProcessor.cjs +69 -0
  10. package/dist/development/src/acl/PredicateDefinitionProcessor.cjs.map +1 -0
  11. package/dist/development/src/acl/PredicateDefinitionProcessor.js +69 -0
  12. package/dist/development/src/acl/PredicateDefinitionProcessor.js.map +1 -0
  13. package/dist/development/src/acl/schemaUtils.cjs +11 -0
  14. package/dist/development/src/acl/schemaUtils.cjs.map +1 -0
  15. package/dist/development/src/acl/schemaUtils.js +11 -0
  16. package/dist/development/src/acl/schemaUtils.js.map +1 -0
  17. package/dist/development/src/dataUtils.cjs +59 -0
  18. package/dist/development/src/dataUtils.cjs.map +1 -0
  19. package/dist/development/src/dataUtils.js +59 -0
  20. package/dist/development/src/dataUtils.js.map +1 -0
  21. package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.cjs +118 -0
  22. package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.cjs.map +1 -0
  23. package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.js +118 -0
  24. package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.js.map +1 -0
  25. package/dist/development/src/definition-generator/DefinitionCodeGenerator.cjs +218 -0
  26. package/dist/development/src/definition-generator/DefinitionCodeGenerator.cjs.map +1 -0
  27. package/dist/development/src/definition-generator/DefinitionCodeGenerator.js +218 -0
  28. package/dist/development/src/definition-generator/DefinitionCodeGenerator.js.map +1 -0
  29. package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs +68 -0
  30. package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs.map +1 -0
  31. package/dist/development/src/definition-generator/DefinitionNamingConventions.js +68 -0
  32. package/dist/development/src/definition-generator/DefinitionNamingConventions.js.map +1 -0
  33. package/dist/development/src/definition-generator/TsDefinitionGenerator.cjs +17 -0
  34. package/dist/development/src/definition-generator/TsDefinitionGenerator.cjs.map +1 -0
  35. package/dist/development/src/definition-generator/TsDefinitionGenerator.js +17 -0
  36. package/dist/development/src/definition-generator/TsDefinitionGenerator.js.map +1 -0
  37. package/dist/development/src/lax/LaxSchemaConverter.cjs +202 -0
  38. package/dist/development/src/lax/LaxSchemaConverter.cjs.map +1 -0
  39. package/dist/development/src/lax/LaxSchemaConverter.js +202 -0
  40. package/dist/development/src/lax/LaxSchemaConverter.js.map +1 -0
  41. package/dist/development/src/lax/schema.cjs +70 -0
  42. package/dist/development/src/lax/schema.cjs.map +1 -0
  43. package/dist/development/src/lax/schema.js +53 -0
  44. package/dist/development/src/lax/schema.js.map +1 -0
  45. package/dist/development/src/model/NamingConventions.cjs +28 -0
  46. package/dist/development/src/model/NamingConventions.cjs.map +1 -0
  47. package/dist/development/src/model/NamingConventions.js +28 -0
  48. package/dist/development/src/model/NamingConventions.js.map +1 -0
  49. package/dist/development/src/model/modelUtils.cjs +229 -0
  50. package/dist/development/src/model/modelUtils.cjs.map +1 -0
  51. package/dist/development/src/model/modelUtils.js +229 -0
  52. package/dist/development/src/model/modelUtils.js.map +1 -0
  53. package/dist/development/src/model/resolveDefaultColumnType.cjs +30 -0
  54. package/dist/development/src/model/resolveDefaultColumnType.cjs.map +1 -0
  55. package/dist/development/src/model/resolveDefaultColumnType.js +30 -0
  56. package/dist/development/src/model/resolveDefaultColumnType.js.map +1 -0
  57. package/dist/development/src/schemaChecksum.cjs +9 -0
  58. package/dist/development/src/schemaChecksum.cjs.map +1 -0
  59. package/dist/development/src/schemaChecksum.js +9 -0
  60. package/dist/development/src/schemaChecksum.js.map +1 -0
  61. package/dist/development/src/schemaFilter.cjs +24 -0
  62. package/dist/development/src/schemaFilter.cjs.map +1 -0
  63. package/dist/development/src/schemaFilter.js +24 -0
  64. package/dist/development/src/schemaFilter.js.map +1 -0
  65. package/dist/development/src/schemaNormalizer.cjs +72 -0
  66. package/dist/development/src/schemaNormalizer.cjs.map +1 -0
  67. package/dist/development/src/schemaNormalizer.js +72 -0
  68. package/dist/development/src/schemaNormalizer.js.map +1 -0
  69. package/dist/development/src/type-schema/acl.cjs +149 -0
  70. package/dist/development/src/type-schema/acl.cjs.map +1 -0
  71. package/dist/development/src/type-schema/acl.js +132 -0
  72. package/dist/development/src/type-schema/acl.js.map +1 -0
  73. package/dist/development/src/type-schema/actions.cjs +88 -0
  74. package/dist/development/src/type-schema/actions.cjs.map +1 -0
  75. package/dist/development/src/type-schema/actions.js +71 -0
  76. package/dist/development/src/type-schema/actions.js.map +1 -0
  77. package/dist/development/src/type-schema/condition.cjs +92 -0
  78. package/dist/development/src/type-schema/condition.cjs.map +1 -0
  79. package/dist/development/src/type-schema/condition.js +75 -0
  80. package/dist/development/src/type-schema/condition.js.map +1 -0
  81. package/dist/development/src/type-schema/model.cjs +222 -0
  82. package/dist/development/src/type-schema/model.cjs.map +1 -0
  83. package/dist/development/src/type-schema/model.js +206 -0
  84. package/dist/development/src/type-schema/model.js.map +1 -0
  85. package/dist/development/src/type-schema/settings.cjs +34 -0
  86. package/dist/development/src/type-schema/settings.cjs.map +1 -0
  87. package/dist/development/src/type-schema/settings.js +17 -0
  88. package/dist/development/src/type-schema/settings.js.map +1 -0
  89. package/dist/development/src/type-schema/validation.cjs +115 -0
  90. package/dist/development/src/type-schema/validation.cjs.map +1 -0
  91. package/dist/development/src/type-schema/validation.js +98 -0
  92. package/dist/development/src/type-schema/validation.js.map +1 -0
  93. package/dist/development/src/type-schema/where.cjs +46 -0
  94. package/dist/development/src/type-schema/where.cjs.map +1 -0
  95. package/dist/development/src/type-schema/where.js +29 -0
  96. package/dist/development/src/type-schema/where.js.map +1 -0
  97. package/dist/development/src/utils/assertNever.cjs +7 -0
  98. package/dist/development/src/utils/assertNever.cjs.map +1 -0
  99. package/dist/development/src/utils/assertNever.js +7 -0
  100. package/dist/development/src/utils/assertNever.js.map +1 -0
  101. package/dist/development/src/utils/deepCompare.cjs +134 -0
  102. package/dist/development/src/utils/deepCompare.cjs.map +1 -0
  103. package/dist/development/src/utils/deepCompare.js +134 -0
  104. package/dist/development/src/utils/deepCompare.js.map +1 -0
  105. package/dist/development/src/utils/isIt.cjs +7 -0
  106. package/dist/development/src/utils/isIt.cjs.map +1 -0
  107. package/dist/development/src/utils/isIt.js +7 -0
  108. package/dist/development/src/utils/isIt.js.map +1 -0
  109. package/dist/development/src/utils/printJsValue.cjs +42 -0
  110. package/dist/development/src/utils/printJsValue.cjs.map +1 -0
  111. package/dist/development/src/utils/printJsValue.js +42 -0
  112. package/dist/development/src/utils/printJsValue.js.map +1 -0
  113. package/dist/development/src/validation/AclValidator.cjs +168 -0
  114. package/dist/development/src/validation/AclValidator.cjs.map +1 -0
  115. package/dist/development/src/validation/AclValidator.js +168 -0
  116. package/dist/development/src/validation/AclValidator.js.map +1 -0
  117. package/dist/development/src/validation/ActionsValidator.cjs +127 -0
  118. package/dist/development/src/validation/ActionsValidator.cjs.map +1 -0
  119. package/dist/development/src/validation/ActionsValidator.js +110 -0
  120. package/dist/development/src/validation/ActionsValidator.js.map +1 -0
  121. package/dist/development/src/validation/MembershipResolver.cjs +129 -0
  122. package/dist/development/src/validation/MembershipResolver.cjs.map +1 -0
  123. package/dist/development/src/validation/MembershipResolver.js +129 -0
  124. package/dist/development/src/validation/MembershipResolver.js.map +1 -0
  125. package/dist/development/src/validation/ModelValidator.cjs +325 -0
  126. package/dist/development/src/validation/ModelValidator.cjs.map +1 -0
  127. package/dist/development/src/validation/ModelValidator.js +325 -0
  128. package/dist/development/src/validation/ModelValidator.js.map +1 -0
  129. package/dist/development/src/validation/SchemaValidator.cjs +29 -0
  130. package/dist/development/src/validation/SchemaValidator.cjs.map +1 -0
  131. package/dist/development/src/validation/SchemaValidator.js +29 -0
  132. package/dist/development/src/validation/SchemaValidator.js.map +1 -0
  133. package/dist/development/src/validation/ValidationValidator.cjs +121 -0
  134. package/dist/development/src/validation/ValidationValidator.cjs.map +1 -0
  135. package/dist/development/src/validation/ValidationValidator.js +121 -0
  136. package/dist/development/src/validation/ValidationValidator.js.map +1 -0
  137. package/dist/development/src/validation/errors.cjs +16 -0
  138. package/dist/development/src/validation/errors.cjs.map +1 -0
  139. package/dist/development/src/validation/errors.js +16 -0
  140. package/dist/development/src/validation/errors.js.map +1 -0
  141. package/dist/production/index.cjs +110 -0
  142. package/dist/production/index.cjs.map +1 -0
  143. package/dist/production/index.js +94 -0
  144. package/dist/production/index.js.map +1 -0
  145. package/dist/production/src/acl/AllowAllPermissionFactory.cjs +42 -0
  146. package/dist/production/src/acl/AllowAllPermissionFactory.cjs.map +1 -0
  147. package/dist/production/src/acl/AllowAllPermissionFactory.js +42 -0
  148. package/dist/production/src/acl/AllowAllPermissionFactory.js.map +1 -0
  149. package/dist/production/src/acl/PredicateDefinitionProcessor.cjs +69 -0
  150. package/dist/production/src/acl/PredicateDefinitionProcessor.cjs.map +1 -0
  151. package/dist/production/src/acl/PredicateDefinitionProcessor.js +69 -0
  152. package/dist/production/src/acl/PredicateDefinitionProcessor.js.map +1 -0
  153. package/dist/production/src/acl/schemaUtils.cjs +11 -0
  154. package/dist/production/src/acl/schemaUtils.cjs.map +1 -0
  155. package/dist/production/src/acl/schemaUtils.js +11 -0
  156. package/dist/production/src/acl/schemaUtils.js.map +1 -0
  157. package/dist/production/src/dataUtils.cjs +59 -0
  158. package/dist/production/src/dataUtils.cjs.map +1 -0
  159. package/dist/production/src/dataUtils.js +59 -0
  160. package/dist/production/src/dataUtils.js.map +1 -0
  161. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs +118 -0
  162. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs.map +1 -0
  163. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js +118 -0
  164. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js.map +1 -0
  165. package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs +218 -0
  166. package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs.map +1 -0
  167. package/dist/production/src/definition-generator/DefinitionCodeGenerator.js +218 -0
  168. package/dist/production/src/definition-generator/DefinitionCodeGenerator.js.map +1 -0
  169. package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs +68 -0
  170. package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs.map +1 -0
  171. package/dist/production/src/definition-generator/DefinitionNamingConventions.js +68 -0
  172. package/dist/production/src/definition-generator/DefinitionNamingConventions.js.map +1 -0
  173. package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs +17 -0
  174. package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs.map +1 -0
  175. package/dist/production/src/definition-generator/TsDefinitionGenerator.js +17 -0
  176. package/dist/production/src/definition-generator/TsDefinitionGenerator.js.map +1 -0
  177. package/dist/production/src/lax/LaxSchemaConverter.cjs +202 -0
  178. package/dist/production/src/lax/LaxSchemaConverter.cjs.map +1 -0
  179. package/dist/production/src/lax/LaxSchemaConverter.js +202 -0
  180. package/dist/production/src/lax/LaxSchemaConverter.js.map +1 -0
  181. package/dist/production/src/lax/schema.cjs +70 -0
  182. package/dist/production/src/lax/schema.cjs.map +1 -0
  183. package/dist/production/src/lax/schema.js +53 -0
  184. package/dist/production/src/lax/schema.js.map +1 -0
  185. package/dist/production/src/model/NamingConventions.cjs +28 -0
  186. package/dist/production/src/model/NamingConventions.cjs.map +1 -0
  187. package/dist/production/src/model/NamingConventions.js +28 -0
  188. package/dist/production/src/model/NamingConventions.js.map +1 -0
  189. package/dist/production/src/model/modelUtils.cjs +229 -0
  190. package/dist/production/src/model/modelUtils.cjs.map +1 -0
  191. package/dist/production/src/model/modelUtils.js +229 -0
  192. package/dist/production/src/model/modelUtils.js.map +1 -0
  193. package/dist/production/src/model/resolveDefaultColumnType.cjs +30 -0
  194. package/dist/production/src/model/resolveDefaultColumnType.cjs.map +1 -0
  195. package/dist/production/src/model/resolveDefaultColumnType.js +30 -0
  196. package/dist/production/src/model/resolveDefaultColumnType.js.map +1 -0
  197. package/dist/production/src/schemaChecksum.cjs +9 -0
  198. package/dist/production/src/schemaChecksum.cjs.map +1 -0
  199. package/dist/production/src/schemaChecksum.js +9 -0
  200. package/dist/production/src/schemaChecksum.js.map +1 -0
  201. package/dist/production/src/schemaFilter.cjs +24 -0
  202. package/dist/production/src/schemaFilter.cjs.map +1 -0
  203. package/dist/production/src/schemaFilter.js +24 -0
  204. package/dist/production/src/schemaFilter.js.map +1 -0
  205. package/dist/production/src/schemaNormalizer.cjs +72 -0
  206. package/dist/production/src/schemaNormalizer.cjs.map +1 -0
  207. package/dist/production/src/schemaNormalizer.js +72 -0
  208. package/dist/production/src/schemaNormalizer.js.map +1 -0
  209. package/dist/production/src/type-schema/acl.cjs +149 -0
  210. package/dist/production/src/type-schema/acl.cjs.map +1 -0
  211. package/dist/production/src/type-schema/acl.js +132 -0
  212. package/dist/production/src/type-schema/acl.js.map +1 -0
  213. package/dist/production/src/type-schema/actions.cjs +88 -0
  214. package/dist/production/src/type-schema/actions.cjs.map +1 -0
  215. package/dist/production/src/type-schema/actions.js +71 -0
  216. package/dist/production/src/type-schema/actions.js.map +1 -0
  217. package/dist/production/src/type-schema/condition.cjs +92 -0
  218. package/dist/production/src/type-schema/condition.cjs.map +1 -0
  219. package/dist/production/src/type-schema/condition.js +75 -0
  220. package/dist/production/src/type-schema/condition.js.map +1 -0
  221. package/dist/production/src/type-schema/model.cjs +222 -0
  222. package/dist/production/src/type-schema/model.cjs.map +1 -0
  223. package/dist/production/src/type-schema/model.js +206 -0
  224. package/dist/production/src/type-schema/model.js.map +1 -0
  225. package/dist/production/src/type-schema/settings.cjs +34 -0
  226. package/dist/production/src/type-schema/settings.cjs.map +1 -0
  227. package/dist/production/src/type-schema/settings.js +17 -0
  228. package/dist/production/src/type-schema/settings.js.map +1 -0
  229. package/dist/production/src/type-schema/validation.cjs +115 -0
  230. package/dist/production/src/type-schema/validation.cjs.map +1 -0
  231. package/dist/production/src/type-schema/validation.js +98 -0
  232. package/dist/production/src/type-schema/validation.js.map +1 -0
  233. package/dist/production/src/type-schema/where.cjs +46 -0
  234. package/dist/production/src/type-schema/where.cjs.map +1 -0
  235. package/dist/production/src/type-schema/where.js +29 -0
  236. package/dist/production/src/type-schema/where.js.map +1 -0
  237. package/dist/production/src/utils/assertNever.cjs +7 -0
  238. package/dist/production/src/utils/assertNever.cjs.map +1 -0
  239. package/dist/production/src/utils/assertNever.js +7 -0
  240. package/dist/production/src/utils/assertNever.js.map +1 -0
  241. package/dist/production/src/utils/deepCompare.cjs +134 -0
  242. package/dist/production/src/utils/deepCompare.cjs.map +1 -0
  243. package/dist/production/src/utils/deepCompare.js +134 -0
  244. package/dist/production/src/utils/deepCompare.js.map +1 -0
  245. package/dist/production/src/utils/isIt.cjs +7 -0
  246. package/dist/production/src/utils/isIt.cjs.map +1 -0
  247. package/dist/production/src/utils/isIt.js +7 -0
  248. package/dist/production/src/utils/isIt.js.map +1 -0
  249. package/dist/production/src/utils/printJsValue.cjs +42 -0
  250. package/dist/production/src/utils/printJsValue.cjs.map +1 -0
  251. package/dist/production/src/utils/printJsValue.js +42 -0
  252. package/dist/production/src/utils/printJsValue.js.map +1 -0
  253. package/dist/production/src/validation/AclValidator.cjs +168 -0
  254. package/dist/production/src/validation/AclValidator.cjs.map +1 -0
  255. package/dist/production/src/validation/AclValidator.js +168 -0
  256. package/dist/production/src/validation/AclValidator.js.map +1 -0
  257. package/dist/production/src/validation/ActionsValidator.cjs +127 -0
  258. package/dist/production/src/validation/ActionsValidator.cjs.map +1 -0
  259. package/dist/production/src/validation/ActionsValidator.js +110 -0
  260. package/dist/production/src/validation/ActionsValidator.js.map +1 -0
  261. package/dist/production/src/validation/MembershipResolver.cjs +129 -0
  262. package/dist/production/src/validation/MembershipResolver.cjs.map +1 -0
  263. package/dist/production/src/validation/MembershipResolver.js +129 -0
  264. package/dist/production/src/validation/MembershipResolver.js.map +1 -0
  265. package/dist/production/src/validation/ModelValidator.cjs +325 -0
  266. package/dist/production/src/validation/ModelValidator.cjs.map +1 -0
  267. package/dist/production/src/validation/ModelValidator.js +325 -0
  268. package/dist/production/src/validation/ModelValidator.js.map +1 -0
  269. package/dist/production/src/validation/SchemaValidator.cjs +29 -0
  270. package/dist/production/src/validation/SchemaValidator.cjs.map +1 -0
  271. package/dist/production/src/validation/SchemaValidator.js +29 -0
  272. package/dist/production/src/validation/SchemaValidator.js.map +1 -0
  273. package/dist/production/src/validation/ValidationValidator.cjs +121 -0
  274. package/dist/production/src/validation/ValidationValidator.cjs.map +1 -0
  275. package/dist/production/src/validation/ValidationValidator.js +121 -0
  276. package/dist/production/src/validation/ValidationValidator.js.map +1 -0
  277. package/dist/production/src/validation/errors.cjs +16 -0
  278. package/dist/production/src/validation/errors.cjs.map +1 -0
  279. package/dist/production/src/validation/errors.js +16 -0
  280. package/dist/production/src/validation/errors.js.map +1 -0
  281. package/dist/tests/cases/unit/conditionSchema.test.d.ts +2 -0
  282. package/dist/tests/cases/unit/conditionSchema.test.d.ts.map +1 -0
  283. package/dist/tests/cases/unit/deepCompare.test.d.ts +2 -0
  284. package/dist/tests/cases/unit/deepCompare.test.d.ts.map +1 -0
  285. package/dist/tests/cases/unit/laxSchemaConverter.test.d.ts +2 -0
  286. package/dist/tests/cases/unit/laxSchemaConverter.test.d.ts.map +1 -0
  287. package/dist/tests/cases/unit/membershipResolver.test.d.ts +2 -0
  288. package/dist/tests/cases/unit/membershipResolver.test.d.ts.map +1 -0
  289. package/dist/tests/cases/unit/modelSchema.test.d.ts +2 -0
  290. package/dist/tests/cases/unit/modelSchema.test.d.ts.map +1 -0
  291. package/dist/tests/cases/unit/modelValidator.test.d.ts +2 -0
  292. package/dist/tests/cases/unit/modelValidator.test.d.ts.map +1 -0
  293. package/dist/tests/cases/unit/printJsvalue.test.d.ts +2 -0
  294. package/dist/tests/cases/unit/printJsvalue.test.d.ts.map +1 -0
  295. package/dist/tests/cases/unit/schemas/acl.d.ts +12 -0
  296. package/dist/tests/cases/unit/schemas/acl.d.ts.map +1 -0
  297. package/dist/tests/cases/unit/schemas/basic.d.ts +4 -0
  298. package/dist/tests/cases/unit/schemas/basic.d.ts.map +1 -0
  299. package/dist/tests/cases/unit/schemas/complex.d.ts +12 -0
  300. package/dist/tests/cases/unit/schemas/complex.d.ts.map +1 -0
  301. package/dist/tests/cases/unit/schemas/enum.d.ts +6 -0
  302. package/dist/tests/cases/unit/schemas/enum.d.ts.map +1 -0
  303. package/dist/tests/cases/unit/schemas/relations.d.ts +14 -0
  304. package/dist/tests/cases/unit/schemas/relations.d.ts.map +1 -0
  305. package/dist/tests/cases/unit/schemas/unique.d.ts +4 -0
  306. package/dist/tests/cases/unit/schemas/unique.d.ts.map +1 -0
  307. package/dist/tests/cases/unit/schemas/view.d.ts +4 -0
  308. package/dist/tests/cases/unit/schemas/view.d.ts.map +1 -0
  309. package/dist/tests/cases/unit/tsDefinitionGenerator.test.d.ts +2 -0
  310. package/dist/tests/cases/unit/tsDefinitionGenerator.test.d.ts.map +1 -0
  311. package/dist/tests/cases/unit/whereSchema.test.d.ts +2 -0
  312. package/dist/tests/cases/unit/whereSchema.test.d.ts.map +1 -0
  313. package/dist/tests/tsconfig.tsbuildinfo +1 -0
  314. package/dist/types/acl/AllowAllPermissionFactory.d.ts +7 -0
  315. package/dist/types/acl/AllowAllPermissionFactory.d.ts.map +1 -0
  316. package/dist/types/acl/PredicateDefinitionProcessor.d.ts +32 -0
  317. package/dist/types/acl/PredicateDefinitionProcessor.d.ts.map +1 -0
  318. package/dist/types/acl/index.d.ts +4 -0
  319. package/dist/types/acl/index.d.ts.map +1 -0
  320. package/dist/types/acl/schemaUtils.d.ts +3 -0
  321. package/dist/types/acl/schemaUtils.d.ts.map +1 -0
  322. package/dist/types/dataUtils.d.ts +18 -0
  323. package/dist/types/dataUtils.d.ts.map +1 -0
  324. package/dist/types/definition-generator/AclDefinitionCodeGenerator.d.ts +19 -0
  325. package/dist/types/definition-generator/AclDefinitionCodeGenerator.d.ts.map +1 -0
  326. package/dist/types/definition-generator/DefinitionCodeGenerator.d.ts +27 -0
  327. package/dist/types/definition-generator/DefinitionCodeGenerator.d.ts.map +1 -0
  328. package/dist/types/definition-generator/DefinitionNamingConventions.d.ts +7 -0
  329. package/dist/types/definition-generator/DefinitionNamingConventions.d.ts.map +1 -0
  330. package/dist/types/definition-generator/TsDefinitionGenerator.d.ts +12 -0
  331. package/dist/types/definition-generator/TsDefinitionGenerator.d.ts.map +1 -0
  332. package/dist/types/definition-generator/index.d.ts +5 -0
  333. package/dist/types/definition-generator/index.d.ts.map +1 -0
  334. package/dist/types/index.d.ts +15 -0
  335. package/dist/types/index.d.ts.map +1 -0
  336. package/dist/types/lax/LaxSchemaConverter.d.ts +10 -0
  337. package/dist/types/lax/LaxSchemaConverter.d.ts.map +1 -0
  338. package/dist/types/lax/index.d.ts +3 -0
  339. package/dist/types/lax/index.d.ts.map +1 -0
  340. package/dist/types/lax/schema.d.ts +285 -0
  341. package/dist/types/lax/schema.d.ts.map +1 -0
  342. package/dist/types/model/NamingConventions.d.ts +17 -0
  343. package/dist/types/model/NamingConventions.d.ts.map +1 -0
  344. package/dist/types/model/index.d.ts +4 -0
  345. package/dist/types/model/index.d.ts.map +1 -0
  346. package/dist/types/model/modelUtils.d.ts +28 -0
  347. package/dist/types/model/modelUtils.d.ts.map +1 -0
  348. package/dist/types/model/resolveDefaultColumnType.d.ts +3 -0
  349. package/dist/types/model/resolveDefaultColumnType.d.ts.map +1 -0
  350. package/dist/types/schemaChecksum.d.ts +3 -0
  351. package/dist/types/schemaChecksum.d.ts.map +1 -0
  352. package/dist/types/schemaFilter.d.ts +3 -0
  353. package/dist/types/schemaFilter.d.ts.map +1 -0
  354. package/dist/types/schemaNormalizer.d.ts +3 -0
  355. package/dist/types/schemaNormalizer.d.ts.map +1 -0
  356. package/dist/types/tsconfig.tsbuildinfo +1 -0
  357. package/dist/types/type-schema/acl.d.ts +10 -0
  358. package/dist/types/type-schema/acl.d.ts.map +1 -0
  359. package/dist/types/type-schema/actions.d.ts +32 -0
  360. package/dist/types/type-schema/actions.d.ts.map +1 -0
  361. package/dist/types/type-schema/condition.d.ts +4 -0
  362. package/dist/types/type-schema/condition.d.ts.map +1 -0
  363. package/dist/types/type-schema/index.d.ts +6 -0
  364. package/dist/types/type-schema/index.d.ts.map +1 -0
  365. package/dist/types/type-schema/model.d.ts +30 -0
  366. package/dist/types/type-schema/model.d.ts.map +1 -0
  367. package/dist/types/type-schema/settings.d.ts +41 -0
  368. package/dist/types/type-schema/settings.d.ts.map +1 -0
  369. package/dist/types/type-schema/validation.d.ts +15 -0
  370. package/dist/types/type-schema/validation.d.ts.map +1 -0
  371. package/dist/types/type-schema/where.d.ts +7 -0
  372. package/dist/types/type-schema/where.d.ts.map +1 -0
  373. package/dist/types/utils/assertNever.d.ts +2 -0
  374. package/dist/types/utils/assertNever.d.ts.map +1 -0
  375. package/dist/types/utils/deepCompare.d.ts +13 -0
  376. package/dist/types/utils/deepCompare.d.ts.map +1 -0
  377. package/dist/types/utils/index.d.ts +4 -0
  378. package/dist/types/utils/index.d.ts.map +1 -0
  379. package/dist/types/utils/isIt.d.ts +2 -0
  380. package/dist/types/utils/isIt.d.ts.map +1 -0
  381. package/dist/types/utils/printJsValue.d.ts +13 -0
  382. package/dist/types/utils/printJsValue.d.ts.map +1 -0
  383. package/dist/types/validation/AclValidator.d.ts +20 -0
  384. package/dist/types/validation/AclValidator.d.ts.map +1 -0
  385. package/dist/types/validation/ActionsValidator.d.ts +13 -0
  386. package/dist/types/validation/ActionsValidator.d.ts.map +1 -0
  387. package/dist/types/validation/MembershipResolver.d.ts +37 -0
  388. package/dist/types/validation/MembershipResolver.d.ts.map +1 -0
  389. package/dist/types/validation/ModelValidator.d.ts +20 -0
  390. package/dist/types/validation/ModelValidator.d.ts.map +1 -0
  391. package/dist/types/validation/SchemaValidator.d.ts +11 -0
  392. package/dist/types/validation/SchemaValidator.d.ts.map +1 -0
  393. package/dist/types/validation/ValidationValidator.d.ts +14 -0
  394. package/dist/types/validation/ValidationValidator.d.ts.map +1 -0
  395. package/dist/types/validation/errors.d.ts +14 -0
  396. package/dist/types/validation/errors.d.ts.map +1 -0
  397. package/dist/types/validation/index.d.ts +7 -0
  398. package/dist/types/validation/index.d.ts.map +1 -0
  399. package/package.json +5 -5
@@ -0,0 +1,129 @@
1
+ import { Acl } from "@contember/schema";
2
+ import { assertNever } from "../utils/assertNever.js";
3
+ import { getRoleVariables } from "../acl/schemaUtils.js";
4
+ import "../type-schema/acl.js";
5
+ import { conditionSchema } from "../type-schema/condition.js";
6
+ import "../type-schema/model.js";
7
+ import "../type-schema/settings.js";
8
+ import "../type-schema/validation.js";
9
+ var __defProp = Object.defineProperty;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
12
+ class MembershipResolver {
13
+ resolve(acl, memberships, identity, isAssumed) {
14
+ const errors = [];
15
+ const parsed = [];
16
+ const roles = acl.roles;
17
+ for (const membership of memberships) {
18
+ if (!roles[membership.role]) {
19
+ errors.push(new MembershipValidationError(
20
+ membership.role,
21
+ "roleNotFound"
22
+ /* ROLE_NOT_FOUND */
23
+ ));
24
+ continue;
25
+ }
26
+ const roleVariables = getRoleVariables(membership.role, acl);
27
+ for (const variable of membership.variables) {
28
+ if (!roleVariables[variable.name] || !isAssumed && roleVariables[variable.name].type === Acl.VariableType.predefined) {
29
+ errors.push(
30
+ new MembershipValidationError(
31
+ membership.role,
32
+ "variableNotFound",
33
+ variable.name
34
+ )
35
+ );
36
+ }
37
+ }
38
+ const [membershipErrors, parsedVariables] = this.readMembershipVariables(roleVariables, membership, identity, isAssumed);
39
+ errors.push(...membershipErrors);
40
+ parsed.push({
41
+ role: membership.role,
42
+ variables: parsedVariables
43
+ });
44
+ }
45
+ return new MembershipReadResult(errors, parsed);
46
+ }
47
+ readMembershipVariables(roleVariables, membership, identity, isAssumed) {
48
+ const errors = [];
49
+ const parsedVariables = [];
50
+ for (const [name, variable] of Object.entries(roleVariables)) {
51
+ const inputVariable = membership.variables.find((it) => it.name === name);
52
+ if (variable.type === Acl.VariableType.predefined) {
53
+ switch (variable.value) {
54
+ case "identityID":
55
+ parsedVariables.push({
56
+ name,
57
+ condition: { in: isAssumed && inputVariable ? inputVariable.values : [identity.identityId] }
58
+ });
59
+ break;
60
+ case "personID":
61
+ parsedVariables.push({
62
+ name,
63
+ condition: { in: isAssumed && inputVariable ? inputVariable.values : identity.personId ? [identity.personId] : [] }
64
+ });
65
+ break;
66
+ default:
67
+ parsedVariables.push({ name, condition: { never: true } });
68
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
69
+ break;
70
+ }
71
+ continue;
72
+ }
73
+ if (!inputVariable) {
74
+ if (variable.fallback) {
75
+ parsedVariables.push({ name, condition: variable.fallback });
76
+ } else {
77
+ errors.push(new MembershipValidationError(membership.role, "variableEmpty", name));
78
+ parsedVariables.push({ name, condition: { never: true } });
79
+ }
80
+ continue;
81
+ }
82
+ if (variable.type === Acl.VariableType.entity) {
83
+ parsedVariables.push({ name, condition: { in: inputVariable.values } });
84
+ } else if (variable.type === Acl.VariableType.condition) {
85
+ try {
86
+ const conditions = inputVariable.values.map((it) => conditionSchema()(JSON.parse(it)));
87
+ parsedVariables.push({
88
+ name,
89
+ condition: conditions.length === 1 ? conditions[0] : { or: conditions }
90
+ });
91
+ } catch {
92
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
93
+ parsedVariables.push({ name, condition: { never: true } });
94
+ }
95
+ } else {
96
+ assertNever();
97
+ }
98
+ }
99
+ return [errors, parsedVariables];
100
+ }
101
+ }
102
+ __publicField(MembershipResolver, "UnknownIdentity", { identityId: "00000000-0000-0000-0000-000000000000" });
103
+ class MembershipReadResult {
104
+ constructor(errors, memberships) {
105
+ this.errors = errors;
106
+ this.memberships = memberships;
107
+ }
108
+ }
109
+ class MembershipValidationError {
110
+ constructor(role, error, variable) {
111
+ this.role = role;
112
+ this.error = error;
113
+ this.variable = variable;
114
+ }
115
+ }
116
+ var MembershipValidationErrorType = /* @__PURE__ */ ((MembershipValidationErrorType2) => {
117
+ MembershipValidationErrorType2["ROLE_NOT_FOUND"] = "roleNotFound";
118
+ MembershipValidationErrorType2["VARIABLE_NOT_FOUND"] = "variableNotFound";
119
+ MembershipValidationErrorType2["VARIABLE_EMPTY"] = "variableEmpty";
120
+ MembershipValidationErrorType2["VARIABLE_INVALID"] = "variableInvalid";
121
+ return MembershipValidationErrorType2;
122
+ })(MembershipValidationErrorType || {});
123
+ export {
124
+ MembershipReadResult,
125
+ MembershipResolver,
126
+ MembershipValidationError,
127
+ MembershipValidationErrorType
128
+ };
129
+ //# sourceMappingURL=MembershipResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MembershipResolver.js","sources":["../../../../../packages/schema-utils/src/validation/MembershipResolver.ts"],"sourcesContent":["import { Acl, Input } from '@contember/schema'\nimport { getRoleVariables } from '../acl'\nimport { conditionSchema } from '../type-schema'\nimport { assertNever } from '../utils'\n\nexport class MembershipResolver {\n\tpublic static UnknownIdentity = { identityId: '00000000-0000-0000-0000-000000000000' }\n\n\tresolve(\n\t\tacl: Acl.Schema,\n\t\tmemberships: readonly Acl.Membership[],\n\t\tidentity: {\n\t\t\tidentityId: string\n\t\t\tpersonId?: string\n\t\t},\n\t\tisAssumed: boolean,\n\t): MembershipReadResult {\n\t\tconst errors: MembershipValidationError[] = []\n\t\tconst parsed: ParsedMembership[] = []\n\t\tconst roles = acl.roles\n\t\tfor (const membership of memberships) {\n\t\t\tif (!roles[membership.role]) {\n\t\t\t\terrors.push(new MembershipValidationError(membership.role, MembershipValidationErrorType.ROLE_NOT_FOUND))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst roleVariables = getRoleVariables(membership.role, acl)\n\t\t\tfor (const variable of membership.variables) {\n\t\t\t\tif (!roleVariables[variable.name] || (!isAssumed && roleVariables[variable.name].type === Acl.VariableType.predefined)) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\tnew MembershipValidationError(\n\t\t\t\t\t\t\tmembership.role,\n\t\t\t\t\t\t\tMembershipValidationErrorType.VARIABLE_NOT_FOUND,\n\t\t\t\t\t\t\tvariable.name,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst [membershipErrors, parsedVariables] = this.readMembershipVariables(roleVariables, membership, identity, isAssumed)\n\t\t\terrors.push(...membershipErrors)\n\t\t\tparsed.push({\n\t\t\t\trole: membership.role,\n\t\t\t\tvariables: parsedVariables,\n\t\t\t})\n\t\t}\n\t\treturn new MembershipReadResult(errors, parsed)\n\t}\n\n\tprivate readMembershipVariables(roleVariables: Acl.Variables, membership: Acl.Membership, identity: {\n\t\tidentityId: string\n\t\tpersonId?: string\n\t}, isAssumed: boolean): [MembershipValidationError[], ParsedMembershipVariable[]] {\n\t\tconst errors: MembershipValidationError[] = []\n\t\tconst parsedVariables: ParsedMembershipVariable[] = []\n\t\tfor (const [name, variable] of Object.entries(roleVariables)) {\n\t\t\tconst inputVariable = membership.variables.find(it => it.name === name)\n\t\t\tif (variable.type === Acl.VariableType.predefined) {\n\t\t\t\tswitch (variable.value) {\n\t\t\t\t\tcase 'identityID':\n\t\t\t\t\t\tparsedVariables.push({\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tcondition: { in: isAssumed && inputVariable ? inputVariable.values : [identity.identityId] },\n\t\t\t\t\t\t})\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'personID':\n\t\t\t\t\t\tparsedVariables.push({\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tcondition: { in: isAssumed && inputVariable ? inputVariable.values : identity.personId ? [identity.personId] : [] },\n\t\t\t\t\t\t})\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tparsedVariables.push({ name, condition: { never: true } })\n\t\t\t\t\t\terrors.push(new MembershipValidationError(membership.role, MembershipValidationErrorType.VARIABLE_INVALID, name))\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (!inputVariable) {\n\t\t\t\tif (variable.fallback) {\n\t\t\t\t\tparsedVariables.push({ name, condition: variable.fallback })\n\t\t\t\t} else {\n\t\t\t\t\terrors.push(new MembershipValidationError(membership.role, MembershipValidationErrorType.VARIABLE_EMPTY, name))\n\t\t\t\t\tparsedVariables.push({ name, condition: { never: true } })\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (variable.type === Acl.VariableType.entity) {\n\t\t\t\tparsedVariables.push({ name, condition: { in: inputVariable.values } }) // todo: cast to int where primary is int\n\t\t\t} else if (variable.type === Acl.VariableType.condition) {\n\t\t\t\ttry {\n\t\t\t\t\tconst conditions = inputVariable.values.map(it => conditionSchema()(JSON.parse(it)))\n\t\t\t\t\tparsedVariables.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tcondition: conditions.length === 1 ? conditions[0] : { or: conditions },\n\t\t\t\t\t})\n\t\t\t\t} catch {\n\t\t\t\t\terrors.push(new MembershipValidationError(membership.role, MembershipValidationErrorType.VARIABLE_INVALID, name))\n\t\t\t\t\tparsedVariables.push({ name, condition: { never: true } })\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(variable)\n\t\t\t}\n\t\t}\n\t\treturn [errors, parsedVariables]\n\t}\n}\n\nexport class MembershipReadResult {\n\tconstructor(\n\t\tpublic readonly errors: MembershipValidationError[],\n\t\tpublic readonly memberships: ParsedMembership[],\n\t) {\n\t}\n}\n\nexport class MembershipValidationError {\n\tconstructor(\n\t\tpublic readonly role: string,\n\t\tpublic readonly error: MembershipValidationErrorType,\n\t\tpublic readonly variable?: string,\n\t) {\n\t}\n}\n\nexport enum MembershipValidationErrorType {\n\tROLE_NOT_FOUND = 'roleNotFound',\n\tVARIABLE_NOT_FOUND = 'variableNotFound',\n\tVARIABLE_EMPTY = 'variableEmpty',\n\tVARIABLE_INVALID = 'variableInvalid',\n}\n\nexport interface ParsedMembershipVariable {\n\treadonly name: string\n\treadonly condition: Input.Condition\n}\n\nexport interface ParsedMembership {\n\treadonly role: string\n\treadonly variables: readonly ParsedMembershipVariable[]\n}\n"],"names":["MembershipValidationErrorType"],"mappings":";;;;;;;;;;;AAKO,MAAM,mBAAmB;AAAA,EAG/B,QACC,KACA,aACA,UAIA,WACuB;AACvB,UAAM,SAAsC,CAAA;AAC5C,UAAM,SAA6B,CAAA;AACnC,UAAM,QAAQ,IAAI;AAClB,eAAW,cAAc,aAAa;AACrC,UAAI,CAAC,MAAM,WAAW,IAAI,GAAG;AAC5B,eAAO,KAAK,IAAI;AAAA,UAA0B,WAAW;AAAA,UAAM;AAAA;AAAA,SAA6C;AACxG;AAAA,MACD;AACA,YAAM,gBAAgB,iBAAiB,WAAW,MAAM,GAAG;AAC3D,iBAAW,YAAY,WAAW,WAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,IAAI,KAAM,CAAC,aAAa,cAAc,SAAS,IAAI,EAAE,SAAS,IAAI,aAAa,YAAa;AACvH,iBAAO;AAAA,YACN,IAAI;AAAA,cACH,WAAW;AAAA,cACX;AAAA,cACA,SAAS;AAAA,YAAA;AAAA,UACV;AAAA,QAEF;AAAA,MACD;AACA,YAAM,CAAC,kBAAkB,eAAe,IAAI,KAAK,wBAAwB,eAAe,YAAY,UAAU,SAAS;AACvH,aAAO,KAAK,GAAG,gBAAgB;AAC/B,aAAO,KAAK;AAAA,QACX,MAAM,WAAW;AAAA,QACjB,WAAW;AAAA,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AAM,WAAW,EAAE,IAAI,cAAc,OAAA,GAAU;AAAA,MACvE,WAAW,SAAS,SAAS,IAAI,aAAa,WAAW;AACxD,YAAI;AACH,gBAAM,aAAa,cAAc,OAAO,IAAI,CAAA,OAAM,gBAAA,EAAkB,KAAK,MAAM,EAAE,CAAC,CAAC;AACnF,0BAAgB,KAAK;AAAA,YACpB;AAAA,YACA,WAAW,WAAW,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,WAAA;AAAA,UAAW,CACtE;AAAA,QACF,QAAQ;AACP,iBAAO,KAAK,IAAI,0BAA0B,WAAW,MAAM,mBAAgD,IAAI,CAAC;AAChH,0BAAgB,KAAK,EAAE,MAAM,WAAW,EAAE,OAAO,KAAA,GAAQ;AAAA,QAC1D;AAAA,MACD,OAAO;AACN,oBAAoB;AAAA,MACrB;AAAA,IACD;AACA,WAAO,CAAC,QAAQ,eAAe;AAAA,EAChC;AACD;AApGC,cADY,oBACE,mBAAkB,EAAE,YAAY,uCAAA,CAAuC;AAsG/E,MAAM,qBAAqB;AAAA,EACjC,YACiB,QACA,aACf;AAFe,SAAA,SAAA;AACA,SAAA,cAAA;AAAA,EAEjB;AACD;AAEO,MAAM,0BAA0B;AAAA,EACtC,YACiB,MACA,OACA,UACf;AAHe,SAAA,OAAA;AACA,SAAA,QAAA;AACA,SAAA,WAAA;AAAA,EAEjB;AACD;AAEO,IAAK,kDAAAA,mCAAL;AACNA,iCAAA,gBAAA,IAAiB;AACjBA,iCAAA,oBAAA,IAAqB;AACrBA,iCAAA,gBAAA,IAAiB;AACjBA,iCAAA,kBAAA,IAAmB;AAJR,SAAAA;AAAA,GAAA,iCAAA,CAAA,CAAA;"}
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const schema = require("@contember/schema");
4
+ const errors = require("./errors.cjs");
5
+ const modelUtils = require("../model/modelUtils.cjs");
6
+ const IDENTIFIER_PATTERN = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
7
+ const RESERVED_WORDS = ["and", "or", "not"];
8
+ class ModelValidator {
9
+ constructor(model) {
10
+ this.model = model;
11
+ }
12
+ validate() {
13
+ const errorBuilder = new errors.ErrorBuilder([], []);
14
+ this.validateEnums(this.model.enums, errorBuilder.for("enums"));
15
+ this.validateEntities(this.model.entities, errorBuilder.for("entities"));
16
+ return errorBuilder.errors;
17
+ }
18
+ validateEnums(enums, errors2) {
19
+ for (const [enumName, enumValues] of Object.entries(enums)) {
20
+ for (const value of enumValues) {
21
+ const valueErrors = errors2.for(enumName, value);
22
+ this.validateIdentifier(value, valueErrors);
23
+ }
24
+ }
25
+ }
26
+ validateEntities(entities, errors2) {
27
+ for (const [entityName, entity] of Object.entries(entities)) {
28
+ const entityErrors = errors2.for(entityName);
29
+ if (entity.name !== entityName) {
30
+ entityErrors.add("MODEL_NAME_MISMATCH", `Entity name "${entity.name}" does not match the name in a map "${entityName}"`);
31
+ }
32
+ this.validateEntity(entity, entityErrors);
33
+ }
34
+ const entitiesArr = Object.values(this.model.entities);
35
+ this.validateMetaSuffixCollisions(entitiesArr, errors2);
36
+ this.validateTableNameCollisions(entitiesArr, errors2);
37
+ this.validateAliasedTypesCollision(entitiesArr, errors2);
38
+ }
39
+ validateEntity(entity, errors2) {
40
+ this.validateIdentifier(entity.name, errors2);
41
+ this.validateEntityName(entity.name, errors2);
42
+ for (const [fieldName, field] of Object.entries(entity.fields)) {
43
+ const fieldErrors = errors2.for(fieldName);
44
+ this.validateField(entity, field, fieldErrors);
45
+ if (field.name !== fieldName) {
46
+ fieldErrors.add("MODEL_NAME_MISMATCH", `Field name "${field.name}" does not match the name in a map "${fieldName}"`);
47
+ }
48
+ }
49
+ this.validateUniqueConstraints(
50
+ entity,
51
+ errors2.for("unique")
52
+ );
53
+ this.validateColumnNamesCollision(entity, errors2);
54
+ }
55
+ validateUniqueConstraints(entity, errors2) {
56
+ for (const constraint of entity.unique) {
57
+ if (entity.view?.materialized && !constraint.index) {
58
+ errors2.add("MODEL_INVALID_CONSTRAINT", "For materialized views, Unique must be defined as an index. Please set index: true.");
59
+ }
60
+ for (const field of constraint.fields) {
61
+ const fieldDef = entity.fields[field];
62
+ if (!fieldDef) {
63
+ errors2.add("MODEL_UNDEFINED_FIELD", `Referenced field ${field} in a constraint does not exists`);
64
+ } else if (modelUtils.isColumn(fieldDef) && fieldDef.list) {
65
+ errors2.add("MODEL_INVALID_FIELD", `Field ${field} in a unique constraint cannot be an array`);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ validateColumnNamesCollision(entity, errors2) {
71
+ const existingColumnNames = /* @__PURE__ */ new Map();
72
+ const addColumnName = (fieldName, columnName) => {
73
+ if (existingColumnNames.has(columnName)) {
74
+ const exitingName = existingColumnNames.get(columnName);
75
+ errors2.for(fieldName).add("MODEL_NAME_COLLISION", `Column name "${columnName}" on field "${fieldName}" collides with a column name on field "${exitingName}".`);
76
+ }
77
+ existingColumnNames.set(columnName, fieldName);
78
+ };
79
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
80
+ visitColumn: ({ column }) => {
81
+ addColumnName(column.name, column.columnName);
82
+ },
83
+ visitOneHasOneOwning: ({ relation }) => {
84
+ addColumnName(relation.name, relation.joiningColumn.columnName);
85
+ },
86
+ visitManyHasOne: ({ relation }) => {
87
+ addColumnName(relation.name, relation.joiningColumn.columnName);
88
+ },
89
+ visitOneHasOneInverse: () => {
90
+ },
91
+ visitOneHasMany: () => {
92
+ },
93
+ visitManyHasManyInverse: () => {
94
+ },
95
+ visitManyHasManyOwning: () => {
96
+ }
97
+ });
98
+ }
99
+ validateField(partialEntity, field, errors2) {
100
+ this.validateIdentifier(field.name, errors2);
101
+ if (isRelation(field)) {
102
+ this.validateRelation(partialEntity, field, errors2);
103
+ } else {
104
+ if (field.sequence && field.nullable) {
105
+ errors2.add("MODEL_INVALID_COLUMN_DEFINITION", "Column with sequence cannot be nullable.");
106
+ }
107
+ }
108
+ }
109
+ validateRelation(partialEntity, field, errors2) {
110
+ const entityName = partialEntity.name;
111
+ const targetEntityName = field.target;
112
+ const targetEntity = this.model.entities[targetEntityName] || void 0;
113
+ if (!targetEntity) {
114
+ return errors2.add("MODEL_UNDEFINED_ENTITY", `Target entity ${targetEntityName} not found`);
115
+ }
116
+ if (((it) => "orderBy" in it)(field)) {
117
+ field.orderBy?.forEach((it) => {
118
+ let entity = targetEntity;
119
+ for (let i = 0; i < it.path.length; i++) {
120
+ const orderByField = entity.fields[it.path[i]];
121
+ const pathStr = it.path.slice(0, i + 1).join(".");
122
+ if (!orderByField) {
123
+ errors2.add("MODEL_UNDEFINED_FIELD", `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`);
124
+ return;
125
+ }
126
+ if (i + 1 < it.path.length) {
127
+ const targetEntity2 = modelUtils.getTargetEntity(this.model, entity, orderByField.name);
128
+ if (!targetEntity2) {
129
+ errors2.add("MODEL_RELATION_REQUIRED", `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not a relation`);
130
+ return;
131
+ }
132
+ entity = targetEntity2;
133
+ }
134
+ }
135
+ });
136
+ }
137
+ if (partialEntity.view) {
138
+ if (field.type === schema.Model.RelationType.ManyHasMany) {
139
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "Many-has-many relation is not allowed on a view entity.");
140
+ }
141
+ if (!targetEntity.view && field.type === schema.Model.RelationType.OneHasMany) {
142
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "One-has-many relation fields on views must point to a view entity.");
143
+ }
144
+ if (!targetEntity.view && field.type === schema.Model.RelationType.OneHasOne && !("joiningColumn" in field)) {
145
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "One-has-one relation fields on views must be owning or point to a view entity.");
146
+ }
147
+ }
148
+ if (modelUtils.isInverseRelation(field)) {
149
+ const ownedBy = field.ownedBy;
150
+ const targetField = targetEntity.fields[ownedBy];
151
+ const relationDescription = `Target relation ${targetEntityName}::${ownedBy}:`;
152
+ if (!targetField) {
153
+ return errors2.add("MODEL_UNDEFINED_FIELD", `${relationDescription} not exists`);
154
+ }
155
+ if (!isRelation(targetField)) {
156
+ return errors2.add("MODEL_RELATION_REQUIRED", `${relationDescription} not a relation`);
157
+ }
158
+ if (targetField.target !== entityName) {
159
+ return errors2.add(
160
+ "MODEL_INVALID_RELATION_DEFINITION",
161
+ `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`
162
+ );
163
+ }
164
+ if (!modelUtils.isOwningRelation(targetField)) {
165
+ errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} not an owning relation`);
166
+ return;
167
+ }
168
+ if (!targetField.inversedBy) {
169
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} inverse relation is not set`);
170
+ }
171
+ if (targetField.inversedBy !== field.name) {
172
+ return errors2.add(
173
+ "MODEL_INVALID_RELATION_DEFINITION",
174
+ `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.inversedBy} given`
175
+ );
176
+ }
177
+ if (field.type === schema.Model.RelationType.OneHasOne && targetField.type !== schema.Model.RelationType.OneHasOne) {
178
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "OneHasOne" type expected, "${targetField.type}" given`);
179
+ }
180
+ if (field.type === schema.Model.RelationType.OneHasMany && targetField.type !== schema.Model.RelationType.ManyHasOne) {
181
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasOne" type expected, "${targetField.type}" given`);
182
+ }
183
+ if (field.type === schema.Model.RelationType.ManyHasMany && targetField.type !== schema.Model.RelationType.ManyHasMany) {
184
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasMany" type expected, "${targetField.type}" given`);
185
+ }
186
+ } else {
187
+ const inversedBy = field.inversedBy;
188
+ if (inversedBy) {
189
+ const targetField = targetEntity.fields[inversedBy];
190
+ const relationDescription = `Target relation ${targetEntityName}::${inversedBy}:`;
191
+ if (!targetField) {
192
+ return errors2.add("MODEL_UNDEFINED_FIELD", `${relationDescription} not exists`);
193
+ }
194
+ if (!isRelation(targetField)) {
195
+ return errors2.add("MODEL_RELATION_REQUIRED", `${relationDescription} not a relation`);
196
+ }
197
+ if (targetField.target !== entityName) {
198
+ return errors2.add(
199
+ "MODEL_INVALID_RELATION_DEFINITION",
200
+ `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`
201
+ );
202
+ }
203
+ if (!modelUtils.isInverseRelation(targetField)) {
204
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} not an inverse relation`);
205
+ }
206
+ if (!targetField.ownedBy) {
207
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} owning relation is not set`);
208
+ }
209
+ if (targetField.ownedBy !== field.name) {
210
+ return errors2.add(
211
+ "MODEL_INVALID_RELATION_DEFINITION",
212
+ `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.ownedBy} given`
213
+ );
214
+ }
215
+ if (field.type === schema.Model.RelationType.OneHasOne && targetField.type !== schema.Model.RelationType.OneHasOne) {
216
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "OneHasOne" type expected, "${targetField.type}" given`);
217
+ }
218
+ if (field.type === schema.Model.RelationType.ManyHasOne && targetField.type !== schema.Model.RelationType.OneHasMany) {
219
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasOne" type expected, "${targetField.type}" given`);
220
+ }
221
+ if (field.type === schema.Model.RelationType.ManyHasMany && targetField.type !== schema.Model.RelationType.ManyHasMany) {
222
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasMany" type expected, "${targetField.type}" given`);
223
+ }
224
+ }
225
+ }
226
+ }
227
+ validateIdentifier(value, errorBuilder) {
228
+ if (!value.match(IDENTIFIER_PATTERN)) {
229
+ return errorBuilder.add("MODEL_INVALID_IDENTIFIER", `${value} must match pattern ${IDENTIFIER_PATTERN.source}`);
230
+ }
231
+ if (RESERVED_WORDS.includes(value)) {
232
+ errorBuilder.add("MODEL_INVALID_IDENTIFIER", `${value} is reserved word`);
233
+ }
234
+ }
235
+ validateEntityName(value, errorBuilder) {
236
+ if (["Query", "Mutation"].includes(value)) {
237
+ errorBuilder.add("MODEL_INVALID_ENTITY_NAME", `${value} is reserved word`);
238
+ }
239
+ }
240
+ validateMetaSuffixCollisions(entities, errorBuilder) {
241
+ const entityNames = new Set(entities.map((it) => it.name));
242
+ for (const entity of entities) {
243
+ if (entity.name.endsWith("Meta")) {
244
+ const baseName = entity.name.substring(0, entity.name.length - 4);
245
+ if (entityNames.has(baseName)) {
246
+ errorBuilder.for(entity.name).add(
247
+ "MODEL_NAME_COLLISION",
248
+ `entity ${entity.name} collides with entity ${baseName}, because a GraphQL type with "Meta" suffix is created for every entity`
249
+ );
250
+ }
251
+ }
252
+ }
253
+ }
254
+ validateTableNameCollisions(entities, errorBuilder) {
255
+ const relationNames = {};
256
+ for (const entity of entities) {
257
+ const description = `table name ${entity.tableName} of entity ${entity.name}`;
258
+ if (relationNames[entity.tableName]) {
259
+ errorBuilder.for(entity.name).add("MODEL_NAME_COLLISION", `${description} collides with a ${relationNames[entity.tableName]}`);
260
+ } else {
261
+ relationNames[entity.tableName] = description;
262
+ }
263
+ }
264
+ for (const entity of entities) {
265
+ const entityErrorBuilder = errorBuilder.for(entity.name);
266
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
267
+ visitManyHasManyOwning: ({ entity: entity2, relation }) => {
268
+ const joiningTable = relation.joiningTable;
269
+ const description = `joining table name ${joiningTable.tableName} of relation ${entity2.name}::${relation.name}`;
270
+ if (relationNames[joiningTable.tableName]) {
271
+ entityErrorBuilder.for(relation.name).add(
272
+ "MODEL_NAME_COLLISION",
273
+ `${description} collides with a ${relationNames[joiningTable.tableName]}.Consider using plural for a relation name or change the joining table name using .joiningTable(...) in schema definition.`
274
+ );
275
+ } else {
276
+ relationNames[joiningTable.tableName] = description;
277
+ }
278
+ },
279
+ visitColumn: () => {
280
+ },
281
+ visitManyHasManyInverse: () => {
282
+ },
283
+ visitOneHasMany: () => {
284
+ },
285
+ visitOneHasOneInverse: () => {
286
+ },
287
+ visitOneHasOneOwning: () => {
288
+ },
289
+ visitManyHasOne: () => {
290
+ }
291
+ });
292
+ }
293
+ }
294
+ validateAliasedTypesCollision(entities, errorBuilder) {
295
+ const aliasedTypes = /* @__PURE__ */ new Map();
296
+ for (const entity of entities) {
297
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
298
+ visitColumn: ({ column }) => {
299
+ if (!column.typeAlias) {
300
+ return;
301
+ }
302
+ if (aliasedTypes.has(column.typeAlias) && aliasedTypes.get(column.typeAlias) !== column.type) {
303
+ errorBuilder.for(column.name).add("MODEL_NAME_COLLISION", `Type alias ${column.typeAlias} already exists for base type ${column.type}`);
304
+ }
305
+ aliasedTypes.set(column.typeAlias, column.type);
306
+ },
307
+ visitManyHasManyOwning: () => {
308
+ },
309
+ visitManyHasManyInverse: () => {
310
+ },
311
+ visitOneHasMany: () => {
312
+ },
313
+ visitOneHasOneInverse: () => {
314
+ },
315
+ visitOneHasOneOwning: () => {
316
+ },
317
+ visitManyHasOne: () => {
318
+ }
319
+ });
320
+ }
321
+ }
322
+ }
323
+ const isRelation = (field) => Object.values(schema.Model.RelationType).includes(field.type);
324
+ exports.ModelValidator = ModelValidator;
325
+ //# sourceMappingURL=ModelValidator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelValidator.cjs","sources":["../../../../../packages/schema-utils/src/validation/ModelValidator.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { ErrorBuilder, ValidationError } from './errors'\nimport { acceptEveryFieldVisitor, getTargetEntity, isColumn, isInverseRelation, isOwningRelation } from '../model'\n\nconst IDENTIFIER_PATTERN = /^[_a-zA-Z][_a-zA-Z0-9]*$/\nconst RESERVED_WORDS = ['and', 'or', 'not']\n\nexport class ModelValidator {\n\tconstructor(private readonly model: Model.Schema) {}\n\n\tpublic validate(): ValidationError[] {\n\t\tconst errorBuilder = new ErrorBuilder([], [])\n\t\tthis.validateEnums(this.model.enums, errorBuilder.for('enums'))\n\t\tthis.validateEntities(this.model.entities, errorBuilder.for('entities'))\n\n\t\treturn errorBuilder.errors\n\t}\n\n\tprivate validateEnums(enums: Model.Schema['enums'], errors: ErrorBuilder): void {\n\t\tfor (const [enumName, enumValues] of Object.entries(enums)) {\n\t\t\tfor (const value of enumValues) {\n\t\t\t\tconst valueErrors = errors.for(enumName, value)\n\t\t\t\tthis.validateIdentifier(value, valueErrors)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateEntities(entities: Model.Schema['entities'], errors: ErrorBuilder): void {\n\t\tfor (const [entityName, entity] of Object.entries(entities)) {\n\t\t\tconst entityErrors = errors.for(entityName)\n\t\t\tif (entity.name !== entityName) {\n\t\t\t\tentityErrors.add('MODEL_NAME_MISMATCH', `Entity name \"${entity.name}\" does not match the name in a map \"${entityName}\"`)\n\t\t\t}\n\t\t\tthis.validateEntity(entity, entityErrors)\n\t\t}\n\t\tconst entitiesArr = Object.values(this.model.entities)\n\t\tthis.validateMetaSuffixCollisions(entitiesArr, errors)\n\t\tthis.validateTableNameCollisions(entitiesArr, errors)\n\t\tthis.validateAliasedTypesCollision(entitiesArr, errors)\n\t}\n\n\tprivate validateEntity(entity: Model.Entity, errors: ErrorBuilder): void {\n\t\tthis.validateIdentifier(entity.name, errors)\n\t\tthis.validateEntityName(entity.name, errors)\n\n\t\tfor (const [fieldName, field] of Object.entries(entity.fields)) {\n\t\t\tconst fieldErrors = errors.for(fieldName)\n\t\t\tthis.validateField(entity, field, fieldErrors)\n\t\t\tif (field.name !== fieldName) {\n\t\t\t\tfieldErrors.add('MODEL_NAME_MISMATCH', `Field name \"${field.name}\" does not match the name in a map \"${fieldName}\"`)\n\t\t\t}\n\t\t}\n\t\tthis.validateUniqueConstraints(\n\t\t\tentity,\n\t\t\terrors.for('unique'),\n\t\t)\n\t\tthis.validateColumnNamesCollision(entity, errors)\n\t}\n\n\tprivate validateUniqueConstraints(entity: Model.Entity, errors: ErrorBuilder): void {\n\t\tfor (const constraint of entity.unique) {\n\t\t\tif (entity.view?.materialized && !constraint.index) {\n\t\t\t\terrors.add('MODEL_INVALID_CONSTRAINT', 'For materialized views, Unique must be defined as an index. Please set index: true.')\n\t\t\t}\n\t\t\tfor (const field of constraint.fields) {\n\t\t\t\tconst fieldDef = entity.fields[field]\n\t\t\t\tif (!fieldDef) {\n\t\t\t\t\terrors.add('MODEL_UNDEFINED_FIELD', `Referenced field ${field} in a constraint does not exists`)\n\t\t\t\t} else if (isColumn(fieldDef) && fieldDef.list) {\n\t\t\t\t\terrors.add('MODEL_INVALID_FIELD', `Field ${field} in a unique constraint cannot be an array`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateColumnNamesCollision(entity: Model.Entity, errors: ErrorBuilder): void {\n\t\tconst existingColumnNames = new Map<string, string>()\n\t\tconst addColumnName = (fieldName: string, columnName: string) => {\n\t\t\tif (existingColumnNames.has(columnName)) {\n\t\t\t\tconst exitingName = existingColumnNames.get(columnName)\n\t\t\t\terrors\n\t\t\t\t\t.for(fieldName)\n\t\t\t\t\t.add('MODEL_NAME_COLLISION', `Column name \"${columnName}\" on field \"${fieldName}\" collides with a column name on field \"${exitingName}\".`)\n\t\t\t}\n\t\t\texistingColumnNames.set(columnName, fieldName)\n\t\t}\n\t\tacceptEveryFieldVisitor(this.model, entity, {\n\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\taddColumnName(column.name, column.columnName)\n\t\t\t},\n\t\t\tvisitOneHasOneOwning: ({ relation }) => {\n\t\t\t\taddColumnName(relation.name, relation.joiningColumn.columnName)\n\t\t\t},\n\t\t\tvisitManyHasOne: ({ relation }) => {\n\t\t\t\taddColumnName(relation.name, relation.joiningColumn.columnName)\n\t\t\t},\n\t\t\tvisitOneHasOneInverse: () => {},\n\t\t\tvisitOneHasMany: () => {},\n\t\t\tvisitManyHasManyInverse: () => {},\n\t\t\tvisitManyHasManyOwning: () => {},\n\t\t})\n\t}\n\n\tprivate validateField(partialEntity: Model.Entity, field: Model.AnyField, errors: ErrorBuilder): void {\n\t\tthis.validateIdentifier(field.name, errors)\n\t\tif (isRelation(field)) {\n\t\t\tthis.validateRelation(partialEntity, field, errors)\n\t\t} else {\n\t\t\tif (field.sequence && field.nullable) {\n\t\t\t\terrors.add('MODEL_INVALID_COLUMN_DEFINITION', 'Column with sequence cannot be nullable.')\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateRelation(partialEntity: Model.Entity, field: Model.AnyRelation, errors: ErrorBuilder): void {\n\t\tconst entityName = partialEntity.name\n\t\tconst targetEntityName = field.target\n\t\tconst targetEntity = this.model.entities[targetEntityName] || undefined\n\t\tif (!targetEntity) {\n\t\t\treturn errors.add('MODEL_UNDEFINED_ENTITY', `Target entity ${targetEntityName} not found`)\n\t\t}\n\t\tif (((it: Model.AnyRelation): it is Model.AnyRelation & Model.OrderableRelation => 'orderBy' in it)(field)) {\n\t\t\t;(field as Model.OrderableRelation).orderBy?.forEach(it => {\n\t\t\t\tlet entity = targetEntity\n\n\t\t\t\tfor (let i = 0; i < it.path.length; i++) {\n\t\t\t\t\tconst orderByField = entity.fields[it.path[i]]\n\t\t\t\t\tconst pathStr = it.path.slice(0, i + 1).join('.')\n\t\t\t\t\tif (!orderByField) {\n\t\t\t\t\t\terrors.add('MODEL_UNDEFINED_FIELD', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (i + 1 < it.path.length) {\n\t\t\t\t\t\tconst targetEntity = getTargetEntity(this.model, entity, orderByField.name)\n\t\t\t\t\t\tif (!targetEntity) {\n\t\t\t\t\t\t\terrors.add('MODEL_RELATION_REQUIRED', `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not a relation`)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tentity = targetEntity\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tif (partialEntity.view) {\n\t\t\tif (field.type === Model.RelationType.ManyHasMany) {\n\t\t\t\treturn errors.add('MODEL_INVALID_VIEW_USAGE', 'Many-has-many relation is not allowed on a view entity.')\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!targetEntity.view\n\t\t\t\t&& field.type === Model.RelationType.OneHasMany\n\t\t\t) {\n\t\t\t\treturn errors.add('MODEL_INVALID_VIEW_USAGE', 'One-has-many relation fields on views must point to a view entity.')\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!targetEntity.view\n\t\t\t\t&& field.type === Model.RelationType.OneHasOne\n\t\t\t\t&& !('joiningColumn' in field)\n\t\t\t) {\n\t\t\t\treturn errors.add('MODEL_INVALID_VIEW_USAGE', 'One-has-one relation fields on views must be owning or point to a view entity.')\n\t\t\t}\n\t\t}\n\t\tif (isInverseRelation(field)) {\n\t\t\tconst ownedBy = field.ownedBy\n\t\t\tconst targetField = targetEntity.fields[ownedBy]\n\t\t\tconst relationDescription = `Target relation ${targetEntityName}::${ownedBy}:`\n\t\t\tif (!targetField) {\n\t\t\t\treturn errors.add('MODEL_UNDEFINED_FIELD', `${relationDescription} not exists`)\n\t\t\t}\n\n\t\t\tif (!isRelation(targetField)) {\n\t\t\t\treturn errors.add('MODEL_RELATION_REQUIRED', `${relationDescription} not a relation`)\n\t\t\t}\n\t\t\tif (targetField.target !== entityName) {\n\t\t\t\treturn errors.add(\n\t\t\t\t\t'MODEL_INVALID_RELATION_DEFINITION',\n\t\t\t\t\t`${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (!isOwningRelation(targetField)) {\n\t\t\t\terrors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} not an owning relation`)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!targetField.inversedBy) {\n\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} inverse relation is not set`)\n\t\t\t}\n\t\t\tif (targetField.inversedBy !== field.name) {\n\t\t\t\treturn errors.add(\n\t\t\t\t\t'MODEL_INVALID_RELATION_DEFINITION',\n\t\t\t\t\t`${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.inversedBy} given`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (field.type === Model.RelationType.OneHasOne && targetField.type !== Model.RelationType.OneHasOne) {\n\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"OneHasOne\" type expected, \"${targetField.type}\" given`)\n\t\t\t}\n\t\t\tif (field.type === Model.RelationType.OneHasMany && targetField.type !== Model.RelationType.ManyHasOne) {\n\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"ManyHasOne\" type expected, \"${targetField.type}\" given`)\n\t\t\t}\n\t\t\tif (field.type === Model.RelationType.ManyHasMany && targetField.type !== Model.RelationType.ManyHasMany) {\n\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"ManyHasMany\" type expected, \"${targetField.type}\" given`)\n\t\t\t}\n\t\t} else {\n\t\t\tconst inversedBy = field.inversedBy\n\t\t\tif (inversedBy) {\n\t\t\t\tconst targetField = targetEntity.fields[inversedBy]\n\t\t\t\tconst relationDescription = `Target relation ${targetEntityName}::${inversedBy}:`\n\t\t\t\tif (!targetField) {\n\t\t\t\t\treturn errors.add('MODEL_UNDEFINED_FIELD', `${relationDescription} not exists`)\n\t\t\t\t}\n\t\t\t\tif (!isRelation(targetField)) {\n\t\t\t\t\treturn errors.add('MODEL_RELATION_REQUIRED', `${relationDescription} not a relation`)\n\t\t\t\t}\n\t\t\t\tif (targetField.target !== entityName) {\n\t\t\t\t\treturn errors.add(\n\t\t\t\t\t\t'MODEL_INVALID_RELATION_DEFINITION',\n\t\t\t\t\t\t`${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!isInverseRelation(targetField)) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} not an inverse relation`)\n\t\t\t\t}\n\t\t\t\tif (!targetField.ownedBy) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} owning relation is not set`)\n\t\t\t\t}\n\t\t\t\tif (targetField.ownedBy !== field.name) {\n\t\t\t\t\treturn errors.add(\n\t\t\t\t\t\t'MODEL_INVALID_RELATION_DEFINITION',\n\t\t\t\t\t\t`${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.ownedBy} given`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (field.type === Model.RelationType.OneHasOne && targetField.type !== Model.RelationType.OneHasOne) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"OneHasOne\" type expected, \"${targetField.type}\" given`)\n\t\t\t\t}\n\t\t\t\tif (field.type === Model.RelationType.ManyHasOne && targetField.type !== Model.RelationType.OneHasMany) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"ManyHasOne\" type expected, \"${targetField.type}\" given`)\n\t\t\t\t}\n\t\t\t\tif (field.type === Model.RelationType.ManyHasMany && targetField.type !== Model.RelationType.ManyHasMany) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} \"ManyHasMany\" type expected, \"${targetField.type}\" given`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateIdentifier(value: string, errorBuilder: ErrorBuilder) {\n\t\tif (!value.match(IDENTIFIER_PATTERN)) {\n\t\t\treturn errorBuilder.add('MODEL_INVALID_IDENTIFIER', `${value} must match pattern ${IDENTIFIER_PATTERN.source}`)\n\t\t}\n\t\tif (RESERVED_WORDS.includes(value)) {\n\t\t\terrorBuilder.add('MODEL_INVALID_IDENTIFIER', `${value} is reserved word`)\n\t\t}\n\t}\n\n\tprivate validateEntityName(value: string, errorBuilder: ErrorBuilder) {\n\t\tif (['Query', 'Mutation'].includes(value)) {\n\t\t\terrorBuilder.add('MODEL_INVALID_ENTITY_NAME', `${value} is reserved word`)\n\t\t}\n\t}\n\n\tprivate validateMetaSuffixCollisions(entities: Model.Entity[], errorBuilder: ErrorBuilder) {\n\t\tconst entityNames = new Set(entities.map(it => it.name))\n\t\tfor (const entity of entities) {\n\t\t\tif (entity.name.endsWith('Meta')) {\n\t\t\t\tconst baseName = entity.name.substring(0, entity.name.length - 4)\n\t\t\t\tif (entityNames.has(baseName)) {\n\t\t\t\t\terrorBuilder.for(entity.name)\n\t\t\t\t\t\t.add(\n\t\t\t\t\t\t\t'MODEL_NAME_COLLISION',\n\t\t\t\t\t\t\t`entity ${entity.name} collides with entity ${baseName}, because a GraphQL type with \"Meta\" suffix is created for every entity`,\n\t\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateTableNameCollisions(entities: Model.Entity[], errorBuilder: ErrorBuilder) {\n\t\tconst relationNames: Record<string, string> = {}\n\t\tfor (const entity of entities) {\n\t\t\tconst description = `table name ${entity.tableName} of entity ${entity.name}`\n\t\t\tif (relationNames[entity.tableName]) {\n\t\t\t\terrorBuilder\n\t\t\t\t\t.for(entity.name)\n\t\t\t\t\t.add('MODEL_NAME_COLLISION', `${description} collides with a ${relationNames[entity.tableName]}`)\n\t\t\t} else {\n\t\t\t\trelationNames[entity.tableName] = description\n\t\t\t}\n\t\t}\n\t\tfor (const entity of entities) {\n\t\t\tconst entityErrorBuilder = errorBuilder.for(entity.name)\n\t\t\tacceptEveryFieldVisitor(this.model, entity, {\n\t\t\t\tvisitManyHasManyOwning: ({ entity, relation }) => {\n\t\t\t\t\tconst joiningTable = relation.joiningTable\n\t\t\t\t\tconst description = `joining table name ${joiningTable.tableName} of relation ${entity.name}::${relation.name}`\n\t\t\t\t\tif (relationNames[joiningTable.tableName]) {\n\t\t\t\t\t\tentityErrorBuilder\n\t\t\t\t\t\t\t.for(relation.name)\n\t\t\t\t\t\t\t.add(\n\t\t\t\t\t\t\t\t'MODEL_NAME_COLLISION',\n\t\t\t\t\t\t\t\t`${description} collides with a ${relationNames[joiningTable.tableName]}.`\n\t\t\t\t\t\t\t\t\t+ 'Consider using plural for a relation name or change the joining table name using .joiningTable(...) in schema definition.',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\trelationNames[joiningTable.tableName] = description\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tvisitColumn: () => {},\n\t\t\t\tvisitManyHasManyInverse: () => {},\n\t\t\t\tvisitOneHasMany: () => {},\n\t\t\t\tvisitOneHasOneInverse: () => {},\n\t\t\t\tvisitOneHasOneOwning: () => {},\n\t\t\t\tvisitManyHasOne: () => {},\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate validateAliasedTypesCollision(entities: Model.Entity[], errorBuilder: ErrorBuilder) {\n\t\tconst aliasedTypes = new Map<string, Model.ColumnType>()\n\t\tfor (const entity of entities) {\n\t\t\tacceptEveryFieldVisitor(this.model, entity, {\n\t\t\t\tvisitColumn: ({ column }) => {\n\t\t\t\t\tif (!column.typeAlias) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif (aliasedTypes.has(column.typeAlias) && aliasedTypes.get(column.typeAlias) !== column.type) {\n\t\t\t\t\t\terrorBuilder\n\t\t\t\t\t\t\t.for(column.name)\n\t\t\t\t\t\t\t.add('MODEL_NAME_COLLISION', `Type alias ${column.typeAlias} already exists for base type ${column.type}`)\n\t\t\t\t\t}\n\t\t\t\t\taliasedTypes.set(column.typeAlias, column.type)\n\t\t\t\t},\n\t\t\t\tvisitManyHasManyOwning: () => {},\n\t\t\t\tvisitManyHasManyInverse: () => {},\n\t\t\t\tvisitOneHasMany: () => {},\n\t\t\t\tvisitOneHasOneInverse: () => {},\n\t\t\t\tvisitOneHasOneOwning: () => {},\n\t\t\t\tvisitManyHasOne: () => {},\n\t\t\t})\n\t\t}\n\t}\n}\n\nconst isRelation = (field: Model.AnyField): field is Model.AnyRelation => Object.values(Model.RelationType).includes(field.type as Model.RelationType)\n"],"names":["ErrorBuilder","errors","isColumn","acceptEveryFieldVisitor","targetEntity","getTargetEntity","Model","isInverseRelation","isOwningRelation","entity"],"mappings":";;;;;AAIA,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB,CAAC,OAAO,MAAM,KAAK;AAEnC,MAAM,eAAe;AAAA,EAC3B,YAA6B,OAAqB;AAArB,SAAA,QAAA;AAAA,EAAsB;AAAA,EAE5C,WAA8B;AACpC,UAAM,eAAe,IAAIA,oBAAa,CAAA,GAAI,CAAA,CAAE;AAC5C,SAAK,cAAc,KAAK,MAAM,OAAO,aAAa,IAAI,OAAO,CAAC;AAC9D,SAAK,iBAAiB,KAAK,MAAM,UAAU,aAAa,IAAI,UAAU,CAAC;AAEvE,WAAO,aAAa;AAAA,EACrB;AAAA,EAEQ,cAAc,OAA8BC,SAA4B;AAC/E,eAAW,CAAC,UAAU,UAAU,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC3D,iBAAW,SAAS,YAAY;AAC/B,cAAM,cAAcA,QAAO,IAAI,UAAU,KAAK;AAC9C,aAAK,mBAAmB,OAAO,WAAW;AAAA,MAC3C;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,iBAAiB,UAAoCA,SAA4B;AACxF,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,QAAQ,GAAG;AAC5D,YAAM,eAAeA,QAAO,IAAI,UAAU;AAC1C,UAAI,OAAO,SAAS,YAAY;AAC/B,qBAAa,IAAI,uBAAuB,gBAAgB,OAAO,IAAI,uCAAuC,UAAU,GAAG;AAAA,MACxH;AACA,WAAK,eAAe,QAAQ,YAAY;AAAA,IACzC;AACA,UAAM,cAAc,OAAO,OAAO,KAAK,MAA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