@intlayer/backend 7.2.1-canary.1 → 7.2.2
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/projectAccessKey.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/OAuthTokenCreatedEmail.d.ts +4 -4
- package/dist/types/emails/OAuthTokenCreatedEmail.d.ts.map +1 -1
- package/dist/types/emails/PasswordChangeConfirmation.d.ts +4 -4
- package/dist/types/emails/ResetUserPassword.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentCancellation.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentError.d.ts +4 -4
- package/dist/types/emails/SubscriptionPaymentError.d.ts.map +1 -1
- 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/dictionary.model.d.ts.map +1 -1
- package/dist/types/models/discussion.model.d.ts +2 -2
- package/dist/types/models/oAuth2.model.d.ts +3 -3
- package/dist/types/models/oAuth2.model.d.ts.map +1 -1
- package/dist/types/routes/ai.routes.d.ts.map +1 -1
- package/dist/types/routes/eventListener.routes.d.ts.map +1 -1
- package/dist/types/routes/project.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/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/session.schema.d.ts +6 -6
- 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/getDictionaryFiltersAndPagination.d.ts +2 -2
- 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,87 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_utils_validation_validateUser = require('../utils/validation/validateUser.cjs');
|
|
3
|
-
let mongoose = require("mongoose");
|
|
4
|
-
let validator = require("validator");
|
|
5
|
-
validator = require_rolldown_runtime.__toESM(validator);
|
|
6
|
-
|
|
7
|
-
//#region src/schemas/user.schema.ts
|
|
8
|
-
const userSchema = new mongoose.Schema({
|
|
9
|
-
email: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true,
|
|
12
|
-
unique: true,
|
|
13
|
-
validate: [validator.default.isEmail, "Please fill a valid email address"],
|
|
14
|
-
lowercase: true,
|
|
15
|
-
trim: true
|
|
16
|
-
},
|
|
17
|
-
name: {
|
|
18
|
-
type: String,
|
|
19
|
-
maxlength: require_utils_validation_validateUser.NAMES_MAX_LENGTH,
|
|
20
|
-
minlength: require_utils_validation_validateUser.NAMES_MIN_LENGTH
|
|
21
|
-
},
|
|
22
|
-
phone: {
|
|
23
|
-
type: String,
|
|
24
|
-
maxlength: 20
|
|
25
|
-
},
|
|
26
|
-
customerId: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: false
|
|
29
|
-
},
|
|
30
|
-
emailsList: {
|
|
31
|
-
type: { newsLetter: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false
|
|
34
|
-
} },
|
|
35
|
-
required: false
|
|
36
|
-
},
|
|
37
|
-
role: {
|
|
38
|
-
type: String,
|
|
39
|
-
enum: ["admin", "user"],
|
|
40
|
-
default: "user",
|
|
41
|
-
required: false
|
|
42
|
-
},
|
|
43
|
-
lastLoginMethod: {
|
|
44
|
-
type: String,
|
|
45
|
-
enum: [
|
|
46
|
-
"email",
|
|
47
|
-
"google",
|
|
48
|
-
"github"
|
|
49
|
-
],
|
|
50
|
-
required: false
|
|
51
|
-
},
|
|
52
|
-
lang: {
|
|
53
|
-
type: String,
|
|
54
|
-
required: false
|
|
55
|
-
},
|
|
56
|
-
dateOfBirth: {
|
|
57
|
-
type: Date,
|
|
58
|
-
required: false
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
timestamps: true,
|
|
62
|
-
toJSON: {
|
|
63
|
-
virtuals: true,
|
|
64
|
-
versionKey: false,
|
|
65
|
-
transform(_doc, ret) {
|
|
66
|
-
const { _id, ...rest } = ret;
|
|
67
|
-
return {
|
|
68
|
-
...rest,
|
|
69
|
-
id: _id.toString()
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
toObject: {
|
|
74
|
-
virtuals: true,
|
|
75
|
-
transform(_doc, ret) {
|
|
76
|
-
const { _id, ...rest } = ret;
|
|
77
|
-
return {
|
|
78
|
-
...rest,
|
|
79
|
-
id: _id
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
exports.userSchema = userSchema;
|
|
87
|
-
//# sourceMappingURL=user.schema.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.schema.cjs","names":["Schema","NAMES_MAX_LENGTH","NAMES_MIN_LENGTH"],"sources":["../../../src/schemas/user.schema.ts"],"sourcesContent":["import {\n NAMES_MAX_LENGTH,\n NAMES_MIN_LENGTH,\n} from '@utils/validation/validateUser';\nimport { Schema } from 'mongoose';\nimport validator from 'validator';\nimport type { UserSchema } from '@/types/user.types';\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 role: {\n type: String,\n enum: ['admin', 'user'],\n default: 'user',\n required: false,\n },\n lastLoginMethod: {\n type: String,\n enum: ['email', 'google', 'github'],\n required: false,\n },\n lang: {\n type: String,\n required: false,\n },\n dateOfBirth: {\n type: Date,\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: any) {\n const { _id, ...rest } = ret;\n return {\n ...rest,\n id: _id.toString(),\n };\n },\n },\n toObject: {\n virtuals: true,\n transform(_doc, ret: any) {\n const { _id, ...rest } = ret;\n return {\n ...rest,\n id: _id,\n };\n },\n },\n }\n);\n"],"mappings":";;;;;;;AAQA,MAAa,aAAa,IAAIA,gBAC5B;CACE,OAAO;EACL,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU,CAAC,kBAAU,SAAS,oCAAoC;EAClE,WAAW;EACX,MAAM;EACP;CACD,MAAM;EACJ,MAAM;EACN,WAAWC;EACX,WAAWC;EACZ;CACD,OAAO;EACL,MAAM;EACN,WAAW;EACZ;CAED,YAAY;EACV,MAAM;EACN,UAAU;EACX;CAED,YAAY;EACV,MAAM,EACJ,YAAY;GACV,MAAM;GACN,SAAS;GACV,EACF;EACD,UAAU;EACX;CACD,MAAM;EACJ,MAAM;EACN,MAAM,CAAC,SAAS,OAAO;EACvB,SAAS;EACT,UAAU;EACX;CACD,iBAAiB;EACf,MAAM;EACN,MAAM;GAAC;GAAS;GAAU;GAAS;EACnC,UAAU;EACX;CACD,MAAM;EACJ,MAAM;EACN,UAAU;EACX;CACD,aAAa;EACX,MAAM;EACN,UAAU;EACX;CACF,EACD;CACE,YAAY;CAEZ,QAAQ;EACN,UAAU;EACV,YAAY;EACZ,UAAU,MAAM,KAAU;GACxB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,UAAO;IACL,GAAG;IACH,IAAI,IAAI,UAAU;IACnB;;EAEJ;CACD,UAAU;EACR,UAAU;EACV,UAAU,MAAM,KAAU;GACxB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,UAAO;IACL,GAAG;IACH,IAAI;IACL;;EAEJ;CACF,CACF"}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_models_dictionary_model = require('../models/dictionary.model.cjs');
|
|
3
|
-
const require_utils_ensureMongoDocumentToObject = require('../utils/ensureMongoDocumentToObject.cjs');
|
|
4
|
-
const require_utils_errors_ErrorsClass = require('../utils/errors/ErrorsClass.cjs');
|
|
5
|
-
const require_utils_removeObjectKeys = require('../utils/removeObjectKeys.cjs');
|
|
6
|
-
const require_utils_validation_validateDictionary = require('../utils/validation/validateDictionary.cjs');
|
|
7
|
-
let mongoose = require("mongoose");
|
|
8
|
-
|
|
9
|
-
//#region src/services/dictionary.service.ts
|
|
10
|
-
/**
|
|
11
|
-
* Finds dictionaries based on filters and pagination options.
|
|
12
|
-
* @param filters - MongoDB filter query.
|
|
13
|
-
* @param skip - Number of documents to skip.
|
|
14
|
-
* @param limit - Number of documents to limit.
|
|
15
|
-
* @returns List of dictionaries matching the filters.
|
|
16
|
-
*/
|
|
17
|
-
const findDictionaries = async (filters, skip = 0, limit = 100, sortOptions) => {
|
|
18
|
-
try {
|
|
19
|
-
return (await require_models_dictionary_model.DictionaryModel.aggregate([
|
|
20
|
-
{ $match: filters },
|
|
21
|
-
...sortOptions && Object.keys(sortOptions).length > 0 ? [{ $sort: sortOptions }] : [],
|
|
22
|
-
{ $skip: skip },
|
|
23
|
-
{ $limit: limit }
|
|
24
|
-
])).map((result) => new require_models_dictionary_model.DictionaryModel(result));
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error("Error fetching dictionaries:", error);
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Finds a dictionary by its ID.
|
|
32
|
-
* @param dictionaryId - The ID of the dictionary to find.
|
|
33
|
-
* @returns The dictionary matching the ID.
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Finds a dictionary by its ID and includes the 'versions' field.
|
|
37
|
-
* @param dictionaryId - The ID of the dictionary to find.
|
|
38
|
-
* @returns The dictionary matching the ID with available versions.
|
|
39
|
-
*/
|
|
40
|
-
const getDictionaryById = async (dictionaryId) => {
|
|
41
|
-
const id = mongoose.Types.ObjectId.isValid(dictionaryId) ? new mongoose.Types.ObjectId(dictionaryId) : dictionaryId;
|
|
42
|
-
const dictionaries = await require_models_dictionary_model.DictionaryModel.aggregate([{ $match: { _id: id } }, { $addFields: { versions: { $map: {
|
|
43
|
-
input: { $objectToArray: "$content" },
|
|
44
|
-
as: "version",
|
|
45
|
-
in: "$$version.k"
|
|
46
|
-
} } } }]);
|
|
47
|
-
if (!dictionaries.length) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_NOT_FOUND", { dictionaryId });
|
|
48
|
-
return new require_models_dictionary_model.DictionaryModel(dictionaries[0]);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Finds a dictionary by its ID.
|
|
52
|
-
* @param dictionaryKey - The ID of the dictionary to find.
|
|
53
|
-
* @returns The dictionary matching the ID.
|
|
54
|
-
*/
|
|
55
|
-
const getDictionaryByKey = async (dictionaryKey, projectId) => {
|
|
56
|
-
return (await getDictionariesByKeys([dictionaryKey], projectId))[0];
|
|
57
|
-
};
|
|
58
|
-
const getDictionariesByKeys = async (dictionaryKeys, projectId) => {
|
|
59
|
-
const dictionaries = await require_models_dictionary_model.DictionaryModel.aggregate([{ $match: {
|
|
60
|
-
key: { $in: dictionaryKeys },
|
|
61
|
-
projectIds: projectId
|
|
62
|
-
} }, { $addFields: { versions: { $map: {
|
|
63
|
-
input: { $objectToArray: "$content" },
|
|
64
|
-
as: "version",
|
|
65
|
-
in: "$$version.k"
|
|
66
|
-
} } } }]);
|
|
67
|
-
if (!dictionaries) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_NOT_FOUND", {
|
|
68
|
-
dictionaryKeys,
|
|
69
|
-
projectId
|
|
70
|
-
});
|
|
71
|
-
return dictionaries.map((result) => new require_models_dictionary_model.DictionaryModel(result));
|
|
72
|
-
};
|
|
73
|
-
const getDictionariesByTags = async (tags, projectId) => {
|
|
74
|
-
return (await require_models_dictionary_model.DictionaryModel.aggregate([{ $match: {
|
|
75
|
-
tags: { $in: tags },
|
|
76
|
-
projectIds: projectId
|
|
77
|
-
} }, { $addFields: { versions: { $map: {
|
|
78
|
-
input: { $objectToArray: "$content" },
|
|
79
|
-
as: "version",
|
|
80
|
-
in: "$$version.k"
|
|
81
|
-
} } } }])).map((result) => new require_models_dictionary_model.DictionaryModel(result));
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Counts the total number of dictionaries that match the filters.
|
|
85
|
-
* @param filters - MongoDB filter query.
|
|
86
|
-
* @returns Total number of dictionaries.
|
|
87
|
-
*/
|
|
88
|
-
const countDictionaries = async (filters) => {
|
|
89
|
-
const result = await require_models_dictionary_model.DictionaryModel.countDocuments(filters);
|
|
90
|
-
if (typeof result === "undefined") throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_COUNT_FAILED", { filters });
|
|
91
|
-
return result;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Creates a new dictionary in the database.
|
|
95
|
-
* @param dictionary - The dictionary data to create.
|
|
96
|
-
* @returns The created dictionary.
|
|
97
|
-
*/
|
|
98
|
-
const createDictionary = async (dictionary) => {
|
|
99
|
-
const errors = await require_utils_validation_validateDictionary.validateDictionary(dictionary);
|
|
100
|
-
if (Object.keys(errors).length > 0) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_INVALID_FIELDS", { errors });
|
|
101
|
-
return await require_models_dictionary_model.DictionaryModel.create(dictionary);
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Updates an existing dictionary in the database by its ID.
|
|
105
|
-
* @param dictionaryId - The ID of the dictionary to update.
|
|
106
|
-
* @param dictionary - The updated dictionary data.
|
|
107
|
-
* @returns The updated dictionary.
|
|
108
|
-
*/
|
|
109
|
-
const updateDictionaryById = async (dictionaryId, dictionary) => {
|
|
110
|
-
const dictionaryToUpdate = require_utils_removeObjectKeys.removeObjectKeys(require_utils_ensureMongoDocumentToObject.ensureMongoDocumentToObject(dictionary), ["id"]);
|
|
111
|
-
const errors = await require_utils_validation_validateDictionary.validateDictionary(dictionaryToUpdate, Object.keys(dictionaryToUpdate));
|
|
112
|
-
if (Object.keys(errors).length > 0) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_INVALID_FIELDS", {
|
|
113
|
-
dictionaryId,
|
|
114
|
-
errors
|
|
115
|
-
});
|
|
116
|
-
if ((await require_models_dictionary_model.DictionaryModel.updateOne({ _id: dictionaryId }, dictionaryToUpdate)).matchedCount === 0) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryId });
|
|
117
|
-
return await getDictionaryById(dictionaryId);
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Updates an existing dictionary in the database by its key.
|
|
121
|
-
* @param dictionaryKey - The ID of the dictionary to update.
|
|
122
|
-
* @param dictionary - The updated dictionary data.
|
|
123
|
-
* @returns The updated dictionary.
|
|
124
|
-
*/
|
|
125
|
-
const updateDictionaryByKey = async (dictionaryKey, dictionary, projectId) => {
|
|
126
|
-
const existing = await require_models_dictionary_model.DictionaryModel.findOne({
|
|
127
|
-
key: dictionaryKey,
|
|
128
|
-
projectIds: projectId
|
|
129
|
-
});
|
|
130
|
-
if (!existing) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_UPDATE_FAILED", { dictionaryKey });
|
|
131
|
-
const dictionaryToUpdate = require_utils_removeObjectKeys.removeObjectKeys(require_utils_ensureMongoDocumentToObject.ensureMongoDocumentToObject(dictionary), ["id"]);
|
|
132
|
-
Object.assign(existing, dictionaryToUpdate);
|
|
133
|
-
await existing.save();
|
|
134
|
-
return existing;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Deletes a dictionary from the database by its ID.
|
|
138
|
-
* @param dictionaryId - The ID of the dictionary to delete.
|
|
139
|
-
* @returns The result of the deletion operation.
|
|
140
|
-
*/
|
|
141
|
-
const deleteDictionaryById = async (dictionaryId) => {
|
|
142
|
-
const dictionary = await require_models_dictionary_model.DictionaryModel.findByIdAndDelete(dictionaryId);
|
|
143
|
-
if (!dictionary) throw new require_utils_errors_ErrorsClass.GenericError("DICTIONARY_NOT_FOUND", { dictionaryId });
|
|
144
|
-
return dictionary;
|
|
145
|
-
};
|
|
146
|
-
const getVersionNumber = (version) => {
|
|
147
|
-
const match = version.match(/^v(\d+)$/);
|
|
148
|
-
if (!match) throw new Error(`Invalid version format: ${version}`);
|
|
149
|
-
return parseInt(match[1], 10);
|
|
150
|
-
};
|
|
151
|
-
const incrementVersion = (dictionary) => {
|
|
152
|
-
const VERSION_PREFIX = "v";
|
|
153
|
-
const versions = [...dictionary.content.keys() ?? []];
|
|
154
|
-
const lastVersion = versions[versions.length - 1];
|
|
155
|
-
let newNumber = getVersionNumber(lastVersion) + 1;
|
|
156
|
-
let newVersion = `${VERSION_PREFIX}${newNumber}`;
|
|
157
|
-
while (versions.includes(newVersion)) {
|
|
158
|
-
newNumber += 1;
|
|
159
|
-
newVersion = `${VERSION_PREFIX}${newNumber}`;
|
|
160
|
-
}
|
|
161
|
-
return newVersion;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
//#endregion
|
|
165
|
-
exports.countDictionaries = countDictionaries;
|
|
166
|
-
exports.createDictionary = createDictionary;
|
|
167
|
-
exports.deleteDictionaryById = deleteDictionaryById;
|
|
168
|
-
exports.findDictionaries = findDictionaries;
|
|
169
|
-
exports.getDictionariesByKeys = getDictionariesByKeys;
|
|
170
|
-
exports.getDictionariesByTags = getDictionariesByTags;
|
|
171
|
-
exports.getDictionaryById = getDictionaryById;
|
|
172
|
-
exports.getDictionaryByKey = getDictionaryByKey;
|
|
173
|
-
exports.incrementVersion = incrementVersion;
|
|
174
|
-
exports.updateDictionaryById = updateDictionaryById;
|
|
175
|
-
exports.updateDictionaryByKey = updateDictionaryByKey;
|
|
176
|
-
//# sourceMappingURL=dictionary.service.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.service.cjs","names":["DictionaryModel","Types","GenericError","validateDictionary","removeObjectKeys","ensureMongoDocumentToObject"],"sources":["../../../src/services/dictionary.service.ts"],"sourcesContent":["import { DictionaryModel } from '@models/dictionary.model';\nimport { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject';\nimport { GenericError } from '@utils/errors';\nimport type { DictionaryFilters } from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport { removeObjectKeys } from '@utils/removeObjectKeys';\nimport {\n type DictionaryFields,\n validateDictionary,\n} from '@utils/validation/validateDictionary';\nimport { Types } from 'mongoose';\nimport type {\n Dictionary,\n DictionaryData,\n DictionaryDocument,\n} from '@/types/dictionary.types';\nimport type { Project } from '@/types/project.types';\n\n/**\n * Finds dictionaries based on filters and pagination options.\n * @param filters - MongoDB filter query.\n * @param skip - Number of documents to skip.\n * @param limit - Number of documents to limit.\n * @returns List of dictionaries matching the filters.\n */\nexport const findDictionaries = async (\n filters: DictionaryFilters,\n skip = 0,\n limit = 100,\n sortOptions?: Record<string, 1 | -1>\n): Promise<DictionaryDocument[]> => {\n try {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the filters\n { $match: filters },\n\n // Stage 2: Sort if provided (default handled in filter builder)\n ...(sortOptions && Object.keys(sortOptions).length > 0\n ? [{ $sort: sortOptions }]\n : []),\n\n // Stage 3: Skip for pagination\n { $skip: skip },\n\n // Stage 4: Limit the number of documents\n { $limit: limit },\n ]);\n\n const formattedResults = dictionaries.map(\n (result) => new DictionaryModel(result)\n );\n\n return formattedResults;\n } catch (error) {\n console.error('Error fetching dictionaries:', error);\n throw error;\n }\n};\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryId - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\n/**\n * Finds a dictionary by its ID and includes the 'versions' field.\n * @param dictionaryId - The ID of the dictionary to find.\n * @returns The dictionary matching the ID with available versions.\n */\nexport const getDictionaryById = async (\n dictionaryId: string | Types.ObjectId\n): Promise<DictionaryDocument> => {\n const id = Types.ObjectId.isValid(dictionaryId as string)\n ? new Types.ObjectId(dictionaryId as string)\n : dictionaryId;\n\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by ID\n { $match: { _id: id } },\n\n // Stage 2: Add the 'versions' field\n {\n $addFields: {\n versions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n if (!dictionaries.length) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return new DictionaryModel(dictionaries[0]);\n};\n\n/**\n * Finds a dictionary by its ID.\n * @param dictionaryKey - The ID of the dictionary to find.\n * @returns The dictionary matching the ID.\n */\nexport const getDictionaryByKey = async (\n dictionaryKey: string,\n projectId: string | Types.ObjectId\n): Promise<DictionaryDocument> => {\n const dictionaries = await getDictionariesByKeys([dictionaryKey], projectId);\n\n return dictionaries[0];\n};\n\nexport const getDictionariesByKeys = async (\n dictionaryKeys: string[],\n projectId: string | Types.ObjectId\n): Promise<DictionaryDocument[]> => {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by key\n { $match: { key: { $in: dictionaryKeys }, projectIds: projectId } },\n\n // Stage 2: Add the 'versions' field\n {\n $addFields: {\n versions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n if (!dictionaries) {\n throw new GenericError('DICTIONARY_NOT_FOUND', {\n dictionaryKeys,\n projectId,\n });\n }\n\n const formattedResults = dictionaries.map(\n (result) => new DictionaryModel(result)\n );\n\n return formattedResults;\n};\n\nexport const getDictionariesByTags = async (\n tags: string[],\n projectId: string | Project['id']\n): Promise<DictionaryDocument[]> => {\n const dictionaries = await DictionaryModel.aggregate<DictionaryDocument>([\n // Stage 1: Match the document by tags\n {\n $match: {\n tags: { $in: tags },\n projectIds: projectId,\n },\n },\n\n // Stage 2: Add the 'versions' field\n {\n $addFields: {\n versions: {\n $map: {\n input: { $objectToArray: '$content' },\n as: 'version',\n in: '$$version.k',\n },\n },\n },\n },\n ]);\n\n const formattedResults = dictionaries.map(\n (result) => new DictionaryModel(result)\n );\n\n return formattedResults;\n};\n\n/**\n * Counts the total number of dictionaries that match the filters.\n * @param filters - MongoDB filter query.\n * @returns Total number of dictionaries.\n */\nexport const countDictionaries = async (\n filters: DictionaryFilters\n): Promise<number> => {\n const result = await DictionaryModel.countDocuments(filters);\n\n if (typeof result === 'undefined') {\n throw new GenericError('DICTIONARY_COUNT_FAILED', { filters });\n }\n\n return result;\n};\n\n/**\n * Creates a new dictionary in the database.\n * @param dictionary - The dictionary data to create.\n * @returns The created dictionary.\n */\nexport const createDictionary = async (\n dictionary: DictionaryData\n): Promise<DictionaryDocument> => {\n const errors = await validateDictionary(dictionary);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n errors,\n });\n }\n\n return await DictionaryModel.create(dictionary);\n};\n\n/**\n * Updates an existing dictionary in the database by its ID.\n * @param dictionaryId - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryById = async (\n dictionaryId: string | Types.ObjectId,\n dictionary: Partial<Dictionary>\n): Promise<DictionaryDocument> => {\n const dictionaryObject = ensureMongoDocumentToObject(dictionary);\n const dictionaryToUpdate = removeObjectKeys(dictionaryObject, [\n 'id',\n ]) as unknown as Partial<Dictionary>;\n\n const updatedKeys = Object.keys(dictionaryToUpdate) as DictionaryFields;\n const errors = await validateDictionary(dictionaryToUpdate, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('DICTIONARY_INVALID_FIELDS', {\n dictionaryId,\n errors,\n });\n }\n\n const result = await DictionaryModel.updateOne(\n { _id: dictionaryId },\n dictionaryToUpdate\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryId });\n }\n\n const updatedDictionary = await getDictionaryById(dictionaryId);\n\n return updatedDictionary;\n};\n\n/**\n * Updates an existing dictionary in the database by its key.\n * @param dictionaryKey - The ID of the dictionary to update.\n * @param dictionary - The updated dictionary data.\n * @returns The updated dictionary.\n */\nexport const updateDictionaryByKey = async (\n dictionaryKey: string,\n dictionary: Partial<Dictionary>,\n projectId: string | Types.ObjectId\n): Promise<DictionaryDocument> => {\n const existing = await DictionaryModel.findOne({\n key: dictionaryKey,\n projectIds: projectId,\n });\n\n if (!existing) {\n throw new GenericError('DICTIONARY_UPDATE_FAILED', { dictionaryKey });\n }\n\n const dictionaryObject = ensureMongoDocumentToObject(dictionary);\n const dictionaryToUpdate = removeObjectKeys(dictionaryObject, [\n 'id',\n ]) as Partial<Dictionary>;\n\n // Optional: run your validateDictionary on dictionaryToUpdate here\n\n // Apply updated fields onto the existing doc\n Object.assign(existing, dictionaryToUpdate);\n\n // Save – this will trigger timestamps on parent + subdocs\n await existing.save();\n\n return existing;\n};\n\n/**\n * Deletes a dictionary from the database by its ID.\n * @param dictionaryId - The ID of the dictionary to delete.\n * @returns The result of the deletion operation.\n */\nexport const deleteDictionaryById = async (\n dictionaryId: string\n): Promise<DictionaryDocument> => {\n const dictionary = await DictionaryModel.findByIdAndDelete(dictionaryId);\n\n if (!dictionary) {\n throw new GenericError('DICTIONARY_NOT_FOUND', { dictionaryId });\n }\n\n return dictionary;\n};\n\n// Function to extract the numeric part of the version\nconst getVersionNumber = (version: string): number => {\n const match = version.match(/^v(\\d+)$/);\n if (!match) {\n throw new Error(`Invalid version format: ${version}`);\n }\n return parseInt(match[1], 10);\n};\n\nexport const incrementVersion = (dictionary: Dictionary): string => {\n const VERSION_PREFIX = 'v';\n\n const versions = [...(dictionary.content.keys() ?? [])];\n const lastVersion = versions[versions.length - 1];\n\n // Start with the next version number\n let newNumber = getVersionNumber(lastVersion) + 1;\n let newVersion = `${VERSION_PREFIX}${newNumber}`;\n\n // Loop until a unique version is found\n while (versions.includes(newVersion)) {\n newNumber += 1;\n newVersion = `${VERSION_PREFIX}${newNumber}`;\n }\n\n return newVersion;\n};\n"],"mappings":"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"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_logger_index = require('../logger/index.cjs');
|
|
3
|
-
const require_emails_InviteUserEmail = require('../emails/InviteUserEmail.cjs');
|
|
4
|
-
const require_emails_MagicLinkEmail = require('../emails/MagicLinkEmail.cjs');
|
|
5
|
-
const require_emails_OAuthTokenCreatedEmail = require('../emails/OAuthTokenCreatedEmail.cjs');
|
|
6
|
-
const require_emails_PasswordChangeConfirmation = require('../emails/PasswordChangeConfirmation.cjs');
|
|
7
|
-
const require_emails_ResetUserPassword = require('../emails/ResetUserPassword.cjs');
|
|
8
|
-
const require_emails_SubscriptionPaymentCancellation = require('../emails/SubscriptionPaymentCancellation.cjs');
|
|
9
|
-
const require_emails_SubscriptionPaymentError = require('../emails/SubscriptionPaymentError.cjs');
|
|
10
|
-
const require_emails_SubscriptionPaymentSuccess = require('../emails/SubscriptionPaymentSuccess.cjs');
|
|
11
|
-
const require_emails_ValidateUserEmail = require('../emails/ValidateUserEmail.cjs');
|
|
12
|
-
const require_emails_Welcome = require('../emails/Welcome.cjs');
|
|
13
|
-
let express_intlayer = require("express-intlayer");
|
|
14
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
-
let resend = require("resend");
|
|
16
|
-
|
|
17
|
-
//#region src/services/email.service.tsx
|
|
18
|
-
const getEmailComponents = (locale) => ({
|
|
19
|
-
invite: {
|
|
20
|
-
template: (0, express_intlayer.t)({
|
|
21
|
-
en: require_emails_InviteUserEmail.InviteUserEmailEN,
|
|
22
|
-
fr: require_emails_InviteUserEmail.InviteUserEmailFR,
|
|
23
|
-
es: require_emails_InviteUserEmail.InviteUserEmailES
|
|
24
|
-
}, locale),
|
|
25
|
-
subject: (0, express_intlayer.t)({
|
|
26
|
-
en: "You have been invited to join Intlayer",
|
|
27
|
-
fr: "Vous êtes invité à rejoindre Intlayer",
|
|
28
|
-
es: "Has sido invitado a unirte a Intlayer"
|
|
29
|
-
}, locale)
|
|
30
|
-
},
|
|
31
|
-
validate: {
|
|
32
|
-
template: (0, express_intlayer.t)({
|
|
33
|
-
en: require_emails_ValidateUserEmail.ValidateUserEmailEN,
|
|
34
|
-
fr: require_emails_ValidateUserEmail.ValidateUserEmailFR,
|
|
35
|
-
es: require_emails_ValidateUserEmail.ValidateUserEmailES
|
|
36
|
-
}, locale),
|
|
37
|
-
subject: (0, express_intlayer.t)({
|
|
38
|
-
en: "Validate your email for Intlayer",
|
|
39
|
-
fr: "Validez votre email pour Intlayer",
|
|
40
|
-
es: "Valida tu correo electrónico para Intlayer"
|
|
41
|
-
}, locale)
|
|
42
|
-
},
|
|
43
|
-
resetPassword: {
|
|
44
|
-
template: (0, express_intlayer.t)({
|
|
45
|
-
en: require_emails_ResetUserPassword.ResetPasswordEmailEN,
|
|
46
|
-
fr: require_emails_ResetUserPassword.ResetPasswordEmailFR,
|
|
47
|
-
es: require_emails_ResetUserPassword.ResetPasswordEmailES
|
|
48
|
-
}, locale),
|
|
49
|
-
subject: (0, express_intlayer.t)({
|
|
50
|
-
en: "Reset your password for Intlayer",
|
|
51
|
-
fr: "Réinitialisez votre mot de passe pour Intlayer",
|
|
52
|
-
es: "Restablece tu contraseña para Intlayer"
|
|
53
|
-
}, locale)
|
|
54
|
-
},
|
|
55
|
-
welcome: {
|
|
56
|
-
template: (0, express_intlayer.t)({
|
|
57
|
-
en: require_emails_Welcome.WelcomeEmailEN,
|
|
58
|
-
fr: require_emails_Welcome.WelcomeEmailFR,
|
|
59
|
-
es: require_emails_Welcome.WelcomeEmailES
|
|
60
|
-
}, locale),
|
|
61
|
-
subject: (0, express_intlayer.t)({
|
|
62
|
-
en: "Welcome to Intlayer!",
|
|
63
|
-
fr: "Bienvenue chez Intlayer!",
|
|
64
|
-
es: "¡Bienvenido a Intlayer!"
|
|
65
|
-
}, locale)
|
|
66
|
-
},
|
|
67
|
-
magicLink: {
|
|
68
|
-
template: (0, express_intlayer.t)({
|
|
69
|
-
en: require_emails_MagicLinkEmail.MagicLinkEmailEN,
|
|
70
|
-
fr: require_emails_MagicLinkEmail.MagicLinkEmailFR,
|
|
71
|
-
es: require_emails_MagicLinkEmail.MagicLinkEmailES
|
|
72
|
-
}, locale),
|
|
73
|
-
subject: (0, express_intlayer.t)({
|
|
74
|
-
en: "Sign in to Intlayer",
|
|
75
|
-
fr: "Connectez-vous à Intlayer",
|
|
76
|
-
es: "Inicia sesión en Intlayer"
|
|
77
|
-
}, locale)
|
|
78
|
-
},
|
|
79
|
-
passwordChangeConfirmation: {
|
|
80
|
-
template: (0, express_intlayer.t)({
|
|
81
|
-
en: require_emails_PasswordChangeConfirmation.PasswordChangeConfirmationEmailEN,
|
|
82
|
-
fr: require_emails_PasswordChangeConfirmation.PasswordChangeConfirmationEmailFR,
|
|
83
|
-
es: require_emails_PasswordChangeConfirmation.PasswordChangeConfirmationEmailES
|
|
84
|
-
}, locale),
|
|
85
|
-
subject: (0, express_intlayer.t)({
|
|
86
|
-
en: "Your Intlayer password has been changed",
|
|
87
|
-
fr: "Votre mot de passe Intlayer a été modifié",
|
|
88
|
-
es: "Tu contraseña de Intlayer ha sido cambiada"
|
|
89
|
-
}, locale)
|
|
90
|
-
},
|
|
91
|
-
subscriptionPaymentSuccess: {
|
|
92
|
-
template: (0, express_intlayer.t)({
|
|
93
|
-
en: require_emails_SubscriptionPaymentSuccess.SubscriptionPaymentSuccessEN,
|
|
94
|
-
fr: require_emails_SubscriptionPaymentSuccess.SubscriptionPaymentSuccessFR,
|
|
95
|
-
es: require_emails_SubscriptionPaymentSuccess.SubscriptionPaymentSuccessES
|
|
96
|
-
}),
|
|
97
|
-
subject: (0, express_intlayer.t)({
|
|
98
|
-
en: "Your payment for Intlayer subscription is confirmed",
|
|
99
|
-
fr: "Votre paiement pour l'abonnement Intlayer est confirmé",
|
|
100
|
-
es: "Tu pago por la suscripción de Intlayer ha sido confirmado"
|
|
101
|
-
})
|
|
102
|
-
},
|
|
103
|
-
subscriptionPaymentCancellation: {
|
|
104
|
-
template: (0, express_intlayer.t)({
|
|
105
|
-
en: require_emails_SubscriptionPaymentCancellation.SubscriptionPaymentCancellationEN,
|
|
106
|
-
fr: require_emails_SubscriptionPaymentCancellation.SubscriptionPaymentCancellationFR,
|
|
107
|
-
es: require_emails_SubscriptionPaymentCancellation.SubscriptionPaymentCancellationES
|
|
108
|
-
}),
|
|
109
|
-
subject: (0, express_intlayer.t)({
|
|
110
|
-
en: "Your Intlayer subscription has been canceled",
|
|
111
|
-
fr: "Votre abonnement Intlayer a été annulé",
|
|
112
|
-
es: "Tu suscripción de Intlayer ha sido cancelada"
|
|
113
|
-
})
|
|
114
|
-
},
|
|
115
|
-
subscriptionPaymentError: {
|
|
116
|
-
template: (0, express_intlayer.t)({
|
|
117
|
-
en: require_emails_SubscriptionPaymentError.SubscriptionPaymentErrorEN,
|
|
118
|
-
fr: require_emails_SubscriptionPaymentError.SubscriptionPaymentErrorFR,
|
|
119
|
-
es: require_emails_SubscriptionPaymentError.SubscriptionPaymentErrorES
|
|
120
|
-
}),
|
|
121
|
-
subject: (0, express_intlayer.t)({
|
|
122
|
-
en: "There was an issue with your Intlayer subscription payment",
|
|
123
|
-
fr: "Un problème est survenu avec votre paiement pour l'abonnement Intlayer",
|
|
124
|
-
es: "Hubo un problema con el pago de tu suscripción de Intlayer"
|
|
125
|
-
})
|
|
126
|
-
},
|
|
127
|
-
oAuthTokenCreated: {
|
|
128
|
-
template: (0, express_intlayer.t)({
|
|
129
|
-
en: require_emails_OAuthTokenCreatedEmail.OAuthTokenCreatedEmailEN,
|
|
130
|
-
fr: require_emails_OAuthTokenCreatedEmail.OAuthTokenCreatedEmailFR,
|
|
131
|
-
es: require_emails_OAuthTokenCreatedEmail.OAuthTokenCreatedEmailES
|
|
132
|
-
}),
|
|
133
|
-
subject: (0, express_intlayer.t)({
|
|
134
|
-
en: "A third-party OAuth application has been added to your Intlayer account",
|
|
135
|
-
fr: "Une application OAuth tierce a été ajoutée à votre compte Intlayer",
|
|
136
|
-
es: "Una aplicación OAuth de terceros ha sido añadida a tu cuenta de Intlayer"
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
const sendEmail = async ({ type, to, subject, locale, ...props }) => {
|
|
141
|
-
const resend$1 = new resend.Resend(process.env.RESEND_API_KEY);
|
|
142
|
-
const { template, subject: baseSubject } = getEmailComponents(locale)[type];
|
|
143
|
-
const react = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(template, { ...props });
|
|
144
|
-
await resend$1.emails.send({
|
|
145
|
-
from: "Intlayer <no-reply@intlayer.org>",
|
|
146
|
-
to,
|
|
147
|
-
subject: subject ?? baseSubject,
|
|
148
|
-
react
|
|
149
|
-
}).catch((err) => require_logger_index.logger.error(err));
|
|
150
|
-
require_logger_index.logger.info(`Email sent ${type} to ${to}`);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
|
-
exports.sendEmail = sendEmail;
|
|
155
|
-
//# sourceMappingURL=email.service.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.cjs","names":["InviteUserEmailEN","InviteUserEmailFR","InviteUserEmailES","ValidateUserEmailEN","ValidateUserEmailFR","ValidateUserEmailES","ResetPasswordEmailEN","ResetPasswordEmailFR","ResetPasswordEmailES","WelcomeEmailEN","WelcomeEmailFR","WelcomeEmailES","MagicLinkEmailEN","MagicLinkEmailFR","MagicLinkEmailES","PasswordChangeConfirmationEmailEN","PasswordChangeConfirmationEmailFR","PasswordChangeConfirmationEmailES","SubscriptionPaymentSuccessEN","SubscriptionPaymentSuccessFR","SubscriptionPaymentSuccessES","SubscriptionPaymentCancellationEN","SubscriptionPaymentCancellationFR","SubscriptionPaymentCancellationES","SubscriptionPaymentErrorEN","SubscriptionPaymentErrorFR","SubscriptionPaymentErrorES","OAuthTokenCreatedEmailEN","OAuthTokenCreatedEmailFR","OAuthTokenCreatedEmailES","resend","Resend","logger"],"sources":["../../../src/services/email.service.tsx"],"sourcesContent":["import {\n InviteUserEmailEN,\n InviteUserEmailES,\n InviteUserEmailFR,\n} from '@emails/InviteUserEmail';\nimport {\n MagicLinkEmailEN,\n MagicLinkEmailES,\n MagicLinkEmailFR,\n} from '@emails/MagicLinkEmail';\nimport {\n OAuthTokenCreatedEmailEN,\n OAuthTokenCreatedEmailES,\n OAuthTokenCreatedEmailFR,\n} from '@emails/OAuthTokenCreatedEmail';\nimport {\n PasswordChangeConfirmationEmailEN,\n PasswordChangeConfirmationEmailES,\n PasswordChangeConfirmationEmailFR,\n} from '@emails/PasswordChangeConfirmation';\nimport {\n ResetPasswordEmailEN,\n ResetPasswordEmailES,\n ResetPasswordEmailFR,\n} from '@emails/ResetUserPassword';\n\nimport {\n SubscriptionPaymentCancellationEN,\n SubscriptionPaymentCancellationES,\n SubscriptionPaymentCancellationFR,\n} from '@emails/SubscriptionPaymentCancellation';\nimport {\n SubscriptionPaymentErrorEN,\n SubscriptionPaymentErrorES,\n SubscriptionPaymentErrorFR,\n} from '@emails/SubscriptionPaymentError';\nimport {\n SubscriptionPaymentSuccessEN,\n SubscriptionPaymentSuccessES,\n SubscriptionPaymentSuccessFR,\n} from '@emails/SubscriptionPaymentSuccess';\nimport {\n ValidateUserEmailEN,\n ValidateUserEmailES,\n ValidateUserEmailFR,\n} from '@emails/ValidateUserEmail';\nimport {\n WelcomeEmailEN,\n WelcomeEmailES,\n WelcomeEmailFR,\n} from '@emails/Welcome';\nimport type { Locale } from '@intlayer/types';\nimport { logger } from '@logger';\nimport { t } from 'express-intlayer';\nimport type { ComponentProps, JSX } from 'react';\nimport { Resend } from 'resend';\n\ntype EmailComponentsType = (...props: any) => JSX.Element;\ntype EmailComponents = {\n [key: string]: {\n template: EmailComponentsType;\n subject: string;\n };\n};\n\nconst getEmailComponents = (locale?: Locale) =>\n ({\n invite: {\n template: t(\n {\n en: InviteUserEmailEN,\n fr: InviteUserEmailFR,\n es: InviteUserEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'You have been invited to join Intlayer',\n fr: 'Vous êtes invité à rejoindre Intlayer',\n es: 'Has sido invitado a unirte a Intlayer',\n },\n locale\n ),\n },\n validate: {\n template: t(\n {\n en: ValidateUserEmailEN,\n fr: ValidateUserEmailFR,\n es: ValidateUserEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'Validate your email for Intlayer',\n fr: 'Validez votre email pour Intlayer',\n es: 'Valida tu correo electrónico para Intlayer',\n },\n locale\n ),\n },\n resetPassword: {\n template: t(\n {\n en: ResetPasswordEmailEN,\n fr: ResetPasswordEmailFR,\n es: ResetPasswordEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'Reset your password for Intlayer',\n fr: 'Réinitialisez votre mot de passe pour Intlayer',\n es: 'Restablece tu contraseña para Intlayer',\n },\n locale\n ),\n },\n welcome: {\n template: t(\n {\n en: WelcomeEmailEN,\n fr: WelcomeEmailFR,\n es: WelcomeEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'Welcome to Intlayer!',\n fr: 'Bienvenue chez Intlayer!',\n es: '¡Bienvenido a Intlayer!',\n },\n locale\n ),\n },\n magicLink: {\n template: t(\n {\n en: MagicLinkEmailEN,\n fr: MagicLinkEmailFR,\n es: MagicLinkEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'Sign in to Intlayer',\n fr: 'Connectez-vous à Intlayer',\n es: 'Inicia sesión en Intlayer',\n },\n locale\n ),\n },\n passwordChangeConfirmation: {\n template: t(\n {\n en: PasswordChangeConfirmationEmailEN,\n fr: PasswordChangeConfirmationEmailFR,\n es: PasswordChangeConfirmationEmailES,\n },\n locale\n ),\n subject: t(\n {\n en: 'Your Intlayer password has been changed',\n fr: 'Votre mot de passe Intlayer a été modifié',\n es: 'Tu contraseña de Intlayer ha sido cambiada',\n },\n locale\n ),\n },\n subscriptionPaymentSuccess: {\n template: t({\n en: SubscriptionPaymentSuccessEN,\n fr: SubscriptionPaymentSuccessFR,\n es: SubscriptionPaymentSuccessES,\n }),\n subject: t({\n en: 'Your payment for Intlayer subscription is confirmed',\n fr: \"Votre paiement pour l'abonnement Intlayer est confirmé\",\n es: 'Tu pago por la suscripción de Intlayer ha sido confirmado',\n }),\n },\n subscriptionPaymentCancellation: {\n template: t({\n en: SubscriptionPaymentCancellationEN,\n fr: SubscriptionPaymentCancellationFR,\n es: SubscriptionPaymentCancellationES,\n }),\n subject: t({\n en: 'Your Intlayer subscription has been canceled',\n fr: 'Votre abonnement Intlayer a été annulé',\n es: 'Tu suscripción de Intlayer ha sido cancelada',\n }),\n },\n subscriptionPaymentError: {\n template: t({\n en: SubscriptionPaymentErrorEN,\n fr: SubscriptionPaymentErrorFR,\n es: SubscriptionPaymentErrorES,\n }),\n subject: t({\n en: 'There was an issue with your Intlayer subscription payment',\n fr: \"Un problème est survenu avec votre paiement pour l'abonnement Intlayer\",\n es: 'Hubo un problema con el pago de tu suscripción de Intlayer',\n }),\n },\n oAuthTokenCreated: {\n template: t({\n en: OAuthTokenCreatedEmailEN,\n fr: OAuthTokenCreatedEmailFR,\n es: OAuthTokenCreatedEmailES,\n }),\n subject: t({\n en: 'A third-party OAuth application has been added to your Intlayer account',\n fr: 'Une application OAuth tierce a été ajoutée à votre compte Intlayer',\n es: 'Una aplicación OAuth de terceros ha sido añadida a tu cuenta de Intlayer',\n }),\n },\n }) satisfies EmailComponents;\n\ntype EmailType = keyof ReturnType<typeof getEmailComponents>;\n\nexport type SendEmailProps<T extends EmailType> = {\n type: T;\n to: string;\n subject?: string;\n locale?: Locale;\n} & ComponentProps<ReturnType<typeof getEmailComponents>[T]['template']>;\n\nexport const sendEmail = async <T extends EmailType>({\n type,\n to,\n subject,\n locale,\n ...props\n}: SendEmailProps<T>) => {\n const resend = new Resend(process.env.RESEND_API_KEY);\n\n const emailComponents = getEmailComponents(locale);\n\n const { template, subject: baseSubject } = emailComponents[type];\n\n type EmailComponentType = (typeof emailComponents)[T]['template'];\n\n const EmailComponent: EmailComponentType = template;\n\n const react = <EmailComponent {...(props as any)} />;\n\n await resend.emails\n .send({\n from: 'Intlayer <no-reply@intlayer.org>',\n to,\n subject: subject ?? baseSubject,\n react,\n })\n .catch((err) => logger.error(err));\n\n logger.info(`Email sent ${type} to ${to}`);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiEA,MAAM,sBAAsB,YACzB;CACC,QAAQ;EACN,kCACE;GACE,IAAIA;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,UAAU;EACR,kCACE;GACE,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,eAAe;EACb,kCACE;GACE,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,SAAS;EACP,kCACE;GACE,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,WAAW;EACT,kCACE;GACE,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,4BAA4B;EAC1B,kCACE;GACE,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,EACD,OACD;EACD,iCACE;GACE,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,EACD,OACD;EACF;CACD,4BAA4B;EAC1B,kCAAY;GACV,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,CAAC;EACF,iCAAW;GACT,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,CAAC;EACH;CACD,iCAAiC;EAC/B,kCAAY;GACV,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,CAAC;EACF,iCAAW;GACT,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,CAAC;EACH;CACD,0BAA0B;EACxB,kCAAY;GACV,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,CAAC;EACF,iCAAW;GACT,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,CAAC;EACH;CACD,mBAAmB;EACjB,kCAAY;GACV,IAAIC;GACJ,IAAIC;GACJ,IAAIC;GACL,CAAC;EACF,iCAAW;GACT,IAAI;GACJ,IAAI;GACJ,IAAI;GACL,CAAC;EACH;CACF;AAWH,MAAa,YAAY,OAA4B,EACnD,MACA,IACA,SACA,QACA,GAAG,YACoB;CACvB,MAAMC,WAAS,IAAIC,cAAO,QAAQ,IAAI,eAAe;CAIrD,MAAM,EAAE,UAAU,SAAS,gBAFH,mBAAmB,OAAO,CAES;CAM3D,MAAM,QAAQ,2CAF6B,YAEb,GAAK,QAAiB;AAEpD,OAAMD,SAAO,OACV,KAAK;EACJ,MAAM;EACN;EACA,SAAS,WAAW;EACpB;EACD,CAAC,CACD,OAAO,QAAQE,4BAAO,MAAM,IAAI,CAAC;AAEpC,6BAAO,KAAK,cAAc,KAAK,MAAM,KAAK"}
|