@contember/engine-tenant-api 1.2.0 → 1.3.0-alpha.13

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 (325) hide show
  1. package/dist/src/TenantContainer.d.ts +1 -1
  2. package/dist/src/TenantContainer.d.ts.map +1 -1
  3. package/dist/src/TenantContainer.js +2 -0
  4. package/dist/src/TenantContainer.js.map +1 -1
  5. package/dist/src/bin/runMigrations.d.ts +2 -0
  6. package/dist/src/bin/runMigrations.d.ts.map +1 -0
  7. package/dist/src/bin/runMigrations.js +28 -0
  8. package/dist/src/bin/runMigrations.js.map +1 -0
  9. package/dist/src/migrations/2018-08-02-174310-init.d.ts +3 -0
  10. package/dist/src/migrations/2018-08-02-174310-init.d.ts.map +1 -0
  11. package/dist/src/migrations/2018-08-02-174310-init.js +64 -0
  12. package/dist/src/migrations/2018-08-02-174310-init.js.map +1 -0
  13. package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts +3 -0
  14. package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts.map +1 -0
  15. package/dist/src/migrations/2018-09-03-140621-identity-project.js +33 -0
  16. package/dist/src/migrations/2018-09-03-140621-identity-project.js.map +1 -0
  17. package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts +3 -0
  18. package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts.map +1 -0
  19. package/dist/src/migrations/2018-10-26-165450-setup-api-key.js +27 -0
  20. package/dist/src/migrations/2018-10-26-165450-setup-api-key.js.map +1 -0
  21. package/dist/src/migrations/2018-10-26-175155-variables.d.ts +3 -0
  22. package/dist/src/migrations/2018-10-26-175155-variables.d.ts.map +1 -0
  23. package/dist/src/migrations/2018-10-26-175155-variables.js +23 -0
  24. package/dist/src/migrations/2018-10-26-175155-variables.js.map +1 -0
  25. package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts +3 -0
  26. package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts.map +1 -0
  27. package/dist/src/migrations/2019-02-18-110949-project-slug.js +18 -0
  28. package/dist/src/migrations/2019-02-18-110949-project-slug.js.map +1 -0
  29. package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts +3 -0
  30. package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts.map +1 -0
  31. package/dist/src/migrations/2019-02-18-160155-session-expiration.js +11 -0
  32. package/dist/src/migrations/2019-02-18-160155-session-expiration.js.map +1 -0
  33. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts +3 -0
  34. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts.map +1 -0
  35. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js +18 -0
  36. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js.map +1 -0
  37. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts +3 -0
  38. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts.map +1 -0
  39. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js +11 -0
  40. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js.map +1 -0
  41. package/dist/src/migrations/2019-09-06-111000-membership.d.ts +3 -0
  42. package/dist/src/migrations/2019-09-06-111000-membership.d.ts.map +1 -0
  43. package/dist/src/migrations/2019-09-06-111000-membership.js +51 -0
  44. package/dist/src/migrations/2019-09-06-111000-membership.js.map +1 -0
  45. package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts +3 -0
  46. package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts.map +1 -0
  47. package/dist/src/migrations/2019-09-06-111001-drop-old-member.js +11 -0
  48. package/dist/src/migrations/2019-09-06-111001-drop-old-member.js.map +1 -0
  49. package/dist/src/migrations/2020-01-29-idenity-note.d.ts +3 -0
  50. package/dist/src/migrations/2020-01-29-idenity-note.d.ts.map +1 -0
  51. package/dist/src/migrations/2020-01-29-idenity-note.js +18 -0
  52. package/dist/src/migrations/2020-01-29-idenity-note.js.map +1 -0
  53. package/dist/src/migrations/2020-04-17-fix-person-index.d.ts +3 -0
  54. package/dist/src/migrations/2020-04-17-fix-person-index.d.ts.map +1 -0
  55. package/dist/src/migrations/2020-04-17-fix-person-index.js +12 -0
  56. package/dist/src/migrations/2020-04-17-fix-person-index.js.map +1 -0
  57. package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts +3 -0
  58. package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts.map +1 -0
  59. package/dist/src/migrations/2020-05-01-170000-api-key-index.js +10 -0
  60. package/dist/src/migrations/2020-05-01-170000-api-key-index.js.map +1 -0
  61. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.d.ts.map +1 -1
  62. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js +2 -50
  63. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js.map +1 -1
  64. package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts +3 -0
  65. package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts.map +1 -0
  66. package/dist/src/migrations/2020-08-07-110000-person-otp.js +12 -0
  67. package/dist/src/migrations/2020-08-07-110000-person-otp.js.map +1 -0
  68. package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts +3 -0
  69. package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts.map +1 -0
  70. package/dist/src/migrations/2020-08-17-162200-mail-templates.js +23 -0
  71. package/dist/src/migrations/2020-08-17-162200-mail-templates.js.map +1 -0
  72. package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts +3 -0
  73. package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts.map +1 -0
  74. package/dist/src/migrations/2020-08-21-143400-person-password-reset.js +23 -0
  75. package/dist/src/migrations/2020-08-21-143400-person-password-reset.js.map +1 -0
  76. package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts +3 -0
  77. package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts.map +1 -0
  78. package/dist/src/migrations/2020-09-07-094200-identity-provider.js +17 -0
  79. package/dist/src/migrations/2020-09-07-094200-identity-provider.js.map +1 -0
  80. package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts +3 -0
  81. package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts.map +1 -0
  82. package/dist/src/migrations/2021-03-28-134000-timestamp.js +27 -0
  83. package/dist/src/migrations/2021-03-28-134000-timestamp.js.map +1 -0
  84. package/dist/src/migrations/2021-07-26-105000-project-config.d.ts +3 -0
  85. package/dist/src/migrations/2021-07-26-105000-project-config.d.ts.map +1 -0
  86. package/dist/src/migrations/2021-07-26-105000-project-config.js +12 -0
  87. package/dist/src/migrations/2021-07-26-105000-project-config.js.map +1 -0
  88. package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts +3 -0
  89. package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts.map +1 -0
  90. package/dist/src/migrations/2021-07-26-132000-project-secrets.js +24 -0
  91. package/dist/src/migrations/2021-07-26-132000-project-secrets.js.map +1 -0
  92. package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts +3 -0
  93. package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts.map +1 -0
  94. package/dist/src/migrations/2021-07-27-174000-project-alias-index.js +10 -0
  95. package/dist/src/migrations/2021-07-27-174000-project-alias-index.js.map +1 -0
  96. package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts +3 -0
  97. package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts.map +1 -0
  98. package/dist/src/migrations/2021-11-24-130000-person-password-null.js +10 -0
  99. package/dist/src/migrations/2021-11-24-130000-person-password-null.js.map +1 -0
  100. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts +3 -0
  101. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts.map +1 -0
  102. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js +18 -0
  103. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js.map +1 -0
  104. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts +3 -0
  105. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts.map +1 -0
  106. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js +11 -0
  107. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js.map +1 -0
  108. package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts +3 -0
  109. package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts.map +1 -0
  110. package/dist/src/migrations/2022-02-09-111800-fix-crypted.js +22 -0
  111. package/dist/src/migrations/2022-02-09-111800-fix-crypted.js.map +1 -0
  112. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts +3 -0
  113. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts.map +1 -0
  114. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js +11 -0
  115. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js.map +1 -0
  116. package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts +3 -0
  117. package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts.map +1 -0
  118. package/dist/src/migrations/2022-06-29-105000-person-idp.js +23 -0
  119. package/dist/src/migrations/2022-06-29-105000-person-idp.js.map +1 -0
  120. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts +3 -0
  121. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts.map +1 -0
  122. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js +12 -0
  123. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js.map +1 -0
  124. package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts +3 -0
  125. package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts.map +1 -0
  126. package/dist/src/migrations/2022-07-07-141000-person-display-name.js +13 -0
  127. package/dist/src/migrations/2022-07-07-141000-person-display-name.js.map +1 -0
  128. package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts +3 -0
  129. package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts.map +1 -0
  130. package/dist/src/migrations/2022-07-14-145000-person-login-options.js +15 -0
  131. package/dist/src/migrations/2022-07-14-145000-person-login-options.js.map +1 -0
  132. package/dist/src/migrations/2022-11-08-project-update-notification.d.ts +3 -0
  133. package/dist/src/migrations/2022-11-08-project-update-notification.d.ts.map +1 -0
  134. package/dist/src/migrations/2022-11-08-project-update-notification.js +64 -0
  135. package/dist/src/migrations/2022-11-08-project-update-notification.js.map +1 -0
  136. package/dist/src/migrations/runner.d.ts +1 -1
  137. package/dist/src/migrations/runner.d.ts.map +1 -1
  138. package/dist/src/migrations/runner.js +68 -5
  139. package/dist/src/migrations/runner.js.map +1 -1
  140. package/dist/src/migrations/snapshot-factory.d.ts +5 -0
  141. package/dist/src/migrations/snapshot-factory.d.ts.map +1 -0
  142. package/dist/src/migrations/snapshot-factory.js +18 -0
  143. package/dist/src/migrations/snapshot-factory.js.map +1 -0
  144. package/dist/src/migrations/snapshot.d.ts +4 -0
  145. package/dist/src/migrations/snapshot.d.ts.map +1 -0
  146. package/dist/src/migrations/snapshot.js +202 -0
  147. package/dist/src/migrations/snapshot.js.map +1 -0
  148. package/dist/src/migrations/tenantCredentials.d.ts +4 -0
  149. package/dist/src/migrations/tenantCredentials.d.ts.map +1 -0
  150. package/dist/src/migrations/tenantCredentials.js +57 -0
  151. package/dist/src/migrations/tenantCredentials.js.map +1 -0
  152. package/dist/src/migrations/types.d.ts +2 -0
  153. package/dist/src/migrations/types.d.ts.map +1 -1
  154. package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts +1 -0
  155. package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts.map +1 -1
  156. package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts +3 -3
  157. package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts.map +1 -1
  158. package/dist/src/model/queries/membership/ProjectMembersQuery.js +22 -10
  159. package/dist/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
  160. package/dist/src/model/service/IDPSignInManager.d.ts +3 -3
  161. package/dist/src/model/service/IDPSignInManager.d.ts.map +1 -1
  162. package/dist/src/model/service/IDPSignInManager.js +13 -5
  163. package/dist/src/model/service/IDPSignInManager.js.map +1 -1
  164. package/dist/src/model/service/ProjectMemberManager.d.ts +2 -2
  165. package/dist/src/model/service/ProjectMemberManager.d.ts.map +1 -1
  166. package/dist/src/model/service/ProjectMemberManager.js +2 -2
  167. package/dist/src/model/service/ProjectMemberManager.js.map +1 -1
  168. package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts +2 -2
  169. package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts.map +1 -1
  170. package/dist/src/model/service/idp/IDPHandlerRegistry.js.map +1 -1
  171. package/dist/src/model/service/idp/IDPManager.d.ts.map +1 -1
  172. package/dist/src/model/service/idp/IDPManager.js +7 -2
  173. package/dist/src/model/service/idp/IDPManager.js.map +1 -1
  174. package/dist/src/model/service/idp/IdentityProviderHandler.d.ts +6 -9
  175. package/dist/src/model/service/idp/IdentityProviderHandler.d.ts.map +1 -1
  176. package/dist/src/model/service/idp/index.d.ts +3 -1
  177. package/dist/src/model/service/idp/index.d.ts.map +1 -1
  178. package/dist/src/model/service/idp/index.js +3 -1
  179. package/dist/src/model/service/idp/index.js.map +1 -1
  180. package/dist/src/model/service/idp/providers/AppleProvider.d.ts +29 -0
  181. package/dist/src/model/service/idp/providers/AppleProvider.d.ts.map +1 -0
  182. package/dist/src/model/service/idp/providers/AppleProvider.js +79 -0
  183. package/dist/src/model/service/idp/providers/AppleProvider.js.map +1 -0
  184. package/dist/src/model/service/idp/providers/FacebookProvider.d.ts +27 -0
  185. package/dist/src/model/service/idp/providers/FacebookProvider.d.ts.map +1 -0
  186. package/dist/src/model/service/idp/providers/FacebookProvider.js +137 -0
  187. package/dist/src/model/service/idp/providers/FacebookProvider.js.map +1 -0
  188. package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts +10 -0
  189. package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts.map +1 -0
  190. package/dist/src/model/service/idp/providers/OIDCHelpers.js +56 -0
  191. package/dist/src/model/service/idp/providers/OIDCHelpers.js.map +1 -0
  192. package/dist/src/model/service/idp/providers/OIDCProvider.d.ts +19 -0
  193. package/dist/src/model/service/idp/providers/OIDCProvider.d.ts.map +1 -0
  194. package/dist/src/model/service/idp/providers/OIDCProvider.js +40 -0
  195. package/dist/src/model/service/idp/providers/OIDCProvider.js.map +1 -0
  196. package/dist/src/model/service/idp/providers/OIDCTypes.d.ts +62 -0
  197. package/dist/src/model/service/idp/providers/OIDCTypes.d.ts.map +1 -0
  198. package/dist/src/model/service/idp/providers/OIDCTypes.js +56 -0
  199. package/dist/src/model/service/idp/providers/OIDCTypes.js.map +1 -0
  200. package/dist/src/model/service/idp/providers/helpers.d.ts +3 -0
  201. package/dist/src/model/service/idp/providers/helpers.d.ts.map +1 -0
  202. package/dist/src/model/service/idp/providers/helpers.js +40 -0
  203. package/dist/src/model/service/idp/providers/helpers.js.map +1 -0
  204. package/dist/src/model/utils/DatabaseContext.d.ts +1 -0
  205. package/dist/src/model/utils/DatabaseContext.d.ts.map +1 -1
  206. package/dist/src/model/utils/DatabaseContext.js +5 -0
  207. package/dist/src/model/utils/DatabaseContext.js.map +1 -1
  208. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.d.ts.map +1 -1
  209. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +4 -3
  210. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  211. package/dist/src/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
  212. package/dist/src/resolvers/mutation/person/IDPMutationResolver.js +10 -3
  213. package/dist/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  214. package/dist/src/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
  215. package/dist/src/resolvers/types/ProjectTypeResolver.js +14 -6
  216. package/dist/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  217. package/dist/src/schema/index.d.ts +26 -8
  218. package/dist/src/schema/index.d.ts.map +1 -1
  219. package/dist/src/schema/index.js +1 -0
  220. package/dist/src/schema/index.js.map +1 -1
  221. package/dist/src/schema/tenant.graphql.d.ts.map +1 -1
  222. package/dist/src/schema/tenant.graphql.js +32 -6
  223. package/dist/src/schema/tenant.graphql.js.map +1 -1
  224. package/dist/src/tsconfig.tsbuildinfo +1 -1
  225. package/dist/tests/cases/integration/db/invite.test.js +2 -2
  226. package/dist/tests/cases/integration/db/unmanagedInvite.test.js +2 -2
  227. package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.d.ts +1 -1
  228. package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +1 -0
  229. package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.js +19 -9
  230. package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.js.map +1 -0
  231. package/dist/tests/src/IdPMock.d.ts +4 -4
  232. package/dist/tests/src/IdPMock.d.ts.map +1 -1
  233. package/dist/tests/src/IdPMock.js +2 -2
  234. package/dist/tests/src/IdPMock.js.map +1 -1
  235. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  236. package/package.json +19 -14
  237. package/src/TenantContainer.ts +4 -2
  238. package/src/bin/runMigrations.ts +32 -0
  239. package/src/migrations/{2018-08-02-174310-init.sql → 2018-08-02-174310-init.ts} +8 -1
  240. package/src/migrations/{2018-09-03-140621-identity-project.sql → 2018-09-03-140621-identity-project.ts} +8 -0
  241. package/src/migrations/{2018-10-26-165450-setup-api-key.sql → 2018-10-26-165450-setup-api-key.ts} +8 -0
  242. package/src/migrations/{2018-10-26-175155-variables.sql → 2018-10-26-175155-variables.ts} +7 -0
  243. package/src/migrations/{2019-02-18-110949-project-slug.sql → 2019-02-18-110949-project-slug.ts} +8 -0
  244. package/src/migrations/2019-02-18-160155-session-expiration.ts +10 -0
  245. package/src/migrations/{2019-05-03-163729-api-key-disabled-at.sql → 2019-05-03-163729-api-key-disabled-at.ts} +8 -0
  246. package/src/migrations/2019-08-14-153300-project-slug-unique.ts +10 -0
  247. package/src/migrations/{2019-09-06-111000-membership.sql → 2019-09-06-111000-membership.ts} +8 -0
  248. package/src/migrations/2019-09-06-111001-drop-old-member.ts +10 -0
  249. package/src/migrations/2020-01-29-idenity-note.ts +18 -0
  250. package/src/migrations/2020-04-17-fix-person-index.ts +12 -0
  251. package/src/migrations/2020-05-01-170000-api-key-index.ts +10 -0
  252. package/src/migrations/2020-06-08-134000-tenant-credentials.ts +3 -54
  253. package/src/migrations/2020-08-07-110000-person-otp.ts +12 -0
  254. package/src/migrations/{2020-08-17-162200-mail-templates.sql → 2020-08-17-162200-mail-templates.ts} +8 -0
  255. package/src/migrations/{2020-08-21-143400-person-password-reset.sql → 2020-08-21-143400-person-password-reset.ts} +8 -0
  256. package/src/migrations/{2020-09-07-094200-identity-provider.sql → 2020-09-07-094200-identity-provider.ts} +8 -0
  257. package/src/migrations/{2021-03-28-134000-timestamp.sql → 2021-03-28-134000-timestamp.ts} +9 -0
  258. package/src/migrations/2021-07-26-105000-project-config.ts +12 -0
  259. package/src/migrations/{2021-07-26-132000-project-secrets.sql → 2021-07-26-132000-project-secrets.ts} +8 -0
  260. package/src/migrations/2021-07-27-174000-project-alias-index.ts +10 -0
  261. package/src/migrations/2021-11-24-130000-person-password-null.ts +10 -0
  262. package/src/migrations/{2021-11-24-161500-mail-template-project-null.sql → 2021-11-24-161500-mail-template-project-null.ts} +8 -0
  263. package/src/migrations/2022-01-04-144000-person-unique-identity.ts +10 -0
  264. package/src/migrations/{2022-02-09-111800-fix-crypted.sql → 2022-02-09-111800-fix-crypted.ts} +8 -0
  265. package/src/migrations/2022-02-11-153000-idp-auto-sign-up.ts +10 -0
  266. package/src/migrations/{2022-06-29-105000-person-idp.sql → 2022-06-29-105000-person-idp.ts} +8 -0
  267. package/src/migrations/2022-07-07-135000-person-email-opt-uniq.ts +11 -0
  268. package/src/migrations/2022-07-07-141000-person-display-name.ts +13 -0
  269. package/src/migrations/{2022-07-14-145000-person-login-options.sql → 2022-07-14-145000-person-login-options.ts} +9 -0
  270. package/src/migrations/2022-11-08-project-update-notification.ts +64 -0
  271. package/src/migrations/runner.ts +72 -8
  272. package/src/migrations/snapshot-factory.ts +21 -0
  273. package/src/migrations/snapshot-template-end.txt +10 -0
  274. package/src/migrations/snapshot-template-start.txt +6 -0
  275. package/src/migrations/snapshot.ts +202 -0
  276. package/src/migrations/tenantCredentials.ts +58 -0
  277. package/src/migrations/types.ts +3 -0
  278. package/src/model/commands/idp/UpdateIdpCommand.ts +1 -0
  279. package/src/model/queries/membership/ProjectMembersQuery.ts +23 -14
  280. package/src/model/service/IDPSignInManager.ts +13 -10
  281. package/src/model/service/ProjectMemberManager.ts +3 -3
  282. package/src/model/service/idp/IDPHandlerRegistry.ts +3 -3
  283. package/src/model/service/idp/IDPManager.ts +6 -2
  284. package/src/model/service/idp/IdentityProviderHandler.ts +7 -15
  285. package/src/model/service/idp/index.ts +3 -1
  286. package/src/model/service/idp/providers/AppleProvider.ts +65 -0
  287. package/src/model/service/idp/providers/FacebookProvider.ts +125 -0
  288. package/src/model/service/idp/providers/OIDCHelpers.ts +54 -0
  289. package/src/model/service/idp/providers/OIDCProvider.ts +40 -0
  290. package/src/model/service/idp/providers/OIDCTypes.ts +61 -0
  291. package/src/model/service/idp/providers/helpers.ts +12 -0
  292. package/src/model/utils/DatabaseContext.ts +6 -0
  293. package/src/resolvers/mutation/idp/UpdateIDPMutationResolver.ts +1 -0
  294. package/src/resolvers/mutation/person/IDPMutationResolver.ts +9 -7
  295. package/src/resolvers/types/ProjectTypeResolver.ts +9 -2
  296. package/src/schema/index.ts +28 -8
  297. package/src/schema/tenant.graphql.ts +32 -6
  298. package/src/tsconfig.json +10 -30
  299. package/tests/cases/integration/db/invite.test.ts +2 -2
  300. package/tests/cases/integration/db/unmanagedInvite.test.ts +2 -2
  301. package/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.ts +17 -9
  302. package/tests/src/IdPMock.ts +4 -4
  303. package/tests/tsconfig.json +2 -6
  304. package/tsconfig.json +2 -6
  305. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +0 -1
  306. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.js.map +0 -1
  307. package/dist/src/model/service/idp/OIDCProvider.d.ts +0 -25
  308. package/dist/src/model/service/idp/OIDCProvider.d.ts.map +0 -1
  309. package/dist/src/model/service/idp/OIDCProvider.js +0 -108
  310. package/dist/src/model/service/idp/OIDCProvider.js.map +0 -1
  311. package/src/migrations/2019-02-18-160155-session-expiration.sql +0 -2
  312. package/src/migrations/2019-08-14-153300-project-slug-unique.sql +0 -2
  313. package/src/migrations/2019-09-06-111001-drop-old-member.sql +0 -2
  314. package/src/migrations/2020-01-29-idenity-note.sql +0 -9
  315. package/src/migrations/2020-04-17-fix-person-index.sql +0 -3
  316. package/src/migrations/2020-05-01-170000-api-key-index.sql +0 -1
  317. package/src/migrations/2020-08-07-110000-person-otp.sql +0 -3
  318. package/src/migrations/2021-07-26-105000-project-config.sql +0 -3
  319. package/src/migrations/2021-07-27-174000-project-alias-index.sql +0 -1
  320. package/src/migrations/2021-11-24-130000-person-password-null.sql +0 -1
  321. package/src/migrations/2022-01-04-144000-person-unique-identity.sql +0 -2
  322. package/src/migrations/2022-02-11-153000-idp-auto-sign-up.sql +0 -2
  323. package/src/migrations/2022-07-07-135000-person-email-opt-uniq.sql +0 -3
  324. package/src/migrations/2022-07-07-141000-person-display-name.sql +0 -4
  325. package/src/model/service/idp/OIDCProvider.ts +0 -100
