@intlayer/backend 5.7.3 → 5.7.5

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 (127) hide show
  1. package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -1
  2. package/dist/cjs/controllers/newsletter.controller.cjs +12 -13
  3. package/dist/cjs/controllers/newsletter.controller.cjs.map +1 -1
  4. package/dist/cjs/controllers/organization.controller.cjs +28 -41
  5. package/dist/cjs/controllers/organization.controller.cjs.map +1 -1
  6. package/dist/cjs/controllers/project.controller.cjs +7 -1
  7. package/dist/cjs/controllers/project.controller.cjs.map +1 -1
  8. package/dist/cjs/controllers/projectAccessKey.controller.cjs +9 -3
  9. package/dist/cjs/controllers/projectAccessKey.controller.cjs.map +1 -1
  10. package/dist/cjs/controllers/stripe.controller.cjs +15 -3
  11. package/dist/cjs/controllers/stripe.controller.cjs.map +1 -1
  12. package/dist/cjs/controllers/tag.controller.cjs +4 -6
  13. package/dist/cjs/controllers/tag.controller.cjs.map +1 -1
  14. package/dist/cjs/controllers/user.controller.cjs +19 -14
  15. package/dist/cjs/controllers/user.controller.cjs.map +1 -1
  16. package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs +5 -7
  17. package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs.map +1 -1
  18. package/dist/cjs/schemas/dictionary.schema.cjs +1 -1
  19. package/dist/cjs/schemas/dictionary.schema.cjs.map +1 -1
  20. package/dist/cjs/schemas/discussion.schema.cjs +1 -1
  21. package/dist/cjs/schemas/discussion.schema.cjs.map +1 -1
  22. package/dist/cjs/schemas/oAuth2.schema.cjs +1 -1
  23. package/dist/cjs/schemas/oAuth2.schema.cjs.map +1 -1
  24. package/dist/cjs/schemas/organization.schema.cjs +1 -1
  25. package/dist/cjs/schemas/organization.schema.cjs.map +1 -1
  26. package/dist/cjs/schemas/plans.schema.cjs +1 -1
  27. package/dist/cjs/schemas/plans.schema.cjs.map +1 -1
  28. package/dist/cjs/schemas/project.schema.cjs +1 -1
  29. package/dist/cjs/schemas/project.schema.cjs.map +1 -1
  30. package/dist/cjs/schemas/session.schema.cjs +1 -1
  31. package/dist/cjs/schemas/session.schema.cjs.map +1 -1
  32. package/dist/cjs/schemas/tag.schema.cjs +1 -1
  33. package/dist/cjs/schemas/tag.schema.cjs.map +1 -1
  34. package/dist/cjs/schemas/user.schema.cjs +1 -1
  35. package/dist/cjs/schemas/user.schema.cjs.map +1 -1
  36. package/dist/cjs/types/organization.types.cjs.map +1 -1
  37. package/dist/cjs/types/project.types.cjs.map +1 -1
  38. package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs +3 -0
  39. package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs.map +1 -1
  40. package/dist/cjs/utils/auth/getAuth.cjs +8 -5
  41. package/dist/cjs/utils/auth/getAuth.cjs.map +1 -1
  42. package/dist/cjs/utils/errors/errorCodes.cjs +13 -0
  43. package/dist/cjs/utils/errors/errorCodes.cjs.map +1 -1
  44. package/dist/cjs/utils/mapper/project.cjs +1 -2
  45. package/dist/cjs/utils/mapper/project.cjs.map +1 -1
  46. package/dist/cjs/utils/mapper/session.cjs +37 -0
  47. package/dist/cjs/utils/mapper/session.cjs.map +1 -0
  48. package/dist/cjs/utils/permissions.cjs +51 -34
  49. package/dist/cjs/utils/permissions.cjs.map +1 -1
  50. package/dist/cjs/utils/validation/validateArray.cjs +5 -1
  51. package/dist/cjs/utils/validation/validateArray.cjs.map +1 -1
  52. package/dist/esm/controllers/dictionary.controller.mjs.map +1 -1
  53. package/dist/esm/controllers/newsletter.controller.mjs +12 -13
  54. package/dist/esm/controllers/newsletter.controller.mjs.map +1 -1
  55. package/dist/esm/controllers/organization.controller.mjs +28 -41
  56. package/dist/esm/controllers/organization.controller.mjs.map +1 -1
  57. package/dist/esm/controllers/project.controller.mjs +7 -1
  58. package/dist/esm/controllers/project.controller.mjs.map +1 -1
  59. package/dist/esm/controllers/projectAccessKey.controller.mjs +10 -4
  60. package/dist/esm/controllers/projectAccessKey.controller.mjs.map +1 -1
  61. package/dist/esm/controllers/stripe.controller.mjs +15 -3
  62. package/dist/esm/controllers/stripe.controller.mjs.map +1 -1
  63. package/dist/esm/controllers/tag.controller.mjs +4 -6
  64. package/dist/esm/controllers/tag.controller.mjs.map +1 -1
  65. package/dist/esm/controllers/user.controller.mjs +19 -14
  66. package/dist/esm/controllers/user.controller.mjs.map +1 -1
  67. package/dist/esm/emails/OAuthTokenCreatedEmail.mjs +5 -7
  68. package/dist/esm/emails/OAuthTokenCreatedEmail.mjs.map +1 -1
  69. package/dist/esm/schemas/dictionary.schema.mjs +1 -1
  70. package/dist/esm/schemas/dictionary.schema.mjs.map +1 -1
  71. package/dist/esm/schemas/discussion.schema.mjs +1 -1
  72. package/dist/esm/schemas/discussion.schema.mjs.map +1 -1
  73. package/dist/esm/schemas/oAuth2.schema.mjs +1 -1
  74. package/dist/esm/schemas/oAuth2.schema.mjs.map +1 -1
  75. package/dist/esm/schemas/organization.schema.mjs +1 -1
  76. package/dist/esm/schemas/organization.schema.mjs.map +1 -1
  77. package/dist/esm/schemas/plans.schema.mjs +1 -1
  78. package/dist/esm/schemas/plans.schema.mjs.map +1 -1
  79. package/dist/esm/schemas/project.schema.mjs +1 -1
  80. package/dist/esm/schemas/project.schema.mjs.map +1 -1
  81. package/dist/esm/schemas/session.schema.mjs +1 -1
  82. package/dist/esm/schemas/session.schema.mjs.map +1 -1
  83. package/dist/esm/schemas/tag.schema.mjs +1 -1
  84. package/dist/esm/schemas/tag.schema.mjs.map +1 -1
  85. package/dist/esm/schemas/user.schema.mjs +1 -1
  86. package/dist/esm/schemas/user.schema.mjs.map +1 -1
  87. package/dist/esm/utils/AI/askDocQuestion/askDocQuestion.mjs +3 -0
  88. package/dist/esm/utils/AI/askDocQuestion/askDocQuestion.mjs.map +1 -1
  89. package/dist/esm/utils/auth/getAuth.mjs +8 -5
  90. package/dist/esm/utils/auth/getAuth.mjs.map +1 -1
  91. package/dist/esm/utils/errors/errorCodes.mjs +13 -0
  92. package/dist/esm/utils/errors/errorCodes.mjs.map +1 -1
  93. package/dist/esm/utils/mapper/project.mjs +1 -2
  94. package/dist/esm/utils/mapper/project.mjs.map +1 -1
  95. package/dist/esm/utils/mapper/session.mjs +13 -0
  96. package/dist/esm/utils/mapper/session.mjs.map +1 -0
  97. package/dist/esm/utils/permissions.mjs +51 -34
  98. package/dist/esm/utils/permissions.mjs.map +1 -1
  99. package/dist/esm/utils/validation/validateArray.mjs +5 -1
  100. package/dist/esm/utils/validation/validateArray.mjs.map +1 -1
  101. package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
  102. package/dist/types/controllers/newsletter.controller.d.ts.map +1 -1
  103. package/dist/types/controllers/organization.controller.d.ts +3 -5
  104. package/dist/types/controllers/organization.controller.d.ts.map +1 -1
  105. package/dist/types/controllers/project.controller.d.ts.map +1 -1
  106. package/dist/types/controllers/projectAccessKey.controller.d.ts.map +1 -1
  107. package/dist/types/controllers/stripe.controller.d.ts +4 -1
  108. package/dist/types/controllers/stripe.controller.d.ts.map +1 -1
  109. package/dist/types/controllers/tag.controller.d.ts.map +1 -1
  110. package/dist/types/controllers/user.controller.d.ts.map +1 -1
  111. package/dist/types/emails/OAuthTokenCreatedEmail.d.ts.map +1 -1
  112. package/dist/types/types/organization.types.d.ts +1 -3
  113. package/dist/types/types/organization.types.d.ts.map +1 -1
  114. package/dist/types/types/project.types.d.ts +1 -3
  115. package/dist/types/types/project.types.d.ts.map +1 -1
  116. package/dist/types/utils/AI/askDocQuestion/askDocQuestion.d.ts.map +1 -1
  117. package/dist/types/utils/auth/getAuth.d.ts +2 -2
  118. package/dist/types/utils/auth/getAuth.d.ts.map +1 -1
  119. package/dist/types/utils/errors/errorCodes.d.ts +13 -0
  120. package/dist/types/utils/errors/errorCodes.d.ts.map +1 -1
  121. package/dist/types/utils/mapper/project.d.ts.map +1 -1
  122. package/dist/types/utils/mapper/session.d.ts +4 -0
  123. package/dist/types/utils/mapper/session.d.ts.map +1 -0
  124. package/dist/types/utils/permissions.d.ts +32 -28
  125. package/dist/types/utils/permissions.d.ts.map +1 -1
  126. package/dist/types/utils/validation/validateArray.d.ts.map +1 -1
  127. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/emails/OAuthTokenCreatedEmail.tsx"],"sourcesContent":["import {\n Body,\n Button,\n Container,\n Head,\n Heading,\n Hr,\n Html,\n Img,\n Link,\n Preview,\n Section,\n Tailwind,\n Text,\n} from '@react-email/components';\n\nexport type OAuthTokenCreatedEmailProps = {\n username: string;\n applicationName: string;\n scopes: string[];\n tokenDetailsUrl: string;\n securityLogUrl: string;\n supportUrl: string;\n};\n\nexport const OAuthTokenCreatedEmailEN = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `A third-party OAuth application has been added to your Intlayer account`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n A third-party OAuth application has been added to your account\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Hey {username}!\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n A third-party OAuth application (\n <strong>{applicationName}</strong>) with {scopes.join(', ')}{' '}\n scopes was recently authorized to access your account.\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n View Application Details\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n To see this and other security events for your account, visit{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n your security log\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n If you run into problems, please contact support by visiting{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n our support page\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n This email was intended for{' '}\n <span className=\"text-black\">{username}</span>. If you were not\n expecting this email, you can ignore it. If you are concerned\n about your account's safety, please reply to this email to get in\n touch with us.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nexport const OAuthTokenCreatedEmailFR = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `Une application OAuth tierce a été ajoutée à votre compte Intlayer`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n Une application OAuth tierce a été ajoutée à votre compte\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Salut {username} !\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Une application OAuth tierce (<strong>{applicationName}</strong>)\n avec les permissions {scopes.join(', ')} a récemment été autorisée\n à accéder à votre compte.\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n Voir les détails de l'application\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Pour voir cet événement et d'autres événements de sécurité pour\n votre compte, visitez{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n votre journal de sécurité\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Si vous rencontrez des problèmes, veuillez contacter le support en\n visitant{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n notre page de support\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n Cet e-mail était destiné à{' '}\n <span className=\"text-black\">{username}</span>. Si vous\n n'attendiez pas cet e-mail, vous pouvez l'ignorer. Si vous êtes\n préoccupé par la sécurité de votre compte, veuillez répondre à cet\n e-mail pour nous contacter.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nexport const OAuthTokenCreatedEmailES = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `Se ha añadido una aplicación OAuth de terceros a tu cuenta de Intlayer`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n Se ha añadido una aplicación OAuth de terceros a tu cuenta\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n ¡Hola {username}!\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Una aplicación OAuth de terceros (\n <strong>{applicationName}</strong>) con permisos{' '}\n {scopes.join(', ')} fue recientemente autorizada para acceder a tu\n cuenta.\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n Ver detalles de la aplicación\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Para ver este y otros eventos de seguridad para tu cuenta, visita{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n tu registro de seguridad\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Si tienes problemas, por favor contacta al soporte visitando{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n nuestra página de soporte\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n Este correo fue enviado a{' '}\n <span className=\"text-black\">{username}</span>. Si no esperabas\n este correo, puedes ignorarlo. Si estás preocupado por la\n seguridad de tu cuenta, por favor responde a este correo para\n contactarte con nosotros.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nconst previewProps: OAuthTokenCreatedEmailProps = {\n username: 'aymericzip',\n applicationName: 'Postman',\n scopes: ['read:user', 'user:email'],\n tokenDetailsUrl:\n 'https://intlayer.org/settings/connections/applications/Ov23li230j1cbJfa4SPW',\n securityLogUrl: 'https://intlayer.org/settings/security-log',\n supportUrl: 'https://intlayer.org/contact',\n};\n\nOAuthTokenCreatedEmailEN.PreviewProps = previewProps;\nOAuthTokenCreatedEmailFR.PreviewProps = previewProps;\nOAuthTokenCreatedEmailES.PreviewProps = previewProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AA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AAU,yCAAwC;AAAA;AAAA,QACY;AAAA,QAClE;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,WAAU;AAAA,YACX;AAAA;AAAA,QAED;AAAA,QAAO;AAAA,SAET;AAAA,MACA,6CAAC,0BAAK,WAAU,yCAAwC;AAAA;AAAA,QACO;AAAA,QAC7D,4CAAC,0BAAK,MAAM,YAAY,WAAU,+BAA8B,0CAEhE;AAAA,QAAO;AAAA,SAET;AAAA,MACA,4CAAC,wBAAG,WAAU,8DAA6D;AAAA,MAC3E,6CAAC,0BAAK,WAAU,6CAA4C;AAAA;AAAA,QAChC;AAAA,QAC1B,4CAAC,UAAK,WAAU,cAAc,oBAAS;AAAA,QAAO;AAAA,SAIhD;AAAA,OACF,GACF,GACF;AAAA,KACF;AAEJ;AAEA,MAAM,eAA4C;AAAA,EAChD,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,QAAQ,CAAC,aAAa,YAAY;AAAA,EAClC,iBACE;AAAA,EACF,gBAAgB;AAAA,EAChB,YAAY;AACd;AAEA,yBAAyB,eAAe;AACxC,yBAAyB,eAAe;AACxC,yBAAyB,eAAe;","names":[]}
1
+ {"version":3,"sources":["../../../src/emails/OAuthTokenCreatedEmail.tsx"],"sourcesContent":["import {\n Body,\n Button,\n Container,\n Head,\n Heading,\n Hr,\n Html,\n Img,\n Link,\n Preview,\n Section,\n Tailwind,\n Text,\n} from '@react-email/components';\n\nexport type OAuthTokenCreatedEmailProps = {\n username: string;\n applicationName: string;\n scopes: string[];\n tokenDetailsUrl: string;\n securityLogUrl: string;\n supportUrl: string;\n};\n\nexport const OAuthTokenCreatedEmailEN = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `A third-party OAuth access key has been added to your Intlayer account`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n A third-party OAuth access key has been added to your account\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Hey {username}!\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n A third-party OAuth access key (<strong>{applicationName}</strong>\n ) with the following permissions was recently authorized to access\n your account:\n <ul>\n {scopes.map((scope) => (\n <li key={scope}>{scope}</li>\n ))}\n </ul>\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n View Application Details\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n To see this and other security events for your account, visit{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n your security log\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n If you run into problems, please contact support by visiting{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n our support page\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n This email was intended for{' '}\n <span className=\"text-black\">{username}</span>. If you were not\n expecting this email, you can ignore it. If you are concerned\n about your account's safety, please reply to this email to get in\n touch with us.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nexport const OAuthTokenCreatedEmailFR = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `Une application OAuth tierce a été ajoutée à votre compte Intlayer`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n Une application OAuth tierce a été ajoutée à votre compte\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Salut {username} !\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Une application OAuth tierce (<strong>{applicationName}</strong>)\n avec les permissions {scopes.join(', ')} a récemment été autorisée\n à accéder à votre compte.\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n Voir les détails de l'application\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Pour voir cet événement et d'autres événements de sécurité pour\n votre compte, visitez{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n votre journal de sécurité\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Si vous rencontrez des problèmes, veuillez contacter le support en\n visitant{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n notre page de support\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n Cet e-mail était destiné à{' '}\n <span className=\"text-black\">{username}</span>. Si vous\n n'attendiez pas cet e-mail, vous pouvez l'ignorer. Si vous êtes\n préoccupé par la sécurité de votre compte, veuillez répondre à cet\n e-mail pour nous contacter.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nexport const OAuthTokenCreatedEmailES = ({\n username,\n applicationName,\n scopes,\n tokenDetailsUrl,\n securityLogUrl,\n supportUrl,\n}: OAuthTokenCreatedEmailProps) => {\n const previewText = `Se ha añadido una aplicación OAuth de terceros a tu cuenta de Intlayer`;\n\n return (\n <Html>\n <Head />\n <Preview>{previewText}</Preview>\n <Tailwind>\n <Body className=\"m-auto px-2 font-sans\">\n <Container className=\"mx-auto my-[40px] max-w-[465px] rounded-xl border border-solid border-[#eaeaea] bg-white p-[20px]\">\n <Section className=\"mt-[32px]\">\n <Img\n src=\"https://intlayer.org/apple-touch-icon.png\"\n width=\"40\"\n height=\"37\"\n alt=\"Intlayer\"\n className=\"mx-auto my-0\"\n />\n </Section>\n <Heading className=\"mx-0 my-[30px] p-0 text-center text-[24px] font-normal text-black\">\n Se ha añadido una aplicación OAuth de terceros a tu cuenta\n </Heading>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n ¡Hola {username}!\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Una aplicación OAuth de terceros (\n <strong>{applicationName}</strong>) con permisos{' '}\n {scopes.join(', ')} fue recientemente autorizada para acceder a tu\n cuenta.\n </Text>\n <Section className=\"my-[32px] text-center\">\n <Button\n className=\"rounded-md bg-[#000000] px-5 py-3 text-center text-[12px] font-semibold text-white no-underline\"\n href={tokenDetailsUrl}\n >\n Ver detalles de la aplicación\n </Button>\n </Section>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Para ver este y otros eventos de seguridad para tu cuenta, visita{' '}\n <Link\n href={securityLogUrl}\n className=\"text-[#000000] no-underline\"\n >\n tu registro de seguridad\n </Link>\n .\n </Text>\n <Text className=\"text-[14px] leading-[24px] text-black\">\n Si tienes problemas, por favor contacta al soporte visitando{' '}\n <Link href={supportUrl} className=\"text-[#000000] no-underline\">\n nuestra página de soporte\n </Link>\n .\n </Text>\n <Hr className=\"mx-0 my-[26px] w-full border border-solid border-[#eaeaea]\" />\n <Text className=\"text-[12px] leading-[24px] text-[#666666]\">\n Este correo fue enviado a{' '}\n <span className=\"text-black\">{username}</span>. Si no esperabas\n este correo, puedes ignorarlo. Si estás preocupado por la\n seguridad de tu cuenta, por favor responde a este correo para\n contactarte con nosotros.\n </Text>\n </Container>\n </Body>\n </Tailwind>\n </Html>\n );\n};\n\nconst previewProps: OAuthTokenCreatedEmailProps = {\n username: 'aymericzip',\n applicationName: 'Postman',\n scopes: ['read:user', 'user:email'],\n tokenDetailsUrl:\n 'https://intlayer.org/settings/connections/applications/Ov23li230j1cbJfa4SPW',\n securityLogUrl: 'https://intlayer.org/settings/security-log',\n supportUrl: 'https://intlayer.org/contact',\n};\n\nOAuthTokenCreatedEmailEN.PreviewProps = previewProps;\nOAuthTokenCreatedEmailFR.PreviewProps = previewProps;\nOAuthTokenCreatedEmailES.PreviewProps = previewProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCM;AArCN,wBAcO;AAWA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmC;AACjC,QAAM,cAAc;AAEpB,SACE,6CAAC,0BACC;AAAA,gDAAC,0BAAK;AAAA,IACN,4CAAC,6BAAS,uBAAY;AAAA,IACtB,4CAAC,8BACC,sDAAC,0BAAK,WAAU,yBACd,uDAAC,+BAAU,WAAU,qGACnB;AAAA,kDAAC,6BAAQ,WAAU,aACjB;AAAA,QAAC;AAAA;AAAA,UACC,KAAI;AAAA,UACJ,OAAM;AAAA,UACN,QAAO;AAAA,UACP,KAAI;AAAA,UACJ,WAAU;AAAA;AAAA,MACZ,GACF;AAAA,MACA,4CAAC,6BAAQ,WAAU,qEAAoE,2EAEvF;AAAA,MACA,6CAAC,0BAAK,WAAU,yCAAwC;AAAA;AAAA,QACjD;AAAA,QAAS;A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Y;AAAA,EAClC,iBACE;AAAA,EACF,gBAAgB;AAAA,EAChB,YAAY;AACd;AAEA,yBAAyB,eAAe;AACxC,yBAAyB,eAAe;AACxC,yBAAyB,eAAe;","names":[]}
@@ -94,7 +94,7 @@ const dictionarySchema = new import_mongoose.Schema(
94
94
  toObject: {
95
95
  virtuals: true,
96
96
  transform(doc, ret) {
97
- ret.id = ret._id.toString();
97
+ ret.id = ret._id;
98
98
  delete ret._id;
99
99
  }
100
100
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import type {\n DictionarySchema,\n VersionedContentEl,\n} from '@/types/dictionary.types';\nimport { Schema } from 'mongoose';\n\nconst versionedContentElSchema = new Schema<VersionedContentEl>(\n {\n name: {\n type: String,\n },\n description: {\n type: String,\n },\n content: {\n type: Schema.Types.Mixed,\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n\nexport const dictionarySchema = new Schema<DictionarySchema>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n tags: {\n type: [String],\n default: [],\n },\n content: {\n type: Map,\n of: versionedContentElSchema,\n required: true,\n default: null,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Map,\n of: String,\n default: null,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAuB;AAEvB,MAAM,2BAA2B,IAAI;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B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import type {\n DictionarySchema,\n VersionedContentEl,\n} from '@/types/dictionary.types';\nimport { Schema } from 'mongoose';\n\nconst versionedContentElSchema = new Schema<VersionedContentEl>(\n {\n name: {\n type: String,\n },\n description: {\n type: String,\n },\n content: {\n type: Schema.Types.Mixed,\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n\nexport const dictionarySchema = new Schema<DictionarySchema>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n tags: {\n type: [String],\n default: [],\n },\n content: {\n type: Map,\n of: versionedContentElSchema,\n required: true,\n default: null,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Map,\n of: String,\n default: null,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAuB;AAEvB,MAAM,2BAA2B,IAAI;AAAA,EACnC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM,uBAAO,MAAM;AAAA,MACnB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,MAAM,CAAC,MAAM;AAAA,MACb,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -85,7 +85,7 @@ const discussionSchema = new import_mongoose.Schema(
85
85
  toObject: {
86
86
  virtuals: true,
87
87
  transform(doc, ret) {
88
- ret.id = ret._id.toString();
88
+ ret.id = ret._id;
89
89
  delete ret._id;
90
90
  }
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/discussion.schema.ts"],"sourcesContent":["import type { DiscussionSchema } from '@/types/discussion.types';\nimport { Schema } from 'mongoose';\n\nexport const discussionSchema = new Schema<DiscussionSchema>(\n {\n discutionId: {\n type: String,\n required: true,\n unique: true,\n },\n messages: [\n {\n role: {\n type: String,\n required: true,\n enum: ['user', 'assistant', 'system'],\n },\n content: {\n type: String,\n required: true,\n },\n timestamp: {\n type: Date,\n default: Date.now,\n },\n },\n ],\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'user',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'project',\n required: true,\n },\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'organization',\n required: true,\n },\n title: {\n type: String,\n required: false,\n },\n isArchived: {\n type: Boolean,\n default: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,MAAM,CAAC,QAAQ,aAAa,QAAQ;AAAA,QACtC;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,SAAS,KAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/discussion.schema.ts"],"sourcesContent":["import type { DiscussionSchema } from '@/types/discussion.types';\nimport { Schema } from 'mongoose';\n\nexport const discussionSchema = new Schema<DiscussionSchema>(\n {\n discutionId: {\n type: String,\n required: true,\n unique: true,\n },\n messages: [\n {\n role: {\n type: String,\n required: true,\n enum: ['user', 'assistant', 'system'],\n },\n content: {\n type: String,\n required: true,\n },\n timestamp: {\n type: Date,\n default: Date.now,\n },\n },\n ],\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'user',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'project',\n required: true,\n },\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'organization',\n required: true,\n },\n title: {\n type: String,\n required: false,\n },\n isArchived: {\n type: Boolean,\n default: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,MAAM,CAAC,QAAQ,aAAa,QAAQ;AAAA,QACtC;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,SAAS,KAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -57,7 +57,7 @@ const accessTokenSchema = new import_mongoose.Schema(
57
57
  toObject: {
58
58
  virtuals: true,
59
59
  transform(doc, ret) {
60
- ret.id = ret._id.toString();
60
+ ret.id = ret._id;
61
61
  delete ret._id;
62
62
  }
63
63
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/oAuth2.schema.ts"],"sourcesContent":["import type { User } from '@/types/user.types';\nimport { Schema } from 'mongoose';\nimport type { Client, Token as TokenType } from 'oauth2-server';\n\nexport type Token = Omit<TokenType, 'client' | 'user'> & {\n clientId: Client['id'];\n userId: User['id'];\n};\n\nexport const accessTokenSchema = new Schema<Token>(\n {\n accessToken: {\n type: String,\n required: true,\n },\n accessTokenExpiresAt: {\n type: Date,\n },\n clientId: {\n type: String,\n ref: 'Project',\n required: true,\n },\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\naccessTokenSchema.index(\n { createdAt: 1 },\n {\n expireAfterSeconds: 60 * 60 * 24 * 10, // 10 Days\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAQhB,MAAM,oBAAoB,IAAI;AAAA,EACnC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,MACpB,MAAM;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,kBAAkB;AAAA,EAChB,EAAE,WAAW,EAAE;AAAA,EACf;AAAA,IACE,oBAAoB,KAAK,KAAK,KAAK;AAAA;AAAA,EACrC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/oAuth2.schema.ts"],"sourcesContent":["import type { User } from '@/types/user.types';\nimport { Schema } from 'mongoose';\nimport type { Client, Token as TokenType } from 'oauth2-server';\n\nexport type Token = Omit<TokenType, 'client' | 'user'> & {\n clientId: Client['id'];\n userId: User['id'];\n};\n\nexport const accessTokenSchema = new Schema<Token>(\n {\n accessToken: {\n type: String,\n required: true,\n },\n accessTokenExpiresAt: {\n type: Date,\n },\n clientId: {\n type: String,\n ref: 'Project',\n required: true,\n },\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\naccessTokenSchema.index(\n { createdAt: 1 },\n {\n expireAfterSeconds: 60 * 60 * 24 * 10, // 10 Days\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAQhB,MAAM,oBAAoB,IAAI;AAAA,EACnC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,MACpB,MAAM;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,kBAAkB;AAAA,EAChB,EAAE,WAAW,EAAE;AAAA,EACf;AAAA,IACE,oBAAoB,KAAK,KAAK,KAAK;AAAA;AAAA,EACrC;AACF;","names":[]}
@@ -68,7 +68,7 @@ const organizationSchema = new import_mongoose.Schema(
68
68
  toObject: {
69
69
  virtuals: true,
70
70
  transform(doc, ret) {
71
- ret.id = ret._id.toString();
71
+ ret.id = ret._id;
72
72
  delete ret._id;
73
73
  }
74
74
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/organization.schema.ts"],"sourcesContent":["import { OrganizationSchema } from '@/export';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateOrganization';\nimport { Schema } from 'mongoose';\nimport { planSchema } from './plans.schema';\n\nexport const organizationSchema = new Schema<OrganizationSchema>(\n {\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n plan: {\n type: planSchema,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\n// Add virtual field for id\norganizationSchema.virtual('id').get(function () {\n return this._id.toString();\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAIO;AACP,sBAAuB;AACvB,mBAA2B;AAEpB,MAAM,qBAAqB,IAAI;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAGA,mBAAmB,QAAQ,IAAI,EAAE,IAAI,WAAY;AAC/C,SAAO,KAAK,IAAI,SAAS;AAC3B,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/organization.schema.ts"],"sourcesContent":["import { OrganizationSchema } from '@/export';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateOrganization';\nimport { Schema } from 'mongoose';\nimport { planSchema } from './plans.schema';\n\nexport const organizationSchema = new Schema<OrganizationSchema>(\n {\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n plan: {\n type: planSchema,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\n// Add virtual field for id\norganizationSchema.virtual('id').get(function () {\n return this._id.toString();\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAIO;AACP,sBAAuB;AACvB,mBAA2B;AAEpB,MAAM,qBAAqB,IAAI;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAGA,mBAAmB,QAAQ,IAAI,EAAE,IAAI,WAAY;AAC/C,SAAO,KAAK,IAAI,SAAS;AAC3B,CAAC;","names":[]}
@@ -82,7 +82,7 @@ const planSchema = new import_mongoose.Schema(
82
82
  toObject: {
83
83
  virtuals: true,
84
84
  transform(doc, ret) {
85
- ret.id = ret._id.toString();
85
+ ret.id = ret._id;
86
86
  delete ret._id;
87
87
  }
88
88
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/plans.schema.ts"],"sourcesContent":["import type { PlanSchema } from '@/types/plan.types';\nimport { Schema } from 'mongoose';\n\nexport const planSchema = new Schema<PlanSchema>(\n {\n type: {\n type: String,\n required: true,\n enum: ['PREMIUM', 'ENTERPRISE'],\n },\n period: {\n type: String,\n required: true,\n enum: ['MONTHLY', 'YEARLY'],\n default: 'MONTHLY',\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n subscriptionId: {\n type: String,\n required: true,\n },\n customerId: {\n type: String,\n required: true,\n },\n priceId: {\n type: String,\n required: true,\n },\n status: {\n type: String,\n required: true,\n enum: [\n 'active',\n 'canceled',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'incomplete_expired',\n 'paused',\n 'trialing',\n ],\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,YAAY;AAAA,IAChC;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,QAAQ;AAAA,MAC1B,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/plans.schema.ts"],"sourcesContent":["import type { PlanSchema } from '@/types/plan.types';\nimport { Schema } from 'mongoose';\n\nexport const planSchema = new Schema<PlanSchema>(\n {\n type: {\n type: String,\n required: true,\n enum: ['PREMIUM', 'ENTERPRISE'],\n },\n period: {\n type: String,\n required: true,\n enum: ['MONTHLY', 'YEARLY'],\n default: 'MONTHLY',\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n subscriptionId: {\n type: String,\n required: true,\n },\n customerId: {\n type: String,\n required: true,\n },\n priceId: {\n type: String,\n required: true,\n },\n status: {\n type: String,\n required: true,\n enum: [\n 'active',\n 'canceled',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'incomplete_expired',\n 'paused',\n 'trialing',\n ],\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,YAAY;AAAA,IAChC;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,QAAQ;AAAA,MAC1B,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -113,7 +113,7 @@ const projectSchema = new import_mongoose.Schema(
113
113
  toObject: {
114
114
  virtuals: true,
115
115
  transform(doc, ret) {
116
- ret.id = ret._id.toString();
116
+ ret.id = ret._id;
117
117
  delete ret._id;
118
118
  }
119
119
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import type {\n OAuth2Access,\n Project,\n ProjectSchema,\n} from '@/types/project.types';\nimport { Locales } from '@intlayer/config';\nimport type { RenameId } from '@utils/mongoDB/types';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Schema } from 'mongoose';\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema<RenameId<OAuth2Access>>(\n {\n clientId: { type: String, required: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true, default: [] },\n grants: { type: [String], required: true, default: [] },\n },\n {\n timestamps: true,\n }\n);\n\nconst projectConfigSchema = new Schema<Project['configuration']>(\n {\n internationalization: {\n locales: {\n type: [String],\n enum: Object.values(Locales),\n required: true,\n },\n defaultLocale: {\n type: String,\n enum: Object.values(Locales),\n },\n },\n editor: {\n applicationURL: {\n type: String,\n },\n cmsURL: {\n type: String,\n },\n },\n },\n {\n _id: false, // Prevents the generation of an _id field for this subdocument\n }\n);\n\nexport const projectSchema = new Schema<ProjectSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n configuration: projectConfigSchema,\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,6BAIO;AACP,sBAAuB;AAGvB,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACzC,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ,UAAU,KAAK;AAAA,IACnE,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,WAAW,EAAE,MAAM,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uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import type {\n OAuth2Access,\n Project,\n ProjectSchema,\n} from '@/types/project.types';\nimport { Locales } from '@intlayer/config';\nimport type { RenameId } from '@utils/mongoDB/types';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Schema } from 'mongoose';\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema<RenameId<OAuth2Access>>(\n {\n clientId: { type: String, required: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true, default: [] },\n grants: { type: [String], required: true, default: [] },\n },\n {\n timestamps: true,\n }\n);\n\nconst projectConfigSchema = new Schema<Project['configuration']>(\n {\n internationalization: {\n locales: {\n type: [String],\n enum: Object.values(Locales),\n required: true,\n },\n defaultLocale: {\n type: String,\n enum: Object.values(Locales),\n },\n },\n editor: {\n applicationURL: {\n type: String,\n },\n cmsURL: {\n type: String,\n },\n },\n },\n {\n _id: false, // Prevents the generation of an _id field for this subdocument\n }\n);\n\nexport const projectSchema = new Schema<ProjectSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n configuration: projectConfigSchema,\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,6BAIO;AACP,sBAAuB;AAGvB,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACzC,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ,UAAU,KAAK;AAAA,IACnE,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,WAAW,EAAE,MAAM,KAAK;AAAA,IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,UAAU,MAAM,SAAS,CAAC,EAAE;AAAA,IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,UAAU,MAAM,SAAS,CAAC,EAAE;AAAA,EACxD;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;A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AI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -50,7 +50,7 @@ const sessionSchema = new import_mongoose.Schema(
50
50
  toObject: {
51
51
  virtuals: true,
52
52
  transform(doc, ret) {
53
- ret.id = ret._id.toString();
53
+ ret.id = ret._id;
54
54
  delete ret._id;
55
55
  }
56
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/session.schema.ts"],"sourcesContent":["import { SessionSchema } from '@/export';\nimport { Schema } from 'mongoose';\n\nexport const sessionSchema = new Schema<SessionSchema>(\n {\n activeOrganizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: false,\n },\n activeProjectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,sBAAsB;AAAA,MACpB,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/session.schema.ts"],"sourcesContent":["import { SessionSchema } from '@/export';\nimport { Schema } from 'mongoose';\n\nexport const sessionSchema = new Schema<SessionSchema>(\n {\n activeOrganizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: false,\n },\n activeProjectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,sBAAsB;AAAA,MACpB,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -73,7 +73,7 @@ const tagSchema = new import_mongoose.Schema(
73
73
  toObject: {
74
74
  virtuals: true,
75
75
  transform(doc, ret) {
76
- ret.id = ret._id.toString();
76
+ ret.id = ret._id;
77
77
  delete ret._id;
78
78
  }
79
79
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/tag.schema.ts"],"sourcesContent":["import type { TagSchema } from '@/types/tag.types';\nimport {\n KEY_MAX_LENGTH,\n KEY_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateTag';\nimport { Schema } from 'mongoose';\n\nexport const tagSchema = new Schema<TagSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n minlength: KEY_MIN_LENGTH,\n maxlength: KEY_MAX_LENGTH,\n },\n name: {\n type: String,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n description: {\n type: String,\n },\n instructions: {\n type: String,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AACP,sBAAuB;AAEhB,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,cAAc;AAAA,MACZ,MAAM;AAAA,IACR;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/tag.schema.ts"],"sourcesContent":["import type { TagSchema } from '@/types/tag.types';\nimport {\n KEY_MAX_LENGTH,\n KEY_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateTag';\nimport { Schema } from 'mongoose';\n\nexport const tagSchema = new Schema<TagSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n minlength: KEY_MIN_LENGTH,\n maxlength: KEY_MAX_LENGTH,\n },\n name: {\n type: String,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n description: {\n type: String,\n },\n instructions: {\n type: String,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AACP,sBAAuB;AAEhB,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,cAAc;AAAA,MACZ,MAAM;AAAA,IACR;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -82,7 +82,7 @@ const userSchema = new import_mongoose.Schema(
82
82
  toObject: {
83
83
  virtuals: true,
84
84
  transform(doc, ret) {
85
- ret.id = ret._id.toString();
85
+ ret.id = ret._id;
86
86
  delete ret._id;
87
87
  }
88
88
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/user.schema.ts"],"sourcesContent":["import type { UserSchema } from '@/types/user.types';\nimport {\n NAMES_MAX_LENGTH,\n NAMES_MIN_LENGTH,\n} from '@utils/validation/validateUser';\nimport { Schema } from 'mongoose';\nimport validator from 'validator';\n\nexport const userSchema = new Schema<UserSchema>(\n {\n email: {\n type: String,\n required: true,\n unique: true,\n validate: [validator.isEmail, 'Please fill a valid email address'],\n lowercase: true,\n trim: true,\n },\n name: {\n type: String,\n maxlength: NAMES_MAX_LENGTH,\n minlength: NAMES_MIN_LENGTH,\n },\n phone: {\n type: String,\n maxlength: 20,\n },\n\n customerId: {\n type: String,\n required: false,\n },\n\n emailsList: {\n type: {\n newsLetter: {\n type: Boolean,\n default: false,\n },\n },\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAGO;AACP,sBAAuB;AACvB,uBAAsB;AAEf,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,UAAU,CAAC,iBAAAA,QAAU,SAAS,mCAAmC;AAAA,MACjE,WAAW;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,IACb;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":["validator"]}
1
+ {"version":3,"sources":["../../../src/schemas/user.schema.ts"],"sourcesContent":["import type { UserSchema } from '@/types/user.types';\nimport {\n NAMES_MAX_LENGTH,\n NAMES_MIN_LENGTH,\n} from '@utils/validation/validateUser';\nimport { Schema } from 'mongoose';\nimport validator from 'validator';\n\nexport const userSchema = new Schema<UserSchema>(\n {\n email: {\n type: String,\n required: true,\n unique: true,\n validate: [validator.isEmail, 'Please fill a valid email address'],\n lowercase: true,\n trim: true,\n },\n name: {\n type: String,\n maxlength: NAMES_MAX_LENGTH,\n minlength: NAMES_MIN_LENGTH,\n },\n phone: {\n type: String,\n maxlength: 20,\n },\n\n customerId: {\n type: String,\n required: false,\n },\n\n emailsList: {\n type: {\n newsLetter: {\n type: Boolean,\n default: false,\n },\n },\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAGO;AACP,sBAAuB;AACvB,uBAAsB;AAEf,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,UAAU,CAAC,iBAAAA,QAAU,SAAS,mCAAmC;AAAA,MACjE,WAAW;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,IACb;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":["validator"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/organization.types.ts"],"sourcesContent":["import type { RenameId } from '@utils/mongoDB/types';\nimport type { Document, Model, ObjectIdToString, Types } from 'mongoose';\nimport type { Plan } from './plan.types';\nimport type { User } from './user.types';\n\nexport type OrganizationCreationData = {\n name: Organization['name'];\n};\n\nexport type OrganizationData = {\n name: string;\n membersIds: User['id'][];\n adminsIds: User['id'][];\n};\n\nexport type Organization = OrganizationData & {\n id: Types.ObjectId;\n creatorId: User['id'];\n plan?: Plan;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type OrganizationAPI = ObjectIdToString<\n Omit<Organization, 'adminsIds'> & {\n adminsIds?: User['id'][];\n }\n>;\n\nexport type OrganizationSchema = RenameId<Organization>;\nexport type OrganizationModelType = Model<Organization>;\nexport type OrganizationDocument = Document<unknown, {}, Organization> &\n Organization;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/organization.types.ts"],"sourcesContent":["import type { RenameId } from '@utils/mongoDB/types';\nimport type { Document, Model, ObjectIdToString, Types } from 'mongoose';\nimport type { Plan } from './plan.types';\nimport type { User } from './user.types';\n\nexport type OrganizationCreationData = {\n name: Organization['name'];\n};\n\nexport type OrganizationData = {\n name: string;\n membersIds: User['id'][];\n adminsIds: User['id'][];\n};\n\nexport type Organization = OrganizationData & {\n id: Types.ObjectId;\n creatorId: User['id'];\n plan?: Plan;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type OrganizationAPI = ObjectIdToString<Organization>;\n\nexport type OrganizationSchema = RenameId<Organization>;\nexport type OrganizationModelType = Model<Organization>;\nexport type OrganizationDocument = Document<unknown, {}, Organization> &\n Organization;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/project.types.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/config';\nimport { RenameId } from '@utils/mongoDB/types';\nimport type { Document, Model, ObjectIdToString, Types } from 'mongoose';\nimport { Token } from 'oauth2-server';\nimport type { Organization, OrganizationAPI } from './organization.types';\nimport type { User, UserAPI } from './user.types';\n\nexport type ProjectCreationData = {\n name: Project['name'];\n};\n\ntype ProjectConfigInternationalization = Pick<\n IntlayerConfig['internationalization'],\n 'locales' | 'defaultLocale'\n>;\n\ntype ProjectConfigEditor = Pick<\n IntlayerConfig['editor'],\n 'applicationURL' | 'cmsURL'\n>;\n\nexport type ProjectConfiguration = {\n internationalization: ProjectConfigInternationalization;\n editor: ProjectConfigEditor;\n};\n\nexport type ProjectData = {\n organizationId: Organization['id'];\n name: string;\n membersIds: User['id'][];\n adminsIds: User['id'][];\n creatorId: User['id'];\n configuration?: ProjectConfiguration;\n};\n\nexport type AccessKeyData = {\n name: string;\n grants: string[];\n expiresAt?: Date;\n};\n\nexport type OAuth2AccessData = AccessKeyData & {\n clientId: string;\n clientSecret: string;\n accessToken: string[];\n userId: User['id'];\n};\n\nexport type OAuth2AccessContext = {\n accessToken: Token;\n user?: UserAPI;\n project?: ProjectAPI;\n organization?: OrganizationAPI;\n grants: Token['grants'];\n};\n\nexport type OAuth2Access = OAuth2AccessData & {\n id: Types.ObjectId;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type Project = ProjectData & {\n id: Types.ObjectId;\n createdAt: number;\n updatedAt: number;\n oAuth2Access: OAuth2Access[];\n};\n\nexport type ProjectAPI = ObjectIdToString<\n Omit<Project, 'adminsIds'> & {\n adminsIds?: User['id'][];\n }\n>;\n\nexport type ProjectSchema = RenameId<Project>;\nexport type ProjectModelType = Model<Project>;\nexport type ProjectDocument = Document<unknown, {}, Project> & Project;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/project.types.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/config';\nimport { RenameId } from '@utils/mongoDB/types';\nimport type { Document, Model, ObjectIdToString, Types } from 'mongoose';\nimport { Token } from 'oauth2-server';\nimport type { Organization, OrganizationAPI } from './organization.types';\nimport type { User, UserAPI } from './user.types';\n\nexport type ProjectCreationData = {\n name: Project['name'];\n};\n\ntype ProjectConfigInternationalization = Pick<\n IntlayerConfig['internationalization'],\n 'locales' | 'defaultLocale'\n>;\n\ntype ProjectConfigEditor = Pick<\n IntlayerConfig['editor'],\n 'applicationURL' | 'cmsURL'\n>;\n\nexport type ProjectConfiguration = {\n internationalization: ProjectConfigInternationalization;\n editor: ProjectConfigEditor;\n};\n\nexport type ProjectData = {\n organizationId: Organization['id'];\n name: string;\n membersIds: User['id'][];\n adminsIds: User['id'][];\n creatorId: User['id'];\n configuration?: ProjectConfiguration;\n};\n\nexport type AccessKeyData = {\n name: string;\n grants: string[];\n expiresAt?: Date;\n};\n\nexport type OAuth2AccessData = AccessKeyData & {\n clientId: string;\n clientSecret: string;\n accessToken: string[];\n userId: User['id'];\n};\n\nexport type OAuth2AccessContext = {\n accessToken: Token;\n user?: UserAPI;\n project?: ProjectAPI;\n organization?: OrganizationAPI;\n grants: Token['grants'];\n};\n\nexport type OAuth2Access = OAuth2AccessData & {\n id: Types.ObjectId;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type Project = ProjectData & {\n id: Types.ObjectId;\n createdAt: number;\n updatedAt: number;\n oAuth2Access: OAuth2Access[];\n};\n\nexport type ProjectAPI = ObjectIdToString<Project>;\n\nexport type ProjectSchema = RenameId<Project>;\nexport type ProjectModelType = Model<Project>;\nexport type ProjectDocument = Document<unknown, {}, Project> & Project;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -107,6 +107,9 @@ const indexMarkdownFiles = async () => {
107
107
  import_dotenv.default.config({
108
108
  path: [`.env.${env}.local`, `.env.${env}`, ".env.local", ".env"]
109
109
  });
110
+ if (process.env.SKIP_DOC_EMBEDDINGS_INDEX === "true") {
111
+ return;
112
+ }
110
113
  const frequentQuestions = await (0, import_docs.getFrequentQuestions)();
111
114
  const docs = await (0, import_docs.getDocs)();
112
115
  const blogs = await (0, import_docs.getBlogs)();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/utils/AI/askDocQuestion/askDocQuestion.ts"],"sourcesContent":["import { getBlogs, getDocs, getFrequentQuestions } from '@intlayer/docs';\nimport { streamText } from 'ai';\nimport dotenv from 'dotenv';\nimport { readFileSync, writeFileSync } from 'fs';\nimport { getMarkdownMetadata } from 'intlayer';\nimport { OpenAI } from 'openai';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport {\n AIConfig,\n AIOptions,\n AIProvider,\n ChatCompletionRequestMessage,\n} from '../aiSdk';\nimport embeddingsList from './embeddings.json' with { type: 'json' };\n\ntype VectorStoreEl = {\n fileKey: string;\n chunkNumber: number;\n content: string;\n embedding: number[];\n docUrl: string;\n docName: string;\n};\n\n/**\n * Simple in-memory vector store to hold document embeddings and their content.\n * Each entry contains:\n * - fileKey: A unique key identifying the file\n * - chunkNumber: The number of the chunk within the document\n * - content: The chunk content\n * - embedding: The numerical embedding vector for the chunk\n */\nconst vectorStore: VectorStoreEl[] = [];\n\n/*\n * Ask question AI configuration\n */\nconst MODEL: AIOptions['model'] = 'chatgpt-4o-latest'; // Model to use for chat completions\nconst MODEL_TEMPERATURE: AIOptions['temperature'] = 0.1; // Temperature to use for chat completions\nconst MAX_RELEVANT_CHUNKS_NB: number = 20; // Maximum number of relevant chunks to attach to chatGPT context\nconst MIN_RELEVANT_CHUNKS_SIMILARITY: number = 0.42; // Minimum similarity required for a chunk to be considered relevant\n\nexport const aiDefaultOptions: AIOptions = {\n provider: AIProvider.OPENAI,\n model: MODEL,\n temperature: MODEL_TEMPERATURE,\n};\n\n/*\n * Embedding model configuration\n */\nconst EMBEDDING_MODEL: OpenAI.EmbeddingModel = 'text-embedding-3-large'; // Model to use for embedding generation\nconst OVERLAP_TOKENS: number = 200; // Number of tokens to overlap between chunks\nconst MAX_CHUNK_TOKENS: number = 800; // Maximum number of tokens per chunk\nconst CHAR_BY_TOKEN: number = 4.15; // Approximate pessimistically the number of characters per token // Can use `tiktoken` or other tokenizers to calculate it more precisely\nconst MAX_CHARS: number = MAX_CHUNK_TOKENS * CHAR_BY_TOKEN;\nconst OVERLAP_CHARS: number = OVERLAP_TOKENS * CHAR_BY_TOKEN;\n\n/**\n * Splits a given text into chunks ensuring each chunk does not exceed MAX_CHARS.\n * @param text - The input text to split.\n * @returns - Array of text chunks.\n */\nconst chunkText = (text: string): string[] => {\n const chunks: string[] = [];\n let start = 0;\n\n while (start < text.length) {\n let end = Math.min(start + MAX_CHARS, text.length);\n\n // Ensure we don't cut words in the middle (find nearest space)\n if (end < text.length) {\n const lastSpace = text.lastIndexOf(' ', end);\n if (lastSpace > start) {\n end = lastSpace;\n }\n }\n\n chunks.push(text.substring(start, end));\n\n // Move start forward correctly\n const nextStart = end - OVERLAP_CHARS;\n if (nextStart <= start) {\n // Prevent infinite loop if overlap is too large\n start = end;\n } else {\n start = nextStart;\n }\n }\n\n return chunks;\n};\n\n/**\n * Generates an embedding for a given text using OpenAI's embedding API.\n * Trims the text if it exceeds the maximum allowed characters.\n *\n * @param text - The input text to generate an embedding for\n * @returns The embedding vector as a number array\n */\nconst generateEmbedding = async (text: string): Promise<number[]> => {\n try {\n const openaiClient = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });\n\n const response = await openaiClient.embeddings.create({\n model: EMBEDDING_MODEL,\n input: text,\n });\n\n return response.data[0].embedding;\n } catch (error) {\n console.error('Error generating embedding:', error);\n return [];\n }\n};\n\n/**\n * Calculates the cosine similarity between two vectors.\n * Cosine similarity measures the cosine of the angle between two vectors in an inner product space.\n * Used to determine the similarity between chunks of text.\n *\n * @param vecA - The first vector\n * @param vecB - The second vector\n * @returns The cosine similarity score\n */\nconst cosineSimilarity = (vecA: number[], vecB: number[]): number => {\n // Calculate the dot product of the two vectors\n const dotProduct = vecA.reduce((sum, a, idx) => sum + a * vecB[idx], 0);\n\n // Calculate the magnitude (Euclidean norm) of each vector\n const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));\n const magnitudeB = Math.sqrt(vecB.reduce((sum, b) => sum + b * b, 0));\n\n // Compute and return the cosine similarity\n return dotProduct / (magnitudeA * magnitudeB);\n};\n\n/**\n * Indexes all Markdown documents by generating embeddings for each chunk and storing them in memory.\n * Also updates the embeddings.json file if new embeddings are generated.\n * Handles cases where files have been updated and chunk counts have changed.\n */\nexport const indexMarkdownFiles = async (): Promise<void> => {\n const env = process.env.NODE_ENV;\n dotenv.config({\n path: [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'],\n });\n\n // Retrieve documentation and blog posts in English locale\n const frequentQuestions = await getFrequentQuestions();\n const docs = await getDocs();\n const blogs = await getBlogs();\n\n let result: Record<string, number[]> = {}; // Object to hold updated embeddings\n const currentChunkKeys = new Set<string>(); // Track which chunks should exist\n\n const files = { ...docs, ...blogs, ...frequentQuestions }; // Combine docs and blogs into a single object\n\n // Iterate over each file key (identifier) in the combined files\n for await (const fileKey of Object.keys(files)) {\n // Get the metadata of the file\n const fileMetadata = getMarkdownMetadata(\n files[fileKey as keyof typeof files] as string\n );\n\n // Split the document into chunks based on headings\n const fileChunks = chunkText(\n files[fileKey as keyof typeof files] as string\n );\n\n // Check if the number of chunks has changed for this file\n const existingChunksForFile = Object.keys(embeddingsList).filter((key) =>\n key.startsWith(`${fileKey}/chunk_`)\n );\n const currentChunkCount = fileChunks.length;\n const previousChunkCount = existingChunksForFile.length;\n\n let shouldRegenerateFileEmbeddings = false;\n\n // If chunk count differs, we need to regenerate embeddings for this file\n if (currentChunkCount !== previousChunkCount) {\n console.info(\n `File \"${fileKey}\" chunk count changed: ${previousChunkCount} -> ${currentChunkCount}. Regenerating embeddings.`\n );\n shouldRegenerateFileEmbeddings = true;\n }\n\n // Iterate over each chunk within the current file\n for await (const chunkIndex of Object.keys(fileChunks)) {\n const chunkNumber = Number(chunkIndex) + 1; // Chunk number starts at 1\n const chunksNumber = fileChunks.length;\n\n const fileChunk = fileChunks[\n chunkIndex as keyof typeof fileChunks\n ] as string;\n\n const embeddingKeyName = `${fileKey}/chunk_${chunkNumber}`; // Unique key for the chunk\n currentChunkKeys.add(embeddingKeyName); // Track this chunk as current\n\n // Retrieve precomputed embedding if available and file hasn't changed\n const docEmbedding = !shouldRegenerateFileEmbeddings\n ? (embeddingsList[embeddingKeyName as keyof typeof embeddingsList] as\n | number[]\n | undefined)\n : undefined;\n\n let embedding = docEmbedding; // Use existing embedding if available and valid\n\n if (!embedding) {\n embedding = await generateEmbedding(fileChunk); // Generate embedding if not present or file changed\n console.info(`- Generated new embedding: ${embeddingKeyName}`);\n }\n\n // Update the result object with the embedding\n result = { ...result, [embeddingKeyName]: embedding };\n\n // Store the embedding and content in the in-memory vector store\n vectorStore.push({\n fileKey,\n chunkNumber,\n embedding,\n content: fileChunk,\n docUrl: fileMetadata.url,\n docName: fileMetadata.title,\n });\n\n console.info(`- Indexed: ${embeddingKeyName}/${chunksNumber}`);\n }\n }\n\n // Remove outdated embeddings that no longer exist in current files\n const filteredEmbeddings: Record<string, number[]> = {};\n for (const [key, embedding] of Object.entries(embeddingsList)) {\n if (currentChunkKeys.has(key)) {\n // Only keep embeddings for chunks that still exist\n if (!result[key]) {\n filteredEmbeddings[key] = embedding as number[];\n }\n }\n }\n\n // Merge filtered existing embeddings with new ones\n result = { ...filteredEmbeddings, ...result };\n\n if (process.env.NODE_ENV === 'development') {\n try {\n // Compare the newly generated embeddings with existing ones\n if (JSON.stringify(result) !== JSON.stringify(embeddingsList)) {\n // If there are new embeddings or changes, save them to embeddings.json\n writeFileSync(\n 'src/utils/AI/askDocQuestion/embeddings.json',\n JSON.stringify(result, null, 2)\n );\n console.info('Updated embeddings.json with new/changed embeddings.');\n }\n } catch (error) {\n console.error(error); // Log any errors during the file write process\n }\n }\n};\n\n// Automatically index Markdown files\nindexMarkdownFiles();\n\n/**\n * Searches the indexed documents for the most relevant chunks based on a query.\n * Utilizes cosine similarity to find the closest matching embeddings.\n *\n * @param query - The search query provided by the user\n * @returns An array of the top matching document chunks' content\n */\nexport const searchChunkReference = async (\n query: string,\n maxResults: number = MAX_RELEVANT_CHUNKS_NB,\n minSimilarity: number = MIN_RELEVANT_CHUNKS_SIMILARITY\n): Promise<VectorStoreEl[]> => {\n // Generate an embedding for the user's query\n const queryEmbedding = await generateEmbedding(query);\n\n // Calculate similarity scores between the query embedding and each document's embedding\n const selection = vectorStore\n .map((chunk) => ({\n ...chunk,\n similarity: cosineSimilarity(queryEmbedding, chunk.embedding), // Add similarity score to each doc\n }))\n .filter((chunk) => chunk.similarity > minSimilarity) // Filter out documents with low similarity scores\n .sort((a, b) => b.similarity - a.similarity) // Sort documents by highest similarity first\n .slice(0, maxResults); // Select the top 6 most similar documents\n\n const orderedDocKeys = new Set(selection.map((chunk) => chunk.fileKey));\n\n const orderedVectorStore = vectorStore.sort((a, b) =>\n orderedDocKeys.has(a.fileKey) ? -1 : 1\n );\n\n const results = orderedVectorStore.filter((chunk) =>\n selection.some(\n (v) => v.fileKey === chunk.fileKey && v.chunkNumber === chunk.chunkNumber\n )\n );\n\n console.log({ orderedDocKeys });\n\n // Return the content of the top matching documents\n return results;\n};\n\n/**\n * Reads the content of a file synchronously.\n *\n * @function\n * @param relativeFilePath - The relative or absolute path to the target file.\n * @returns The entire contents of the specified file as a UTF-8 encoded string.\n */\nconst getFileContent = (relativeFilePath: string): string => {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n const absolutePath = join(__dirname, relativeFilePath);\n const fileContent = readFileSync(absolutePath, 'utf-8');\n return fileContent;\n};\n\nconst CHAT_GPT_PROMPT = getFileContent('./PROMPT.md');\n\n// Initial prompt configuration for the chatbot\nexport const initPrompt: ChatCompletionRequestMessage = {\n role: 'system',\n content: CHAT_GPT_PROMPT,\n};\n\nexport type AskDocQuestionResult = {\n response: string;\n relatedFiles: string[];\n};\n\nexport type AskDocQuestionOptions = {\n onMessage?: (chunk: string) => void;\n};\n\n/**\n * Handles the \"Ask a question\" endpoint in an Express.js route.\n * Processes user messages, retrieves relevant documents, and interacts with AI models to generate responses.\n *\n * @param messages - An array of chat messages from the user and assistant\n * @returns The assistant's response as a string\n */\nexport const askDocQuestion = async (\n messages: ChatCompletionRequestMessage[],\n aiConfig: AIConfig,\n options?: AskDocQuestionOptions\n): Promise<AskDocQuestionResult> => {\n // Format the user's question to keep only the relevant keywords\n const query = messages\n .filter((message) => message.role === 'user')\n .map((message) => `- ${message.content}`)\n .join('\\n');\n\n // 1) Find relevant documents based on the user's question\n const relevantFilesReferences = await searchChunkReference(query);\n\n // 2) Integrate the relevant documents into the initial system prompt\n const systemPrompt = initPrompt.content.replace(\n '{{relevantFilesReferences}}',\n relevantFilesReferences.length === 0\n ? 'Not relevant file found related to the question.'\n : relevantFilesReferences\n .map((doc, idx) =>\n [\n '-----',\n '---',\n `chunkId: ${idx}`,\n `docChunk: \"${doc.chunkNumber}/${doc.fileKey.length}\"`,\n `docName: \"${doc.docName}\"`,\n `docUrl: \"${doc.docUrl}\"`,\n `---`,\n doc.content,\n `-----`,\n ].join('\\n')\n )\n .join('\\n\\n') // Insert relevant docs into the prompt\n );\n\n // Format messages for AI SDK\n const aiMessages = [\n {\n role: 'system' as const,\n content: systemPrompt,\n },\n ...messages.slice(-8),\n ];\n\n if (!aiConfig) {\n throw new Error('Failed to initialize AI configuration');\n }\n\n // 3) Use the AI SDK to stream the response\n let fullResponse = '';\n const stream = streamText({\n ...aiConfig,\n messages: aiMessages,\n });\n\n // Process the stream\n for await (const chunk of stream.textStream) {\n fullResponse += chunk;\n options?.onMessage?.(chunk);\n }\n\n // 4) Extract unique related files\n const relatedFiles = [\n ...new Set(relevantFilesReferences.map((doc) => doc.fileKey)),\n ];\n\n // 5) Return the assistant's response to the user\n return {\n response: fullResponse ?? 'Error: No result found',\n relatedFiles,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwD;AACxD,gBAA2B;AAC3B,oBAAmB;AACnB,gBAA4C;AAC5C,sBAAoC;AACpC,oBAAuB;AACvB,kBAA8B;AAC9B,iBAA8B;AAC9B,mBAKO;AACP,wBAA2B;AAd3B;AAiCA,MAAM,cAA+B,CAAC;AAKtC,MAAM,QAA4B;AAClC,MAAM,oBAA8C;AACpD,MAAM,yBAAiC;AACvC,MAAM,iCAAyC;AAExC,MAAM,mBAA8B;AAAA,EACzC,UAAU,wBAAW;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AACf;AAKA,MAAM,kBAAyC;AAC/C,MAAM,iBAAyB;AAC/B,MAAM,mBAA2B;AACjC,MAAM,gBAAwB;AAC9B,MAAM,YAAoB,mBAAmB;AAC7C,MAAM,gBAAwB,iBAAiB;AAO/C,MAAM,YAAY,CAAC,SAA2B;AAC5C,QAAM,SAAmB,CAAC;AAC1B,MAAI,QAAQ;AAEZ,SAAO,QAAQ,KAAK,QAAQ;AAC1B,QAAI,MAAM,KAAK,IAAI,QAAQ,WAAW,KAAK,MAAM;AAGjD,QAAI,MAAM,KAAK,QAAQ;AACrB,YAAM,YAAY,KAAK,YAAY,KAAK,GAAG;AAC3C,UAAI,YAAY,OAAO;AACrB,cAAM;AAAA,MACR;AAAA,IACF;AAEA,WAAO,KAAK,KAAK,UAAU,OAAO,GAAG,CAAC;AAGtC,UAAM,YAAY,MAAM;AACxB,QAAI,aAAa,OAAO;AAEtB,cAAQ;AAAA,IACV,OAA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AAG,IAAI,IAAI,wBAAwB,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;AAAA,EAC9D;AAGA,SAAO;AAAA,IACL,UAAU,gBAAgB;AAAA,IAC1B;AAAA,EACF;AACF;","names":["dotenv","embeddingsList"]}
1
+ {"version":3,"sources":["../../../../../src/utils/AI/askDocQuestion/askDocQuestion.ts"],"sourcesContent":["import { getBlogs, getDocs, getFrequentQuestions } from '@intlayer/docs';\nimport { streamText } from 'ai';\nimport dotenv from 'dotenv';\nimport { readFileSync, writeFileSync } from 'fs';\nimport { getMarkdownMetadata } from 'intlayer';\nimport { OpenAI } from 'openai';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport {\n AIConfig,\n AIOptions,\n AIProvider,\n ChatCompletionRequestMessage,\n} from '../aiSdk';\nimport embeddingsList from './embeddings.json' with { type: 'json' };\n\ntype VectorStoreEl = {\n fileKey: string;\n chunkNumber: number;\n content: string;\n embedding: number[];\n docUrl: string;\n docName: string;\n};\n\n/**\n * Simple in-memory vector store to hold document embeddings and their content.\n * Each entry contains:\n * - fileKey: A unique key identifying the file\n * - chunkNumber: The number of the chunk within the document\n * - content: The chunk content\n * - embedding: The numerical embedding vector for the chunk\n */\nconst vectorStore: VectorStoreEl[] = [];\n\n/*\n * Ask question AI configuration\n */\nconst MODEL: AIOptions['model'] = 'chatgpt-4o-latest'; // Model to use for chat completions\nconst MODEL_TEMPERATURE: AIOptions['temperature'] = 0.1; // Temperature to use for chat completions\nconst MAX_RELEVANT_CHUNKS_NB: number = 20; // Maximum number of relevant chunks to attach to chatGPT context\nconst MIN_RELEVANT_CHUNKS_SIMILARITY: number = 0.42; // Minimum similarity required for a chunk to be considered relevant\n\nexport const aiDefaultOptions: AIOptions = {\n provider: AIProvider.OPENAI,\n model: MODEL,\n temperature: MODEL_TEMPERATURE,\n};\n\n/*\n * Embedding model configuration\n */\nconst EMBEDDING_MODEL: OpenAI.EmbeddingModel = 'text-embedding-3-large'; // Model to use for embedding generation\nconst OVERLAP_TOKENS: number = 200; // Number of tokens to overlap between chunks\nconst MAX_CHUNK_TOKENS: number = 800; // Maximum number of tokens per chunk\nconst CHAR_BY_TOKEN: number = 4.15; // Approximate pessimistically the number of characters per token // Can use `tiktoken` or other tokenizers to calculate it more precisely\nconst MAX_CHARS: number = MAX_CHUNK_TOKENS * CHAR_BY_TOKEN;\nconst OVERLAP_CHARS: number = OVERLAP_TOKENS * CHAR_BY_TOKEN;\n\n/**\n * Splits a given text into chunks ensuring each chunk does not exceed MAX_CHARS.\n * @param text - The input text to split.\n * @returns - Array of text chunks.\n */\nconst chunkText = (text: string): string[] => {\n const chunks: string[] = [];\n let start = 0;\n\n while (start < text.length) {\n let end = Math.min(start + MAX_CHARS, text.length);\n\n // Ensure we don't cut words in the middle (find nearest space)\n if (end < text.length) {\n const lastSpace = text.lastIndexOf(' ', end);\n if (lastSpace > start) {\n end = lastSpace;\n }\n }\n\n chunks.push(text.substring(start, end));\n\n // Move start forward correctly\n const nextStart = end - OVERLAP_CHARS;\n if (nextStart <= start) {\n // Prevent infinite loop if overlap is too large\n start = end;\n } else {\n start = nextStart;\n }\n }\n\n return chunks;\n};\n\n/**\n * Generates an embedding for a given text using OpenAI's embedding API.\n * Trims the text if it exceeds the maximum allowed characters.\n *\n * @param text - The input text to generate an embedding for\n * @returns The embedding vector as a number array\n */\nconst generateEmbedding = async (text: string): Promise<number[]> => {\n try {\n const openaiClient = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });\n\n const response = await openaiClient.embeddings.create({\n model: EMBEDDING_MODEL,\n input: text,\n });\n\n return response.data[0].embedding;\n } catch (error) {\n console.error('Error generating embedding:', error);\n return [];\n }\n};\n\n/**\n * Calculates the cosine similarity between two vectors.\n * Cosine similarity measures the cosine of the angle between two vectors in an inner product space.\n * Used to determine the similarity between chunks of text.\n *\n * @param vecA - The first vector\n * @param vecB - The second vector\n * @returns The cosine similarity score\n */\nconst cosineSimilarity = (vecA: number[], vecB: number[]): number => {\n // Calculate the dot product of the two vectors\n const dotProduct = vecA.reduce((sum, a, idx) => sum + a * vecB[idx], 0);\n\n // Calculate the magnitude (Euclidean norm) of each vector\n const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));\n const magnitudeB = Math.sqrt(vecB.reduce((sum, b) => sum + b * b, 0));\n\n // Compute and return the cosine similarity\n return dotProduct / (magnitudeA * magnitudeB);\n};\n\n/**\n * Indexes all Markdown documents by generating embeddings for each chunk and storing them in memory.\n * Also updates the embeddings.json file if new embeddings are generated.\n * Handles cases where files have been updated and chunk counts have changed.\n */\nexport const indexMarkdownFiles = async (): Promise<void> => {\n const env = process.env.NODE_ENV;\n dotenv.config({\n path: [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'],\n });\n\n if (process.env.SKIP_DOC_EMBEDDINGS_INDEX === 'true') {\n return;\n }\n\n // Retrieve documentation and blog posts in English locale\n const frequentQuestions = await getFrequentQuestions();\n const docs = await getDocs();\n const blogs = await getBlogs();\n\n let result: Record<string, number[]> = {}; // Object to hold updated embeddings\n const currentChunkKeys = new Set<string>(); // Track which chunks should exist\n\n const files = { ...docs, ...blogs, ...frequentQuestions }; // Combine docs and blogs into a single object\n\n // Iterate over each file key (identifier) in the combined files\n for await (const fileKey of Object.keys(files)) {\n // Get the metadata of the file\n const fileMetadata = getMarkdownMetadata(\n files[fileKey as keyof typeof files] as string\n );\n\n // Split the document into chunks based on headings\n const fileChunks = chunkText(\n files[fileKey as keyof typeof files] as string\n );\n\n // Check if the number of chunks has changed for this file\n const existingChunksForFile = Object.keys(embeddingsList).filter((key) =>\n key.startsWith(`${fileKey}/chunk_`)\n );\n const currentChunkCount = fileChunks.length;\n const previousChunkCount = existingChunksForFile.length;\n\n let shouldRegenerateFileEmbeddings = false;\n\n // If chunk count differs, we need to regenerate embeddings for this file\n if (currentChunkCount !== previousChunkCount) {\n console.info(\n `File \"${fileKey}\" chunk count changed: ${previousChunkCount} -> ${currentChunkCount}. Regenerating embeddings.`\n );\n shouldRegenerateFileEmbeddings = true;\n }\n\n // Iterate over each chunk within the current file\n for await (const chunkIndex of Object.keys(fileChunks)) {\n const chunkNumber = Number(chunkIndex) + 1; // Chunk number starts at 1\n const chunksNumber = fileChunks.length;\n\n const fileChunk = fileChunks[\n chunkIndex as keyof typeof fileChunks\n ] as string;\n\n const embeddingKeyName = `${fileKey}/chunk_${chunkNumber}`; // Unique key for the chunk\n currentChunkKeys.add(embeddingKeyName); // Track this chunk as current\n\n // Retrieve precomputed embedding if available and file hasn't changed\n const docEmbedding = !shouldRegenerateFileEmbeddings\n ? (embeddingsList[embeddingKeyName as keyof typeof embeddingsList] as\n | number[]\n | undefined)\n : undefined;\n\n let embedding = docEmbedding; // Use existing embedding if available and valid\n\n if (!embedding) {\n embedding = await generateEmbedding(fileChunk); // Generate embedding if not present or file changed\n console.info(`- Generated new embedding: ${embeddingKeyName}`);\n }\n\n // Update the result object with the embedding\n result = { ...result, [embeddingKeyName]: embedding };\n\n // Store the embedding and content in the in-memory vector store\n vectorStore.push({\n fileKey,\n chunkNumber,\n embedding,\n content: fileChunk,\n docUrl: fileMetadata.url,\n docName: fileMetadata.title,\n });\n\n console.info(`- Indexed: ${embeddingKeyName}/${chunksNumber}`);\n }\n }\n\n // Remove outdated embeddings that no longer exist in current files\n const filteredEmbeddings: Record<string, number[]> = {};\n for (const [key, embedding] of Object.entries(embeddingsList)) {\n if (currentChunkKeys.has(key)) {\n // Only keep embeddings for chunks that still exist\n if (!result[key]) {\n filteredEmbeddings[key] = embedding as number[];\n }\n }\n }\n\n // Merge filtered existing embeddings with new ones\n result = { ...filteredEmbeddings, ...result };\n\n if (process.env.NODE_ENV === 'development') {\n try {\n // Compare the newly generated embeddings with existing ones\n if (JSON.stringify(result) !== JSON.stringify(embeddingsList)) {\n // If there are new embeddings or changes, save them to embeddings.json\n writeFileSync(\n 'src/utils/AI/askDocQuestion/embeddings.json',\n JSON.stringify(result, null, 2)\n );\n console.info('Updated embeddings.json with new/changed embeddings.');\n }\n } catch (error) {\n console.error(error); // Log any errors during the file write process\n }\n }\n};\n\n// Automatically index Markdown files\nindexMarkdownFiles();\n\n/**\n * Searches the indexed documents for the most relevant chunks based on a query.\n * Utilizes cosine similarity to find the closest matching embeddings.\n *\n * @param query - The search query provided by the user\n * @returns An array of the top matching document chunks' content\n */\nexport const searchChunkReference = async (\n query: string,\n maxResults: number = MAX_RELEVANT_CHUNKS_NB,\n minSimilarity: number = MIN_RELEVANT_CHUNKS_SIMILARITY\n): Promise<VectorStoreEl[]> => {\n // Generate an embedding for the user's query\n const queryEmbedding = await generateEmbedding(query);\n\n // Calculate similarity scores between the query embedding and each document's embedding\n const selection = vectorStore\n .map((chunk) => ({\n ...chunk,\n similarity: cosineSimilarity(queryEmbedding, chunk.embedding), // Add similarity score to each doc\n }))\n .filter((chunk) => chunk.similarity > minSimilarity) // Filter out documents with low similarity scores\n .sort((a, b) => b.similarity - a.similarity) // Sort documents by highest similarity first\n .slice(0, maxResults); // Select the top 6 most similar documents\n\n const orderedDocKeys = new Set(selection.map((chunk) => chunk.fileKey));\n\n const orderedVectorStore = vectorStore.sort((a, b) =>\n orderedDocKeys.has(a.fileKey) ? -1 : 1\n );\n\n const results = orderedVectorStore.filter((chunk) =>\n selection.some(\n (v) => v.fileKey === chunk.fileKey && v.chunkNumber === chunk.chunkNumber\n )\n );\n\n console.log({ orderedDocKeys });\n\n // Return the content of the top matching documents\n return results;\n};\n\n/**\n * Reads the content of a file synchronously.\n *\n * @function\n * @param relativeFilePath - The relative or absolute path to the target file.\n * @returns The entire contents of the specified file as a UTF-8 encoded string.\n */\nconst getFileContent = (relativeFilePath: string): string => {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n const absolutePath = join(__dirname, relativeFilePath);\n const fileContent = readFileSync(absolutePath, 'utf-8');\n return fileContent;\n};\n\nconst CHAT_GPT_PROMPT = getFileContent('./PROMPT.md');\n\n// Initial prompt configuration for the chatbot\nexport const initPrompt: ChatCompletionRequestMessage = {\n role: 'system',\n content: CHAT_GPT_PROMPT,\n};\n\nexport type AskDocQuestionResult = {\n response: string;\n relatedFiles: string[];\n};\n\nexport type AskDocQuestionOptions = {\n onMessage?: (chunk: string) => void;\n};\n\n/**\n * Handles the \"Ask a question\" endpoint in an Express.js route.\n * Processes user messages, retrieves relevant documents, and interacts with AI models to generate responses.\n *\n * @param messages - An array of chat messages from the user and assistant\n * @returns The assistant's response as a string\n */\nexport const askDocQuestion = async (\n messages: ChatCompletionRequestMessage[],\n aiConfig: AIConfig,\n options?: AskDocQuestionOptions\n): Promise<AskDocQuestionResult> => {\n // Format the user's question to keep only the relevant keywords\n const query = messages\n .filter((message) => message.role === 'user')\n .map((message) => `- ${message.content}`)\n .join('\\n');\n\n // 1) Find relevant documents based on the user's question\n const relevantFilesReferences = await searchChunkReference(query);\n\n // 2) Integrate the relevant documents into the initial system prompt\n const systemPrompt = initPrompt.content.replace(\n '{{relevantFilesReferences}}',\n relevantFilesReferences.length === 0\n ? 'Not relevant file found related to the question.'\n : relevantFilesReferences\n .map((doc, idx) =>\n [\n '-----',\n '---',\n `chunkId: ${idx}`,\n `docChunk: \"${doc.chunkNumber}/${doc.fileKey.length}\"`,\n `docName: \"${doc.docName}\"`,\n `docUrl: \"${doc.docUrl}\"`,\n `---`,\n doc.content,\n `-----`,\n ].join('\\n')\n )\n .join('\\n\\n') // Insert relevant docs into the prompt\n );\n\n // Format messages for AI SDK\n const aiMessages = [\n {\n role: 'system' as const,\n content: systemPrompt,\n },\n ...messages.slice(-8),\n ];\n\n if (!aiConfig) {\n throw new Error('Failed to initialize AI configuration');\n }\n\n // 3) Use the AI SDK to stream the response\n let fullResponse = '';\n const stream = streamText({\n ...aiConfig,\n messages: aiMessages,\n });\n\n // Process the stream\n for await (const chunk of stream.textStream) {\n fullResponse += chunk;\n options?.onMessage?.(chunk);\n }\n\n // 4) Extract unique related files\n const relatedFiles = [\n ...new Set(relevantFilesReferences.map((doc) => doc.fileKey)),\n ];\n\n // 5) Return the assistant's response to the user\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gB;AAAA,IAC1B;AAAA,EACF;AACF;","names":["dotenv","embeddingsList"]}
@@ -30,6 +30,7 @@ var import_project = require('./../../services/project.service.cjs');
30
30
  var import_user2 = require('./../../services/user.service.cjs');
31
31
  var import_organization2 = require('./../../utils/mapper/organization.cjs');
32
32
  var import_project2 = require('./../../utils/mapper/project.cjs');
33
+ var import_session = require('./../../utils/mapper/session.cjs');
33
34
  var import_user3 = require('./../../utils/mapper/user.cjs');
34
35
  var import_permissions = require('./../../utils/permissions.cjs');
35
36
  var import_better_auth = require("better-auth");
@@ -44,9 +45,9 @@ const formatSession = (session) => {
44
45
  }
45
46
  const resultSession = {
46
47
  session: session.session,
47
- user: (0, import_user3.mapUserToAPI)(session.user),
48
- organization: (0, import_organization2.mapOrganizationToAPI)(session.organization),
49
- project: (0, import_project2.mapProjectToAPI)(session.project),
48
+ user: session.user,
49
+ organization: session.organization,
50
+ project: session.project,
50
51
  authType: "session",
51
52
  permissions,
52
53
  roles
@@ -88,7 +89,7 @@ const getAuth = (dbClient) => {
88
89
  },
89
90
  hooks: {
90
91
  after: (0, import_api.createAuthMiddleware)(async (ctx) => {
91
- const { path, context } = ctx;
92
+ const { path, context, error } = ctx;
92
93
  const newUser = context.newSession?.user;
93
94
  const existingUser = context.session?.user;
94
95
  const user = newUser ?? existingUser;
@@ -170,7 +171,8 @@ const getAuth = (dbClient) => {
170
171
  project: projectAPI ?? null,
171
172
  authType: "session"
172
173
  };
173
- return formatSession(sessionWithNoPermission);
174
+ const formattedSession = formatSession(sessionWithNoPermission);
175
+ return (0, import_session.mapSessionToAPI)(formattedSession);
174
176
  })
175
177
  ],
176
178
  emailAndPassword: {
@@ -199,6 +201,7 @@ const getAuth = (dbClient) => {
199
201
  },
200
202
  emailVerification: {
201
203
  autoSignInAfterVerification: true,
204
+ sendOnSignIn: true,
202
205
  sendVerificationEmail: async ({ user, url }) => {
203
206
  import_logger.logger.info("sending verification email", { email: user.email });
204
207
  await (0, import_email.sendEmail)({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/auth/getAuth.ts"],"sourcesContent":["import type { OrganizationAPI } from '@/types/organization.types';\nimport type { ProjectAPI } from '@/types/project.types';\nimport type {\n SessionAPI,\n SessionContext,\n SessionDataApi,\n} from '@/types/session.types';\nimport type { User, UserAPI } from '@/types/user.types';\nimport { sendVerificationUpdate } from '@controllers/user.controller';\nimport { logger } from '@logger';\nimport { sendEmail } from '@services/email.service';\nimport { getOrganizationById } from '@services/organization.service';\nimport { getProjectById } from '@services/project.service';\nimport { getUserById } from '@services/user.service';\nimport { mapOrganizationToAPI } from '@utils/mapper/organization';\nimport { mapProjectToAPI } from '@utils/mapper/project';\nimport { mapUserToAPI } from '@utils/mapper/user';\nimport {\n computeEffectivePermission,\n getSessionRoles,\n intersectPermissions,\n} from '@utils/permissions';\nimport { betterAuth, OmitId } from 'better-auth';\nimport { mongodbAdapter } from 'better-auth/adapters/mongodb';\nimport { createAuthMiddleware } from 'better-auth/api';\nimport { customSession } from 'better-auth/plugins';\nimport type { MongoClient } from 'mongodb';\n\nexport type Auth = ReturnType<typeof betterAuth>;\n\nexport const formatSession = (session: SessionContext): OmitId<SessionAPI> => {\n const roles = getSessionRoles(session);\n let permissions = computeEffectivePermission(roles);\n\n // Intersect in the case a Access Token try to override the permissions\n if (session.permissions) {\n permissions = intersectPermissions(permissions, session.permissions);\n }\n\n const resultSession = {\n session: session.session,\n user: mapUserToAPI(session.user),\n organization: mapOrganizationToAPI(session.organization),\n project: mapProjectToAPI(session.project),\n authType: 'session',\n permissions,\n roles,\n } as OmitId<SessionAPI>;\n\n return resultSession;\n};\n\nexport const getAuth = (dbClient: MongoClient): Auth => {\n if (!dbClient) {\n throw new Error('MongoDB connection not established');\n }\n\n const auth = betterAuth({\n appName: 'Intlayer',\n\n database: mongodbAdapter(dbClient.db()),\n\n /**\n * User model\n */\n user: {\n modelName: 'users',\n },\n\n databaseHooks: {\n user: {\n create: {\n // Runs once, immediately after the INSERT\n after: async (user) => {\n if (!user?.emailVerified) return;\n\n await sendEmail({\n type: 'welcome',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n loginLink: `${process.env.CLIENT_URL}/auth/login`,\n locale: (user as any).lang,\n });\n logger.info('Welcome e‑mail delivered', {\n email: user.email,\n });\n },\n },\n },\n },\n\n hooks: {\n after: createAuthMiddleware(async (ctx) => {\n const { path, context } = ctx;\n\n const newUser = context.newSession?.user;\n const existingUser = context.session?.user;\n const user = newUser ?? existingUser;\n\n if (!user) return;\n\n if (['/verify-email'].includes(path)) {\n sendVerificationUpdate(user as unknown as User);\n logger.info('SSE verification update sent', {\n email: user.email,\n userId: user.id,\n });\n\n await sendEmail({\n type: 'welcome',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n loginLink: `${process.env.CLIENT_URL}/auth/login`,\n locale: (user as any).lang,\n });\n logger.info('Welcome e‑mail delivered', {\n email: user.email,\n });\n }\n }),\n },\n\n advanced: {\n // 1️⃣ Change or drop the global prefix\n // cookiePrefix: \"intlayer\", // => intlayer.session_token\n cookiePrefix: 'intlayer', // => session_token (no prefix)\n\n // 2️⃣ Override just the session‑token cookie\n cookies: {\n session_token: {\n // name: 'intlayer_session_token', // final name depends on the prefix above\n // attributes: { sameSite: \"lax\", maxAge: 60 * 60 * 24 } // optional\n },\n },\n\n // 3️⃣ (optional) turn off the automatic __Secure‑ prefix in non‑prod\n // useSecureCookies: false,\n },\n\n session: {\n modelName: 'sessions',\n id: 'id',\n\n additionalFields: {\n activeOrganizationId: { type: 'string', nullable: true, input: false },\n activeProjectId: { type: 'string', nullable: true, input: false },\n },\n },\n\n plugins: [\n customSession(async ({ session }) => {\n const typedSession = session as unknown as SessionDataApi;\n\n let userAPI: UserAPI | null = null;\n let organizationAPI: OrganizationAPI | null = null;\n let projectAPI: ProjectAPI | null = null;\n\n if (typedSession.userId) {\n const userData = await getUserById(typedSession.userId);\n\n if (userData) {\n userAPI = mapUserToAPI(userData);\n }\n }\n\n if (typedSession.activeOrganizationId) {\n const orgData = await getOrganizationById(\n typedSession.activeOrganizationId\n );\n\n if (orgData) {\n organizationAPI = mapOrganizationToAPI(orgData);\n }\n }\n if (typedSession.activeProjectId) {\n const projectData = await getProjectById(\n typedSession.activeProjectId\n );\n\n if (projectData) {\n projectAPI = mapProjectToAPI(projectData);\n }\n }\n\n const sessionWithNoPermission: SessionContext = {\n session: typedSession,\n user: userAPI!,\n organization: organizationAPI ?? null,\n project: projectAPI ?? null,\n authType: 'session',\n };\n\n return formatSession(sessionWithNoPermission);\n }),\n ],\n\n emailAndPassword: {\n enabled: true,\n disableSignUp: false,\n requireEmailVerification: true,\n minPasswordLength: 8,\n maxPasswordLength: 128,\n autoSignIn: true,\n sendResetPassword: async ({ user, url }) => {\n logger.info('sending reset password email', { email: user.email });\n await sendEmail({\n type: 'resetPassword',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n resetLink: url,\n });\n },\n resetPasswordTokenExpiresIn: 3600,\n },\n accountLinking: {\n enabled: true, // allow linking in general\n trustedProviders: ['google', 'github'], // optional: auto‑link when Google verifies the e‑mail\n },\n emailVerification: {\n autoSignInAfterVerification: true,\n sendVerificationEmail: async ({ user, url }) => {\n logger.info('sending verification email', { email: user.email });\n await sendEmail({\n type: 'validate',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n validationLink: url,\n });\n },\n },\n\n crossSubDomainCookies: {\n enabled: true,\n additionalCookies: ['session_token'],\n domain: process.env.CLIENT_URL as string,\n },\n cookiePrefix: 'intlayer',\n cookies: {\n session_token: {\n name: 'session_token',\n attributes: {\n httpOnly: true,\n secure: true,\n },\n },\n },\n\n trustedOrigins: [process.env.CLIENT_URL as string],\n\n socialProviders: {\n google: {\n clientId: process.env.GOOGLE_CLIENT_ID as string,\n clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,\n },\n github: {\n clientId: process.env.GITHUB_CLIENT_ID as string,\n clientSecret: process.env.GITHUB_CLIENT_SECRET as string,\n },\n },\n\n logger: {\n log: (level, message, ...args) => logger[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;AAAA,MACA,6BAA6B;AAAA,IAC/B;AAAA,IACA,gBAAgB;AAAA,MACd,SAAS;AAAA;AAAA,MACT,kBAAkB,CAAC,UAAU,QAAQ;AAAA;AAAA,IACvC;AAAA,IACA,mBAAmB;AAAA,MACjB,6BAA6B;AAAA,MAC7B,uBAAuB,OAAO,EAAE,MAAM,IAAI,MAAM;AAC9C,6BAAO,KAAK,8BAA8B,EAAE,OAAO,KAAK,MAAM,CAAC;AAC/D,kBAAM,wBAAU;AAAA,UACd,MAAM;AAAA,UACN,IAAI,KAAK;AAAA,UACT,UAAU,KAAK,QAAQ,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC;AAAA,UAC9C,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IAEA,uBAAuB;AAAA,MACrB,SAAS;AAAA,MACT,mBAAmB,CAAC,eAAe;AAAA,MACnC,QAAQ,QAAQ,IAAI;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,IACd,SAAS;AAAA,MACP,eAAe;AAAA,QACb,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU;AAAA,UACV,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,IAEA,gBAAgB,CAAC,QAAQ,IAAI,UAAoB;AAAA,IAEjD,iBAAiB;AAAA,MACf,QAAQ;AAAA,QACN,UAAU,QAAQ,IAAI;AAAA,QACtB,cAAc,QAAQ,IAAI;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,QACN,UAAU,QAAQ,IAAI;AAAA,QACtB,cAAc,QAAQ,IAAI;AAAA,MAC5B;AAAA,IACF;AAAA,IAEA,QAAQ;AAAA,MACN,KAAK,CAAC,OAAO,YAAY,SAAS,qBAAO,KAAK,EAAE,SAAS,GAAG,IAAI;AAAA,IAClE;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["import_user","import_organization","import_project"]}
1
+ {"version":3,"sources":["../../../../src/utils/auth/getAuth.ts"],"sourcesContent":["import type { OrganizationAPI } from '@/types/organization.types';\nimport type { ProjectAPI } from '@/types/project.types';\nimport type {\n Session,\n SessionContext,\n SessionDataApi,\n} from '@/types/session.types';\nimport type { User, UserAPI } from '@/types/user.types';\nimport { sendVerificationUpdate } from '@controllers/user.controller';\nimport { logger } from '@logger';\nimport { sendEmail } from '@services/email.service';\nimport { getOrganizationById } from '@services/organization.service';\nimport { getProjectById } from '@services/project.service';\nimport { getUserById } from '@services/user.service';\nimport { mapOrganizationToAPI } from '@utils/mapper/organization';\nimport { mapProjectToAPI } from '@utils/mapper/project';\nimport { mapSessionToAPI } from '@utils/mapper/session';\nimport { mapUserToAPI } from '@utils/mapper/user';\nimport {\n computeEffectivePermission,\n getSessionRoles,\n intersectPermissions,\n} from '@utils/permissions';\nimport { betterAuth, OmitId } from 'better-auth';\nimport { mongodbAdapter } from 'better-auth/adapters/mongodb';\nimport { createAuthMiddleware } from 'better-auth/api';\nimport { customSession } from 'better-auth/plugins';\nimport type { MongoClient } from 'mongodb';\n\nexport type Auth = ReturnType<typeof betterAuth>;\n\nexport const formatSession = (session: SessionContext): OmitId<Session> => {\n const roles = getSessionRoles(session);\n let permissions = computeEffectivePermission(roles);\n\n // Intersect in the case a Access Token try to override the permissions\n if (session.permissions) {\n permissions = intersectPermissions(permissions, session.permissions);\n }\n\n const resultSession = {\n session: session.session,\n user: session.user,\n organization: session.organization,\n project: session.project,\n authType: 'session',\n permissions,\n roles,\n } as OmitId<Session>;\n\n return resultSession;\n};\n\nexport const getAuth = (dbClient: MongoClient): Auth => {\n if (!dbClient) {\n throw new Error('MongoDB connection not established');\n }\n\n const auth = betterAuth({\n appName: 'Intlayer',\n\n database: mongodbAdapter(dbClient.db()),\n\n /**\n * User model\n */\n user: {\n modelName: 'users',\n },\n\n databaseHooks: {\n user: {\n create: {\n // Runs once, immediately after the INSERT\n after: async (user) => {\n if (!user?.emailVerified) return;\n\n await sendEmail({\n type: 'welcome',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n loginLink: `${process.env.CLIENT_URL}/auth/login`,\n locale: (user as any).lang,\n });\n logger.info('Welcome e‑mail delivered', {\n email: user.email,\n });\n },\n },\n },\n },\n\n hooks: {\n after: createAuthMiddleware(async (ctx) => {\n const { path, context, error } = ctx;\n\n const newUser = context.newSession?.user;\n const existingUser = context.session?.user;\n const user = newUser ?? existingUser;\n\n if (!user) return;\n\n if (['/verify-email'].includes(path)) {\n sendVerificationUpdate(user as unknown as User);\n logger.info('SSE verification update sent', {\n email: user.email,\n userId: user.id,\n });\n\n await sendEmail({\n type: 'welcome',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n loginLink: `${process.env.CLIENT_URL}/auth/login`,\n locale: (user as any).lang,\n });\n logger.info('Welcome e‑mail delivered', {\n email: user.email,\n });\n }\n }),\n },\n\n advanced: {\n // 1️⃣ Change or drop the global prefix\n // cookiePrefix: \"intlayer\", // => intlayer.session_token\n cookiePrefix: 'intlayer', // => session_token (no prefix)\n\n // 2️⃣ Override just the session‑token cookie\n cookies: {\n session_token: {\n // name: 'intlayer_session_token', // final name depends on the prefix above\n // attributes: { sameSite: \"lax\", maxAge: 60 * 60 * 24 } // optional\n },\n },\n\n // 3️⃣ (optional) turn off the automatic __Secure‑ prefix in non‑prod\n // useSecureCookies: false,\n },\n\n session: {\n modelName: 'sessions',\n id: 'id',\n\n additionalFields: {\n activeOrganizationId: { type: 'string', nullable: true, input: false },\n activeProjectId: { type: 'string', nullable: true, input: false },\n },\n },\n\n plugins: [\n customSession(async ({ session }) => {\n const typedSession = session as unknown as SessionDataApi;\n\n let userAPI: UserAPI | null = null;\n let organizationAPI: OrganizationAPI | null = null;\n let projectAPI: ProjectAPI | null = null;\n\n if (typedSession.userId) {\n const userData = await getUserById(typedSession.userId);\n\n if (userData) {\n userAPI = mapUserToAPI(userData);\n }\n }\n\n if (typedSession.activeOrganizationId) {\n const orgData = await getOrganizationById(\n typedSession.activeOrganizationId\n );\n\n if (orgData) {\n organizationAPI = mapOrganizationToAPI(orgData);\n }\n }\n if (typedSession.activeProjectId) {\n const projectData = await getProjectById(\n typedSession.activeProjectId\n );\n\n if (projectData) {\n projectAPI = mapProjectToAPI(projectData);\n }\n }\n\n const sessionWithNoPermission: SessionContext = {\n session: typedSession,\n user: userAPI!,\n organization: organizationAPI ?? null,\n project: projectAPI ?? null,\n authType: 'session',\n };\n\n const formattedSession = formatSession(sessionWithNoPermission);\n\n return mapSessionToAPI(formattedSession);\n }),\n ],\n\n emailAndPassword: {\n enabled: true,\n disableSignUp: false,\n requireEmailVerification: true,\n minPasswordLength: 8,\n maxPasswordLength: 128,\n autoSignIn: true,\n sendResetPassword: async ({ user, url }) => {\n logger.info('sending reset password email', { email: user.email });\n await sendEmail({\n type: 'resetPassword',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n resetLink: url,\n });\n },\n resetPasswordTokenExpiresIn: 3600,\n },\n accountLinking: {\n enabled: true, // allow linking in general\n trustedProviders: ['google', 'github'], // optional: auto‑link when Google verifies the e‑mail\n },\n emailVerification: {\n autoSignInAfterVerification: true,\n sendOnSignIn: true,\n sendVerificationEmail: async ({ user, url }) => {\n logger.info('sending verification email', { email: user.email });\n await sendEmail({\n type: 'validate',\n to: user.email,\n username: user.name ?? user.email.split('@')[0],\n validationLink: url,\n });\n },\n },\n\n crossSubDomainCookies: {\n enabled: true,\n additionalCookies: ['session_token'],\n domain: process.env.CLIENT_URL as string,\n },\n cookiePrefix: 'intlayer',\n cookies: {\n session_token: {\n name: 'session_token',\n attributes: {\n httpOnly: true,\n secure: true,\n },\n },\n },\n\n trustedOrigins: [process.env.CLIENT_URL as string],\n\n socialProviders: {\n google: {\n clientId: process.env.GOOGLE_CLIENT_ID as string,\n clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,\n },\n github: {\n clientId: process.env.GITHUB_CLIENT_ID as string,\n clientSecret: process.env.GITHUB_CLIENT_SECRET as string,\n },\n },\n\n logger: {\n log: (level, message, ...args) => logger[level](message, ...args),\n },\n });\n\n return auth;\n};\n"],"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,IAC/B;AAAA,IACA,gBAAgB;AAAA,MACd,SAAS;AAAA;AAAA,MACT,kBAAkB,CAAC,UAAU,QAAQ;AAAA;AAAA,IACvC;AAAA,IACA,mBAAmB;AAAA,MACjB,6BAA6B;AAAA,MAC7B,cAAc;AAAA,MACd,uBAAuB,OAAO,EAAE,MAAM,IAAI,MAAM;AAC9C,6BAAO,KAAK,8BAA8B,EAAE,OAAO,KAAK,MAAM,CAAC;AAC/D,kBAAM,wBAAU;AAAA,UACd,MAAM;AAAA,UACN,IAAI,KAAK;AAAA,UACT,UAAU,KAAK,QAAQ,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC;AAAA,UAC9C,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IAEA,uBAAuB;AAAA,MACrB,SAAS;AAAA,MACT,mBAAmB,CAAC,eAAe;AAAA,MACnC,QAAQ,QAAQ,IAAI;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,IACd,SAAS;AAAA,MACP,eAAe;AAAA,QACb,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU;AAAA,UACV,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,IAEA,gBAAgB,CAAC,QAAQ,IAAI,UAAoB;AAAA,IAEjD,iBAAiB;AAAA,MACf,QAAQ;AAAA,QACN,UAAU,QAAQ,IAAI;AAAA,QACtB,cAAc,QAAQ,IAAI;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,QACN,UAAU,QAAQ,IAAI;AAAA,QACtB,cAAc,QAAQ,IAAI;AAAA,MAC5B;AAAA,IACF;AAAA,IAEA,QAAQ;AAAA,MACN,KAAK,CAAC,OAAO,YAAY,SAAS,qBAAO,KAAK,EAAE,SAAS,GAAG,IAAI;AAAA,IAClE;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["import_user","import_organization","import_project"]}
@@ -1387,6 +1387,19 @@ const errorData = {
1387
1387
  es: "No tienes permisos para acceder a este recurso."
1388
1388
  },
1389
1389
  statusCode: import_httpStatusCodes.HttpStatusCodes.FORBIDDEN_403
1390
+ },
1391
+ INVALID_REQUEST_BODY: {
1392
+ title: {
1393
+ en: "Invalid Request Body",
1394
+ fr: "Corps de requ\xEAte invalide",
1395
+ es: "Cuerpo de solicitud inv\xE1lido"
1396
+ },
1397
+ message: {
1398
+ en: "The request body is invalid.",
1399
+ fr: "Le corps de la requ\xEAte est invalide.",
1400
+ es: "El cuerpo de la solicitud es inv\xE1lido."
1401
+ },
1402
+ statusCode: import_httpStatusCodes.HttpStatusCodes.BAD_REQUEST_400
1390
1403
  }
1391
1404
  };
1392
1405
  // Annotate the CommonJS export names for ESM import in node: