@contember/schema-utils 1.4.0-rc.8 → 2.0.0-alpha.8

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 (486) hide show
  1. package/dist/development/index.cjs +109 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +93 -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 +71 -0
  10. package/dist/development/src/acl/PredicateDefinitionProcessor.cjs.map +1 -0
  11. package/dist/development/src/acl/PredicateDefinitionProcessor.js +71 -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 +221 -0
  26. package/dist/development/src/definition-generator/DefinitionCodeGenerator.cjs.map +1 -0
  27. package/dist/development/src/definition-generator/DefinitionCodeGenerator.js +221 -0
  28. package/dist/development/src/definition-generator/DefinitionCodeGenerator.js.map +1 -0
  29. package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs +19 -0
  30. package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs.map +1 -0
  31. package/dist/development/src/definition-generator/DefinitionNamingConventions.js +19 -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 +231 -0
  50. package/dist/development/src/model/modelUtils.cjs.map +1 -0
  51. package/dist/development/src/model/modelUtils.js +231 -0
  52. package/dist/development/src/model/modelUtils.js.map +1 -0
  53. package/dist/development/src/model/resolveDefaultColumnType.cjs +28 -0
  54. package/dist/development/src/model/resolveDefaultColumnType.cjs.map +1 -0
  55. package/dist/development/src/model/resolveDefaultColumnType.js +28 -0
  56. package/dist/development/src/model/resolveDefaultColumnType.js.map +1 -0
  57. package/dist/development/src/schemaFilter.cjs +24 -0
  58. package/dist/development/src/schemaFilter.cjs.map +1 -0
  59. package/dist/development/src/schemaFilter.js +24 -0
  60. package/dist/development/src/schemaFilter.js.map +1 -0
  61. package/dist/development/src/schemaNormalizer.cjs +70 -0
  62. package/dist/development/src/schemaNormalizer.cjs.map +1 -0
  63. package/dist/development/src/schemaNormalizer.js +70 -0
  64. package/dist/development/src/schemaNormalizer.js.map +1 -0
  65. package/dist/development/src/type-schema/acl.cjs +143 -0
  66. package/dist/development/src/type-schema/acl.cjs.map +1 -0
  67. package/dist/development/src/type-schema/acl.js +126 -0
  68. package/dist/development/src/type-schema/acl.js.map +1 -0
  69. package/dist/development/src/type-schema/actions.cjs +87 -0
  70. package/dist/development/src/type-schema/actions.cjs.map +1 -0
  71. package/dist/development/src/type-schema/actions.js +70 -0
  72. package/dist/development/src/type-schema/actions.js.map +1 -0
  73. package/dist/development/src/type-schema/condition.cjs +87 -0
  74. package/dist/development/src/type-schema/condition.cjs.map +1 -0
  75. package/dist/development/src/type-schema/condition.js +70 -0
  76. package/dist/development/src/type-schema/condition.js.map +1 -0
  77. package/dist/development/src/type-schema/model.cjs +195 -0
  78. package/dist/development/src/type-schema/model.cjs.map +1 -0
  79. package/dist/development/src/type-schema/model.js +178 -0
  80. package/dist/development/src/type-schema/model.js.map +1 -0
  81. package/dist/development/src/type-schema/settings.cjs +32 -0
  82. package/dist/development/src/type-schema/settings.cjs.map +1 -0
  83. package/dist/development/src/type-schema/settings.js +15 -0
  84. package/dist/development/src/type-schema/settings.js.map +1 -0
  85. package/dist/development/src/type-schema/validation.cjs +115 -0
  86. package/dist/development/src/type-schema/validation.cjs.map +1 -0
  87. package/dist/development/src/type-schema/validation.js +98 -0
  88. package/dist/development/src/type-schema/validation.js.map +1 -0
  89. package/dist/development/src/type-schema/where.cjs +44 -0
  90. package/dist/development/src/type-schema/where.cjs.map +1 -0
  91. package/dist/development/src/type-schema/where.js +27 -0
  92. package/dist/development/src/type-schema/where.js.map +1 -0
  93. package/dist/development/src/utils/assertNever.cjs +7 -0
  94. package/dist/development/src/utils/assertNever.cjs.map +1 -0
  95. package/dist/development/src/utils/assertNever.js +7 -0
  96. package/dist/development/src/utils/assertNever.js.map +1 -0
  97. package/dist/development/src/utils/deepCompare.cjs +134 -0
  98. package/dist/development/src/utils/deepCompare.cjs.map +1 -0
  99. package/dist/development/src/utils/deepCompare.js +134 -0
  100. package/dist/development/src/utils/deepCompare.js.map +1 -0
  101. package/dist/development/src/utils/isIt.cjs +7 -0
  102. package/dist/development/src/utils/isIt.cjs.map +1 -0
  103. package/dist/development/src/utils/isIt.js +7 -0
  104. package/dist/development/src/utils/isIt.js.map +1 -0
  105. package/dist/development/src/utils/printJsValue.cjs +42 -0
  106. package/dist/development/src/utils/printJsValue.cjs.map +1 -0
  107. package/dist/development/src/utils/printJsValue.js +42 -0
  108. package/dist/development/src/utils/printJsValue.js.map +1 -0
  109. package/dist/development/src/validation/AclValidator.cjs +168 -0
  110. package/dist/development/src/validation/AclValidator.cjs.map +1 -0
  111. package/dist/development/src/validation/AclValidator.js +168 -0
  112. package/dist/development/src/validation/AclValidator.js.map +1 -0
  113. package/dist/development/src/validation/ActionsValidator.cjs +127 -0
  114. package/dist/development/src/validation/ActionsValidator.cjs.map +1 -0
  115. package/dist/development/src/validation/ActionsValidator.js +110 -0
  116. package/dist/development/src/validation/ActionsValidator.js.map +1 -0
  117. package/dist/development/src/validation/MembershipResolver.cjs +126 -0
  118. package/dist/development/src/validation/MembershipResolver.cjs.map +1 -0
  119. package/dist/development/src/validation/MembershipResolver.js +126 -0
  120. package/dist/development/src/validation/MembershipResolver.js.map +1 -0
  121. package/dist/development/src/validation/ModelValidator.cjs +310 -0
  122. package/dist/development/src/validation/ModelValidator.cjs.map +1 -0
  123. package/dist/development/src/validation/ModelValidator.js +310 -0
  124. package/dist/development/src/validation/ModelValidator.js.map +1 -0
  125. package/dist/development/src/validation/SchemaValidator.cjs +29 -0
  126. package/dist/development/src/validation/SchemaValidator.cjs.map +1 -0
  127. package/dist/development/src/validation/SchemaValidator.js +29 -0
  128. package/dist/development/src/validation/SchemaValidator.js.map +1 -0
  129. package/dist/development/src/validation/ValidationValidator.cjs +121 -0
  130. package/dist/development/src/validation/ValidationValidator.cjs.map +1 -0
  131. package/dist/development/src/validation/ValidationValidator.js +121 -0
  132. package/dist/development/src/validation/ValidationValidator.js.map +1 -0
  133. package/dist/development/src/validation/errors.cjs +16 -0
  134. package/dist/development/src/validation/errors.cjs.map +1 -0
  135. package/dist/development/src/validation/errors.js +16 -0
  136. package/dist/development/src/validation/errors.js.map +1 -0
  137. package/dist/production/index.cjs +109 -0
  138. package/dist/production/index.cjs.map +1 -0
  139. package/dist/production/index.js +93 -0
  140. package/dist/production/index.js.map +1 -0
  141. package/dist/production/src/acl/AllowAllPermissionFactory.cjs +42 -0
  142. package/dist/production/src/acl/AllowAllPermissionFactory.cjs.map +1 -0
  143. package/dist/production/src/acl/AllowAllPermissionFactory.js +42 -0
  144. package/dist/production/src/acl/AllowAllPermissionFactory.js.map +1 -0
  145. package/dist/production/src/acl/PredicateDefinitionProcessor.cjs +71 -0
  146. package/dist/production/src/acl/PredicateDefinitionProcessor.cjs.map +1 -0
  147. package/dist/production/src/acl/PredicateDefinitionProcessor.js +71 -0
  148. package/dist/production/src/acl/PredicateDefinitionProcessor.js.map +1 -0
  149. package/dist/production/src/acl/schemaUtils.cjs +11 -0
  150. package/dist/production/src/acl/schemaUtils.cjs.map +1 -0
  151. package/dist/production/src/acl/schemaUtils.js +11 -0
  152. package/dist/production/src/acl/schemaUtils.js.map +1 -0
  153. package/dist/production/src/dataUtils.cjs +59 -0
  154. package/dist/production/src/dataUtils.cjs.map +1 -0
  155. package/dist/production/src/dataUtils.js +59 -0
  156. package/dist/production/src/dataUtils.js.map +1 -0
  157. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs +118 -0
  158. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs.map +1 -0
  159. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js +118 -0
  160. package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js.map +1 -0
  161. package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs +221 -0
  162. package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs.map +1 -0
  163. package/dist/production/src/definition-generator/DefinitionCodeGenerator.js +221 -0
  164. package/dist/production/src/definition-generator/DefinitionCodeGenerator.js.map +1 -0
  165. package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs +19 -0
  166. package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs.map +1 -0
  167. package/dist/production/src/definition-generator/DefinitionNamingConventions.js +19 -0
  168. package/dist/production/src/definition-generator/DefinitionNamingConventions.js.map +1 -0
  169. package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs +17 -0
  170. package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs.map +1 -0
  171. package/dist/production/src/definition-generator/TsDefinitionGenerator.js +17 -0
  172. package/dist/production/src/definition-generator/TsDefinitionGenerator.js.map +1 -0
  173. package/dist/production/src/lax/LaxSchemaConverter.cjs +202 -0
  174. package/dist/production/src/lax/LaxSchemaConverter.cjs.map +1 -0
  175. package/dist/production/src/lax/LaxSchemaConverter.js +202 -0
  176. package/dist/production/src/lax/LaxSchemaConverter.js.map +1 -0
  177. package/dist/production/src/lax/schema.cjs +70 -0
  178. package/dist/production/src/lax/schema.cjs.map +1 -0
  179. package/dist/production/src/lax/schema.js +53 -0
  180. package/dist/production/src/lax/schema.js.map +1 -0
  181. package/dist/production/src/model/NamingConventions.cjs +28 -0
  182. package/dist/production/src/model/NamingConventions.cjs.map +1 -0
  183. package/dist/production/src/model/NamingConventions.js +28 -0
  184. package/dist/production/src/model/NamingConventions.js.map +1 -0
  185. package/dist/production/src/model/modelUtils.cjs +231 -0
  186. package/dist/production/src/model/modelUtils.cjs.map +1 -0
  187. package/dist/production/src/model/modelUtils.js +231 -0
  188. package/dist/production/src/model/modelUtils.js.map +1 -0
  189. package/dist/production/src/model/resolveDefaultColumnType.cjs +28 -0
  190. package/dist/production/src/model/resolveDefaultColumnType.cjs.map +1 -0
  191. package/dist/production/src/model/resolveDefaultColumnType.js +28 -0
  192. package/dist/production/src/model/resolveDefaultColumnType.js.map +1 -0
  193. package/dist/production/src/schemaFilter.cjs +24 -0
  194. package/dist/production/src/schemaFilter.cjs.map +1 -0
  195. package/dist/production/src/schemaFilter.js +24 -0
  196. package/dist/production/src/schemaFilter.js.map +1 -0
  197. package/dist/production/src/schemaNormalizer.cjs +70 -0
  198. package/dist/production/src/schemaNormalizer.cjs.map +1 -0
  199. package/dist/production/src/schemaNormalizer.js +70 -0
  200. package/dist/production/src/schemaNormalizer.js.map +1 -0
  201. package/dist/production/src/type-schema/acl.cjs +143 -0
  202. package/dist/production/src/type-schema/acl.cjs.map +1 -0
  203. package/dist/production/src/type-schema/acl.js +126 -0
  204. package/dist/production/src/type-schema/acl.js.map +1 -0
  205. package/dist/production/src/type-schema/actions.cjs +87 -0
  206. package/dist/production/src/type-schema/actions.cjs.map +1 -0
  207. package/dist/production/src/type-schema/actions.js +70 -0
  208. package/dist/production/src/type-schema/actions.js.map +1 -0
  209. package/dist/production/src/type-schema/condition.cjs +87 -0
  210. package/dist/production/src/type-schema/condition.cjs.map +1 -0
  211. package/dist/production/src/type-schema/condition.js +70 -0
  212. package/dist/production/src/type-schema/condition.js.map +1 -0
  213. package/dist/production/src/type-schema/model.cjs +195 -0
  214. package/dist/production/src/type-schema/model.cjs.map +1 -0
  215. package/dist/production/src/type-schema/model.js +178 -0
  216. package/dist/production/src/type-schema/model.js.map +1 -0
  217. package/dist/production/src/type-schema/settings.cjs +32 -0
  218. package/dist/production/src/type-schema/settings.cjs.map +1 -0
  219. package/dist/production/src/type-schema/settings.js +15 -0
  220. package/dist/production/src/type-schema/settings.js.map +1 -0
  221. package/dist/production/src/type-schema/validation.cjs +115 -0
  222. package/dist/production/src/type-schema/validation.cjs.map +1 -0
  223. package/dist/production/src/type-schema/validation.js +98 -0
  224. package/dist/production/src/type-schema/validation.js.map +1 -0
  225. package/dist/production/src/type-schema/where.cjs +44 -0
  226. package/dist/production/src/type-schema/where.cjs.map +1 -0
  227. package/dist/production/src/type-schema/where.js +27 -0
  228. package/dist/production/src/type-schema/where.js.map +1 -0
  229. package/dist/production/src/utils/assertNever.cjs +7 -0
  230. package/dist/production/src/utils/assertNever.cjs.map +1 -0
  231. package/dist/production/src/utils/assertNever.js +7 -0
  232. package/dist/production/src/utils/assertNever.js.map +1 -0
  233. package/dist/production/src/utils/deepCompare.cjs +134 -0
  234. package/dist/production/src/utils/deepCompare.cjs.map +1 -0
  235. package/dist/production/src/utils/deepCompare.js +134 -0
  236. package/dist/production/src/utils/deepCompare.js.map +1 -0
  237. package/dist/production/src/utils/isIt.cjs +7 -0
  238. package/dist/production/src/utils/isIt.cjs.map +1 -0
  239. package/dist/production/src/utils/isIt.js +7 -0
  240. package/dist/production/src/utils/isIt.js.map +1 -0
  241. package/dist/production/src/utils/printJsValue.cjs +42 -0
  242. package/dist/production/src/utils/printJsValue.cjs.map +1 -0
  243. package/dist/production/src/utils/printJsValue.js +42 -0
  244. package/dist/production/src/utils/printJsValue.js.map +1 -0
  245. package/dist/production/src/validation/AclValidator.cjs +168 -0
  246. package/dist/production/src/validation/AclValidator.cjs.map +1 -0
  247. package/dist/production/src/validation/AclValidator.js +168 -0
  248. package/dist/production/src/validation/AclValidator.js.map +1 -0
  249. package/dist/production/src/validation/ActionsValidator.cjs +127 -0
  250. package/dist/production/src/validation/ActionsValidator.cjs.map +1 -0
  251. package/dist/production/src/validation/ActionsValidator.js +110 -0
  252. package/dist/production/src/validation/ActionsValidator.js.map +1 -0
  253. package/dist/production/src/validation/MembershipResolver.cjs +126 -0
  254. package/dist/production/src/validation/MembershipResolver.cjs.map +1 -0
  255. package/dist/production/src/validation/MembershipResolver.js +126 -0
  256. package/dist/production/src/validation/MembershipResolver.js.map +1 -0
  257. package/dist/production/src/validation/ModelValidator.cjs +310 -0
  258. package/dist/production/src/validation/ModelValidator.cjs.map +1 -0
  259. package/dist/production/src/validation/ModelValidator.js +310 -0
  260. package/dist/production/src/validation/ModelValidator.js.map +1 -0
  261. package/dist/production/src/validation/SchemaValidator.cjs +29 -0
  262. package/dist/production/src/validation/SchemaValidator.cjs.map +1 -0
  263. package/dist/production/src/validation/SchemaValidator.js +29 -0
  264. package/dist/production/src/validation/SchemaValidator.js.map +1 -0
  265. package/dist/production/src/validation/ValidationValidator.cjs +121 -0
  266. package/dist/production/src/validation/ValidationValidator.cjs.map +1 -0
  267. package/dist/production/src/validation/ValidationValidator.js +121 -0
  268. package/dist/production/src/validation/ValidationValidator.js.map +1 -0
  269. package/dist/production/src/validation/errors.cjs +16 -0
  270. package/dist/production/src/validation/errors.cjs.map +1 -0
  271. package/dist/production/src/validation/errors.js +16 -0
  272. package/dist/production/src/validation/errors.js.map +1 -0
  273. package/dist/tests/cases/unit/schemas/acl.d.ts +7 -7
  274. package/dist/tests/cases/unit/schemas/acl.d.ts.map +1 -1
  275. package/dist/tests/cases/unit/schemas/basic.d.ts +1 -1
  276. package/dist/tests/cases/unit/schemas/basic.d.ts.map +1 -1
  277. package/dist/tests/cases/unit/schemas/enum.d.ts +3 -3
  278. package/dist/tests/cases/unit/schemas/enum.d.ts.map +1 -1
  279. package/dist/tests/cases/unit/schemas/relations.d.ts +7 -7
  280. package/dist/tests/cases/unit/schemas/relations.d.ts.map +1 -1
  281. package/dist/tests/cases/unit/schemas/unique.d.ts +1 -1
  282. package/dist/tests/cases/unit/schemas/unique.d.ts.map +1 -1
  283. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  284. package/dist/{src → types}/acl/schemaUtils.d.ts.map +1 -1
  285. package/dist/{src → types}/dataUtils.d.ts +1 -1
  286. package/dist/types/dataUtils.d.ts.map +1 -0
  287. package/dist/{src → types}/lax/schema.d.ts +21 -21
  288. package/dist/{src → types}/model/modelUtils.d.ts +1 -1
  289. package/dist/types/model/modelUtils.d.ts.map +1 -0
  290. package/dist/{src → types}/model/resolveDefaultColumnType.d.ts.map +1 -1
  291. package/dist/{src → types}/schemaFilter.d.ts.map +1 -1
  292. package/dist/{src → types}/schemaNormalizer.d.ts.map +1 -1
  293. package/dist/types/tsconfig.tsbuildinfo +1 -0
  294. package/dist/{src → types}/type-schema/condition.d.ts +1 -2
  295. package/dist/types/type-schema/condition.d.ts.map +1 -0
  296. package/dist/types/type-schema/settings.d.ts +46 -0
  297. package/dist/types/type-schema/settings.d.ts.map +1 -0
  298. package/dist/{src → types}/type-schema/where.d.ts.map +1 -1
  299. package/dist/{src → types}/utils/deepCompare.d.ts.map +1 -1
  300. package/dist/types/utils/isIt.d.ts +2 -0
  301. package/dist/{src → types}/utils/isIt.d.ts.map +1 -1
  302. package/dist/{src → types}/utils/printJsValue.d.ts.map +1 -1
  303. package/dist/{src → types}/validation/MembershipResolver.d.ts.map +1 -1
  304. package/package.json +24 -12
  305. package/src/tsconfig.json +1 -1
  306. package/tests/cases/unit/tsDefinitionGenerator.test.ts +4 -3
  307. package/tests/tsconfig.json +2 -1
  308. package/vitest.config.ts +3 -0
  309. package/dist/src/acl/AllowAllPermissionFactory.js +0 -42
  310. package/dist/src/acl/AllowAllPermissionFactory.js.map +0 -1
  311. package/dist/src/acl/PredicateDefinitionProcessor.js +0 -75
  312. package/dist/src/acl/PredicateDefinitionProcessor.js.map +0 -1
  313. package/dist/src/acl/index.js +0 -20
  314. package/dist/src/acl/index.js.map +0 -1
  315. package/dist/src/acl/schemaUtils.js +0 -9
  316. package/dist/src/acl/schemaUtils.js.map +0 -1
  317. package/dist/src/dataUtils.d.ts.map +0 -1
  318. package/dist/src/dataUtils.js +0 -58
  319. package/dist/src/dataUtils.js.map +0 -1
  320. package/dist/src/definition-generator/AclDefinitionCodeGenerator.js +0 -116
  321. package/dist/src/definition-generator/AclDefinitionCodeGenerator.js.map +0 -1
  322. package/dist/src/definition-generator/DefinitionCodeGenerator.js +0 -216
  323. package/dist/src/definition-generator/DefinitionCodeGenerator.js.map +0 -1
  324. package/dist/src/definition-generator/DefinitionNamingConventions.js +0 -18
  325. package/dist/src/definition-generator/DefinitionNamingConventions.js.map +0 -1
  326. package/dist/src/definition-generator/TsDefinitionGenerator.js +0 -20
  327. package/dist/src/definition-generator/TsDefinitionGenerator.js.map +0 -1
  328. package/dist/src/definition-generator/index.js +0 -21
  329. package/dist/src/definition-generator/index.js.map +0 -1
  330. package/dist/src/index.js +0 -59
  331. package/dist/src/index.js.map +0 -1
  332. package/dist/src/lax/LaxSchemaConverter.js +0 -203
  333. package/dist/src/lax/LaxSchemaConverter.js.map +0 -1
  334. package/dist/src/lax/index.js +0 -21
  335. package/dist/src/lax/index.js.map +0 -1
  336. package/dist/src/lax/schema.js +0 -67
  337. package/dist/src/lax/schema.js.map +0 -1
  338. package/dist/src/model/NamingConventions.js +0 -29
  339. package/dist/src/model/NamingConventions.js.map +0 -1
  340. package/dist/src/model/index.js +0 -20
  341. package/dist/src/model/index.js.map +0 -1
  342. package/dist/src/model/modelUtils.d.ts.map +0 -1
  343. package/dist/src/model/modelUtils.js +0 -219
  344. package/dist/src/model/modelUtils.js.map +0 -1
  345. package/dist/src/model/resolveDefaultColumnType.js +0 -29
  346. package/dist/src/model/resolveDefaultColumnType.js.map +0 -1
  347. package/dist/src/schemaFilter.js +0 -29
  348. package/dist/src/schemaFilter.js.map +0 -1
  349. package/dist/src/schemaNormalizer.js +0 -72
  350. package/dist/src/schemaNormalizer.js.map +0 -1
  351. package/dist/src/tsconfig.tsbuildinfo +0 -1
  352. package/dist/src/type-schema/acl.js +0 -114
  353. package/dist/src/type-schema/acl.js.map +0 -1
  354. package/dist/src/type-schema/actions.js +0 -77
  355. package/dist/src/type-schema/actions.js.map +0 -1
  356. package/dist/src/type-schema/condition.d.ts.map +0 -1
  357. package/dist/src/type-schema/condition.js +0 -95
  358. package/dist/src/type-schema/condition.js.map +0 -1
  359. package/dist/src/type-schema/index.js +0 -22
  360. package/dist/src/type-schema/index.js.map +0 -1
  361. package/dist/src/type-schema/model.js +0 -156
  362. package/dist/src/type-schema/model.js.map +0 -1
  363. package/dist/src/type-schema/settings.d.ts +0 -35
  364. package/dist/src/type-schema/settings.d.ts.map +0 -1
  365. package/dist/src/type-schema/settings.js +0 -39
  366. package/dist/src/type-schema/settings.js.map +0 -1
  367. package/dist/src/type-schema/validation.js +0 -95
  368. package/dist/src/type-schema/validation.js.map +0 -1
  369. package/dist/src/type-schema/where.js +0 -50
  370. package/dist/src/type-schema/where.js.map +0 -1
  371. package/dist/src/utils/assertNever.js +0 -8
  372. package/dist/src/utils/assertNever.js.map +0 -1
  373. package/dist/src/utils/deepCompare.js +0 -136
  374. package/dist/src/utils/deepCompare.js.map +0 -1
  375. package/dist/src/utils/index.js +0 -20
  376. package/dist/src/utils/index.js.map +0 -1
  377. package/dist/src/utils/isIt.d.ts +0 -2
  378. package/dist/src/utils/isIt.js +0 -11
  379. package/dist/src/utils/isIt.js.map +0 -1
  380. package/dist/src/utils/printJsValue.js +0 -57
  381. package/dist/src/utils/printJsValue.js.map +0 -1
  382. package/dist/src/validation/AclValidator.js +0 -147
  383. package/dist/src/validation/AclValidator.js.map +0 -1
  384. package/dist/src/validation/ActionsValidator.js +0 -134
  385. package/dist/src/validation/ActionsValidator.js.map +0 -1
  386. package/dist/src/validation/MembershipResolver.js +0 -113
  387. package/dist/src/validation/MembershipResolver.js.map +0 -1
  388. package/dist/src/validation/ModelValidator.js +0 -306
  389. package/dist/src/validation/ModelValidator.js.map +0 -1
  390. package/dist/src/validation/SchemaValidator.js +0 -27
  391. package/dist/src/validation/SchemaValidator.js.map +0 -1
  392. package/dist/src/validation/ValidationValidator.js +0 -109
  393. package/dist/src/validation/ValidationValidator.js.map +0 -1
  394. package/dist/src/validation/errors.js +0 -17
  395. package/dist/src/validation/errors.js.map +0 -1
  396. package/dist/src/validation/index.js +0 -23
  397. package/dist/src/validation/index.js.map +0 -1
  398. package/dist/tests/cases/unit/conditionSchema.test.js +0 -50
  399. package/dist/tests/cases/unit/conditionSchema.test.js.map +0 -1
  400. package/dist/tests/cases/unit/deepCompare.test.js +0 -43
  401. package/dist/tests/cases/unit/deepCompare.test.js.map +0 -1
  402. package/dist/tests/cases/unit/laxSchemaConverter.test.js +0 -118
  403. package/dist/tests/cases/unit/laxSchemaConverter.test.js.map +0 -1
  404. package/dist/tests/cases/unit/membershipResolver.test.js +0 -168
  405. package/dist/tests/cases/unit/membershipResolver.test.js.map +0 -1
  406. package/dist/tests/cases/unit/modelValidator.test.js +0 -97
  407. package/dist/tests/cases/unit/modelValidator.test.js.map +0 -1
  408. package/dist/tests/cases/unit/printJsvalue.test.js +0 -90
  409. package/dist/tests/cases/unit/printJsvalue.test.js.map +0 -1
  410. package/dist/tests/cases/unit/schemas/acl.js +0 -47
  411. package/dist/tests/cases/unit/schemas/acl.js.map +0 -1
  412. package/dist/tests/cases/unit/schemas/basic.js +0 -11
  413. package/dist/tests/cases/unit/schemas/basic.js.map +0 -1
  414. package/dist/tests/cases/unit/schemas/enum.js +0 -13
  415. package/dist/tests/cases/unit/schemas/enum.js.map +0 -1
  416. package/dist/tests/cases/unit/schemas/relations.js +0 -27
  417. package/dist/tests/cases/unit/schemas/relations.js.map +0 -1
  418. package/dist/tests/cases/unit/schemas/unique.js +0 -20
  419. package/dist/tests/cases/unit/schemas/unique.js.map +0 -1
  420. package/dist/tests/cases/unit/tsDefinitionGenerator.test.js +0 -58
  421. package/dist/tests/cases/unit/tsDefinitionGenerator.test.js.map +0 -1
  422. package/dist/tests/cases/unit/whereSchema.test.js +0 -85
  423. package/dist/tests/cases/unit/whereSchema.test.js.map +0 -1
  424. /package/dist/{src → types}/acl/AllowAllPermissionFactory.d.ts +0 -0
  425. /package/dist/{src → types}/acl/AllowAllPermissionFactory.d.ts.map +0 -0
  426. /package/dist/{src → types}/acl/PredicateDefinitionProcessor.d.ts +0 -0
  427. /package/dist/{src → types}/acl/PredicateDefinitionProcessor.d.ts.map +0 -0
  428. /package/dist/{src → types}/acl/index.d.ts +0 -0
  429. /package/dist/{src → types}/acl/index.d.ts.map +0 -0
  430. /package/dist/{src → types}/acl/schemaUtils.d.ts +0 -0
  431. /package/dist/{src → types}/definition-generator/AclDefinitionCodeGenerator.d.ts +0 -0
  432. /package/dist/{src → types}/definition-generator/AclDefinitionCodeGenerator.d.ts.map +0 -0
  433. /package/dist/{src → types}/definition-generator/DefinitionCodeGenerator.d.ts +0 -0
  434. /package/dist/{src → types}/definition-generator/DefinitionCodeGenerator.d.ts.map +0 -0
  435. /package/dist/{src → types}/definition-generator/DefinitionNamingConventions.d.ts +0 -0
  436. /package/dist/{src → types}/definition-generator/DefinitionNamingConventions.d.ts.map +0 -0
  437. /package/dist/{src → types}/definition-generator/TsDefinitionGenerator.d.ts +0 -0
  438. /package/dist/{src → types}/definition-generator/TsDefinitionGenerator.d.ts.map +0 -0
  439. /package/dist/{src → types}/definition-generator/index.d.ts +0 -0
  440. /package/dist/{src → types}/definition-generator/index.d.ts.map +0 -0
  441. /package/dist/{src → types}/index.d.ts +0 -0
  442. /package/dist/{src → types}/index.d.ts.map +0 -0
  443. /package/dist/{src → types}/lax/LaxSchemaConverter.d.ts +0 -0
  444. /package/dist/{src → types}/lax/LaxSchemaConverter.d.ts.map +0 -0
  445. /package/dist/{src → types}/lax/index.d.ts +0 -0
  446. /package/dist/{src → types}/lax/index.d.ts.map +0 -0
  447. /package/dist/{src → types}/lax/schema.d.ts.map +0 -0
  448. /package/dist/{src → types}/model/NamingConventions.d.ts +0 -0
  449. /package/dist/{src → types}/model/NamingConventions.d.ts.map +0 -0
  450. /package/dist/{src → types}/model/index.d.ts +0 -0
  451. /package/dist/{src → types}/model/index.d.ts.map +0 -0
  452. /package/dist/{src → types}/model/resolveDefaultColumnType.d.ts +0 -0
  453. /package/dist/{src → types}/schemaFilter.d.ts +0 -0
  454. /package/dist/{src → types}/schemaNormalizer.d.ts +0 -0
  455. /package/dist/{src → types}/type-schema/acl.d.ts +0 -0
  456. /package/dist/{src → types}/type-schema/acl.d.ts.map +0 -0
  457. /package/dist/{src → types}/type-schema/actions.d.ts +0 -0
  458. /package/dist/{src → types}/type-schema/actions.d.ts.map +0 -0
  459. /package/dist/{src → types}/type-schema/index.d.ts +0 -0
  460. /package/dist/{src → types}/type-schema/index.d.ts.map +0 -0
  461. /package/dist/{src → types}/type-schema/model.d.ts +0 -0
  462. /package/dist/{src → types}/type-schema/model.d.ts.map +0 -0
  463. /package/dist/{src → types}/type-schema/validation.d.ts +0 -0
  464. /package/dist/{src → types}/type-schema/validation.d.ts.map +0 -0
  465. /package/dist/{src → types}/type-schema/where.d.ts +0 -0
  466. /package/dist/{src → types}/utils/assertNever.d.ts +0 -0
  467. /package/dist/{src → types}/utils/assertNever.d.ts.map +0 -0
  468. /package/dist/{src → types}/utils/deepCompare.d.ts +0 -0
  469. /package/dist/{src → types}/utils/index.d.ts +0 -0
  470. /package/dist/{src → types}/utils/index.d.ts.map +0 -0
  471. /package/dist/{src → types}/utils/printJsValue.d.ts +0 -0
  472. /package/dist/{src → types}/validation/AclValidator.d.ts +0 -0
  473. /package/dist/{src → types}/validation/AclValidator.d.ts.map +0 -0
  474. /package/dist/{src → types}/validation/ActionsValidator.d.ts +0 -0
  475. /package/dist/{src → types}/validation/ActionsValidator.d.ts.map +0 -0
  476. /package/dist/{src → types}/validation/MembershipResolver.d.ts +0 -0
  477. /package/dist/{src → types}/validation/ModelValidator.d.ts +0 -0
  478. /package/dist/{src → types}/validation/ModelValidator.d.ts.map +0 -0
  479. /package/dist/{src → types}/validation/SchemaValidator.d.ts +0 -0
  480. /package/dist/{src → types}/validation/SchemaValidator.d.ts.map +0 -0
  481. /package/dist/{src → types}/validation/ValidationValidator.d.ts +0 -0
  482. /package/dist/{src → types}/validation/ValidationValidator.d.ts.map +0 -0
  483. /package/dist/{src → types}/validation/errors.d.ts +0 -0
  484. /package/dist/{src → types}/validation/errors.d.ts.map +0 -0
  485. /package/dist/{src → types}/validation/index.d.ts +0 -0
  486. /package/dist/{src → types}/validation/index.d.ts.map +0 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const schema = require("@contember/schema");
