@baseplate-dev/plugin-auth 0.1.2 → 1.0.0

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 (242) hide show
  1. package/dist/auth/core/common.d.ts +1 -0
  2. package/dist/auth/core/common.d.ts.map +1 -1
  3. package/dist/auth/core/common.js.map +1 -1
  4. package/dist/auth/core/node.d.ts.map +1 -1
  5. package/dist/auth/core/node.js +6 -3
  6. package/dist/auth/core/node.js.map +1 -1
  7. package/dist/auth/core/schema/models.d.ts.map +1 -1
  8. package/dist/auth/core/schema/models.js +11 -0
  9. package/dist/auth/core/schema/models.js.map +1 -1
  10. package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts +13 -1
  11. package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts.map +1 -1
  12. package/dist/auth/generators/fastify/auth-module/auth-module.generator.js +20 -8
  13. package/dist/auth/generators/fastify/auth-module/auth-module.generator.js.map +1 -1
  14. package/dist/auth/generators/fastify/auth-module/generated/index.d.ts +88 -0
  15. package/dist/auth/generators/fastify/auth-module/generated/index.d.ts.map +1 -0
  16. package/dist/auth/generators/fastify/auth-module/generated/index.js +9 -0
  17. package/dist/auth/generators/fastify/auth-module/generated/index.js.map +1 -0
  18. package/dist/auth/generators/fastify/auth-module/generated/template-paths.d.ts +16 -0
  19. package/dist/auth/generators/fastify/auth-module/generated/template-paths.d.ts.map +1 -0
  20. package/dist/auth/generators/fastify/auth-module/generated/template-paths.js +26 -0
  21. package/dist/auth/generators/fastify/auth-module/generated/template-paths.js.map +1 -0
  22. package/dist/auth/generators/fastify/auth-module/generated/ts-import-providers.d.ts +10 -0
  23. package/dist/auth/generators/fastify/auth-module/generated/ts-import-providers.d.ts.map +1 -0
  24. package/dist/auth/generators/fastify/auth-module/generated/ts-import-providers.js +23 -0
  25. package/dist/auth/generators/fastify/auth-module/generated/ts-import-providers.js.map +1 -0
  26. package/dist/auth/generators/fastify/auth-module/generated/{ts-templates.d.ts → typed-templates.d.ts} +26 -41
  27. package/dist/auth/generators/fastify/auth-module/generated/typed-templates.d.ts.map +1 -0
  28. package/dist/auth/generators/fastify/auth-module/generated/typed-templates.js +68 -0
  29. package/dist/auth/generators/fastify/auth-module/generated/typed-templates.js.map +1 -0
  30. package/dist/auth/generators/fastify/auth-module/index.d.ts +2 -0
  31. package/dist/auth/generators/fastify/auth-module/index.d.ts.map +1 -0
  32. package/dist/auth/generators/fastify/auth-module/index.js +2 -0
  33. package/dist/auth/generators/fastify/auth-module/index.js.map +1 -0
  34. package/dist/auth/generators/fastify/auth-module/templates/{utils → module/utils}/cookie-signer.ts +6 -0
  35. package/dist/auth/generators/fastify/index.d.ts +1 -1
  36. package/dist/auth/generators/fastify/index.d.ts.map +1 -1
  37. package/dist/auth/generators/fastify/index.js +1 -1
  38. package/dist/auth/generators/fastify/index.js.map +1 -1
  39. package/dist/auth0/core/schema/models.d.ts.map +1 -1
  40. package/dist/auth0/core/schema/models.js +6 -0
  41. package/dist/auth0/core/schema/models.js.map +1 -1
  42. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts +14 -6
  43. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts.map +1 -1
  44. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js +11 -16
  45. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js.map +1 -1
  46. package/dist/auth0/generators/fastify/auth0-module/generated/index.d.ts +62 -0
  47. package/dist/auth0/generators/fastify/auth0-module/generated/index.d.ts.map +1 -0
  48. package/dist/auth0/generators/fastify/auth0-module/generated/index.js +9 -0
  49. package/dist/auth0/generators/fastify/auth0-module/generated/index.js.map +1 -0
  50. package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.d.ts +13 -0
  51. package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.d.ts.map +1 -0
  52. package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.js +23 -0
  53. package/dist/auth0/generators/fastify/auth0-module/generated/template-paths.js.map +1 -0
  54. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.d.ts +10 -0
  55. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.d.ts.map +1 -0
  56. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.js +23 -0
  57. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-providers.js.map +1 -0
  58. package/dist/auth0/generators/fastify/auth0-module/generated/{ts-templates.d.ts → typed-templates.d.ts} +2 -2
  59. package/dist/auth0/generators/fastify/auth0-module/generated/typed-templates.d.ts.map +1 -0
  60. package/dist/auth0/generators/fastify/auth0-module/generated/{ts-templates.js → typed-templates.js} +11 -8
  61. package/dist/auth0/generators/fastify/auth0-module/generated/typed-templates.js.map +1 -0
  62. package/dist/auth0/generators/fastify/auth0-module/index.d.ts +2 -0
  63. package/dist/auth0/generators/fastify/auth0-module/index.d.ts.map +1 -0
  64. package/dist/auth0/generators/fastify/auth0-module/index.js +2 -0
  65. package/dist/auth0/generators/fastify/auth0-module/index.js.map +1 -0
  66. package/dist/auth0/generators/fastify/index.d.ts +1 -1
  67. package/dist/auth0/generators/fastify/index.d.ts.map +1 -1
  68. package/dist/auth0/generators/fastify/index.js +1 -1
  69. package/dist/auth0/generators/fastify/index.js.map +1 -1
  70. package/dist/auth0/generators/react/auth0-apollo/index.d.ts +2 -0
  71. package/dist/auth0/generators/react/auth0-apollo/index.d.ts.map +1 -0
  72. package/dist/auth0/generators/react/auth0-apollo/index.js +2 -0
  73. package/dist/auth0/generators/react/auth0-apollo/index.js.map +1 -0
  74. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts +101 -8
  75. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts.map +1 -1
  76. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js +10 -11
  77. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js.map +1 -1
  78. package/dist/auth0/generators/react/auth0-callback/generated/index.d.ts +290 -0
  79. package/dist/auth0/generators/react/auth0-callback/generated/index.d.ts.map +1 -0
  80. package/dist/auth0/generators/react/auth0-callback/generated/index.js +7 -0
  81. package/dist/auth0/generators/react/auth0-callback/generated/index.js.map +1 -0
  82. package/dist/auth0/generators/react/auth0-callback/generated/template-paths.d.ts +13 -0
  83. package/dist/auth0/generators/react/auth0-callback/generated/template-paths.d.ts.map +1 -0
  84. package/dist/auth0/generators/react/auth0-callback/generated/template-paths.js +23 -0
  85. package/dist/auth0/generators/react/auth0-callback/generated/template-paths.js.map +1 -0
  86. package/dist/auth0/generators/react/auth0-callback/generated/typed-templates.d.ts +280 -0
  87. package/dist/auth0/generators/react/auth0-callback/generated/typed-templates.d.ts.map +1 -0
  88. package/dist/auth0/generators/react/auth0-callback/generated/{ts-templates.js → typed-templates.js} +11 -9
  89. package/dist/auth0/generators/react/auth0-callback/generated/typed-templates.js.map +1 -0
  90. package/dist/auth0/generators/react/auth0-callback/index.d.ts +2 -0
  91. package/dist/auth0/generators/react/auth0-callback/index.d.ts.map +1 -0
  92. package/dist/auth0/generators/react/auth0-callback/index.js +2 -0
  93. package/dist/auth0/generators/react/auth0-callback/index.js.map +1 -0
  94. package/dist/auth0/generators/react/auth0-callback/templates/{auth0-callback.page.tsx → routes/auth0-callback.page.tsx} +3 -3
  95. package/dist/auth0/generators/react/auth0-callback/templates/{signup.page.tsx → routes/signup.page.tsx} +3 -3
  96. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts +106 -12
  97. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts.map +1 -1
  98. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js +12 -16
  99. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js.map +1 -1
  100. package/dist/auth0/generators/react/auth0-components/generated/index.d.ts +151 -0
  101. package/dist/auth0/generators/react/auth0-components/generated/index.d.ts.map +1 -0
  102. package/dist/auth0/generators/react/auth0-components/generated/index.js +9 -0
  103. package/dist/auth0/generators/react/auth0-components/generated/index.js.map +1 -0
  104. package/dist/auth0/generators/react/auth0-components/generated/template-paths.d.ts +12 -0
  105. package/dist/auth0/generators/react/auth0-components/generated/template-paths.d.ts.map +1 -0
  106. package/dist/auth0/generators/react/auth0-components/generated/template-paths.js +22 -0
  107. package/dist/auth0/generators/react/auth0-components/generated/template-paths.js.map +1 -0
  108. package/dist/auth0/generators/react/auth0-components/generated/ts-import-providers.d.ts +10 -0
  109. package/dist/auth0/generators/react/auth0-components/generated/ts-import-providers.d.ts.map +1 -0
  110. package/dist/auth0/generators/react/auth0-components/generated/ts-import-providers.js +25 -0
  111. package/dist/auth0/generators/react/auth0-components/generated/ts-import-providers.js.map +1 -0
  112. package/dist/auth0/generators/react/auth0-components/generated/typed-templates.d.ts +132 -0
  113. package/dist/auth0/generators/react/auth0-components/generated/typed-templates.d.ts.map +1 -0
  114. package/dist/auth0/generators/react/auth0-components/generated/typed-templates.js +17 -0
  115. package/dist/auth0/generators/react/auth0-components/generated/typed-templates.js.map +1 -0
  116. package/dist/auth0/generators/react/auth0-components/index.d.ts +2 -0
  117. package/dist/auth0/generators/react/auth0-components/index.d.ts.map +1 -0
  118. package/dist/auth0/generators/react/auth0-components/index.js +2 -0
  119. package/dist/auth0/generators/react/auth0-components/index.js.map +1 -0
  120. package/dist/auth0/generators/react/auth0-components/templates/{RequireAuth.tsx → src/components/require-auth/require-auth.tsx} +4 -4
  121. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +10 -2
  122. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts.map +1 -1
  123. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js +13 -24
  124. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js.map +1 -1
  125. package/dist/auth0/generators/react/auth0-hooks/generated/index.d.ts +51 -0
  126. package/dist/auth0/generators/react/auth0-hooks/generated/index.d.ts.map +1 -0
  127. package/dist/auth0/generators/react/auth0-hooks/generated/index.js +9 -0
  128. package/dist/auth0/generators/react/auth0-hooks/generated/index.js.map +1 -0
  129. package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.d.ts +16 -0
  130. package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.d.ts.map +1 -0
  131. package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.js +26 -0
  132. package/dist/auth0/generators/react/auth0-hooks/generated/template-paths.js.map +1 -0
  133. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.d.ts +16 -0
  134. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.d.ts.map +1 -0
  135. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.js +27 -0
  136. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-providers.js.map +1 -0
  137. package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.d.ts +44 -0
  138. package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.d.ts.map +1 -0
  139. package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.js +67 -0
  140. package/dist/auth0/generators/react/auth0-hooks/generated/typed-templates.js.map +1 -0
  141. package/dist/auth0/generators/react/auth0-hooks/index.d.ts +2 -0
  142. package/dist/auth0/generators/react/auth0-hooks/index.d.ts.map +1 -0
  143. package/dist/auth0/generators/react/auth0-hooks/index.js +2 -0
  144. package/dist/auth0/generators/react/auth0-hooks/index.js.map +1 -0
  145. package/dist/auth0/generators/react/index.d.ts +5 -5
  146. package/dist/auth0/generators/react/index.d.ts.map +1 -1
  147. package/dist/auth0/generators/react/index.js +5 -5
  148. package/dist/auth0/generators/react/index.js.map +1 -1
  149. package/dist/auth0/generators/react/react-auth0/index.d.ts +2 -0
  150. package/dist/auth0/generators/react/react-auth0/index.d.ts.map +1 -0
  151. package/dist/auth0/generators/react/react-auth0/index.js +2 -0
  152. package/dist/auth0/generators/react/react-auth0/index.js.map +1 -0
  153. package/dist/web/assets/{__federation_expose_auth0CoreCommon--n6esVYP.js → __federation_expose_auth0CoreCommon-hOTVdirQ.js} +3 -3
  154. package/dist/web/assets/{__federation_expose_auth0CoreCommon--n6esVYP.js.map → __federation_expose_auth0CoreCommon-hOTVdirQ.js.map} +1 -1
  155. package/dist/web/assets/{__federation_expose_auth0CoreWeb-Ql6gpX5q.js → __federation_expose_auth0CoreWeb-xV61eveJ.js} +13 -9
  156. package/dist/web/assets/__federation_expose_auth0CoreWeb-xV61eveJ.js.map +1 -0
  157. package/dist/web/assets/__federation_expose_authCoreCommon-CndjGc3R.js +36 -0
  158. package/dist/web/assets/__federation_expose_authCoreCommon-CndjGc3R.js.map +1 -0
  159. package/dist/web/assets/__federation_expose_authCoreWeb-CJ4-gYAU.js +442 -0
  160. package/dist/web/assets/__federation_expose_authCoreWeb-CJ4-gYAU.js.map +1 -0
  161. package/dist/web/assets/{__federation_fn_import-BiwmVFwy.js → __federation_fn_import-Drn1CtCD.js} +2 -2
  162. package/dist/web/assets/{__federation_fn_import-BiwmVFwy.js.map → __federation_fn_import-Drn1CtCD.js.map} +1 -1
  163. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-CY8oz43s.js → web-CcNXBRTZ.js} +18 -7
  164. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CcNXBRTZ.js.map +1 -0
  165. package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-B62IPizQ.js → project-builder-lib-Tb9xtEo4.js} +162 -829
  166. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-Tb9xtEo4.js.map +1 -0
  167. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-BU2QTWNs.js → ui-components-0t9VhwId.js} +17757 -9806
  168. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-0t9VhwId.js.map +1 -0
  169. package/dist/web/assets/{index-CgJx-krK.js → index-CZqpaSlN.js} +10 -4
  170. package/dist/web/assets/{index-CgJx-krK.js.map → index-CZqpaSlN.js.map} +1 -1
  171. package/dist/web/assets/{index.esm-BcxPd7Ha.js → index.esm-SbEmZvZj.js} +3 -3
  172. package/dist/web/assets/{index.esm-BcxPd7Ha.js.map → index.esm-SbEmZvZj.js.map} +1 -1
  173. package/dist/web/assets/{model-utils-CbQJy1wE.js → model-merger-BLh0ERqk.js} +807 -19
  174. package/dist/web/assets/model-merger-BLh0ERqk.js.map +1 -0
  175. package/dist/web/assets/plugin-definition-CNgM5Juv.js +34 -0
  176. package/dist/web/assets/plugin-definition-CNgM5Juv.js.map +1 -0
  177. package/dist/web/assets/plugin-definition-CQ2no5O3.js +22 -0
  178. package/dist/web/assets/plugin-definition-CQ2no5O3.js.map +1 -0
  179. package/dist/web/assets/{react-2jQE8aG0.js → react-BiQIVSjI.js} +2 -2
  180. package/dist/web/assets/{react-2jQE8aG0.js.map → react-BiQIVSjI.js.map} +1 -1
  181. package/dist/web/assets/remoteEntry.js +8 -2
  182. package/dist/web/assets/remoteEntry.js.map +1 -1
  183. package/dist/web/assets/{plugin-definition-BQRupXoQ.js → schema-CaLuKwEg.js} +16 -27
  184. package/dist/web/assets/schema-CaLuKwEg.js.map +1 -0
  185. package/dist/web/assets/styles-BPCQNyj6.js +8 -0
  186. package/dist/web/assets/styles-BPCQNyj6.js.map +1 -0
  187. package/manifest.json +1 -1
  188. package/package.json +23 -13
  189. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.d.ts.map +0 -1
  190. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js +0 -94
  191. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js.map +0 -1
  192. package/dist/auth/generators/fastify/auth-module/templates/management.ts +0 -22
  193. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session-payload.object-type.ts +0 -23
  194. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.mutations.ts +0 -22
  195. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.queries.ts +0 -20
  196. package/dist/auth/generators/fastify/auth-module/templates/user-session.service.ts +0 -101
  197. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts +0 -3
  198. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts.map +0 -1
  199. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js +0 -12
  200. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js.map +0 -1
  201. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.d.ts.map +0 -1
  202. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.js.map +0 -1
  203. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts +0 -106
  204. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts.map +0 -1
  205. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.js.map +0 -1
  206. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts +0 -3
  207. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts.map +0 -1
  208. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js +0 -12
  209. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js.map +0 -1
  210. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts +0 -45
  211. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts.map +0 -1
  212. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js +0 -13
  213. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js.map +0 -1
  214. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts +0 -8
  215. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts.map +0 -1
  216. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js +0 -12
  217. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js.map +0 -1
  218. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts +0 -3
  219. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts.map +0 -1
  220. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js +0 -16
  221. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js.map +0 -1
  222. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts +0 -33
  223. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts.map +0 -1
  224. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js +0 -50
  225. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js.map +0 -1
  226. package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js.map +0 -1
  227. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js.map +0 -1
  228. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js.map +0 -1
  229. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js.map +0 -1
  230. package/dist/web/assets/model-utils-CbQJy1wE.js.map +0 -1
  231. package/dist/web/assets/plugin-definition-BQRupXoQ.js.map +0 -1
  232. /package/dist/auth/generators/fastify/auth-module/templates/{user-session.constants.ts → module/constants/user-session.constants.ts} +0 -0
  233. /package/dist/auth/generators/fastify/auth-module/templates/{services → module/services}/user-session.service.ts +0 -0
  234. /package/dist/auth/generators/fastify/auth-module/templates/{utils → module/utils}/session-cookie.ts +0 -0
  235. /package/dist/auth/generators/fastify/auth-module/templates/{utils → module/utils}/verify-request-origin.ts +0 -0
  236. /package/dist/auth0/generators/fastify/auth0-module/templates/{management.ts → module/services/management.ts} +0 -0
  237. /package/dist/auth0/generators/fastify/auth0-module/templates/{user-session.service.ts → module/services/user-session.service.ts} +0 -0
  238. /package/dist/auth0/generators/react/auth0-hooks/templates/{useCurrentUser.gql → src/hooks/useCurrentUser.gql} +0 -0
  239. /package/dist/auth0/generators/react/auth0-hooks/templates/{useCurrentUser.ts → src/hooks/useCurrentUser.ts} +0 -0
  240. /package/dist/auth0/generators/react/auth0-hooks/templates/{useLogOut.ts → src/hooks/useLogOut.ts} +0 -0
  241. /package/dist/auth0/generators/react/auth0-hooks/templates/{useRequiredUserId.ts → src/hooks/useRequiredUserId.ts} +0 -0
  242. /package/dist/auth0/generators/react/auth0-hooks/templates/{useSession.ts → src/hooks/useSession.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { importShared } from './__federation_fn_import-BiwmVFwy.js';
1
+ import { importShared } from './__federation_fn_import-Drn1CtCD.js';
2
2
 
3
3
  function createInitializedPluginSpec(spec, implementation) {
4
4
  return { spec, implementation };
@@ -19,10 +19,135 @@ function createPluginSpec(name, options) {
19
19
 
20
20
  function noop() { }
21
21
 
22
+ function isPrimitive(value) {
23
+ return value == null || (typeof value !== 'object' && typeof value !== 'function');
24
+ }
25
+
26
+ function isTypedArray(x) {
27
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
28
+ }
29
+
22
30
  function getSymbols(object) {
23
31
  return Object.getOwnPropertySymbols(object).filter(symbol => Object.prototype.propertyIsEnumerable.call(object, symbol));
24
32
  }
25
33
 
34
+ function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map(), cloneValue = undefined) {
35
+ const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
36
+ if (cloned != null) {
37
+ return cloned;
38
+ }
39
+ if (isPrimitive(valueToClone)) {
40
+ return valueToClone;
41
+ }
42
+ if (stack.has(valueToClone)) {
43
+ return stack.get(valueToClone);
44
+ }
45
+ if (Array.isArray(valueToClone)) {
46
+ const result = new Array(valueToClone.length);
47
+ stack.set(valueToClone, result);
48
+ for (let i = 0; i < valueToClone.length; i++) {
49
+ result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
50
+ }
51
+ if (Object.hasOwn(valueToClone, 'index')) {
52
+ result.index = valueToClone.index;
53
+ }
54
+ if (Object.hasOwn(valueToClone, 'input')) {
55
+ result.input = valueToClone.input;
56
+ }
57
+ return result;
58
+ }
59
+ if (valueToClone instanceof Date) {
60
+ return new Date(valueToClone.getTime());
61
+ }
62
+ if (valueToClone instanceof RegExp) {
63
+ const result = new RegExp(valueToClone.source, valueToClone.flags);
64
+ result.lastIndex = valueToClone.lastIndex;
65
+ return result;
66
+ }
67
+ if (valueToClone instanceof Map) {
68
+ const result = new Map();
69
+ stack.set(valueToClone, result);
70
+ for (const [key, value] of valueToClone) {
71
+ result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
72
+ }
73
+ return result;
74
+ }
75
+ if (valueToClone instanceof Set) {
76
+ const result = new Set();
77
+ stack.set(valueToClone, result);
78
+ for (const value of valueToClone) {
79
+ result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
80
+ }
81
+ return result;
82
+ }
83
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(valueToClone)) {
84
+ return valueToClone.subarray();
85
+ }
86
+ if (isTypedArray(valueToClone)) {
87
+ const result = new (Object.getPrototypeOf(valueToClone).constructor)(valueToClone.length);
88
+ stack.set(valueToClone, result);
89
+ for (let i = 0; i < valueToClone.length; i++) {
90
+ result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
91
+ }
92
+ return result;
93
+ }
94
+ if (valueToClone instanceof ArrayBuffer ||
95
+ (typeof SharedArrayBuffer !== 'undefined' && valueToClone instanceof SharedArrayBuffer)) {
96
+ return valueToClone.slice(0);
97
+ }
98
+ if (valueToClone instanceof DataView) {
99
+ const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
100
+ stack.set(valueToClone, result);
101
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
102
+ return result;
103
+ }
104
+ if (typeof File !== 'undefined' && valueToClone instanceof File) {
105
+ const result = new File([valueToClone], valueToClone.name, {
106
+ type: valueToClone.type,
107
+ });
108
+ stack.set(valueToClone, result);
109
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
110
+ return result;
111
+ }
112
+ if (valueToClone instanceof Blob) {
113
+ const result = new Blob([valueToClone], { type: valueToClone.type });
114
+ stack.set(valueToClone, result);
115
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
116
+ return result;
117
+ }
118
+ if (valueToClone instanceof Error) {
119
+ const result = new valueToClone.constructor();
120
+ stack.set(valueToClone, result);
121
+ result.message = valueToClone.message;
122
+ result.name = valueToClone.name;
123
+ result.stack = valueToClone.stack;
124
+ result.cause = valueToClone.cause;
125
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
126
+ return result;
127
+ }
128
+ if (typeof valueToClone === 'object' && valueToClone !== null) {
129
+ const result = Object.create(Object.getPrototypeOf(valueToClone));
130
+ stack.set(valueToClone, result);
131
+ copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
132
+ return result;
133
+ }
134
+ return valueToClone;
135
+ }
136
+ function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
137
+ const keys = [...Object.keys(source), ...getSymbols(source)];
138
+ for (let i = 0; i < keys.length; i++) {
139
+ const key = keys[i];
140
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
141
+ if (descriptor == null || descriptor.writable) {
142
+ target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
143
+ }
144
+ }
145
+ }
146
+
147
+ function cloneDeep(obj) {
148
+ return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
149
+ }
150
+
26
151
  function isPlainObject(value) {
27
152
  if (!value || typeof value !== 'object') {
28
153
  return false;
@@ -37,6 +162,59 @@ function isPlainObject(value) {
37
162
  return Object.prototype.toString.call(value) === '[object Object]';
38
163
  }
39
164
 
165
+ function mapValues(object, getNewValue) {
166
+ const result = {};
167
+ const keys = Object.keys(object);
168
+ for (let i = 0; i < keys.length; i++) {
169
+ const key = keys[i];
170
+ const value = object[key];
171
+ result[key] = getNewValue(value, key, object);
172
+ }
173
+ return result;
174
+ }
175
+
176
+ function merge(target, source) {
177
+ const sourceKeys = Object.keys(source);
178
+ for (let i = 0; i < sourceKeys.length; i++) {
179
+ const key = sourceKeys[i];
180
+ const sourceValue = source[key];
181
+ const targetValue = target[key];
182
+ if (Array.isArray(sourceValue)) {
183
+ if (Array.isArray(targetValue)) {
184
+ target[key] = merge(targetValue, sourceValue);
185
+ }
186
+ else {
187
+ target[key] = merge([], sourceValue);
188
+ }
189
+ }
190
+ else if (isPlainObject(sourceValue)) {
191
+ if (isPlainObject(targetValue)) {
192
+ target[key] = merge(targetValue, sourceValue);
193
+ }
194
+ else {
195
+ target[key] = merge({}, sourceValue);
196
+ }
197
+ }
198
+ else if (targetValue === undefined || sourceValue !== undefined) {
199
+ target[key] = sourceValue;
200
+ }
201
+ }
202
+ return target;
203
+ }
204
+
205
+ function omit(obj, keys) {
206
+ const result = { ...obj };
207
+ for (let i = 0; i < keys.length; i++) {
208
+ const key = keys[i];
209
+ delete result[key];
210
+ }
211
+ return result;
212
+ }
213
+
214
+ function toMerged(target, source) {
215
+ return merge(cloneDeep(target), source);
216
+ }
217
+
40
218
  function getTag(value) {
41
219
  if (value == null) {
42
220
  return value === undefined ? '[object Undefined]' : '[object Null]';
@@ -284,10 +462,10 @@ const UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
284
462
  */
285
463
  const customNanoid = customAlphabet(`${NUMBERS}${LOWERCASE}${UPPERCASE}_`, 12);
286
464
  /**
287
- * Generate a random ID string made up of numbers, lowercase, and uppercase letters
288
- * @returns A random ID string
465
+ * Generate a random key string made up of numbers, lowercase, and uppercase letters
466
+ * @returns A random key string
289
467
  */
290
- function randomUid(length = 12) {
468
+ function randomKey(length = 12) {
291
469
  return customNanoid(length);
292
470
  }
293
471
 
@@ -313,19 +491,27 @@ const CASE_VALIDATORS = {
313
491
  /**
314
492
  * Zod validator for validating kebab case, e.g. "my-project".
315
493
  */
316
- KEBAB_CASE: z$2.string().regex(KEBAB_CASE_REGEX),
494
+ KEBAB_CASE: z$2.string().regex(KEBAB_CASE_REGEX, {
495
+ message: 'Must be kebab case (e.g. "my-project")',
496
+ }),
317
497
  /**
318
498
  * Zod validator for validating pascal case, e.g. "MyProject".
319
499
  */
320
- PASCAL_CASE: z$2.string().regex(PASCAL_CASE_REGEX),
500
+ PASCAL_CASE: z$2.string().regex(PASCAL_CASE_REGEX, {
501
+ message: 'Must be pascal case (e.g. "MyProject")',
502
+ }),
321
503
  /**
322
504
  * Zod validator for validating camel case, e.g. "myProject".
323
505
  */
324
- CAMEL_CASE: z$2.string().regex(CAMEL_CASE_REGEX),
506
+ CAMEL_CASE: z$2.string().regex(CAMEL_CASE_REGEX, {
507
+ message: 'Must be camel case (e.g. "myProject")',
508
+ }),
325
509
  /**
326
510
  * Zod validator for validating constant case, e.g. "MY_PROJECT".
327
511
  */
328
- CONSTANT_CASE: z$2.string().regex(CONSTANT_CASE_REGEX),
512
+ CONSTANT_CASE: z$2.string().regex(CONSTANT_CASE_REGEX, {
513
+ message: 'Must be constant case (e.g. "MY_PROJECT")',
514
+ }),
329
515
  };
330
516
 
331
517
  /**
@@ -366,15 +552,15 @@ class DefinitionEntityType {
366
552
  * @returns The new ID.
367
553
  */
368
554
  generateNewId() {
369
- return `${this.prefix}:${randomUid()}`;
555
+ return `${this.prefix}:${randomKey()}`;
370
556
  }
371
- fromUid(uid) {
372
- if (!uid) {
557
+ idFromKey(key) {
558
+ if (!key) {
373
559
  return undefined;
374
560
  }
375
- return `${this.prefix}:${uid}`;
561
+ return `${this.prefix}:${key}`;
376
562
  }
377
- toUid(id) {
563
+ keyFromId(id) {
378
564
  return id.split(':')[1];
379
565
  }
380
566
  isId(id) {
@@ -577,6 +763,107 @@ function getWithPath(object, path, defaultValue) {
577
763
  return current;
578
764
  }
579
765
 
766
+ function isObject(value) {
767
+ return value !== null && (typeof value === 'object' || typeof value === 'function');
768
+ }
769
+
770
+ function isMatch(target, source) {
771
+ if (source === target) {
772
+ return true;
773
+ }
774
+ switch (typeof source) {
775
+ case 'object': {
776
+ if (source == null) {
777
+ return true;
778
+ }
779
+ const keys = Object.keys(source);
780
+ if (target == null) {
781
+ return keys.length === 0;
782
+ }
783
+ if (Array.isArray(source)) {
784
+ return isArrayMatch(target, source);
785
+ }
786
+ if (source instanceof Map) {
787
+ return isMapMatch(target, source);
788
+ }
789
+ if (source instanceof Set) {
790
+ return isSetMatch(target, source);
791
+ }
792
+ for (let i = 0; i < keys.length; i++) {
793
+ const key = keys[i];
794
+ if (!isPrimitive(target) && !(key in target)) {
795
+ return false;
796
+ }
797
+ if (source[key] === undefined && target[key] !== undefined) {
798
+ return false;
799
+ }
800
+ if (source[key] === null && target[key] !== null) {
801
+ return false;
802
+ }
803
+ if (!isMatch(target[key], source[key])) {
804
+ return false;
805
+ }
806
+ }
807
+ return true;
808
+ }
809
+ case 'function': {
810
+ if (Object.keys(source).length > 0) {
811
+ return isMatch(target, { ...source });
812
+ }
813
+ return false;
814
+ }
815
+ default: {
816
+ if (!isObject(target)) {
817
+ return eq(target, source);
818
+ }
819
+ return !source;
820
+ }
821
+ }
822
+ }
823
+ function isMapMatch(target, source) {
824
+ if (source.size === 0) {
825
+ return true;
826
+ }
827
+ if (!(target instanceof Map)) {
828
+ return false;
829
+ }
830
+ for (const [key, value] of source.entries()) {
831
+ if (!isMatch(target.get(key), value)) {
832
+ return false;
833
+ }
834
+ }
835
+ return true;
836
+ }
837
+ function isArrayMatch(target, source) {
838
+ if (source.length === 0) {
839
+ return true;
840
+ }
841
+ if (!Array.isArray(target)) {
842
+ return false;
843
+ }
844
+ const countedIndex = new Set();
845
+ for (let i = 0; i < source.length; i++) {
846
+ const sourceItem = source[i];
847
+ const index = target.findIndex((targetItem, index) => {
848
+ return isMatch(targetItem, sourceItem) && !countedIndex.has(index);
849
+ });
850
+ if (index === -1) {
851
+ return false;
852
+ }
853
+ countedIndex.add(index);
854
+ }
855
+ return true;
856
+ }
857
+ function isSetMatch(target, source) {
858
+ if (source.size === 0) {
859
+ return true;
860
+ }
861
+ if (!(target instanceof Set)) {
862
+ return false;
863
+ }
864
+ return isArrayMatch([...target], [...source]);
865
+ }
866
+
580
867
  const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
581
868
  function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
582
869
  switch (typeof value) {
@@ -804,7 +1091,7 @@ class ZodRefBuilder {
804
1091
  const idPath = entity.idPath
805
1092
  ? this._constructPathWithoutPrefix(entity.idPath)
806
1093
  : [...this._constructPathWithoutPrefix(entity.path), 'id'];
807
- // TODO [>=0.9.16] Remove the fallback to generateNewId once a new version is released and manual setter
1094
+ // TODO [>=0.2.0] Remove the fallback to generateNewId once we've released a new major verison.
808
1095
  const id = get(this.data, idPath) ??
809
1096
  entity.type.generateNewId();
810
1097
  if (!get(this.data, idPath)) {
@@ -1102,10 +1389,14 @@ Object.defineProperty(ZodRefWrapper, "create", {
1102
1389
  })
1103
1390
  });
1104
1391
 
1392
+ function definitionSchema(creator) {
1393
+ return (options) => creator(options);
1394
+ }
1395
+
1105
1396
  const {z} = await importShared('zod');
1106
1397
  const featureEntityType = createEntityType('feature');
1107
1398
  const featureNameSchema = CASE_VALIDATORS.KEBAB_CASE;
1108
- const featureSchema = zEnt(z.object({
1399
+ const createFeatureSchema = definitionSchema(() => zEnt(z.object({
1109
1400
  name: z
1110
1401
  .string()
1111
1402
  .min(1)
@@ -1118,8 +1409,21 @@ const featureSchema = zEnt(z.object({
1118
1409
  type: featureEntityType,
1119
1410
  onDelete: 'DELETE_PARENT',
1120
1411
  }),
1121
- }), { type: featureEntityType });
1122
- const featuresSchema = z.array(featureSchema).default([]);
1412
+ }), { type: featureEntityType }));
1413
+ const createFeaturesSchema = definitionSchema((ctx) => z.array(createFeatureSchema(ctx)).default([]));
1414
+
1415
+ const modelEntityType = createEntityType('model');
1416
+ const modelScalarFieldEntityType = createEntityType('model-scalar-field', {
1417
+ parentType: modelEntityType,
1418
+ });
1419
+ const modelLocalRelationEntityType = createEntityType('model-local-relation', { parentType: modelEntityType });
1420
+ const modelForeignRelationEntityType = createEntityType('model-foreign-relation', { parentType: modelEntityType });
1421
+ const modelUniqueConstraintEntityType = createEntityType('model-unique-constraint', { parentType: modelEntityType });
1422
+ const modelTransformerEntityType = createEntityType('model-transformer', { parentType: modelEntityType });
1423
+ const modelEnumEntityType = createEntityType('model-enum');
1424
+ const modelEnumValueEntityType = createEntityType('model-enum-value', {
1425
+ parentType: modelEnumEntityType,
1426
+ });
1123
1427
 
1124
1428
  function getRootFeatures(projectDefinition) {
1125
1429
  return projectDefinition.features.filter((f) => !f.parentRef);
@@ -1259,5 +1563,489 @@ const ModelUtils = {
1259
1563
  getModelIdByNameOrDefault,
1260
1564
  };
1261
1565
 
1262
- export { CASE_VALIDATORS as C, DefinitionEntityType as D, FeatureUtils as F, ModelUtils as M, ZodRefWrapper as Z, isEqual as a, createEntityType as b, createPluginSpec as c, get as d, eq as e, zRef as f, getSymbols as g, zEnt as h, isPlainObject as i, createDefinitionEntityNameResolver as j, ZodRef as k, featureEntityType as l, zRefBuilder as m, zRefId as n, featuresSchema as o, zPluginWrapper as p, ZodPluginWrapper as q, createInitializedPluginSpec as r, set as s, ZodRefBuilder as t, featureNameSchema as u, featureSchema as v, zodPluginSymbol as z };
1263
- //# sourceMappingURL=model-utils-CbQJy1wE.js.map
1566
+ /**
1567
+ * Allows diffing of arbitrary JSON objects.
1568
+ */
1569
+ class DefinitionDiffField {
1570
+ constructor(
1571
+ /**
1572
+ * The name of the field to be presented to the user.
1573
+ */
1574
+ name) {
1575
+ Object.defineProperty(this, "name", {
1576
+ enumerable: true,
1577
+ configurable: true,
1578
+ writable: true,
1579
+ value: name
1580
+ });
1581
+ }
1582
+ }
1583
+ /**
1584
+ * A field that is an array of objects with a unique key.
1585
+ */
1586
+ class DefinitionDiffKeyedArrayField extends DefinitionDiffField {
1587
+ constructor(name, getKey, options = {}) {
1588
+ super(name);
1589
+ Object.defineProperty(this, "getKey", {
1590
+ enumerable: true,
1591
+ configurable: true,
1592
+ writable: true,
1593
+ value: getKey
1594
+ });
1595
+ Object.defineProperty(this, "options", {
1596
+ enumerable: true,
1597
+ configurable: true,
1598
+ writable: true,
1599
+ value: options
1600
+ });
1601
+ this.getKey = getKey;
1602
+ }
1603
+ diff(current, desired) {
1604
+ const currentValue = current ?? [];
1605
+ const desiredValue = desired ?? [];
1606
+ if (!Array.isArray(currentValue) || !Array.isArray(desiredValue)) {
1607
+ throw new TypeError('Current and desired must be arrays');
1608
+ }
1609
+ const ops = [];
1610
+ const { allowRemove, ignoreFields = ['id'] } = this.options;
1611
+ const currentByKey = new Map(currentValue.map((item) => [this.getKey(item), item]));
1612
+ const desiredByKey = new Map(desiredValue.map((item) => [this.getKey(item), item]));
1613
+ for (const [key, desiredItem] of desiredByKey) {
1614
+ const currentItem = currentByKey.get(key);
1615
+ if (!currentItem) {
1616
+ ops.push({ type: 'add', key, item: desiredItem });
1617
+ continue;
1618
+ }
1619
+ if (!isMatch(omit(currentItem, ignoreFields), omit(desiredItem, ignoreFields))) {
1620
+ ops.push({ type: 'update', key, item: desiredItem });
1621
+ }
1622
+ }
1623
+ if (allowRemove) {
1624
+ for (const [key, currentItem] of currentByKey) {
1625
+ if (!desiredByKey.has(key)) {
1626
+ ops.push({ type: 'remove', key, item: currentItem });
1627
+ }
1628
+ }
1629
+ }
1630
+ return ops;
1631
+ }
1632
+ apply(current, diff) {
1633
+ const patch = diff;
1634
+ const currentValue = current ?? [];
1635
+ if (!Array.isArray(currentValue)) {
1636
+ throw new TypeError('Current must be array');
1637
+ }
1638
+ const items = [...currentValue];
1639
+ for (const { type, key, item } of patch) {
1640
+ const index = items.findIndex((i) => this.getKey(i) === key);
1641
+ switch (type) {
1642
+ case 'add': {
1643
+ items.push(item);
1644
+ break;
1645
+ }
1646
+ case 'update': {
1647
+ if (index === -1) {
1648
+ throw new Error(`Cannot apply patch. Item with key "${key}" not found.`);
1649
+ }
1650
+ // Preserve existing id if present.
1651
+ items[index] = toMerged(items[index], item);
1652
+ break;
1653
+ }
1654
+ case 'remove': {
1655
+ if (index !== -1) {
1656
+ items.splice(index, 1);
1657
+ }
1658
+ break;
1659
+ }
1660
+ }
1661
+ }
1662
+ return items;
1663
+ }
1664
+ getActionVerb(isNew) {
1665
+ return isNew ? 'created' : 'added or updated';
1666
+ }
1667
+ }
1668
+ /**
1669
+ * A field that is a replacement for the entire object or array.
1670
+ */
1671
+ class DefinitionDiffReplacementField extends DefinitionDiffField {
1672
+ diff(current, desired) {
1673
+ if (desired === undefined) {
1674
+ return [];
1675
+ }
1676
+ if (!isMatch(current, desired)) {
1677
+ return [{ type: 'update', key: '*', item: desired }];
1678
+ }
1679
+ return [];
1680
+ }
1681
+ apply(current, diff) {
1682
+ if (diff.length === 0)
1683
+ return current;
1684
+ return diff[0].item;
1685
+ }
1686
+ getActionVerb(isNew) {
1687
+ return isNew ? 'set' : 'replaced';
1688
+ }
1689
+ }
1690
+ /**
1691
+ * A field that ensures an array contains certain values.
1692
+ * This field type only adds items, never removes them.
1693
+ */
1694
+ class DefinitionDiffArrayIncludesField extends DefinitionDiffField {
1695
+ constructor(name, getKey) {
1696
+ super(name);
1697
+ Object.defineProperty(this, "getKey", {
1698
+ enumerable: true,
1699
+ configurable: true,
1700
+ writable: true,
1701
+ value: getKey
1702
+ });
1703
+ }
1704
+ diff(current, desired) {
1705
+ const currentValue = current ?? [];
1706
+ const desiredValue = desired ?? [];
1707
+ if (!Array.isArray(currentValue) || !Array.isArray(desiredValue)) {
1708
+ throw new TypeError('Current and desired must be arrays');
1709
+ }
1710
+ const ops = [];
1711
+ const currentSet = new Set(this.getKey ? currentValue.map(this.getKey) : currentValue);
1712
+ for (const item of desiredValue) {
1713
+ const key = this.getKey ? this.getKey(item) : String(item);
1714
+ if (!currentSet.has(key)) {
1715
+ ops.push({ type: 'add', key, item });
1716
+ }
1717
+ }
1718
+ return ops;
1719
+ }
1720
+ apply(current, diff) {
1721
+ const currentValue = (current ?? []);
1722
+ if (!Array.isArray(currentValue)) {
1723
+ throw new TypeError('Current must be array');
1724
+ }
1725
+ const items = [...currentValue];
1726
+ for (const { type, item } of diff) {
1727
+ if (type === 'add') {
1728
+ items.push(item);
1729
+ }
1730
+ }
1731
+ return items;
1732
+ }
1733
+ getActionVerb(isNew) {
1734
+ return isNew ? 'created' : 'added';
1735
+ }
1736
+ }
1737
+ function createDefinitionDiffConfig(config) {
1738
+ return config;
1739
+ }
1740
+ /**
1741
+ * Creates a diff between two objects.
1742
+ */
1743
+ function createDefinitionDiff(current, desired, configuration) {
1744
+ const ops = mapValues(configuration, (field, key) => {
1745
+ if (!field)
1746
+ return [];
1747
+ return field.diff(get(current, key), get(desired, key));
1748
+ });
1749
+ if (Object.values(ops).every((ops) => ops.length === 0)) {
1750
+ return undefined;
1751
+ }
1752
+ return ops;
1753
+ }
1754
+ /**
1755
+ * Applies a diff to an object.
1756
+ */
1757
+ function applyDefinitionDiff(current, diff, configuration) {
1758
+ const clonedCurrent = cloneDeep(current);
1759
+ for (const [key, ops] of Object.entries(diff)) {
1760
+ if (!ops)
1761
+ continue;
1762
+ const field = configuration[key];
1763
+ const currentValue = get(clonedCurrent, key);
1764
+ set(clonedCurrent, key, field.apply(currentValue, ops));
1765
+ }
1766
+ return clonedCurrent;
1767
+ }
1768
+
1769
+ /**
1770
+ * Computes a unique key for a unique constraint by sorting its field refs.
1771
+ *
1772
+ * @param constraint - Unique constraint input.
1773
+ * @returns A key string.
1774
+ */
1775
+ function getUniqueConstraintKey(constraint) {
1776
+ const fields = constraint.fields.map((f) => f.fieldRef).sort();
1777
+ return fields.join('|');
1778
+ }
1779
+ const modelMergerDefinitionDiffConfig = createDefinitionDiffConfig({
1780
+ 'model.fields': new DefinitionDiffKeyedArrayField('fields', (f) => f.name),
1781
+ 'model.relations': new DefinitionDiffKeyedArrayField('relations', (r) => r.name),
1782
+ 'model.uniqueConstraints': new DefinitionDiffKeyedArrayField('unique constraints', (c) => getUniqueConstraintKey(c)),
1783
+ 'model.primaryKeyFieldRefs': new DefinitionDiffReplacementField('primary key fields'),
1784
+ 'graphql.objectType.enabled': new DefinitionDiffReplacementField('GraphQL object type enabled'),
1785
+ 'graphql.objectType.fields': new DefinitionDiffArrayIncludesField('GraphQL object type fields'),
1786
+ 'graphql.objectType.localRelations': new DefinitionDiffArrayIncludesField('GraphQL object type local relations'),
1787
+ 'graphql.objectType.foreignRelations': new DefinitionDiffArrayIncludesField('GraphQL object type foreign relations'),
1788
+ });
1789
+ /**
1790
+ * Serializes a model merger model input such that all IDs are replaced with
1791
+ * names.
1792
+ *
1793
+ * @param input - The model merger model input.
1794
+ * @param definitionContainer - The definition container.
1795
+ * @returns The serialized model merger model input.
1796
+ */
1797
+ function serializeModelMergerModelInput(input, definitionContainer, siblingModels) {
1798
+ const siblingModelFieldIdMap = new Map([
1799
+ ...input.model.fields.map((f) => [f.id, f.name]),
1800
+ ...siblingModels.flatMap((m) => m.model.fields.map((f) => [f.id, f.name])),
1801
+ ]);
1802
+ const siblingModelRelationIdMap = new Map([
1803
+ ...(input.model.relations ?? []).map((r) => [r.id, r.name]),
1804
+ ...siblingModels.flatMap((m) => (m.model.relations ?? []).map((r) => [r.id, r.name])),
1805
+ ...(input.model.relations ?? []).map((r) => [r.foreignId, r.foreignRelationName]),
1806
+ ...siblingModels.flatMap((m) => (m.model.relations ?? []).map((r) => [r.foreignId, r.foreignRelationName])),
1807
+ ]);
1808
+ const fieldNameFromId = (id) => siblingModelFieldIdMap.get(id) ?? definitionContainer.nameFromId(id);
1809
+ const relationNameFromId = (id) => siblingModelRelationIdMap.get(id) ?? definitionContainer.nameFromId(id);
1810
+ return {
1811
+ ...input,
1812
+ model: {
1813
+ ...input.model,
1814
+ relations: input.model.relations?.map((r) => ({
1815
+ ...r,
1816
+ references: r.references.map((reference) => ({
1817
+ ...reference,
1818
+ localRef: fieldNameFromId(reference.localRef),
1819
+ foreignRef: fieldNameFromId(reference.foreignRef),
1820
+ })),
1821
+ })),
1822
+ uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
1823
+ ...c,
1824
+ fields: c.fields.map((f) => ({
1825
+ ...f,
1826
+ fieldRef: fieldNameFromId(f.fieldRef),
1827
+ })),
1828
+ })),
1829
+ primaryKeyFieldRefs: input.model.primaryKeyFieldRefs.map(fieldNameFromId),
1830
+ },
1831
+ graphql: {
1832
+ ...input.graphql,
1833
+ objectType: {
1834
+ ...input.graphql?.objectType,
1835
+ fields: input.graphql?.objectType?.fields.map(fieldNameFromId) ?? [],
1836
+ localRelations: input.graphql?.objectType?.localRelations?.map(relationNameFromId),
1837
+ foreignRelations: input.graphql?.objectType?.foreignRelations?.map(relationNameFromId),
1838
+ },
1839
+ },
1840
+ };
1841
+ }
1842
+ /**
1843
+ * Attaches IDs to the model merger model input.
1844
+ *
1845
+ * @param input - The model merger model input.
1846
+ * @returns The model merger model input with IDs attached.
1847
+ */
1848
+ function attachIdsToModelMergerModelInput(input) {
1849
+ return {
1850
+ ...input,
1851
+ model: {
1852
+ ...input.model,
1853
+ fields: input.model.fields.map((f) => ({
1854
+ ...f,
1855
+ id: f.id ?? modelScalarFieldEntityType.generateNewId(),
1856
+ })),
1857
+ relations: input.model.relations?.map((r) => ({
1858
+ ...r,
1859
+ id: r.id ?? modelLocalRelationEntityType.generateNewId(),
1860
+ foreignId: r.foreignId ?? modelForeignRelationEntityType.generateNewId(),
1861
+ })),
1862
+ uniqueConstraints: input.model.uniqueConstraints?.map((c) => ({
1863
+ ...c,
1864
+ id: c.id ?? modelUniqueConstraintEntityType.generateNewId(),
1865
+ })),
1866
+ },
1867
+ };
1868
+ }
1869
+ /**
1870
+ * Deserializes a model merger model input converting all names to IDs.
1871
+ *
1872
+ * @param input - The model merger model input.
1873
+ * @param resolveForeignFieldRef - A function that resolves the foreign field ref.
1874
+ * @returns The deserialized model merger model input.
1875
+ */
1876
+ function deserializeModelMergerModelInput(input, resolveForeignFieldRef, resolveForeignRelationRef) {
1877
+ const inputWithIds = attachIdsToModelMergerModelInput(input);
1878
+ const resolveLocalFieldName = (name) => {
1879
+ const field = inputWithIds.model.fields.find((f) => f.name === name);
1880
+ if (!field) {
1881
+ throw new Error(`Field ${name} not found`);
1882
+ }
1883
+ return field.id;
1884
+ };
1885
+ const resolveLocalRelationName = (name) => {
1886
+ const relation = inputWithIds.model.relations?.find((r) => r.name === name);
1887
+ if (!relation) {
1888
+ throw new Error(`Relation ${name} not found`);
1889
+ }
1890
+ return relation.id;
1891
+ };
1892
+ return {
1893
+ ...inputWithIds,
1894
+ model: {
1895
+ ...inputWithIds.model,
1896
+ relations: inputWithIds.model.relations?.map((relation) => ({
1897
+ ...relation,
1898
+ references: relation.references.map((reference) => ({
1899
+ ...reference,
1900
+ localRef: resolveLocalFieldName(reference.localRef),
1901
+ foreignRef: resolveForeignFieldRef(relation.modelRef, reference.foreignRef),
1902
+ })),
1903
+ })),
1904
+ uniqueConstraints: inputWithIds.model.uniqueConstraints?.map((constraint) => ({
1905
+ ...constraint,
1906
+ fields: constraint.fields.map((field) => ({
1907
+ ...field,
1908
+ fieldRef: resolveLocalFieldName(field.fieldRef),
1909
+ })),
1910
+ })),
1911
+ primaryKeyFieldRefs: inputWithIds.model.primaryKeyFieldRefs.map((fieldRef) => resolveLocalFieldName(fieldRef)),
1912
+ },
1913
+ graphql: {
1914
+ ...inputWithIds.graphql,
1915
+ objectType: {
1916
+ ...inputWithIds.graphql?.objectType,
1917
+ fields: inputWithIds.graphql?.objectType?.fields.map((fieldRef) => resolveLocalFieldName(fieldRef)) ?? [],
1918
+ localRelations: inputWithIds.graphql?.objectType?.localRelations?.map((relationRef) => resolveLocalRelationName(relationRef)) ?? [],
1919
+ foreignRelations: inputWithIds.graphql?.objectType?.foreignRelations?.map((relationRef) => resolveForeignRelationRef(relationRef)) ?? [],
1920
+ },
1921
+ },
1922
+ };
1923
+ }
1924
+ /**
1925
+ * Creates a new blank model config input from a name and feature ref.
1926
+ *
1927
+ * @param name - The name of the model.
1928
+ * @param featureRef - The feature ref of the model.
1929
+ * @returns The new model config input.
1930
+ */
1931
+ function createNewModelConfigInput(name, featureRef) {
1932
+ return {
1933
+ id: modelEntityType.generateNewId(),
1934
+ name,
1935
+ featureRef,
1936
+ model: {
1937
+ fields: [],
1938
+ primaryKeyFieldRefs: [],
1939
+ },
1940
+ };
1941
+ }
1942
+ /**
1943
+ * Diff the model definition.
1944
+ *
1945
+ * @param current - The current model definition or a new model to be created.
1946
+ * @param desired - The desired model definition.
1947
+ * @param definitionContainer - Project definition container.
1948
+ * @param options - Diff options.
1949
+ * @returns A diff output or undefined if there are no differences.
1950
+ */
1951
+ function createModelMergerResult(current, desired, definitionContainer, { siblingModels = [] } = {}) {
1952
+ const currentModel = current ?? createNewModelConfigInput(desired.name, desired.featureRef);
1953
+ // resolves all the names of the current model config input
1954
+ const resolvedCurrent = serializeModelMergerModelInput(currentModel, definitionContainer, siblingModels);
1955
+ const diff = createDefinitionDiff(resolvedCurrent, desired, modelMergerDefinitionDiffConfig);
1956
+ if (!diff) {
1957
+ return undefined;
1958
+ }
1959
+ return {
1960
+ isNewModel: !current,
1961
+ id: currentModel.id,
1962
+ name: currentModel.name,
1963
+ featureRef: currentModel.featureRef,
1964
+ changes: diff,
1965
+ };
1966
+ }
1967
+ /**
1968
+ * Creates a model merger result for a set of models.
1969
+ *
1970
+ * @param current - A map of model IDs
1971
+ * @param desired - The desired model definition.
1972
+ * @param definitionContainer - Project definition container.
1973
+ * @param options - Diff options.
1974
+ * @returns A model merger result for a set of models.
1975
+ */
1976
+ function createModelMergerResults(current, desired, definitionContainer, { siblingModels = [] } = {}) {
1977
+ return mapValues(desired, (desired, key) => createModelMergerResult(current[key] && modelEntityType.isId(current[key])
1978
+ ? ModelUtils.byIdOrThrow(definitionContainer.definition, current[key])
1979
+ : undefined, desired, definitionContainer, {
1980
+ siblingModels,
1981
+ }));
1982
+ }
1983
+ function applyModelMergerDiff(model, diff, definitionContainer, siblingModels = []) {
1984
+ const resolvedCurrent = serializeModelMergerModelInput(model, definitionContainer, siblingModels);
1985
+ const patchedCurrent = applyDefinitionDiff(resolvedCurrent, diff, modelMergerDefinitionDiffConfig);
1986
+ return {
1987
+ ...model,
1988
+ ...deserializeModelMergerModelInput(patchedCurrent, (modelId, fieldName) => {
1989
+ const siblingModel = siblingModels.find((m) => m.id === modelId);
1990
+ if (siblingModel) {
1991
+ const field = siblingModel.model.fields.find((f) => f.name === fieldName);
1992
+ if (!field) {
1993
+ throw new Error(`Field ${fieldName} not found in sibling model ${modelId}`);
1994
+ }
1995
+ return field.id;
1996
+ }
1997
+ const model = ModelUtils.byIdOrThrow(definitionContainer.definition, modelId);
1998
+ const field = model.model.fields.find((f) => f.name === fieldName);
1999
+ if (!field) {
2000
+ throw new Error(`Field ${fieldName} not found in model ${model.name}`);
2001
+ }
2002
+ return field.id;
2003
+ }, (relationName) => {
2004
+ // Search sibling model first
2005
+ let relationId;
2006
+ for (const siblingModel of siblingModels) {
2007
+ const relation = siblingModel.model.relations?.find((r) => r.foreignRelationName === relationName);
2008
+ if (relation) {
2009
+ relationId = relation.foreignId;
2010
+ break;
2011
+ }
2012
+ }
2013
+ if (relationId) {
2014
+ return relationId;
2015
+ }
2016
+ const relations = ModelUtils.getRelationsToModel(definitionContainer.definition, model.id);
2017
+ const relation = relations.find((r) => r.relation.foreignRelationName === relationName &&
2018
+ r.relation.modelRef === model.id);
2019
+ if (!relation) {
2020
+ throw new Error(`Relation ${relationName} not found in model ${model.name}`);
2021
+ }
2022
+ return relation.relation.foreignId;
2023
+ }),
2024
+ };
2025
+ }
2026
+ function applyModelMergerResultInPlace(draftConfig, result, definitionContainer, { siblingModels = [] } = {}) {
2027
+ const model = result.isNewModel
2028
+ ? createNewModelConfigInput(result.name, result.featureRef)
2029
+ : ModelUtils.byIdOrThrow(definitionContainer.definition, result.id);
2030
+ const newModel = applyModelMergerDiff(model, result.changes, definitionContainer, siblingModels);
2031
+ if (result.isNewModel) {
2032
+ draftConfig.models.push(newModel);
2033
+ }
2034
+ else {
2035
+ const index = draftConfig.models.findIndex((m) => m.id === result.id);
2036
+ if (index === -1) {
2037
+ throw new Error(`Model ${result.id} not found`);
2038
+ }
2039
+ draftConfig.models[index] = newModel;
2040
+ }
2041
+ return newModel.id;
2042
+ }
2043
+ function createAndApplyModelMergerResults(draftConfig, current, desired, definitionContainer, { siblingModels = [] } = {}) {
2044
+ const results = createModelMergerResults(current, desired, definitionContainer, { siblingModels });
2045
+ return mapValues(results, (result, key) => result
2046
+ ? applyModelMergerResultInPlace(draftConfig, result, definitionContainer, { siblingModels })
2047
+ : desired[key].name);
2048
+ }
2049
+
2050
+ export { ZodPluginWrapper as A, createInitializedPluginSpec as B, CASE_VALIDATORS as C, ZodRefBuilder as D, ZodRef as E, FeatureUtils as F, DefinitionEntityType as G, featureNameSchema as H, createFeatureSchema as I, modelMergerDefinitionDiffConfig as J, createModelMergerResult as K, createModelMergerResults as L, ModelUtils as M, applyModelMergerDiff as N, applyModelMergerResultInPlace as O, createAndApplyModelMergerResults as P, DefinitionDiffKeyedArrayField as Q, DefinitionDiffReplacementField as R, DefinitionDiffArrayIncludesField as S, createDefinitionDiffConfig as T, createDefinitionDiff as U, applyDefinitionDiff as V, ZodRefWrapper as Z, createEntityType as a, zRef as b, createPluginSpec as c, definitionSchema as d, modelForeignRelationEntityType as e, modelLocalRelationEntityType as f, get as g, modelScalarFieldEntityType as h, isEqual as i, zEnt as j, modelTransformerEntityType as k, createDefinitionEntityNameResolver as l, mapValues as m, modelEntityType as n, modelEnumValueEntityType as o, featureEntityType as p, modelEnumEntityType as q, zRefBuilder as r, set as s, zRefId as t, modelUniqueConstraintEntityType as u, createFeaturesSchema as v, zPluginWrapper as w, omit as x, cloneDeep as y, zodPluginSymbol as z };
2051
+ //# sourceMappingURL=model-merger-BLh0ERqk.js.map