@intlayer/backend 7.2.1-canary.1 → 7.2.3
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.
- package/dist/esm/utils/AI/aiSdk.mjs +7 -1
- package/dist/esm/utils/AI/aiSdk.mjs.map +1 -1
- package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
- package/dist/types/controllers/tag.controller.d.ts.map +1 -1
- package/dist/types/emails/InviteUserEmail.d.ts +4 -4
- package/dist/types/emails/InviteUserEmail.d.ts.map +1 -1
- package/dist/types/emails/MagicLinkEmail.d.ts +4 -4
- package/dist/types/emails/MagicLinkEmail.d.ts.map +1 -1
- package/dist/types/emails/OAuthTokenCreatedEmail.d.ts +4 -4
- package/dist/types/emails/PasswordChangeConfirmation.d.ts +4 -4
- package/dist/types/emails/PasswordChangeConfirmation.d.ts.map +1 -1
- package/dist/types/emails/ResetUserPassword.d.ts +4 -4
- package/dist/types/emails/ResetUserPassword.d.ts.map +1 -1
- package/dist/types/emails/SubscriptionPaymentCancellation.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentCancellation.d.ts.map +1 -1
- package/dist/types/emails/SubscriptionPaymentError.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentSuccess.d.ts +4 -4
- package/dist/types/emails/ValidateUserEmail.d.ts +4 -4
- package/dist/types/emails/Welcome.d.ts +4 -4
- package/dist/types/emails/Welcome.d.ts.map +1 -1
- package/dist/types/models/dictionary.model.d.ts +4 -4
- package/dist/types/models/discussion.model.d.ts +2 -2
- package/dist/types/models/discussion.model.d.ts.map +1 -1
- package/dist/types/models/oAuth2.model.d.ts +3 -3
- package/dist/types/routes/eventListener.routes.d.ts.map +1 -1
- package/dist/types/schemas/dictionary.schema.d.ts +6 -6
- package/dist/types/schemas/dictionary.schema.d.ts.map +1 -1
- package/dist/types/schemas/discussion.schema.d.ts +6 -6
- package/dist/types/schemas/oAuth2.schema.d.ts +5 -5
- package/dist/types/schemas/oAuth2.schema.d.ts.map +1 -1
- package/dist/types/schemas/organization.schema.d.ts +6 -6
- package/dist/types/schemas/plans.schema.d.ts +6 -6
- package/dist/types/schemas/project.schema.d.ts +6 -6
- package/dist/types/schemas/project.schema.d.ts.map +1 -1
- package/dist/types/schemas/tag.schema.d.ts +6 -6
- package/dist/types/schemas/user.schema.d.ts +6 -6
- package/dist/types/utils/filtersAndPagination/getDiscussionFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts +2 -2
- package/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts +2 -2
- package/package.json +17 -18
- package/dist/cjs/_virtual/_utils_asset.cjs +0 -98
- package/dist/cjs/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/cjs/controllers/ai.controller.cjs +0 -381
- package/dist/cjs/controllers/ai.controller.cjs.map +0 -1
- package/dist/cjs/controllers/dictionary.controller.cjs +0 -463
- package/dist/cjs/controllers/dictionary.controller.cjs.map +0 -1
- package/dist/cjs/controllers/eventListener.controller.cjs +0 -53
- package/dist/cjs/controllers/eventListener.controller.cjs.map +0 -1
- package/dist/cjs/controllers/newsletter.controller.cjs +0 -164
- package/dist/cjs/controllers/newsletter.controller.cjs.map +0 -1
- package/dist/cjs/controllers/oAuth2.controller.cjs +0 -22
- package/dist/cjs/controllers/oAuth2.controller.cjs.map +0 -1
- package/dist/cjs/controllers/organization.controller.cjs +0 -492
- package/dist/cjs/controllers/organization.controller.cjs.map +0 -1
- package/dist/cjs/controllers/project.controller.cjs +0 -430
- package/dist/cjs/controllers/project.controller.cjs.map +0 -1
- package/dist/cjs/controllers/projectAccessKey.controller.cjs +0 -161
- package/dist/cjs/controllers/projectAccessKey.controller.cjs.map +0 -1
- package/dist/cjs/controllers/search.controller.cjs +0 -14
- package/dist/cjs/controllers/search.controller.cjs.map +0 -1
- package/dist/cjs/controllers/stripe.controller.cjs +0 -149
- package/dist/cjs/controllers/stripe.controller.cjs.map +0 -1
- package/dist/cjs/controllers/tag.controller.cjs +0 -226
- package/dist/cjs/controllers/tag.controller.cjs.map +0 -1
- package/dist/cjs/controllers/user.controller.cjs +0 -269
- package/dist/cjs/controllers/user.controller.cjs.map +0 -1
- package/dist/cjs/emails/InviteUserEmail.cjs +0 -325
- package/dist/cjs/emails/InviteUserEmail.cjs.map +0 -1
- package/dist/cjs/emails/MagicLinkEmail.cjs +0 -242
- package/dist/cjs/emails/MagicLinkEmail.cjs.map +0 -1
- package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs +0 -301
- package/dist/cjs/emails/OAuthTokenCreatedEmail.cjs.map +0 -1
- package/dist/cjs/emails/PasswordChangeConfirmation.cjs +0 -177
- package/dist/cjs/emails/PasswordChangeConfirmation.cjs.map +0 -1
- package/dist/cjs/emails/ResetUserPassword.cjs +0 -240
- package/dist/cjs/emails/ResetUserPassword.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentCancellation.cjs +0 -202
- package/dist/cjs/emails/SubscriptionPaymentCancellation.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentError.cjs +0 -202
- package/dist/cjs/emails/SubscriptionPaymentError.cjs.map +0 -1
- package/dist/cjs/emails/SubscriptionPaymentSuccess.cjs +0 -208
- package/dist/cjs/emails/SubscriptionPaymentSuccess.cjs.map +0 -1
- package/dist/cjs/emails/ValidateUserEmail.cjs +0 -240
- package/dist/cjs/emails/ValidateUserEmail.cjs.map +0 -1
- package/dist/cjs/emails/Welcome.cjs +0 -216
- package/dist/cjs/emails/Welcome.cjs.map +0 -1
- package/dist/cjs/emails/index.cjs +0 -25
- package/dist/cjs/export.cjs +0 -24
- package/dist/cjs/index.cjs +0 -91
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/logger/index.cjs +0 -13
- package/dist/cjs/logger/index.cjs.map +0 -1
- package/dist/cjs/middlewares/oAuth2.middleware.cjs +0 -42
- package/dist/cjs/middlewares/oAuth2.middleware.cjs.map +0 -1
- package/dist/cjs/middlewares/request.middleware.cjs +0 -17
- package/dist/cjs/middlewares/request.middleware.cjs.map +0 -1
- package/dist/cjs/middlewares/sessionAuth.middleware.cjs +0 -22
- package/dist/cjs/middlewares/sessionAuth.middleware.cjs.map +0 -1
- package/dist/cjs/models/dictionary.model.cjs +0 -10
- package/dist/cjs/models/dictionary.model.cjs.map +0 -1
- package/dist/cjs/models/discussion.model.cjs +0 -10
- package/dist/cjs/models/discussion.model.cjs.map +0 -1
- package/dist/cjs/models/oAuth2.model.cjs +0 -10
- package/dist/cjs/models/oAuth2.model.cjs.map +0 -1
- package/dist/cjs/models/organization.model.cjs +0 -10
- package/dist/cjs/models/organization.model.cjs.map +0 -1
- package/dist/cjs/models/project.model.cjs +0 -10
- package/dist/cjs/models/project.model.cjs.map +0 -1
- package/dist/cjs/models/session.model.cjs +0 -10
- package/dist/cjs/models/session.model.cjs.map +0 -1
- package/dist/cjs/models/tag.model.cjs +0 -10
- package/dist/cjs/models/tag.model.cjs.map +0 -1
- package/dist/cjs/models/user.model.cjs +0 -10
- package/dist/cjs/models/user.model.cjs.map +0 -1
- package/dist/cjs/routes/ai.routes.cjs +0 -75
- package/dist/cjs/routes/ai.routes.cjs.map +0 -1
- package/dist/cjs/routes/dictionary.routes.cjs +0 -64
- package/dist/cjs/routes/dictionary.routes.cjs.map +0 -1
- package/dist/cjs/routes/eventListener.routes.cjs +0 -20
- package/dist/cjs/routes/eventListener.routes.cjs.map +0 -1
- package/dist/cjs/routes/newsletter.routes.cjs +0 -34
- package/dist/cjs/routes/newsletter.routes.cjs.map +0 -1
- package/dist/cjs/routes/organization.routes.cjs +0 -70
- package/dist/cjs/routes/organization.routes.cjs.map +0 -1
- package/dist/cjs/routes/project.routes.cjs +0 -83
- package/dist/cjs/routes/project.routes.cjs.map +0 -1
- package/dist/cjs/routes/search.routes.cjs +0 -20
- package/dist/cjs/routes/search.routes.cjs.map +0 -1
- package/dist/cjs/routes/stripe.routes.cjs +0 -34
- package/dist/cjs/routes/stripe.routes.cjs.map +0 -1
- package/dist/cjs/routes/tags.routes.cjs +0 -40
- package/dist/cjs/routes/tags.routes.cjs.map +0 -1
- package/dist/cjs/routes/user.routes.cjs +0 -58
- package/dist/cjs/routes/user.routes.cjs.map +0 -1
- package/dist/cjs/schemas/dictionary.schema.cjs +0 -73
- package/dist/cjs/schemas/dictionary.schema.cjs.map +0 -1
- package/dist/cjs/schemas/discussion.schema.cjs +0 -81
- package/dist/cjs/schemas/discussion.schema.cjs.map +0 -1
- package/dist/cjs/schemas/oAuth2.schema.cjs +0 -49
- package/dist/cjs/schemas/oAuth2.schema.cjs.map +0 -1
- package/dist/cjs/schemas/organization.schema.cjs +0 -62
- package/dist/cjs/schemas/organization.schema.cjs.map +0 -1
- package/dist/cjs/schemas/plans.schema.cjs +0 -75
- package/dist/cjs/schemas/plans.schema.cjs.map +0 -1
- package/dist/cjs/schemas/project.schema.cjs +0 -112
- package/dist/cjs/schemas/project.schema.cjs.map +0 -1
- package/dist/cjs/schemas/session.schema.cjs +0 -43
- package/dist/cjs/schemas/session.schema.cjs.map +0 -1
- package/dist/cjs/schemas/tag.schema.cjs +0 -62
- package/dist/cjs/schemas/tag.schema.cjs.map +0 -1
- package/dist/cjs/schemas/user.schema.cjs +0 -87
- package/dist/cjs/schemas/user.schema.cjs.map +0 -1
- package/dist/cjs/services/dictionary.service.cjs +0 -176
- package/dist/cjs/services/dictionary.service.cjs.map +0 -1
- package/dist/cjs/services/email.service.cjs +0 -155
- package/dist/cjs/services/email.service.cjs.map +0 -1
- package/dist/cjs/services/oAuth2.service.cjs +0 -211
- package/dist/cjs/services/oAuth2.service.cjs.map +0 -1
- package/dist/cjs/services/organization.service.cjs +0 -106
- package/dist/cjs/services/organization.service.cjs.map +0 -1
- package/dist/cjs/services/project.service.cjs +0 -89
- package/dist/cjs/services/project.service.cjs.map +0 -1
- package/dist/cjs/services/projectAccessKey.service.cjs +0 -111
- package/dist/cjs/services/projectAccessKey.service.cjs.map +0 -1
- package/dist/cjs/services/subscription.service.cjs +0 -184
- package/dist/cjs/services/subscription.service.cjs.map +0 -1
- package/dist/cjs/services/tag.service.cjs +0 -88
- package/dist/cjs/services/tag.service.cjs.map +0 -1
- package/dist/cjs/services/user.service.cjs +0 -120
- package/dist/cjs/services/user.service.cjs.map +0 -1
- package/dist/cjs/types/Routes.cjs +0 -0
- package/dist/cjs/types/dictionary.types.cjs +0 -0
- package/dist/cjs/types/discussion.types.cjs +0 -0
- package/dist/cjs/types/oAuth2.types.cjs +0 -0
- package/dist/cjs/types/organization.types.cjs +0 -0
- package/dist/cjs/types/plan.types.cjs +0 -0
- package/dist/cjs/types/project.types.cjs +0 -0
- package/dist/cjs/types/session.types.cjs +0 -0
- package/dist/cjs/types/tag.types.cjs +0 -0
- package/dist/cjs/types/user.types.cjs +0 -10
- package/dist/cjs/types/user.types.cjs.map +0 -1
- package/dist/cjs/utils/AI/aiSdk.cjs +0 -94
- package/dist/cjs/utils/AI/aiSdk.cjs.map +0 -1
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs +0 -201
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs.map +0 -1
- package/dist/cjs/utils/AI/askDocQuestion/indexMarkdownFiles.cjs +0 -150
- package/dist/cjs/utils/AI/askDocQuestion/indexMarkdownFiles.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionary/index.cjs +0 -60
- package/dist/cjs/utils/AI/auditDictionary/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs +0 -63
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs +0 -45
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/auditTag/index.cjs +0 -40
- package/dist/cjs/utils/AI/auditTag/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/autocomplete/index.cjs +0 -41
- package/dist/cjs/utils/AI/autocomplete/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/customQuery/index.cjs +0 -27
- package/dist/cjs/utils/AI/customQuery/index.cjs.map +0 -1
- package/dist/cjs/utils/AI/translateJSON/index.cjs +0 -71
- package/dist/cjs/utils/AI/translateJSON/index.cjs.map +0 -1
- package/dist/cjs/utils/access.cjs +0 -0
- package/dist/cjs/utils/accessControl.cjs +0 -133
- package/dist/cjs/utils/accessControl.cjs.map +0 -1
- package/dist/cjs/utils/auth/getAuth.cjs +0 -218
- package/dist/cjs/utils/auth/getAuth.cjs.map +0 -1
- package/dist/cjs/utils/cors.cjs +0 -33
- package/dist/cjs/utils/cors.cjs.map +0 -1
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs +0 -13
- package/dist/cjs/utils/ensureArrayQueryFilter.cjs.map +0 -1
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs +0 -16
- package/dist/cjs/utils/ensureMongoDocumentToObject.cjs.map +0 -1
- package/dist/cjs/utils/errors/ErrorHandler.cjs +0 -76
- package/dist/cjs/utils/errors/ErrorHandler.cjs.map +0 -1
- package/dist/cjs/utils/errors/ErrorsClass.cjs +0 -54
- package/dist/cjs/utils/errors/ErrorsClass.cjs.map +0 -1
- package/dist/cjs/utils/errors/errorCodes.cjs +0 -1387
- package/dist/cjs/utils/errors/errorCodes.cjs.map +0 -1
- package/dist/cjs/utils/errors/index.cjs +0 -8
- package/dist/cjs/utils/extractJSON.cjs +0 -61
- package/dist/cjs/utils/extractJSON.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs +0 -94
- package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getDiscussionFiltersAndPagination.cjs +0 -65
- package/dist/cjs/utils/filtersAndPagination/getDiscussionFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs +0 -36
- package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs +0 -49
- package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs +0 -53
- package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs +0 -57
- package/dist/cjs/utils/filtersAndPagination/getTagFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs +0 -74
- package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs.map +0 -1
- package/dist/cjs/utils/httpStatusCodes.cjs +0 -401
- package/dist/cjs/utils/httpStatusCodes.cjs.map +0 -1
- package/dist/cjs/utils/mapper/dictionary.cjs +0 -29
- package/dist/cjs/utils/mapper/dictionary.cjs.map +0 -1
- package/dist/cjs/utils/mapper/organization.cjs +0 -19
- package/dist/cjs/utils/mapper/organization.cjs.map +0 -1
- package/dist/cjs/utils/mapper/project.cjs +0 -26
- package/dist/cjs/utils/mapper/project.cjs.map +0 -1
- package/dist/cjs/utils/mapper/session.cjs +0 -15
- package/dist/cjs/utils/mapper/session.cjs.map +0 -1
- package/dist/cjs/utils/mapper/tag.cjs +0 -25
- package/dist/cjs/utils/mapper/tag.cjs.map +0 -1
- package/dist/cjs/utils/mapper/user.cjs +0 -24
- package/dist/cjs/utils/mapper/user.cjs.map +0 -1
- package/dist/cjs/utils/mergeFunctionTypes.cjs +0 -0
- package/dist/cjs/utils/mongoDB/connectDB.cjs +0 -32
- package/dist/cjs/utils/mongoDB/connectDB.cjs.map +0 -1
- package/dist/cjs/utils/mongoDB/types.cjs +0 -0
- package/dist/cjs/utils/oAuth2.cjs +0 -25
- package/dist/cjs/utils/oAuth2.cjs.map +0 -1
- package/dist/cjs/utils/permissions.cjs +0 -103
- package/dist/cjs/utils/permissions.cjs.map +0 -1
- package/dist/cjs/utils/plan.cjs +0 -63
- package/dist/cjs/utils/plan.cjs.map +0 -1
- package/dist/cjs/utils/rateLimiter.cjs +0 -48
- package/dist/cjs/utils/rateLimiter.cjs.map +0 -1
- package/dist/cjs/utils/removeObjectKeys.cjs +0 -11
- package/dist/cjs/utils/removeObjectKeys.cjs.map +0 -1
- package/dist/cjs/utils/responseData.cjs +0 -33
- package/dist/cjs/utils/responseData.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateArray.cjs +0 -31
- package/dist/cjs/utils/validation/validateArray.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateDictionary.cjs +0 -35
- package/dist/cjs/utils/validation/validateDictionary.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateEmail.cjs +0 -20
- package/dist/cjs/utils/validation/validateEmail.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateOrganization.cjs +0 -43
- package/dist/cjs/utils/validation/validateOrganization.cjs.map +0 -1
- package/dist/cjs/utils/validation/validatePhone.cjs +0 -20
- package/dist/cjs/utils/validation/validatePhone.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateProject.cjs +0 -55
- package/dist/cjs/utils/validation/validateProject.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateString.cjs +0 -21
- package/dist/cjs/utils/validation/validateString.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateTag.cjs +0 -47
- package/dist/cjs/utils/validation/validateTag.cjs.map +0 -1
- package/dist/cjs/utils/validation/validateUser.cjs +0 -47
- package/dist/cjs/utils/validation/validateUser.cjs.map +0 -1
- package/dist/cjs/webhooks/stripe.webhook.cjs +0 -116
- package/dist/cjs/webhooks/stripe.webhook.cjs.map +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
2
|
-
const require_utils_AI_askDocQuestion_askDocQuestion = require('../utils/AI/askDocQuestion/askDocQuestion.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/controllers/search.controller.ts
|
|
5
|
-
const searchDocUtil = async (req, res) => {
|
|
6
|
-
const { input } = req.query;
|
|
7
|
-
const docFileList = (await require_utils_AI_askDocQuestion_askDocQuestion.searchChunkReference(input, 30, .2)).map((doc) => doc.fileKey);
|
|
8
|
-
const responseData = require_utils_responseData.formatResponse({ data: Array.from(new Set(docFileList)) });
|
|
9
|
-
res.json(responseData);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
exports.searchDocUtil = searchDocUtil;
|
|
14
|
-
//# sourceMappingURL=search.controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.controller.cjs","names":["formatResponse"],"sources":["../../../src/controllers/search.controller.ts"],"sourcesContent":["import * as askDocQuestionUtil from '@utils/AI/askDocQuestion/askDocQuestion';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { Request, Response } from 'express';\n\nexport type SearchDocUtilParams = {\n input: string;\n};\nexport type SearchDocUtilResult = ResponseData<string[]>;\n\nexport const searchDocUtil = async (\n req: Request<unknown, unknown, unknown, SearchDocUtilParams>,\n res: Response<SearchDocUtilResult>\n) => {\n const { input } = req.query;\n\n const response = await askDocQuestionUtil.searchChunkReference(\n input,\n 30,\n 0.2\n );\n const docFileList = response.map((doc) => doc.fileKey);\n\n const uniqueDocFileList = Array.from(new Set(docFileList));\n\n const responseData = formatResponse<string[]>({\n data: uniqueDocFileList,\n });\n\n res.json(responseData);\n};\n"],"mappings":";;;;AASA,MAAa,gBAAgB,OAC3B,KACA,QACG;CACH,MAAM,EAAE,UAAU,IAAI;CAOtB,MAAM,eALW,0EACf,OACA,IACA,GACD,EAC4B,KAAK,QAAQ,IAAI,QAAQ;CAItD,MAAM,eAAeA,0CAAyB,EAC5C,MAHwB,MAAM,KAAK,IAAI,IAAI,YAAY,CAAC,EAIzD,CAAC;AAEF,KAAI,KAAK,aAAa"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
3
|
-
const require_utils_errors_ErrorHandler = require('../utils/errors/ErrorHandler.cjs');
|
|
4
|
-
const require_services_email_service = require('../services/email.service.cjs');
|
|
5
|
-
const require_utils_plan = require('../utils/plan.cjs');
|
|
6
|
-
const require_services_subscription_service = require('../services/subscription.service.cjs');
|
|
7
|
-
let express_intlayer = require("express-intlayer");
|
|
8
|
-
let stripe = require("stripe");
|
|
9
|
-
|
|
10
|
-
//#region src/controllers/stripe.controller.ts
|
|
11
|
-
/**
|
|
12
|
-
* Simulate pricing for a given set of prices and a promotion code.
|
|
13
|
-
*
|
|
14
|
-
* @param req - The request object containing the price IDs and promotion code.
|
|
15
|
-
* @param res - The response object to send the simulated pricing result.
|
|
16
|
-
*/
|
|
17
|
-
const getPricing = async (req, res) => {
|
|
18
|
-
const { priceIds, promoCode } = req.body;
|
|
19
|
-
const formattedPricingResult = require_utils_responseData.formatResponse({ data: await require_services_subscription_service.getPricing(priceIds, promoCode) });
|
|
20
|
-
res.status(200).json(formattedPricingResult);
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Handles subscription creation or update with Stripe and returns a ClientSecret.
|
|
24
|
-
* @param req - Express request object.
|
|
25
|
-
* @param res - Express response object.
|
|
26
|
-
*/
|
|
27
|
-
const getSubscription = async (req, res) => {
|
|
28
|
-
try {
|
|
29
|
-
const stripe$1 = new stripe.Stripe(process.env.STRIPE_SECRET_KEY);
|
|
30
|
-
const { organization, user } = res.locals;
|
|
31
|
-
const { priceId, promoCode } = req.body;
|
|
32
|
-
if (!organization) {
|
|
33
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_FOUND");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (!user) {
|
|
37
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const { period, type } = require_utils_plan.retrievePlanInformation(priceId);
|
|
41
|
-
if (organization.plan?.subscriptionId && organization.plan?.type === type && organization.plan?.period === period && organization.plan?.status === "active") {
|
|
42
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ALREADY_SUBSCRIBED", { organizationId: organization.id });
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
let customerId = organization.plan?.customerId;
|
|
46
|
-
if (!customerId) customerId = (await stripe$1.customers.create({ metadata: {
|
|
47
|
-
organizationId: String(organization.id),
|
|
48
|
-
userId: String(user.id),
|
|
49
|
-
locale: res.locals.locale
|
|
50
|
-
} })).id;
|
|
51
|
-
const promoCodeId = promoCode ? await require_services_subscription_service.getCouponId(promoCode) : null;
|
|
52
|
-
const discounts = promoCodeId ? [{ coupon: promoCodeId }] : [];
|
|
53
|
-
const subscription = await stripe$1.subscriptions.create({
|
|
54
|
-
customer: customerId,
|
|
55
|
-
items: [{ price: priceId }],
|
|
56
|
-
expand: ["latest_invoice.confirmation_secret"],
|
|
57
|
-
payment_settings: { payment_method_types: ["card"] },
|
|
58
|
-
payment_behavior: "default_incomplete",
|
|
59
|
-
discounts
|
|
60
|
-
});
|
|
61
|
-
if (!subscription) {
|
|
62
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "SUBSCRIPTION_CREATION_FAILED", {
|
|
63
|
-
user,
|
|
64
|
-
organization,
|
|
65
|
-
priceId
|
|
66
|
-
});
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const clientSecret = subscription.latest_invoice?.confirmation_secret?.client_secret;
|
|
70
|
-
if (!clientSecret) {
|
|
71
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "SUBSCRIPTION_CREATION_FAILED", {
|
|
72
|
-
user,
|
|
73
|
-
organization,
|
|
74
|
-
priceId
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const responseData = require_utils_responseData.formatResponse({ data: {
|
|
79
|
-
subscription,
|
|
80
|
-
clientSecret
|
|
81
|
-
} });
|
|
82
|
-
res.json(responseData);
|
|
83
|
-
return;
|
|
84
|
-
} catch (error) {
|
|
85
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Cancels a subscription for an organization.
|
|
91
|
-
* @param _req - Express request object.
|
|
92
|
-
* @param res - Express response object.
|
|
93
|
-
*/
|
|
94
|
-
const cancelSubscription = async (_req, res) => {
|
|
95
|
-
const stripe$1 = new stripe.Stripe(process.env.STRIPE_SECRET_KEY);
|
|
96
|
-
try {
|
|
97
|
-
const { organization, user } = res.locals;
|
|
98
|
-
if (!organization) {
|
|
99
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_FOUND");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (!user) {
|
|
103
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (!organization.plan?.subscriptionId) {
|
|
107
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_PLAN_NOT_FOUND");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
await stripe$1.subscriptions.cancel(organization.plan.subscriptionId);
|
|
111
|
-
const plan = await require_services_subscription_service.cancelSubscription(organization.plan.subscriptionId, String(organization.id));
|
|
112
|
-
if (!plan) {
|
|
113
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_PLAN_NOT_FOUND");
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const formattedPlan = require_utils_responseData.formatResponse({
|
|
117
|
-
message: (0, express_intlayer.t)({
|
|
118
|
-
en: "Subscription cancelled successfully",
|
|
119
|
-
fr: "Souscription annulée avec succès",
|
|
120
|
-
es: "Suscripción cancelada con éxito"
|
|
121
|
-
}),
|
|
122
|
-
description: (0, express_intlayer.t)({
|
|
123
|
-
en: "Your subscription has been cancelled successfully",
|
|
124
|
-
fr: "Votre souscription a été annulée avec succès",
|
|
125
|
-
es: "Su suscripción ha sido cancelada con éxito"
|
|
126
|
-
}),
|
|
127
|
-
data: plan
|
|
128
|
-
});
|
|
129
|
-
res.json(formattedPlan);
|
|
130
|
-
await require_services_email_service.sendEmail({
|
|
131
|
-
type: "subscriptionPaymentCancellation",
|
|
132
|
-
to: user.email,
|
|
133
|
-
email: user.email,
|
|
134
|
-
cancellationDate: (/* @__PURE__ */ new Date()).toLocaleDateString(),
|
|
135
|
-
reactivateLink: `${process.env.CLIENT_URL}/pricing`,
|
|
136
|
-
username: user.name,
|
|
137
|
-
organizationName: organization.name,
|
|
138
|
-
planName: plan.type
|
|
139
|
-
});
|
|
140
|
-
} catch (error) {
|
|
141
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
|
-
exports.cancelSubscription = cancelSubscription;
|
|
147
|
-
exports.getPricing = getPricing;
|
|
148
|
-
exports.getSubscription = getSubscription;
|
|
149
|
-
//# sourceMappingURL=stripe.controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.controller.cjs","names":["formatResponse","stripe","Stripe","retrievePlanInformation","discounts: Stripe.SubscriptionCreateParams.Discount[]"],"sources":["../../../src/controllers/stripe.controller.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types';\nimport type { ResponseWithSession } from '@middlewares/sessionAuth.middleware';\nimport * as emailService from '@services/email.service';\nimport * as subscriptionService from '@services/subscription.service';\nimport { type AppError, ErrorHandler } from '@utils/errors';\nimport { retrievePlanInformation } from '@utils/plan';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { Request } from 'express';\nimport { t } from 'express-intlayer';\nimport { Stripe } from 'stripe';\nimport type { Organization } from '@/types/organization.types';\n\nexport type GetPricingBody = {\n priceIds: string[];\n promoCode?: string;\n};\n\nexport type GetPricingResult = ResponseData<subscriptionService.PricingResult>;\n\n/**\n * Simulate pricing for a given set of prices and a promotion code.\n *\n * @param req - The request object containing the price IDs and promotion code.\n * @param res - The response object to send the simulated pricing result.\n */\nexport const getPricing = async (\n req: Request<undefined, undefined, GetPricingBody>,\n res: ResponseWithSession<GetPricingResult>\n) => {\n const { priceIds, promoCode } = req.body;\n\n const pricingResult = await subscriptionService.getPricing(\n priceIds,\n promoCode\n );\n\n const formattedPricingResult =\n formatResponse<subscriptionService.PricingResult>({\n data: pricingResult,\n });\n\n res.status(200).json(formattedPricingResult);\n};\n\nexport type GetCheckoutSessionBody = {\n priceId: string;\n promoCode?: string;\n};\n\nexport type GetCheckoutSessionResult = ResponseData<{\n subscription: Stripe.Response<Stripe.Subscription>;\n clientSecret: string;\n}>;\n\n/**\n * Handles subscription creation or update with Stripe and returns a ClientSecret.\n * @param req - Express request object.\n * @param res - Express response object.\n */\nexport const getSubscription = async (\n req: Request<undefined, undefined, GetCheckoutSessionBody>,\n res: ResponseWithSession<GetCheckoutSessionResult>\n): Promise<void> => {\n try {\n const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);\n\n // Extract organization and user from response locals (set by authentication middleware)\n const { organization, user } = res.locals;\n // Get the price ID (Stripe Price ID) from the request body\n const { priceId, promoCode } = req.body;\n\n // Validate that the organization exists\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_FOUND');\n return;\n }\n\n // Validate that the user exists\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n const { period, type } = retrievePlanInformation(priceId);\n\n if (\n organization.plan?.subscriptionId &&\n organization.plan?.type === type &&\n organization.plan?.period === period &&\n organization.plan?.status === 'active'\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'ALREADY_SUBSCRIBED', {\n organizationId: organization.id,\n });\n return;\n }\n\n // Attempt to retrieve the Stripe customer ID from the organization's plan\n let customerId = organization.plan?.customerId;\n\n if (!customerId) {\n // If no customer ID exists, create a new Stripe customer for the organization\n const customer = await stripe.customers.create({\n metadata: {\n organizationId: String(organization.id),\n userId: String(user.id),\n // Include the locale for potential localization\n locale: (res.locals as unknown as { locale: Locale }).locale,\n },\n });\n customerId = customer.id;\n }\n\n const promoCodeId = promoCode\n ? await subscriptionService.getCouponId(promoCode)\n : null;\n\n const discounts: Stripe.SubscriptionCreateParams.Discount[] = promoCodeId\n ? [{ coupon: promoCodeId }]\n : [];\n\n // If no subscription exists, create a new one\n const subscription = await stripe.subscriptions.create({\n customer: customerId, // Associate the subscription with the customer\n items: [{ price: priceId }], // Set the price ID for the subscription\n expand: ['latest_invoice.confirmation_secret'],\n payment_settings: {\n payment_method_types: ['card'], // Specify payment method types\n },\n payment_behavior: 'default_incomplete', // Create the subscription in an incomplete state until payment is confirmed\n discounts,\n });\n\n // Handle subscription creation failure\n if (!subscription) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'SUBSCRIPTION_CREATION_FAILED',\n {\n user,\n organization,\n priceId,\n }\n );\n return;\n }\n\n const clientSecret = (\n subscription.latest_invoice as Stripe.Invoice & {\n confirmation_secret?: { client_secret: string };\n }\n )?.confirmation_secret?.client_secret;\n\n // Handle subscription creation failure\n if (!clientSecret) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'SUBSCRIPTION_CREATION_FAILED',\n {\n user,\n organization,\n priceId,\n }\n );\n return;\n }\n\n // Prepare the response data with subscription details\n const responseData = formatResponse<GetCheckoutSessionResult['data']>({\n data: { subscription, clientSecret },\n });\n\n // Send the response back to the client\n res.json(responseData);\n\n return;\n } catch (error) {\n // Handle any errors that occur during the process\n\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\ntype CancelSubscriptionData = Organization['plan'];\n\ntype CancelSubscriptionResult = ResponseData<CancelSubscriptionData>;\n\n/**\n * Cancels a subscription for an organization.\n * @param _req - Express request object.\n * @param res - Express response object.\n */\nexport const cancelSubscription = async (\n _req: Request,\n res: ResponseWithSession<CancelSubscriptionResult>\n): Promise<void> => {\n const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);\n\n try {\n // Extract the organization and user from the response locals\n // These are typically set by authentication middleware earlier in the request pipeline\n const { organization, user } = res.locals;\n\n // Validate that the organization exists\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_FOUND');\n return;\n }\n\n // Validate that the user exists\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n // Check if the organization has an active subscription to cancel\n if (!organization.plan?.subscriptionId) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'ORGANIZATION_PLAN_NOT_FOUND'\n );\n return;\n }\n\n // Cancel the subscription on Stripe immediately using the subscription ID\n await stripe.subscriptions.cancel(organization.plan.subscriptionId);\n\n // Update the organization's plan in the database to reflect the cancellation\n const plan = await subscriptionService.cancelSubscription(\n organization.plan.subscriptionId,\n String(organization.id)\n );\n\n // If the plan could not be updated in the database, handle the error\n if (!plan) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'ORGANIZATION_PLAN_NOT_FOUND'\n );\n return;\n }\n\n // Prepare a formatted response with a success message and the updated plan data\n const formattedPlan = formatResponse<CancelSubscriptionData>({\n message: t({\n en: 'Subscription cancelled successfully',\n fr: 'Souscription annulée avec succès',\n es: 'Suscripción cancelada con éxito',\n }),\n description: t({\n en: 'Your subscription has been cancelled successfully',\n fr: 'Votre souscription a été annulée avec succès',\n es: 'Su suscripción ha sido cancelada con éxito',\n }),\n data: plan!,\n });\n\n // Send the response back to the client\n res.json(formattedPlan);\n\n await emailService.sendEmail({\n type: 'subscriptionPaymentCancellation',\n to: user.email,\n email: user.email,\n cancellationDate: new Date().toLocaleDateString(),\n reactivateLink: `${process.env.CLIENT_URL}/pricing`,\n username: user.name,\n organizationName: organization.name,\n planName: plan.type,\n });\n } catch (error) {\n // Handle any errors that occur during the cancellation process\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n }\n};\n"],"mappings":"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"}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_logger_index = require('../logger/index.cjs');
|
|
3
|
-
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
4
|
-
const require_utils_errors_ErrorHandler = require('../utils/errors/ErrorHandler.cjs');
|
|
5
|
-
const require_services_tag_service = require('../services/tag.service.cjs');
|
|
6
|
-
const require_utils_permissions = require('../utils/permissions.cjs');
|
|
7
|
-
const require_utils_filtersAndPagination_getTagFiltersAndPagination = require('../utils/filtersAndPagination/getTagFiltersAndPagination.cjs');
|
|
8
|
-
const require_utils_mapper_tag = require('../utils/mapper/tag.cjs');
|
|
9
|
-
let express_intlayer = require("express-intlayer");
|
|
10
|
-
|
|
11
|
-
//#region src/controllers/tag.controller.ts
|
|
12
|
-
/**
|
|
13
|
-
* Retrieves a list of tags based on filters and pagination.
|
|
14
|
-
*/
|
|
15
|
-
const getTags = async (req, res, _next) => {
|
|
16
|
-
const { user, organization, roles } = res.locals;
|
|
17
|
-
const { filters, sortOptions, pageSize, skip, page, getNumberOfPages } = require_utils_filtersAndPagination_getTagFiltersAndPagination.getTagFiltersAndPagination(req, res);
|
|
18
|
-
if (!user) {
|
|
19
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!organization) {
|
|
23
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_DEFINED");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
const tags = await require_services_tag_service.findTags(filters, skip, pageSize, sortOptions);
|
|
28
|
-
if (!require_utils_permissions.hasPermission(roles, "tag:read")({
|
|
29
|
-
...res.locals,
|
|
30
|
-
targetTags: tags
|
|
31
|
-
})) {
|
|
32
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const totalItems = await require_services_tag_service.countTags(filters);
|
|
36
|
-
const responseData = require_utils_responseData.formatPaginatedResponse({
|
|
37
|
-
data: require_utils_mapper_tag.mapTagsToAPI(tags),
|
|
38
|
-
page,
|
|
39
|
-
pageSize,
|
|
40
|
-
totalPages: getNumberOfPages(totalItems),
|
|
41
|
-
totalItems
|
|
42
|
-
});
|
|
43
|
-
res.json(responseData);
|
|
44
|
-
return;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Adds a new tag to the database.
|
|
52
|
-
*/
|
|
53
|
-
const addTag = async (req, res, _next) => {
|
|
54
|
-
const { organization, project, user, roles } = res.locals;
|
|
55
|
-
const tagData = req.body;
|
|
56
|
-
if (!user) {
|
|
57
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (!organization) {
|
|
61
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_DEFINED");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (!project) {
|
|
65
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_DEFINED");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (!tagData) require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_DATA_NOT_FOUND");
|
|
69
|
-
const tag = {
|
|
70
|
-
creatorId: user.id,
|
|
71
|
-
organizationId: organization.id,
|
|
72
|
-
projectId: project.id,
|
|
73
|
-
...tagData
|
|
74
|
-
};
|
|
75
|
-
if (!require_utils_permissions.hasPermission(roles, "tag:admin")({
|
|
76
|
-
...res.locals,
|
|
77
|
-
targetTags: [tag]
|
|
78
|
-
})) {
|
|
79
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const formattedTag = require_utils_mapper_tag.mapTagToAPI(await require_services_tag_service.createTag(tag));
|
|
84
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
85
|
-
message: (0, express_intlayer.t)({
|
|
86
|
-
en: "Tag created successfully",
|
|
87
|
-
fr: "Tag créé avec succès",
|
|
88
|
-
es: "Tag creado con éxito"
|
|
89
|
-
}),
|
|
90
|
-
description: (0, express_intlayer.t)({
|
|
91
|
-
en: "Your tag has been created successfully",
|
|
92
|
-
fr: "Votre tag a été créé avec succès",
|
|
93
|
-
es: "Su tag ha sido creado con éxito"
|
|
94
|
-
}),
|
|
95
|
-
data: formattedTag
|
|
96
|
-
});
|
|
97
|
-
res.json(responseData);
|
|
98
|
-
return;
|
|
99
|
-
} catch (error) {
|
|
100
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Updates an existing tag in the database.
|
|
106
|
-
*/
|
|
107
|
-
const updateTag = async (req, res, _next) => {
|
|
108
|
-
const { tagId } = req.params;
|
|
109
|
-
const { organization, user, roles } = res.locals;
|
|
110
|
-
if (!user) {
|
|
111
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (!organization) {
|
|
115
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_DEFINED");
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
const tag = {
|
|
120
|
-
_id: tagId,
|
|
121
|
-
name: req.body.name,
|
|
122
|
-
key: req.body.key,
|
|
123
|
-
description: req.body.description,
|
|
124
|
-
instructions: req.body.instructions
|
|
125
|
-
};
|
|
126
|
-
const tagToDelete = await require_services_tag_service.getTagById(tagId);
|
|
127
|
-
if (!require_utils_permissions.hasPermission(roles, "tag:write")({
|
|
128
|
-
...res.locals,
|
|
129
|
-
targetTags: [tagToDelete]
|
|
130
|
-
})) {
|
|
131
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (String(tagToDelete.organizationId) !== String(organization.id)) {
|
|
135
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "TAG_NOT_IN_ORGANIZATION");
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const formattedTag = require_utils_mapper_tag.mapTagToAPI(await require_services_tag_service.updateTagById(tag._id, tag));
|
|
139
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
140
|
-
message: (0, express_intlayer.t)({
|
|
141
|
-
en: "Tag updated successfully",
|
|
142
|
-
fr: "Tag mis à jour avec succès",
|
|
143
|
-
es: "Tag actualizado con éxito"
|
|
144
|
-
}),
|
|
145
|
-
description: (0, express_intlayer.t)({
|
|
146
|
-
en: "Your tag has been updated successfully",
|
|
147
|
-
fr: "Votre tag a été mis à jour avec succès",
|
|
148
|
-
es: "Su tag ha sido actualizado con éxito"
|
|
149
|
-
}),
|
|
150
|
-
data: formattedTag
|
|
151
|
-
});
|
|
152
|
-
res.json(responseData);
|
|
153
|
-
return;
|
|
154
|
-
} catch (error) {
|
|
155
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Deletes a tag from the database by its ID.
|
|
161
|
-
* @param req - Express request object.
|
|
162
|
-
* @param res - Express response object.
|
|
163
|
-
* @returns Response confirming the deletion.
|
|
164
|
-
*/
|
|
165
|
-
const deleteTag = async (req, res, _next) => {
|
|
166
|
-
const { user, organization, roles } = res.locals;
|
|
167
|
-
const { tagId } = req.params;
|
|
168
|
-
if (!user) {
|
|
169
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_DEFINED");
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (!organization) {
|
|
173
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "ORGANIZATION_NOT_DEFINED");
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (!tagId) {
|
|
177
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "TAG_ID_NOT_FOUND");
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
const tagToDelete = await require_services_tag_service.getTagById(tagId);
|
|
182
|
-
if (!require_utils_permissions.hasPermission(roles, "tag:admin")({
|
|
183
|
-
...res.locals,
|
|
184
|
-
targetTags: [tagToDelete]
|
|
185
|
-
})) {
|
|
186
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "PERMISSION_DENIED");
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (String(tagToDelete.organizationId) !== String(organization.id)) {
|
|
190
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "TAG_NOT_IN_ORGANIZATION");
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const deletedTag = await require_services_tag_service.deleteTagById(tagId);
|
|
194
|
-
if (!deletedTag) {
|
|
195
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleGenericErrorResponse(res, "TAG_NOT_FOUND", { tagId });
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
require_logger_index.logger.info(`Tag deleted: ${String(deletedTag.id)}`);
|
|
199
|
-
const formattedTag = require_utils_mapper_tag.mapTagToAPI(deletedTag);
|
|
200
|
-
const responseData = require_utils_responseData.formatResponse({
|
|
201
|
-
message: (0, express_intlayer.t)({
|
|
202
|
-
en: "Tag deleted successfully",
|
|
203
|
-
fr: "Tag supprimé avec succès",
|
|
204
|
-
es: "Tag eliminado con éxito"
|
|
205
|
-
}),
|
|
206
|
-
description: (0, express_intlayer.t)({
|
|
207
|
-
en: "Your tag has been deleted successfully",
|
|
208
|
-
fr: "Votre tag a été supprimé avec succès",
|
|
209
|
-
es: "Su tag ha sido eliminado con éxito"
|
|
210
|
-
}),
|
|
211
|
-
data: formattedTag
|
|
212
|
-
});
|
|
213
|
-
res.json(responseData);
|
|
214
|
-
return;
|
|
215
|
-
} catch (error) {
|
|
216
|
-
require_utils_errors_ErrorHandler.ErrorHandler.handleAppErrorResponse(res, error);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
exports.addTag = addTag;
|
|
223
|
-
exports.deleteTag = deleteTag;
|
|
224
|
-
exports.getTags = getTags;
|
|
225
|
-
exports.updateTag = updateTag;
|
|
226
|
-
//# sourceMappingURL=tag.controller.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag.controller.cjs","names":["getTagFiltersAndPagination","hasPermission","formatPaginatedResponse","mapTagsToAPI","tag: TagData","mapTagToAPI","formatResponse"],"sources":["../../../src/controllers/tag.controller.ts"],"sourcesContent":["import { logger } from '@logger';\nimport type { ResponseWithSession } from '@middlewares/sessionAuth.middleware';\nimport * as tagService from '@services/tag.service';\nimport { type AppError, ErrorHandler } from '@utils/errors';\nimport type { FiltersAndPagination } from '@utils/filtersAndPagination/getFiltersAndPaginationFromBody';\nimport {\n getTagFiltersAndPagination,\n type TagFiltersParams,\n} from '@utils/filtersAndPagination/getTagFiltersAndPagination';\nimport { mapTagsToAPI, mapTagToAPI } from '@utils/mapper/tag';\nimport { hasPermission } from '@utils/permissions';\nimport {\n formatPaginatedResponse,\n formatResponse,\n type PaginatedResponse,\n type ResponseData,\n} from '@utils/responseData';\nimport type { NextFunction, Request } from 'express';\nimport { t } from 'express-intlayer';\nimport type {\n Tag,\n TagAPI,\n TagCreationData,\n TagData,\n TagSchema,\n} from '@/types/tag.types';\n\nexport type GetTagsParams = FiltersAndPagination<TagFiltersParams>;\nexport type GetTagsResult = PaginatedResponse<TagAPI>;\n\n/**\n * Retrieves a list of tags based on filters and pagination.\n */\nexport const getTags = async (\n req: Request<GetTagsParams>,\n res: ResponseWithSession<GetTagsResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, organization, roles } = res.locals;\n const { filters, sortOptions, pageSize, skip, page, getNumberOfPages } =\n getTagFiltersAndPagination(req, res);\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_DEFINED');\n return;\n }\n\n try {\n const tags = await tagService.findTags(\n filters,\n skip,\n pageSize,\n sortOptions\n );\n\n if (\n !hasPermission(\n roles,\n 'tag:read'\n )({\n ...res.locals,\n targetTags: tags,\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n const totalItems = await tagService.countTags(filters);\n\n const formattedTags = mapTagsToAPI(tags);\n\n const responseData = formatPaginatedResponse<TagAPI>({\n data: formattedTags,\n page,\n pageSize,\n totalPages: getNumberOfPages(totalItems),\n totalItems,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type AddTagBody = TagCreationData;\nexport type AddTagResult = ResponseData<TagAPI>;\n\n/**\n * Adds a new tag to the database.\n */\nexport const addTag = async (\n req: Request<any, any, AddTagBody>,\n res: ResponseWithSession<AddTagResult>,\n _next: NextFunction\n): Promise<void> => {\n const { organization, project, user, roles } = res.locals;\n const tagData = req.body;\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_DEFINED');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_DEFINED');\n return;\n }\n\n if (!tagData) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_DATA_NOT_FOUND');\n }\n\n const tag: TagData = {\n creatorId: user.id,\n organizationId: organization.id,\n projectId: project.id,\n ...tagData,\n };\n\n if (\n !hasPermission(\n roles,\n 'tag:admin'\n )({\n ...res.locals,\n targetTags: [tag as Tag],\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n try {\n const newTag = await tagService.createTag(tag);\n\n const formattedTag = mapTagToAPI(newTag);\n\n const responseData = formatResponse<TagAPI>({\n message: t({\n en: 'Tag created successfully',\n fr: 'Tag créé avec succès',\n es: 'Tag creado con éxito',\n }),\n description: t({\n en: 'Your tag has been created successfully',\n fr: 'Votre tag a été créé avec succès',\n es: 'Su tag ha sido creado con éxito',\n }),\n data: formattedTag,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type UpdateTagParams = { tagId: string | Tag['id'] };\nexport type UpdateTagBody = Partial<TagData>;\nexport type UpdateTagResult = ResponseData<TagAPI>;\n\n/**\n * Updates an existing tag in the database.\n */\nexport const updateTag = async (\n req: Request<UpdateTagParams, any, UpdateTagBody>,\n res: ResponseWithSession<UpdateTagResult>,\n _next: NextFunction\n): Promise<void> => {\n const { tagId } = req.params;\n const { organization, user, roles } = res.locals;\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_DEFINED');\n return;\n }\n\n try {\n const tag = {\n _id: tagId,\n name: req.body.name,\n key: req.body.key,\n description: req.body.description,\n instructions: req.body.instructions,\n } as Partial<TagSchema> & { _id: Tag['id'] };\n\n const tagToDelete = await tagService.getTagById(tagId);\n\n if (\n !hasPermission(\n roles,\n 'tag:write'\n )({\n ...res.locals,\n targetTags: [tagToDelete],\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n if (String(tagToDelete.organizationId) !== String(organization.id)) {\n ErrorHandler.handleGenericErrorResponse(res, 'TAG_NOT_IN_ORGANIZATION');\n return;\n }\n\n const updatedTag = await tagService.updateTagById(tag._id, tag);\n\n const formattedTag = mapTagToAPI(updatedTag);\n\n const responseData = formatResponse<TagAPI>({\n message: t({\n en: 'Tag updated successfully',\n fr: 'Tag mis à jour avec succès',\n es: 'Tag actualizado con éxito',\n }),\n description: t({\n en: 'Your tag has been updated successfully',\n fr: 'Votre tag a été mis à jour avec succès',\n es: 'Su tag ha sido actualizado con éxito',\n }),\n data: formattedTag,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type DeleteTagParams = { tagId: string | Tag['id'] };\nexport type DeleteTagResult = ResponseData<TagAPI>;\n\n/**\n * Deletes a tag from the database by its ID.\n * @param req - Express request object.\n * @param res - Express response object.\n * @returns Response confirming the deletion.\n */\nexport const deleteTag = async (\n req: Request<DeleteTagParams>,\n res: ResponseWithSession<DeleteTagResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, organization, roles } = res.locals;\n const { tagId } = req.params;\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_DEFINED');\n return;\n }\n\n if (!organization) {\n ErrorHandler.handleGenericErrorResponse(res, 'ORGANIZATION_NOT_DEFINED');\n return;\n }\n\n if (!tagId) {\n ErrorHandler.handleGenericErrorResponse(res, 'TAG_ID_NOT_FOUND');\n return;\n }\n\n try {\n const tagToDelete = await tagService.getTagById(tagId);\n\n if (\n !hasPermission(\n roles,\n 'tag:admin'\n )({\n ...res.locals,\n targetTags: [tagToDelete],\n })\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'PERMISSION_DENIED');\n return;\n }\n\n if (String(tagToDelete.organizationId) !== String(organization.id)) {\n ErrorHandler.handleGenericErrorResponse(res, 'TAG_NOT_IN_ORGANIZATION');\n return;\n }\n\n const deletedTag = await tagService.deleteTagById(tagId);\n\n if (!deletedTag) {\n ErrorHandler.handleGenericErrorResponse(res, 'TAG_NOT_FOUND', {\n tagId,\n });\n\n return;\n }\n\n logger.info(`Tag deleted: ${String(deletedTag.id)}`);\n\n const formattedTag = mapTagToAPI(deletedTag);\n\n const responseData = formatResponse<TagAPI>({\n message: t({\n en: 'Tag deleted successfully',\n fr: 'Tag supprimé avec succès',\n es: 'Tag eliminado con éxito',\n }),\n description: t({\n en: 'Your tag has been deleted successfully',\n fr: 'Votre tag a été supprimé avec succès',\n es: 'Su tag ha sido eliminado con éxito',\n }),\n data: formattedTag,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":"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"}
|