4
+ const assertNever = require("../utils/assertNever.cjs");
5
+ const schemaUtils = require("../acl/schemaUtils.cjs");
6
+ require("../type-schema/acl.cjs");
7
+ const condition = require("../type-schema/condition.cjs");
8
+ require("../type-schema/model.cjs");
9
+ require("../type-schema/settings.cjs");
10
+ require("../type-schema/validation.cjs");
11
+ var __defProp = Object.defineProperty;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
14
+ class MembershipResolver {
15
+ resolve(acl, memberships, identity) {
16
+ const errors = [];
17
+ const parsed = [];
18
+ const roles = acl.roles;
19
+ for (const membership of memberships) {
20
+ if (!roles[membership.role]) {
21
+ errors.push(new MembershipValidationError(
22
+ membership.role,
23
+ "roleNotFound"
24
+ /* ROLE_NOT_FOUND */
25
+ ));
26
+ continue;
27
+ }
28
+ const roleVariables = schemaUtils.getRoleVariables(membership.role, acl);
29
+ for (const variable of membership.variables) {
30
+ if (!roleVariables[variable.name] || roleVariables[variable.name].type === schema.Acl.VariableType.predefined) {
31
+ errors.push(
32
+ new MembershipValidationError(
33
+ membership.role,
34
+ "variableNotFound",
35
+ variable.name
36
+ )
37
+ );
38
+ }
39
+ }
40
+ const [membershipErrors, parsedVariables] = this.readMembershipVariables(roleVariables, membership, identity);
41
+ errors.push(...membershipErrors);
42
+ parsed.push({
43
+ role: membership.role,
44
+ variables: parsedVariables
45
+ });
46
+ }
47
+ return new MembershipReadResult(errors, parsed);
48
+ }
49
+ readMembershipVariables(roleVariables, membership, identity) {
50
+ const errors = [];
51
+ const parsedVariables = [];
52
+ for (const [name, variable] of Object.entries(roleVariables)) {
53
+ if (variable.type === schema.Acl.VariableType.predefined) {
54
+ switch (variable.value) {
55
+ case "identityID":
56
+ parsedVariables.push({ name, condition: { in: [identity.identityId] } });
57
+ break;
58
+ case "personID":
59
+ parsedVariables.push({
60
+ name,
61
+ condition: { in: identity.personId ? [identity.personId] : [] }
62
+ });
63
+ break;
64
+ default:
65
+ parsedVariables.push({ name, condition: { never: true } });
66
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
67
+ break;
68
+ }
69
+ continue;
70
+ }
71
+ const inputVariable = membership.variables.find((it) => it.name === name);
72
+ if (!inputVariable) {
73
+ if (variable.fallback) {
74
+ parsedVariables.push({ name, condition: variable.fallback });
75
+ } else {
76
+ errors.push(new MembershipValidationError(membership.role, "variableEmpty", name));
77
+ parsedVariables.push({ name, condition: { never: true } });
78
+ }
79
+ continue;
80
+ }
81
+ if (variable.type === schema.Acl.VariableType.entity) {
82
+ parsedVariables.push({ name, condition: { in: inputVariable.values } });
83
+ } else if (variable.type === schema.Acl.VariableType.condition) {
84
+ try {
85
+ const conditions = inputVariable.values.map((it) => condition.conditionSchema()(JSON.parse(it)));
86
+ parsedVariables.push({
87
+ name,
88
+ condition: conditions.length === 1 ? conditions[0] : { or: conditions }
89
+ });
90
+ } catch {
91
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
92
+ parsedVariables.push({ name, condition: { never: true } });
93
+ }
94
+ } else {
95
+ assertNever.assertNever();
96
+ }
97
+ }
98
+ return [errors, parsedVariables];
99
+ }
100
+ }
101
+ __publicField(MembershipResolver, "UnknownIdentity", { identityId: "00000000-0000-0000-0000-000000000000" });
102
+ class MembershipReadResult {
103
+ constructor(errors, memberships) {
104
+ this.errors = errors;
105
+ this.memberships = memberships;
106
+ }
107
+ }
108
+ class MembershipValidationError {
109
+ constructor(role, error, variable) {
110
+ this.role = role;
111
+ this.error = error;
112
+ this.variable = variable;
113
+ }
114
+ }
115
+ var MembershipValidationErrorType = /* @__PURE__ */ ((MembershipValidationErrorType2) => {
116
+ MembershipValidationErrorType2["ROLE_NOT_FOUND"] = "roleNotFound";
117
+ MembershipValidationErrorType2["VARIABLE_NOT_FOUND"] = "variableNotFound";
118
+ MembershipValidationErrorType2["VARIABLE_EMPTY"] = "variableEmpty";
119
+ MembershipValidationErrorType2["VARIABLE_INVALID"] = "variableInvalid";
120
+ return MembershipValidationErrorType2;
121
+ })(MembershipValidationErrorType || {});
122
+ exports.MembershipReadResult = MembershipReadResult;
123
+ exports.MembershipResolver = MembershipResolver;
124
+ exports.MembershipValidationError = MembershipValidationError;
125
+ exports.MembershipValidationErrorType = MembershipValidationErrorType;
126
+ //# sourceMappingURL=MembershipResolver.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MembershipResolver.cjs","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\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): 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] || 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)\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}): [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\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({ name, condition: { in: [identity.identityId] } })\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: 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\tconst inputVariable = membership.variables.find(it => it.name === name)\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\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\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":["getRoleVariables","Acl","conditionSchema","assertNever","MembershipValidationErrorType"],"mappings":";;;;;;;;;;;;;AAMO,MAAM,mBAAmB;AAAA,EAG/B,QACC,KACA,aACA,UAIuB;AACvB,UAAM,SA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AA;AAmG/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;AAEY,IAAA,kDAAAC,mCAAL;AACNA,iCAAA,gBAAiB,IAAA;AACjBA,iCAAA,oBAAqB,IAAA;AACrBA,iCAAA,gBAAiB,IAAA;AACjBA,iCAAA,kBAAmB,IAAA;AAJRA,SAAAA;AAAA,GAAA,iCAAA,CAAA,CAAA;;;;;"}
@@ -0,0 +1,126 @@
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) {
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] || 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);
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) {
48
+ const errors = [];
49
+ const parsedVariables = [];
50
+ for (const [name, variable] of Object.entries(roleVariables)) {
51
+ if (variable.type === Acl.VariableType.predefined) {
52
+ switch (variable.value) {
53
+ case "identityID":
54
+ parsedVariables.push({ name, condition: { in: [identity.identityId] } });
55
+ break;
56
+ case "personID":
57
+ parsedVariables.push({
58
+ name,
59
+ condition: { in: identity.personId ? [identity.personId] : [] }
60
+ });
61
+ break;
62
+ default:
63
+ parsedVariables.push({ name, condition: { never: true } });
64
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
65
+ break;
66
+ }
67
+ continue;
68
+ }
69
+ const inputVariable = membership.variables.find((it) => it.name === name);
70
+ if (!inputVariable) {
71
+ if (variable.fallback) {
72
+ parsedVariables.push({ name, condition: variable.fallback });
73
+ } else {
74
+ errors.push(new MembershipValidationError(membership.role, "variableEmpty", name));
75
+ parsedVariables.push({ name, condition: { never: true } });
76
+ }
77
+ continue;
78
+ }
79
+ if (variable.type === Acl.VariableType.entity) {
80
+ parsedVariables.push({ name, condition: { in: inputVariable.values } });
81
+ } else if (variable.type === Acl.VariableType.condition) {
82
+ try {
83
+ const conditions = inputVariable.values.map((it) => conditionSchema()(JSON.parse(it)));
84
+ parsedVariables.push({
85
+ name,
86
+ condition: conditions.length === 1 ? conditions[0] : { or: conditions }
87
+ });
88
+ } catch {
89
+ errors.push(new MembershipValidationError(membership.role, "variableInvalid", name));
90
+ parsedVariables.push({ name, condition: { never: true } });
91
+ }
92
+ } else {
93
+ assertNever();
94
+ }
95
+ }
96
+ return [errors, parsedVariables];
97
+ }
98
+ }
99
+ __publicField(MembershipResolver, "UnknownIdentity", { identityId: "00000000-0000-0000-0000-000000000000" });
100
+ class MembershipReadResult {
101
+ constructor(errors, memberships) {
102
+ this.errors = errors;
103
+ this.memberships = memberships;
104
+ }
105
+ }
106
+ class MembershipValidationError {
107
+ constructor(role, error, variable) {
108
+ this.role = role;
109
+ this.error = error;
110
+ this.variable = variable;
111
+ }
112
+ }
113
+ var MembershipValidationErrorType = /* @__PURE__ */ ((MembershipValidationErrorType2) => {
114
+ MembershipValidationErrorType2["ROLE_NOT_FOUND"] = "roleNotFound";
115
+ MembershipValidationErrorType2["VARIABLE_NOT_FOUND"] = "variableNotFound";
116
+ MembershipValidationErrorType2["VARIABLE_EMPTY"] = "variableEmpty";
117
+ MembershipValidationErrorType2["VARIABLE_INVALID"] = "variableInvalid";
118
+ return MembershipValidationErrorType2;
119
+ })(MembershipValidationErrorType || {});
120
+ export {
121
+ MembershipReadResult,
122
+ MembershipResolver,
123
+ MembershipValidationError,
124
+ MembershipValidationErrorType
125
+ };
126
+ //# 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\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): 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] || 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)\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}): [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\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({ name, condition: { in: [identity.identityId] } })\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: 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\tconst inputVariable = membership.variables.find(it => it.name === name)\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\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\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":";;;;;;;;;;;AAMO,MAAM,mBAAmB;AAAA,EAG/B,QACC,KACA,aACA,UAIuB;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;AAChD,iBAAA,YAAY,WAAW,WAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,IAAI,KAAK,cAAc,SAAS,IAAI,EAAE,SAAS,IAAI,aAAa,YAAY;AAChG,iBAAA;AAAA,YACN,IAAI;AAAA,cACH,WAAW;AAAA,cACX;AAAA,cACA,SAAS;AAAA,YACV;AAAA,UAAA;AAAA,QAEF;AAAA,MACD;AACM,YAAA,CAAC,kBAAkB,eAAe,IAAI,KAAK,wBAAwB,eAAe,YAAY,QAAQ;AACrG,aAAA,KAAK,GAAG,gBAAgB;AAC/B,aAAO,KAAK;AAAA,QACX,MAAM,WAAW;AAAA,QACjB,WAAW;AAAA,MAAA,CACX;AAAA,IACF;AACO,WAAA,IAAI,qBAAqB,QAAQ,MAAM;AAAA,EAC/C;AAAA,EAEQ,wBAAwB,eAA8B,YAA4B,UAG5B;AAC7D,UAAM,SAAsC,CAAA;AAC5C,UAAM,kBAA8C,CAAA;AACpD,eAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,aAAa,GAAG;AAC7D,UAAI,SAAS,SAAS,IAAI,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AA0B,WAAW,MAAM,mBAAgD,IAAI,CAAC;AAChG,0BAAA,KAAK,EAAE,MAAM,WAAW,EAAE,OAAO,QAAQ;AAAA,QAC1D;AAAA,MAAA,OACM;AACN,oBAAoB;AAAA,MACrB;AAAA,IACD;AACO,WAAA,CAAC,QAAQ,eAAe;AAAA,EAChC;AACD;AAjGC,cADY,oBACE,mBAAkB,EAAE,YAAY,uCAAuC,CAAA;AAmG/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;AAEY,IAAA,kDAAAA,mCAAL;AACNA,iCAAA,gBAAiB,IAAA;AACjBA,iCAAA,oBAAqB,IAAA;AACrBA,iCAAA,gBAAiB,IAAA;AACjBA,iCAAA,kBAAmB,IAAA;AAJRA,SAAAA;AAAA,GAAA,iCAAA,CAAA,CAAA;"}
@@ -0,0 +1,310 @@
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.unique,
51
+ new Set(Object.keys(entity.fields)),
52
+ errors2.for("unique")
53
+ );
54
+ this.validateColumnNamesCollision(entity, errors2);
55
+ }
56
+ validateUniqueConstraints(uniqueConstraints, fields, errors2) {
57
+ for (const constraint of uniqueConstraints) {
58
+ for (const field of constraint.fields) {
59
+ if (!fields.has(field)) {
60
+ errors2.add("MODEL_UNDEFINED_FIELD", `Referenced field ${field} in a constraint does not exists`);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ validateColumnNamesCollision(entity, errors2) {
66
+ const existingColumnNames = /* @__PURE__ */ new Map();
67
+ const addColumnName = (fieldName, columnName) => {
68
+ if (existingColumnNames.has(columnName)) {
69
+ const exitingName = existingColumnNames.get(columnName);
70
+ errors2.for(fieldName).add("MODEL_NAME_COLLISION", `Column name "${columnName}" on field "${fieldName}" collides with a column name on field "${exitingName}".`);
71
+ }
72
+ existingColumnNames.set(columnName, fieldName);
73
+ };
74
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
75
+ visitColumn: ({ column }) => {
76
+ addColumnName(column.name, column.columnName);
77
+ },
78
+ visitOneHasOneOwning: ({ relation }) => {
79
+ addColumnName(relation.name, relation.joiningColumn.columnName);
80
+ },
81
+ visitManyHasOne: ({ relation }) => {
82
+ addColumnName(relation.name, relation.joiningColumn.columnName);
83
+ },
84
+ visitOneHasOneInverse: () => {
85
+ },
86
+ visitOneHasMany: () => {
87
+ },
88
+ visitManyHasManyInverse: () => {
89
+ },
90
+ visitManyHasManyOwning: () => {
91
+ }
92
+ });
93
+ }
94
+ validateField(partialEntity, field, errors2) {
95
+ this.validateIdentifier(field.name, errors2);
96
+ if (isRelation(field)) {
97
+ this.validateRelation(partialEntity, field, errors2);
98
+ } else {
99
+ if (field.sequence && field.nullable) {
100
+ errors2.add("MODEL_INVALID_COLUMN_DEFINITION", "Column with sequence cannot be nullable.");
101
+ }
102
+ }
103
+ }
104
+ validateRelation(partialEntity, field, errors2) {
105
+ const entityName = partialEntity.name;
106
+ const targetEntityName = field.target;
107
+ const targetEntity = this.model.entities[targetEntityName] || void 0;
108
+ if (!targetEntity) {
109
+ return errors2.add("MODEL_UNDEFINED_ENTITY", `Target entity ${targetEntityName} not found`);
110
+ }
111
+ if (((it) => "orderBy" in it)(field)) {
112
+ field.orderBy?.forEach((it) => {
113
+ let entity = targetEntity;
114
+ for (let i = 0; i < it.path.length; i++) {
115
+ const orderByField = entity.fields[it.path[i]];
116
+ const pathStr = it.path.slice(0, i + 1).join(".");
117
+ if (!orderByField) {
118
+ errors2.add("MODEL_UNDEFINED_FIELD", `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not defined`);
119
+ return;
120
+ }
121
+ if (i + 1 < it.path.length) {
122
+ const targetEntity2 = modelUtils.getTargetEntity(this.model, entity, orderByField.name);
123
+ if (!targetEntity2) {
124
+ errors2.add("MODEL_RELATION_REQUIRED", `Invalid orderBy of ${entityName}::${field.name}: field ${pathStr} is not a relation`);
125
+ return;
126
+ }
127
+ entity = targetEntity2;
128
+ }
129
+ }
130
+ });
131
+ }
132
+ if (partialEntity.view) {
133
+ if (field.type === schema.Model.RelationType.ManyHasMany) {
134
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "Many-has-many relation is not allowed on a view entity.");
135
+ }
136
+ if (!targetEntity.view && field.type === schema.Model.RelationType.OneHasMany) {
137
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "One-has-many relation fields on views must point to a view entity.");
138
+ }
139
+ if (!targetEntity.view && field.type === schema.Model.RelationType.OneHasOne && !("joiningColumn" in field)) {
140
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", "One-has-one relation fields on views must be owning or point to a view entity.");
141
+ }
142
+ }
143
+ if (modelUtils.isInverseRelation(field)) {
144
+ const ownedBy = field.ownedBy;
145
+ const targetField = targetEntity.fields[ownedBy];
146
+ const relationDescription = `Target relation ${targetEntityName}::${ownedBy}:`;
147
+ if (!targetField) {
148
+ return errors2.add("MODEL_UNDEFINED_FIELD", `${relationDescription} not exists`);
149
+ }
150
+ if (!isRelation(targetField)) {
151
+ return errors2.add("MODEL_RELATION_REQUIRED", `${relationDescription} not a relation`);
152
+ }
153
+ if (targetField.target !== entityName) {
154
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`);
155
+ }
156
+ if (!modelUtils.isOwningRelation(targetField)) {
157
+ errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} not an owning relation`);
158
+ return;
159
+ }
160
+ if (!targetField.inversedBy) {
161
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} inverse relation is not set`);
162
+ }
163
+ if (targetField.inversedBy !== field.name) {
164
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.inversedBy} given`);
165
+ }
166
+ if (field.type === schema.Model.RelationType.OneHasOne && targetField.type !== schema.Model.RelationType.OneHasOne) {
167
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "OneHasOne" type expected, "${targetField.type}" given`);
168
+ }
169
+ if (field.type === schema.Model.RelationType.OneHasMany && targetField.type !== schema.Model.RelationType.ManyHasOne) {
170
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasOne" type expected, "${targetField.type}" given`);
171
+ }
172
+ if (field.type === schema.Model.RelationType.ManyHasMany && targetField.type !== schema.Model.RelationType.ManyHasMany) {
173
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasMany" type expected, "${targetField.type}" given`);
174
+ }
175
+ } else {
176
+ const inversedBy = field.inversedBy;
177
+ if (targetEntity.view) {
178
+ if ("joiningColumn" in field) {
179
+ return errors2.add("MODEL_INVALID_VIEW_USAGE", `View entity ${targetEntity.name} cannot be referenced from an owning relation. Try switching the owning side.`);
180
+ }
181
+ }
182
+ if (inversedBy) {
183
+ const targetField = targetEntity.fields[inversedBy];
184
+ const relationDescription = `Target relation ${targetEntityName}::${inversedBy}:`;
185
+ if (!targetField) {
186
+ return errors2.add("MODEL_UNDEFINED_FIELD", `${relationDescription} not exists`);
187
+ }
188
+ if (!isRelation(targetField)) {
189
+ return errors2.add("MODEL_RELATION_REQUIRED", `${relationDescription} not a relation`);
190
+ }
191
+ if (targetField.target !== entityName) {
192
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`);
193
+ }
194
+ if (!modelUtils.isInverseRelation(targetField)) {
195
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} not an inverse relation`);
196
+ }
197
+ if (!targetField.ownedBy) {
198
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} owning relation is not set`);
199
+ }
200
+ if (targetField.ownedBy !== field.name) {
201
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.ownedBy} given`);
202
+ }
203
+ if (field.type === schema.Model.RelationType.OneHasOne && targetField.type !== schema.Model.RelationType.OneHasOne) {
204
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "OneHasOne" type expected, "${targetField.type}" given`);
205
+ }
206
+ if (field.type === schema.Model.RelationType.ManyHasOne && targetField.type !== schema.Model.RelationType.OneHasMany) {
207
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasOne" type expected, "${targetField.type}" given`);
208
+ }
209
+ if (field.type === schema.Model.RelationType.ManyHasMany && targetField.type !== schema.Model.RelationType.ManyHasMany) {
210
+ return errors2.add("MODEL_INVALID_RELATION_DEFINITION", `${relationDescription} "ManyHasMany" type expected, "${targetField.type}" given`);
211
+ }
212
+ }
213
+ }
214
+ }
215
+ validateIdentifier(value, errorBuilder) {
216
+ if (!value.match(IDENTIFIER_PATTERN)) {
217
+ return errorBuilder.add("MODEL_INVALID_IDENTIFIER", `${value} must match pattern ${IDENTIFIER_PATTERN.source}`);
218
+ }
219
+ if (RESERVED_WORDS.includes(value)) {
220
+ errorBuilder.add("MODEL_INVALID_IDENTIFIER", `${value} is reserved word`);
221
+ }
222
+ }
223
+ validateEntityName(value, errorBuilder) {
224
+ if (["Query", "Mutation"].includes(value)) {
225
+ errorBuilder.add("MODEL_INVALID_ENTITY_NAME", `${value} is reserved word`);
226
+ }
227
+ }
228
+ validateMetaSuffixCollisions(entities, errorBuilder) {
229
+ const entityNames = new Set(entities.map((it) => it.name));
230
+ for (const entity of entities) {
231
+ if (entity.name.endsWith("Meta")) {
232
+ const baseName = entity.name.substring(0, entity.name.length - 4);
233
+ if (entityNames.has(baseName)) {
234
+ errorBuilder.for(entity.name).add("MODEL_NAME_COLLISION", `entity ${entity.name} collides with entity ${baseName}, because a GraphQL type with "Meta" suffix is created for every entity`);
235
+ }
236
+ }
237
+ }
238
+ }
239
+ validateTableNameCollisions(entities, errorBuilder) {
240
+ const relationNames = {};
241
+ for (const entity of entities) {
242
+ const description = `table name ${entity.tableName} of entity ${entity.name}`;
243
+ if (relationNames[entity.tableName]) {
244
+ errorBuilder.for(entity.name).add("MODEL_NAME_COLLISION", `${description} collides with a ${relationNames[entity.tableName]}`);
245
+ } else {
246
+ relationNames[entity.tableName] = description;
247
+ }
248
+ }
249
+ for (const entity of entities) {
250
+ const entityErrorBuilder = errorBuilder.for(entity.name);
251
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
252
+ visitManyHasManyOwning: ({ entity: entity2, relation }) => {
253
+ const joiningTable = relation.joiningTable;
254
+ const description = `joining table name ${joiningTable.tableName} of relation ${entity2.name}::${relation.name}`;
255
+ if (relationNames[joiningTable.tableName]) {
256
+ entityErrorBuilder.for(relation.name).add(
257
+ "MODEL_NAME_COLLISION",
258
+ `${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.`
259
+ );
260
+ } else {
261
+ relationNames[joiningTable.tableName] = description;
262
+ }
263
+ },
264
+ visitColumn: () => {
265
+ },
266
+ visitManyHasManyInverse: () => {
267
+ },
268
+ visitOneHasMany: () => {
269
+ },
270
+ visitOneHasOneInverse: () => {
271
+ },
272
+ visitOneHasOneOwning: () => {
273
+ },
274
+ visitManyHasOne: () => {
275
+ }
276
+ });
277
+ }
278
+ }
279
+ validateAliasedTypesCollision(entities, errorBuilder) {
280
+ const aliasedTypes = /* @__PURE__ */ new Map();
281
+ for (const entity of entities) {
282
+ modelUtils.acceptEveryFieldVisitor(this.model, entity, {
283
+ visitColumn: ({ column }) => {
284
+ if (!column.typeAlias) {
285
+ return;
286
+ }
287
+ if (aliasedTypes.has(column.typeAlias) && aliasedTypes.get(column.typeAlias) !== column.type) {
288
+ errorBuilder.for(column.name).add("MODEL_NAME_COLLISION", `Type alias ${column.typeAlias} already exists for base type ${column.type}`);
289
+ }
290
+ aliasedTypes.set(column.typeAlias, column.type);
291
+ },
292
+ visitManyHasManyOwning: () => {
293
+ },
294
+ visitManyHasManyInverse: () => {
295
+ },
296
+ visitOneHasMany: () => {
297
+ },
298
+ visitOneHasOneInverse: () => {
299
+ },
300
+ visitOneHasOneOwning: () => {
301
+ },
302
+ visitManyHasOne: () => {
303
+ }
304
+ });
305
+ }
306
+ }
307
+ }
308
+ const isRelation = (field) => Object.values(schema.Model.RelationType).includes(field.type);
309
+ exports.ModelValidator = ModelValidator;
310
+ //# 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, isInverseRelation, isOwningRelation } from '../model'\n\nconst IDENTIFIER_PATTERN = /^[_a-zA-Z][_a-zA-Z0-9]*$/\nconst RESERVED_WORDS = ['and', 'or', 'not']\n\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.unique,\n\t\t\tnew Set(Object.keys(entity.fields)),\n\t\t\terrors.for('unique'),\n\t\t)\n\t\tthis.validateColumnNamesCollision(entity, errors)\n\t}\n\n\tprivate validateUniqueConstraints(uniqueConstraints: Model.Entity['unique'], fields: Set<string>, errors: ErrorBuilder): void {\n\t\tfor (const constraint of uniqueConstraints) {\n\t\t\tfor (const field of constraint.fields) {\n\t\t\t\tif (!fields.has(field)) {\n\t\t\t\t\terrors.add('MODEL_UNDEFINED_FIELD', `Referenced field ${field} in a constraint does not exists`)\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\tfield.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\tfield.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('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`)\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('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.inversedBy} given`)\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 (targetEntity.view) {\n\t\t\t\tif ('joiningColumn' in field) {\n\t\t\t\t\treturn errors.add('MODEL_INVALID_VIEW_USAGE', `View entity ${targetEntity.name} cannot be referenced from an owning relation. Try switching the owning side.`)\n\t\t\t\t}\n\t\t\t}\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('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} back reference to entity ${entityName} expected, but ${targetField.target} given`)\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('MODEL_INVALID_RELATION_DEFINITION', `${relationDescription} back reference ${entityName}::${field.name} expected, ${targetField.target}::${targetField.ownedBy} given`)\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\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('MODEL_NAME_COLLISION', `entity ${entity.name} collides with entity ${baseName}, because a GraphQL type with \"Meta\" suffix is created for every entity`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\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('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'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\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 =>\n\tObject.values(Model.RelationType).includes(field.type as Model.RelationType)\n"],"names":["ErrorBuilder","errors","acceptEveryFieldVisitor","targetEntity","getTargetEntity","Model","isInverseRelation","isOwningRelation","entity"],"mappings":";;;;;AAIA,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB,CAAC,OAAO,MAAM,KAAK;AAGnC,MAAM,eAAe;AAAA,EAC3B,YAA6B,OAAqB;AAArB,SAAA,QAAA;AAAA,EAAuB;AAAA,EAE7C,WAA8B;AACpC,UAAM,eAAe,IAAIA,OAAAA,aAAa,CAAC,GAAG,CAAE,CAAA;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;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