package/package.json CHANGED
@@ -1,33 +1,38 @@
1
1
  {
2
2
  "name": "@contember/engine-tenant-api",
3
- "version": "1.2.0",
3
+ "version": "1.3.0-alpha.13",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/src/index.d.ts",
7
+ "exports": {
8
+ "typescript": "./src/index.ts",
9
+ "default": "./dist/src/index.js"
10
+ },
7
11
  "scripts": {
8
12
  "generate": "gql-gen --config graphql-tenant.codegen.yml",
9
13
  "test": "vitest --no-threads"
10
14
  },
11
15
  "dependencies": {
12
- "@contember/authorization": "^1.2.0",
13
- "@contember/config-loader": "^1.2.0",
14
- "@contember/database": "^1.2.0",
15
- "@contember/database-migrations": "^1.2.0",
16
- "@contember/dic": "^1.2.0",
17
- "@contember/logger": "^1.2.0",
18
- "@contember/typesafe": "^1.2.0",
19
- "@contember/graphql-utils": "^1.2.0",
20
- "@contember/schema": "^1.2.0",
21
- "@contember/schema-utils": "^1.2.0",
16
+ "@contember/authorization": "1.3.0-alpha.13",
17
+ "@contember/config-loader": "1.3.0-alpha.13",
18
+ "@contember/database": "1.3.0-alpha.13",
19
+ "@contember/database-migrations": "1.3.0-alpha.13",
20
+ "@contember/dic": "1.3.0-alpha.13",
21
+ "@contember/graphql-utils": "1.3.0-alpha.13",
22
+ "@contember/logger": "1.3.0-alpha.13",
23
+ "@contember/schema": "1.3.0-alpha.13",
24
+ "@contember/schema-utils": "1.3.0-alpha.13",
25
+ "@contember/typesafe": "1.3.0-alpha.13",
22
26
  "@graphql-tools/utils": "^8.6.13",
23
27
  "graphql-tag": "^2.12.5",
28
+ "jose": "^4.10",
24
29
  "mustache": "^4.0.0",
25
30
  "nodemailer": "^6.4.2",
26
- "openid-client": "^4.2.1",
31
+ "openid-client": "^5.3.1",
27
32
  "otpauth": "^7.0.6"
28
33
  },
29
34
  "devDependencies": {
30
- "@contember/database-tester": "^1.2.0",
35
+ "@contember/database-tester": "1.3.0-alpha.13",
31
36
  "@graphql-codegen/cli": "^2.6.2",
32
37
  "@graphql-codegen/typescript": "^2.5.1",
33
38
  "@graphql-codegen/typescript-operations": "^2.4.2",
@@ -42,4 +47,4 @@
42
47
  "graphql": ">= 14.6.0",
43
48
  "pg": "^8.9.0"
44
49
  }
45
- }
50
+ }
@@ -4,9 +4,9 @@ import { Builder } from '@contember/dic'
4
4
  import {
5
5
  AclSchemaAccessNodeFactory,
6
6
  ApiKeyManager,
7
- ApiKeyService,
7
+ ApiKeyService, AppleProvider,
8
8
  DatabaseContext,
9
- DatabaseContextFactory,
9
+ DatabaseContextFactory, FacebookProvider,
10
10
  Identity,
11
11
  IdentityFactory,
12
12
  IDPHandlerRegistry,
@@ -158,6 +158,8 @@ export class TenantContainerFactory {
158
158
  .addService('idpRegistry', () => {
159
159
  const idpRegistry = new IDPHandlerRegistry()
160
160
  idpRegistry.registerHandler('oidc', new OIDCProvider())
161
+ idpRegistry.registerHandler('facebook', new FacebookProvider())
162
+ idpRegistry.registerHandler('apple', new AppleProvider())
161
163
  return idpRegistry
162
164
  })
163
165
  .addService('idpSignInManager', ({ apiKeyManager, idpRegistry }) =>
@@ -0,0 +1,32 @@
1
+ import { TenantMigrationsRunner } from '../migrations'
2
+ import { createLogger, PrettyPrintLoggerHandler } from '@contember/logger'
3
+
4
+ let uuidNum = 0
5
+ const dummyUuid = () => '123e4567-e89b-12d3-a456-' + (uuidNum++).toString().padStart(12, '0')
6
+
7
+ ;(async () => {
8
+ const migrationsRunner = new TenantMigrationsRunner(
9
+ {
10
+ database: process.env.PGDATABASE as string,
11
+ host: process.env.PGHOST as string,
12
+ password: process.env.PGPASSWORD as string,
13
+ user: process.env.PGUSER as string,
14
+ port: process.env.PGPORT ? Number(process.env.PGPORT) : 5432,
15
+ },
16
+ 'tenant',
17
+ {
18
+ rootToken: '0',
19
+ },
20
+ {
21
+ bcrypt: () => {
22
+ throw new Error()
23
+ },
24
+ uuid: dummyUuid,
25
+ },
26
+ )
27
+ await migrationsRunner.run(createLogger(new PrettyPrintLoggerHandler(process.stderr)))
28
+ })().catch(e => {
29
+ // eslint-disable-next-line no-console
30
+ console.error(e)
31
+ process.exit(1)
32
+ })
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE "identity" (
2
5
  "id" uuid NOT NULL,
3
6
  "parent_id" uuid,
@@ -53,4 +56,8 @@ CREATE TABLE "project_member" (
53
56
  );
54
57
 
55
58
  CREATE UNIQUE INDEX project_member_project_id_person_id ON "project_member" ("project_id", "person_id");
56
- CREATE INDEX "project_member_person_id" ON "project_member" ("person_id");
59
+ CREATE INDEX "project_member_person_id" ON "project_member" ("person_id");`
60
+
61
+ export default async function (builder: MigrationBuilder) {
62
+ builder.sql(sql)
63
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE "project_member"
2
5
  ADD COLUMN "identity_id" UUID DEFAULT NULL,
3
6
  ADD COLUMN "roles" jsonb NOT NULL DEFAULT '[]' :: jsonb;
@@ -22,3 +25,8 @@ ALTER TABLE "project_member"
22
25
  ALTER "roles" DROP DEFAULT,
23
26
  ALTER "identity_id" DROP DEFAULT,
24
27
  ALTER "identity_id" SET NOT NULL;
28
+ `
29
+
30
+ export default async function (builder: MigrationBuilder) {
31
+ builder.sql(sql)
32
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  DO
2
5
  $BLOCK$
3
6
  BEGIN
@@ -16,3 +19,8 @@ $BLOCK$
16
19
  END IF;
17
20
  END
18
21
  $BLOCK$;
22
+ `
23
+
24
+ export default async function (builder: MigrationBuilder) {
25
+ builder.sql(sql)
26
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE "project_member_variable" (
2
5
  "id" uuid NOT NULL,
3
6
  "project_id" uuid NOT NULL,
@@ -12,3 +15,7 @@ CREATE TABLE "project_member_variable" (
12
15
  ON DELETE CASCADE,
13
16
  CONSTRAINT project_member_variable_unique UNIQUE ("project_id", "identity_id", "variable")
14
17
  );
18
+ `
19
+ export default async function (builder: MigrationBuilder) {
20
+ builder.sql(sql)
21
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE "project"
2
5
  ADD COLUMN slug TEXT DEFAULT NULL;
3
6
 
@@ -7,3 +10,8 @@ SET slug = name;
7
10
  ALTER TABLE "project"
8
11
  ALTER slug DROP DEFAULT,
9
12
  ALTER slug SET NOT NULL;
13
+ `
14
+
15
+ export default async function (builder: MigrationBuilder) {
16
+ builder.sql(sql)
17
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE "api_key"
5
+ ADD COLUMN expiration INT DEFAULT NULL;
6
+ `
7
+
8
+ export default async function (builder: MigrationBuilder) {
9
+ builder.sql(sql)
10
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE "api_key"
2
5
  ADD COLUMN "disabled_at" TIMESTAMP;
3
6
 
@@ -7,3 +10,8 @@ WHERE "enabled" = FALSE;
7
10
 
8
11
  ALTER TABLE "api_key"
9
12
  DROP COLUMN "enabled";
13
+ `
14
+
15
+ export default async function (builder: MigrationBuilder) {
16
+ builder.sql(sql)
17
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ CREATE UNIQUE INDEX "project_slug"
5
+ ON "project"("slug");
6
+ `
7
+
8
+ export default async function (builder: MigrationBuilder) {
9
+ builder.sql(sql)
10
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE project_membership (
2
5
  id UUID NOT NULL PRIMARY KEY,
3
6
  project_id UUID NOT NULL,
@@ -40,3 +43,8 @@ INSERT
40
43
  INTO project_membership_variable(id, membership_id, variable, value)
41
44
  SELECT public.uuid_generate_v4(), data.id, data.variable, data.value
42
45
  FROM data;
46
+ `
47
+
48
+ export default async function (builder: MigrationBuilder) {
49
+ builder.sql(sql)
50
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ DROP TABLE project_member;
5
+ DROP TABLE project_member_variable;
6
+ `
7
+
8
+ export default async function (builder: MigrationBuilder) {
9
+ builder.sql(sql)
10
+ }
@@ -0,0 +1,18 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE identity
5
+ ADD COLUMN description TEXT,
6
+ ADD COLUMN created_at TIMESTAMP;
7
+
8
+ UPDATE identity
9
+ SET created_at = NOW();
10
+
11
+ ALTER TABLE identity
12
+ ALTER created_at SET NOT NULL;
13
+ `
14
+
15
+ export default async function (builder: MigrationBuilder) {
16
+ builder.sql(sql)
17
+ }
18
+
@@ -0,0 +1,12 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ DROP INDEX "person_identity_id";
5
+
6
+ CREATE INDEX "person_identity_id" ON "person" USING btree ("identity_id");
7
+ `
8
+
9
+ export default async function (builder: MigrationBuilder) {
10
+ builder.sql(sql)
11
+ }
12
+
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ CREATE UNIQUE INDEX api_key_token_hash ON api_key(token_hash)
5
+ `
6
+
7
+ export default async function (builder: MigrationBuilder) {
8
+ builder.sql(sql)
9
+ }
10
+
@@ -1,58 +1,7 @@
1
- import { escapeValue, MigrationBuilder } from '@contember/database-migrations'
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
2
  import { TenantMigrationArgs } from './types'
3
+ import { createCredentials } from './tenantCredentials'
3
4
 
4
5
  export default async function (builder: MigrationBuilder, args: TenantMigrationArgs) {
5
- const credentials = await args.getCredentials()
6
- if (credentials.loginTokenHash) {
7
- const tokenHash = credentials.loginTokenHash
8
- builder.sql(`
9
- WITH identity AS (
10
- INSERT INTO identity(id, parent_id, roles, description, created_at)
11
- VALUES (public."uuid_generate_v4"(), NULL, '["login"]'::JSONB, 'Login key', now()) RETURNING id
12
- )
13
- INSERT INTO api_key (id, token_hash, type, identity_id, disabled_at, expires_at, expiration, created_at)
14
- SELECT public."uuid_generate_v4"(), ${escapeValue(tokenHash)}, 'permanent', identity.id, NULL, NULL, NULL, now()
15
- FROM identity
16
- `)
17
- }
18
-
19
- if (!credentials.rootTokenHash) {
20
- throw 'Please specify a root token using CONTEMBER_ROOT_TOKEN env variable.'
21
- }
22
-
23
- if (credentials.rootEmail && !credentials.rootPasswordBcrypted) {
24
- throw 'Please specify a root password using CONTEMBER_ROOT_PASSWORD env variable.'
25
- }
26
- const rootEmail = credentials.rootPasswordBcrypted ? credentials.rootEmail || 'root@localhost' : null
27
- const rootPasswordHash = credentials.rootPasswordBcrypted || null
28
-
29
- const rootTokenHash = credentials.rootTokenHash
30
-
31
- builder.sql(`
32
- WITH identity AS (
33
- INSERT INTO identity(id, parent_id, roles, description, created_at)
34
- VALUES (
35
- public."uuid_generate_v4"(),
36
- NULL,
37
- '["super_admin"]'::JSONB
38
- || (CASE WHEN ${escapeValue(rootEmail)} IS NOT NULL THEN '["person"]'::JSONB ELSE '[]'::JSONB END),
39
- 'Superadmin',
40
- now()
41
- ) RETURNING id
42
- ),
43
- person AS (
44
- INSERT INTO person(id, email, password_hash, identity_id)
45
- SELECT public."uuid_generate_v4"(), ${escapeValue(rootEmail)}, ${escapeValue(rootPasswordHash)}, identity.id
46
- FROM identity
47
- WHERE ${escapeValue(rootEmail)} IS NOT NULL
48
- RETURNING id
49
- ),
50
- api_key AS (
51
- INSERT INTO api_key (id, token_hash, type, identity_id, disabled_at, expires_at, expiration, created_at)
52
- SELECT public."uuid_generate_v4"(), ${escapeValue(rootTokenHash)}, 'permanent', identity.id, NULL, NULL, NULL, now()
53
- FROM identity WHERE ${escapeValue(rootTokenHash)} IS NOT NULL
54
- RETURNING id
55
- )
56
- SELECT * FROM person, api_key
57
- `)
6
+ await createCredentials(builder, args)
58
7
  }
@@ -0,0 +1,12 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE "person"
5
+ ADD COLUMN otp_uri TEXT DEFAULT NULL,
6
+ ADD COLUMN otp_activated_at TIMESTAMP DEFAULT NULL
7
+ `
8
+
9
+ export default async function (builder: MigrationBuilder) {
10
+ builder.sql(sql)
11
+ }
12
+
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE mail_template (
2
5
  id UUID NOT NULL PRIMARY KEY,
3
6
  project_id UUID NOT NULL,
@@ -12,3 +15,8 @@ CREATE TABLE mail_template (
12
15
  CREATE UNIQUE INDEX mail_template_identifier ON mail_template(project_id, mail_type, variant);
13
16
  CREATE INDEX mail_template_project_index
14
17
  ON mail_template(project_id);
18
+ `
19
+
20
+ export default async function (builder: MigrationBuilder) {
21
+ builder.sql(sql)
22
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE person_password_reset (
2
5
  id UUID NOT NULL,
3
6
  token_hash TEXT NOT NULL,
@@ -12,4 +15,9 @@ CREATE TABLE person_password_reset (
12
15
 
13
16
  CREATE UNIQUE INDEX person_password_reset_token
14
17
  ON person_password_reset(token_hash);
18
+ `
19
+
15
20
 
21
+ export default async function (builder: MigrationBuilder) {
22
+ builder.sql(sql)
23
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE identity_provider (
2
5
  id UUID NOT NULL,
3
6
  slug TEXT UNIQUE NOT NULL,
@@ -6,3 +9,8 @@ CREATE TABLE identity_provider (
6
9
  disabled_at TIMESTAMP DEFAULT NULL,
7
10
  CONSTRAINT identity_provider_id PRIMARY KEY ("id")
8
11
  );
12
+ `
13
+
14
+ export default async function (builder: MigrationBuilder) {
15
+ builder.sql(sql)
16
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE identity_provider
2
5
  ALTER disabled_at TYPE TIMESTAMPTZ;
3
6
 
@@ -16,4 +19,10 @@ ALTER TABLE person_password_reset
16
19
  ALTER expires_at TYPE TIMESTAMPTZ,
17
20
  ALTER created_at TYPE TIMESTAMPTZ,
18
21
  ALTER used_at TYPE TIMESTAMPTZ;
22
+ `
23
+
24
+ export default async function (builder: MigrationBuilder) {
25
+ builder.sql(sql)
26
+ }
27
+
19
28
 
@@ -0,0 +1,12 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE project
5
+ ADD COLUMN config JSONB NOT NULL DEFAULT '{}'::JSONB,
6
+ add column updated_at timestamptz not null DEFAULT now();
7
+ `
8
+
9
+ export default async function (builder: MigrationBuilder) {
10
+ builder.sql(sql)
11
+ }
12
+
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE project_secret
2
5
  (
3
6
  id UUID NOT NULL PRIMARY KEY,
@@ -13,3 +16,8 @@ CREATE TABLE project_secret
13
16
  CREATE UNIQUE INDEX project_secret_unique ON project_secret (project_id, key);
14
17
  CREATE INDEX project_secret_project_index
15
18
  ON project_secret (project_id);
19
+ `
20
+
21
+ export default async function (builder: MigrationBuilder) {
22
+ builder.sql(sql)
23
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ CREATE INDEX project_alias ON project USING gin ((config -> 'alias'));
5
+ `
6
+
7
+ export default async function (builder: MigrationBuilder) {
8
+ builder.sql(sql)
9
+ }
10
+
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE person ALTER COLUMN password_hash DROP NOT NULL;
5
+ `
6
+
7
+ export default async function (builder: MigrationBuilder) {
8
+ builder.sql(sql)
9
+ }
10
+
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE "mail_template" ALTER COLUMN "project_id" DROP NOT NULL;
2
5
 
3
6
  DROP INDEX mail_template_identifier;
@@ -7,3 +10,8 @@ CREATE UNIQUE INDEX mail_template_identifier
7
10
 
8
11
  CREATE UNIQUE INDEX mail_template_identifier_global
9
12
  ON mail_template (mail_type, variant) WHERE project_id IS NULL;
13
+ `
14
+
15
+ export default async function (builder: MigrationBuilder) {
16
+ builder.sql(sql)
17
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE person
5
+ ADD UNIQUE (identity_id);
6
+ `
7
+
8
+ export default async function (builder: MigrationBuilder) {
9
+ builder.sql(sql)
10
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE project_secret
2
5
  ADD COLUMN value BYTEA,
3
6
  ADD COLUMN version SMALLINT;
@@ -11,3 +14,8 @@ ALTER TABLE project_secret
11
14
  ALTER version SET NOT NULL,
12
15
  DROP value_encrypted,
13
16
  DROP iv;
17
+ `
18
+
19
+ export default async function (builder: MigrationBuilder) {
20
+ builder.sql(sql)
21
+ }
@@ -0,0 +1,10 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE identity_provider
5
+ ADD COLUMN auto_sign_up BOOLEAN NOT NULL DEFAULT FALSE;
6
+ `
7
+
8
+ export default async function (builder: MigrationBuilder) {
9
+ builder.sql(sql)
10
+ }
@@ -1,3 +1,6 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  CREATE TABLE person_identity_provider
2
5
  (
3
6
  id UUID NOT NULL PRIMARY KEY,
@@ -12,3 +15,8 @@ CREATE TABLE person_identity_provider
12
15
  CREATE INDEX person_identity_provider_person_id ON person_identity_provider (person_id);
13
16
  CREATE UNIQUE INDEX person_identity_provider_identifier
14
17
  ON person_identity_provider (identity_provider_id, external_identifier);
18
+ `
19
+
20
+ export default async function (builder: MigrationBuilder) {
21
+ builder.sql(sql)
22
+ }
@@ -0,0 +1,11 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE person
5
+ ALTER email DROP NOT NULL,
6
+ ADD CONSTRAINT email_unique UNIQUE (email);
7
+ `
8
+
9
+ export default async function (builder: MigrationBuilder) {
10
+ builder.sql(sql)
11
+ }
@@ -0,0 +1,13 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ ALTER TABLE person
5
+ ADD name TEXT;
6
+ UPDATE person
7
+ SET name = SPLIT_PART(email, '@', 1);
8
+ `
9
+
10
+ export default async function (builder: MigrationBuilder) {
11
+ builder.sql(sql)
12
+ }
13
+
@@ -1,6 +1,15 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
1
4
  ALTER TABLE person
2
5
  ADD idp_only BOOLEAN NOT NULL DEFAULT FALSE,
3
6
  ADD CONSTRAINT idp_only_no_email CHECK ( idp_only = FALSE OR (idp_only = TRUE AND email IS NULL));
4
7
 
5
8
  ALTER TABLE identity_provider
6
9
  ADD exclusive BOOLEAN DEFAULT FALSE;
10
+ `
11
+
12
+ export default async function (builder: MigrationBuilder) {
13
+ builder.sql(sql)
14
+ }
15
+