arkos 1.3.10-canary.2 → 1.3.10-canary.4
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/cjs/modules/email/email.service.js +6 -4
- package/dist/cjs/modules/email/email.service.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/dynamic-loader.js +2 -2
- package/dist/cjs/utils/dynamic-loader.js.map +1 -1
- package/dist/esm/modules/email/email.service.js +6 -4
- package/dist/esm/modules/email/email.service.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/dynamic-loader.js +2 -2
- package/dist/esm/utils/dynamic-loader.js.map +1 -1
- package/dist/types/modules/email/email.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -50,10 +50,12 @@ class EmailService {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
getTransporter(customConfig) {
|
|
53
|
-
if (customConfig)
|
|
54
|
-
|
|
53
|
+
if (customConfig) {
|
|
54
|
+
const { name, ...config } = customConfig;
|
|
55
|
+
return nodemailer_1.default.createTransport(config);
|
|
56
|
+
}
|
|
55
57
|
if (!this.transporter) {
|
|
56
|
-
const config = this.getEmailConfig();
|
|
58
|
+
const { name, ...config } = this.getEmailConfig() || {};
|
|
57
59
|
this.transporter = nodemailer_1.default.createTransport(config);
|
|
58
60
|
}
|
|
59
61
|
return this.transporter;
|
|
@@ -74,7 +76,7 @@ class EmailService {
|
|
|
74
76
|
from: fromAddress,
|
|
75
77
|
text: options?.text || (0, html_to_text_1.convert)(options.html),
|
|
76
78
|
});
|
|
77
|
-
return { success: true,
|
|
79
|
+
return { success: true, ...info };
|
|
78
80
|
}
|
|
79
81
|
async verifyConnection(transporterToVerify) {
|
|
80
82
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":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AI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,mBAAQ,CAChB,2EAA2E;gBACzE,6GAA6G,EAC/G,GAAG,EACH;gBACE,IAAI,EAAE,2FAA2F;aAClG,CACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI;YACJ,IAAI,EAAE,IAAI,IAAI,GAAG;YACjB,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;YAC5C,IAAI,EAAE;gBACJ,IAAI;gBACJ,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;IAOO,cAAc,CAAC,YAAoC;QACzD,IAAI,YAAY;
|
|
1
|
+
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAqD;AACrD,+CAAuC;AACvC,yCAA8C;AAC9C,iFAAwD;AAqCxD,MAAa,YAAY;IAUvB,YAAY,MAA8B;QATlC,gBAAW,GAAuB,IAAI,CAAC;QACvC,iBAAY,GAAiC,IAAI,CAAC;QASxD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC7B,CAAC;IACH,CAAC;IAUO,cAAc;QACpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAA,uBAAc,GAAE,CAAC;QACjD,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1D,MAAM,IAAI,GACR,YAAY,EAAE,IAAI;YAClB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,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CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAMM,YAAY,CAAC,MAA6B;QAC/C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAOM,MAAM,CAAC,MAAM,CAAC,MAA6B;QAChD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF;AA5JD,oCA4JC;AAED,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC,kBAAe,YAAY,CAAC","sourcesContent":["import nodemailer, { Transporter } from \"nodemailer\";\nimport { convert } from \"html-to-text\";\nimport { getArkosConfig } from \"../../server\";\nimport AppError from \"../error-handler/utils/app-error\";\n\n/**\n * Defines the options for sending an email.\n */\nexport type EmailOptions = {\n from?: string;\n to: string | string[];\n subject: string;\n text?: string;\n html: string;\n};\n\n/**\n * Defines the authentication options for SMTP.\n */\nexport type SMTPAuthOptions = {\n user: string;\n pass: string;\n};\n\n/**\n * Defines the connection options for SMTP server.\n */\nexport type SMTPConnectionOptions = {\n host?: string;\n port?: number;\n secure?: boolean;\n auth?: SMTPAuthOptions;\n name?: string;\n};\n\n/**\n * A service class to handle email-related tasks, including sending emails.\n *\n * See the api reference [www.arkosjs.com/docs/api-reference/the-email-service-class](https://www.arkosjs.com/docs/api-reference/the-email-service-class)\n */\nexport class EmailService {\n private transporter: Transporter | null = null;\n private customConfig: SMTPConnectionOptions | null = null;\n\n /**\n * Creates an instance of the EmailService class.\n *\n * @param {SMTPConnectionOptions} [config] - Optional custom SMTP configuration.\n * If provided, these settings will be used instead of the Arkos config.\n */\n constructor(config?: SMTPConnectionOptions) {\n if (config) {\n this.customConfig = config;\n }\n }\n\n /**\n * Gets the email configuration from multiple sources with priority:\n * 1. Constructor customConfig\n * 2. ArkosConfig\n * 3. Environment variables\n * @returns Configuration object with host, port, and auth details\n * @throws AppError if required email configuration is not set\n */\n private getEmailConfig(): SMTPConnectionOptions {\n if (this.customConfig) {\n return this.customConfig;\n }\n\n const { email: emailConfigs } = getArkosConfig();\n const host = emailConfigs?.host || process.env.EMAIL_HOST;\n const port =\n emailConfigs?.port ||\n (process.env.EMAIL_PORT ? parseInt(process.env.EMAIL_PORT) : undefined);\n const secure =\n emailConfigs?.secure !== undefined\n ? emailConfigs.secure\n : process.env.EMAIL_SECURE\n ? process.env.EMAIL_SECURE === \"true\"\n : undefined;\n const user = emailConfigs?.auth?.user || process.env.EMAIL_USER;\n const pass = emailConfigs?.auth?.pass || process.env.EMAIL_PASSWORD;\n const name = emailConfigs?.name || process.env.EMAIL_NAME;\n\n if (!host || !user || !pass) {\n throw new AppError(\n \"You are trying to use emailService without setting email configurations. \" +\n \"Please configure either arkosConfig.email or environment variables (EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD)\",\n 500,\n {\n docs: \"Read more about emailService at https://www.arkosjs.com/docs/core-concepts/sending-emails\",\n }\n );\n }\n\n return {\n host,\n port: port || 465,\n secure: secure !== undefined ? secure : true,\n auth: {\n user,\n pass,\n },\n name,\n };\n }\n\n /**\n * Gets or creates a transporter using the email configuration\n * @param customConfig Optional override connection settings (takes full priority if provided)\n * @returns A configured nodemailer transporter\n */\n private getTransporter(customConfig?: SMTPConnectionOptions): Transporter {\n if (customConfig) {\n const { name, ...config } = customConfig;\n return nodemailer.createTransport(config);\n }\n\n if (!this.transporter) {\n const { name, ...config } = this.getEmailConfig() || {};\n this.transporter = nodemailer.createTransport(config);\n }\n return this.transporter;\n }\n\n /**\n * Sends an email with the provided options.\n * Can use either the default configuration or custom connection options.\n *\n * @param {EmailOptions} options - The options for the email to be sent.\n * @param {SMTPConnectionOptions} [connectionOptions] - Optional custom connection settings.\n * @param {boolean} [skipVerification=false] - Whether to skip connection verification.\n * @returns {Promise<{ success: boolean; messageId?: string } & Record<string, any>>} Result with message ID on success.\n */\n public async send(\n options: EmailOptions,\n connectionOptions?: SMTPConnectionOptions,\n skipVerification: boolean = false\n ): Promise<{ success: boolean; messageId?: string } & Record<string, any>> {\n const config = this.getEmailConfig();\n const transporter = connectionOptions\n ? this.getTransporter(connectionOptions)\n : this.getTransporter();\n\n const fromAddress =\n options.from || connectionOptions?.auth?.user || config.auth?.user;\n\n if (connectionOptions || !skipVerification) {\n const isConnected = await this.verifyConnection(transporter);\n if (!isConnected) throw new Error(\"Failed to connect to email server\");\n }\n\n const info = await transporter.sendMail({\n ...options,\n from: fromAddress,\n text: options?.text || convert(options.html),\n });\n\n return { success: true, ...info };\n }\n\n /**\n * Verifies the connection to the email server.\n * @param {Transporter} [transporterToVerify] - Optional transporter to verify.\n * @returns {Promise<boolean>} A promise that resolves to true if connection is valid.\n */\n public async verifyConnection(\n transporterToVerify?: Transporter\n ): Promise<boolean> {\n try {\n const transporter = transporterToVerify || this.getTransporter();\n await transporter.verify();\n return true;\n } catch (error) {\n console.error(\"Email Server Connection Failed\", error);\n return false;\n }\n }\n\n /**\n * Updates the custom configuration for this email service instance.\n * @param {SMTPConnectionOptions} config - The new connection options.\n */\n public updateConfig(config: SMTPConnectionOptions): void {\n this.customConfig = config;\n this.transporter = null; // Reset transporter so it will be recreated with new config\n }\n\n /**\n * Creates a new instance of EmailService with custom configuration.\n * @param {SMTPConnectionOptions} config - The connection options for the new instance.\n * @returns {EmailService} A new EmailService instance.\n */\n public static create(config: SMTPConnectionOptions): EmailService {\n return new EmailService(config);\n }\n}\n\nconst emailService = new EmailService();\n\nexport default emailService;\n"]}
|
|
@@ -202,7 +202,8 @@ async function importModuleComponents(modelName, arkosConfig, moduleDirExists) {
|
|
|
202
202
|
? "schemas"
|
|
203
203
|
: "dtos"
|
|
204
204
|
: null;
|
|
205
|
-
const [
|
|
205
|
+
const [validators] = await Promise.all([
|
|
206
|
+
validationSubdir && processSubdir(modelName, validationSubdir),
|
|
206
207
|
...Object.entries(fileStructure.core).map(async ([key, fileName]) => {
|
|
207
208
|
if (["createMany", "findMany", "findOne", "updateMany"].includes(key) ||
|
|
208
209
|
!fileName)
|
|
@@ -242,7 +243,6 @@ async function importModuleComponents(modelName, arkosConfig, moduleDirExists) {
|
|
|
242
243
|
(0, cli_helpers_1.killServerChildProcess)();
|
|
243
244
|
}
|
|
244
245
|
}),
|
|
245
|
-
validationSubdir && processSubdir(modelName, validationSubdir),
|
|
246
246
|
]);
|
|
247
247
|
prismaModelsModules[(0, change_case_helpers_1.pascalCase)(modelName)] = {
|
|
248
248
|
...result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAuBA,kDAKC;AAED,kDAEC;AAaD,oFA0DC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAwCD,8DAoDC;AAQD,oDAyBC;AASD,wDAmFC;AAaD,0DAwCC;AAvbD,6BAAoC;AACpC,gDAAwB;AAExB,yDAAiE;AAEjE,kDAA0B;AAC1B,6EAG0C;AAC1C,uEAAsE;AACtE,qDAAiE;AACjE,6DAAwD;AACxD,yFAA+D;AAC/D,4FAAmE;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,SAAgB,mBAAmB,CACjC,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,OAAO,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,CAAC;AACpD,CAAC;AAaD,SAAgB,oCAAoC,CAAC,SAAiB;IACpE,MAAM,cAAc,GAAG,IAAA,+BAAS,EAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAA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U,EAAC,SAAS,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,kBAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,MAAM,sBAAsB,CAC1B,SAAS,EACT,WAAW,EACX,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,0BAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n): any {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":";;;;;;AAuBA,kDAKC;AAED,kDAEC;AAaD,oFA0DC;AAED,0BAKC;AAED,kCAEC;AAED,sCAqDC;AAwCD,8DAoDC;AAQD,oDAyBC;AASD,wDAmFC;AAaD,0DAwCC;AAvbD,6BAAoC;AACpC,gDAAwB;AAExB,yDAAiE;AAEjE,kDAA0B;AAC1B,6EAG0C;AAC1C,uEAAsE;AACtE,qDAAiE;AACjE,6DAAwD;AACxD,yFAA+D;AAC/D,4FAAmE;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,SAAgB,mBAAmB,CACjC,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,OAAO,mBAAmB,CAAC,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC,CAAC;AACpD,CAAC;AAaD,SAAgB,oCAAoC,CAAC,SAAiB;IACpE,MAAM,cAAc,GAAG,IAAA,+BAAS,EAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GA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C,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,kBAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,MAAM,sBAAsB,CAC1B,SAAS,EACT,WAAW,EACX,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,0BAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,IAAA,gBAAG,GAAE,EACL,KAAK,EACL,SAAS,EACT,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,IAAA,+BAAS,EAAC,kBAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n): any {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [validators] = await Promise.all([\n validationSubdir && processSubdir(modelName, validationSubdir),\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
@@ -44,10 +44,12 @@ export class EmailService {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
getTransporter(customConfig) {
|
|
47
|
-
if (customConfig)
|
|
48
|
-
|
|
47
|
+
if (customConfig) {
|
|
48
|
+
const { name, ...config } = customConfig;
|
|
49
|
+
return nodemailer.createTransport(config);
|
|
50
|
+
}
|
|
49
51
|
if (!this.transporter) {
|
|
50
|
-
const config = this.getEmailConfig();
|
|
52
|
+
const { name, ...config } = this.getEmailConfig() || {};
|
|
51
53
|
this.transporter = nodemailer.createTransport(config);
|
|
52
54
|
}
|
|
53
55
|
return this.transporter;
|
|
@@ -68,7 +70,7 @@ export class EmailService {
|
|
|
68
70
|
from: fromAddress,
|
|
69
71
|
text: options?.text || convert(options.html),
|
|
70
72
|
});
|
|
71
|
-
return { success: true,
|
|
73
|
+
return { success: true, ...info };
|
|
72
74
|
}
|
|
73
75
|
async verifyConnection(transporterToVerify) {
|
|
74
76
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":"AAAA,OAAO,UAA2B,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OA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AI,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,QAAQ,CAChB,2EAA2E;gBACzE,6GAA6G,EAC/G,GAAG,EACH;gBACE,IAAI,EAAE,2FAA2F;aAClG,CACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI;YACJ,IAAI,EAAE,IAAI,IAAI,GAAG;YACjB,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;YAC5C,IAAI,EAAE;gBACJ,IAAI;gBACJ,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;IAOO,cAAc,CAAC,YAAoC;QACzD,IAAI,YAAY;
|
|
1
|
+
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":"AAAA,OAAO,UAA2B,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,QAAQ,MAAM,kCAAkC,CAAC;AAqCxD,MAAM,OAAO,YAAY;IAUvB,YAAY,MAA8B;QATlC,gBAAW,GAAuB,IAAI,CAAC;QACvC,iBAAY,GAAiC,IAAI,CAAC;QASxD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC7B,CAAC;IACH,CAAC;IAUO,cAAc;QACpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,cAAc,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1D,MAAM,IAAI,GACR,YAAY,EAAE,IAAI;YAClB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CA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AAmB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACjE,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAMM,YAAY,CAAC,MAA6B;QAC/C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAOM,MAAM,CAAC,MAAM,CAAC,MAA6B;QAChD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF;AAED,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC,eAAe,YAAY,CAAC","sourcesContent":["import nodemailer, { Transporter } from \"nodemailer\";\nimport { convert } from \"html-to-text\";\nimport { getArkosConfig } from \"../../server\";\nimport AppError from \"../error-handler/utils/app-error\";\n\n/**\n * Defines the options for sending an email.\n */\nexport type EmailOptions = {\n from?: string;\n to: string | string[];\n subject: string;\n text?: string;\n html: string;\n};\n\n/**\n * Defines the authentication options for SMTP.\n */\nexport type SMTPAuthOptions = {\n user: string;\n pass: string;\n};\n\n/**\n * Defines the connection options for SMTP server.\n */\nexport type SMTPConnectionOptions = {\n host?: string;\n port?: number;\n secure?: boolean;\n auth?: SMTPAuthOptions;\n name?: string;\n};\n\n/**\n * A service class to handle email-related tasks, including sending emails.\n *\n * See the api reference [www.arkosjs.com/docs/api-reference/the-email-service-class](https://www.arkosjs.com/docs/api-reference/the-email-service-class)\n */\nexport class EmailService {\n private transporter: Transporter | null = null;\n private customConfig: SMTPConnectionOptions | null = null;\n\n /**\n * Creates an instance of the EmailService class.\n *\n * @param {SMTPConnectionOptions} [config] - Optional custom SMTP configuration.\n * If provided, these settings will be used instead of the Arkos config.\n */\n constructor(config?: SMTPConnectionOptions) {\n if (config) {\n this.customConfig = config;\n }\n }\n\n /**\n * Gets the email configuration from multiple sources with priority:\n * 1. Constructor customConfig\n * 2. ArkosConfig\n * 3. Environment variables\n * @returns Configuration object with host, port, and auth details\n * @throws AppError if required email configuration is not set\n */\n private getEmailConfig(): SMTPConnectionOptions {\n if (this.customConfig) {\n return this.customConfig;\n }\n\n const { email: emailConfigs } = getArkosConfig();\n const host = emailConfigs?.host || process.env.EMAIL_HOST;\n const port =\n emailConfigs?.port ||\n (process.env.EMAIL_PORT ? parseInt(process.env.EMAIL_PORT) : undefined);\n const secure =\n emailConfigs?.secure !== undefined\n ? emailConfigs.secure\n : process.env.EMAIL_SECURE\n ? process.env.EMAIL_SECURE === \"true\"\n : undefined;\n const user = emailConfigs?.auth?.user || process.env.EMAIL_USER;\n const pass = emailConfigs?.auth?.pass || process.env.EMAIL_PASSWORD;\n const name = emailConfigs?.name || process.env.EMAIL_NAME;\n\n if (!host || !user || !pass) {\n throw new AppError(\n \"You are trying to use emailService without setting email configurations. \" +\n \"Please configure either arkosConfig.email or environment variables (EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD)\",\n 500,\n {\n docs: \"Read more about emailService at https://www.arkosjs.com/docs/core-concepts/sending-emails\",\n }\n );\n }\n\n return {\n host,\n port: port || 465,\n secure: secure !== undefined ? secure : true,\n auth: {\n user,\n pass,\n },\n name,\n };\n }\n\n /**\n * Gets or creates a transporter using the email configuration\n * @param customConfig Optional override connection settings (takes full priority if provided)\n * @returns A configured nodemailer transporter\n */\n private getTransporter(customConfig?: SMTPConnectionOptions): Transporter {\n if (customConfig) {\n const { name, ...config } = customConfig;\n return nodemailer.createTransport(config);\n }\n\n if (!this.transporter) {\n const { name, ...config } = this.getEmailConfig() || {};\n this.transporter = nodemailer.createTransport(config);\n }\n return this.transporter;\n }\n\n /**\n * Sends an email with the provided options.\n * Can use either the default configuration or custom connection options.\n *\n * @param {EmailOptions} options - The options for the email to be sent.\n * @param {SMTPConnectionOptions} [connectionOptions] - Optional custom connection settings.\n * @param {boolean} [skipVerification=false] - Whether to skip connection verification.\n * @returns {Promise<{ success: boolean; messageId?: string } & Record<string, any>>} Result with message ID on success.\n */\n public async send(\n options: EmailOptions,\n connectionOptions?: SMTPConnectionOptions,\n skipVerification: boolean = false\n ): Promise<{ success: boolean; messageId?: string } & Record<string, any>> {\n const config = this.getEmailConfig();\n const transporter = connectionOptions\n ? this.getTransporter(connectionOptions)\n : this.getTransporter();\n\n const fromAddress =\n options.from || connectionOptions?.auth?.user || config.auth?.user;\n\n if (connectionOptions || !skipVerification) {\n const isConnected = await this.verifyConnection(transporter);\n if (!isConnected) throw new Error(\"Failed to connect to email server\");\n }\n\n const info = await transporter.sendMail({\n ...options,\n from: fromAddress,\n text: options?.text || convert(options.html),\n });\n\n return { success: true, ...info };\n }\n\n /**\n * Verifies the connection to the email server.\n * @param {Transporter} [transporterToVerify] - Optional transporter to verify.\n * @returns {Promise<boolean>} A promise that resolves to true if connection is valid.\n */\n public async verifyConnection(\n transporterToVerify?: Transporter\n ): Promise<boolean> {\n try {\n const transporter = transporterToVerify || this.getTransporter();\n await transporter.verify();\n return true;\n } catch (error) {\n console.error(\"Email Server Connection Failed\", error);\n return false;\n }\n }\n\n /**\n * Updates the custom configuration for this email service instance.\n * @param {SMTPConnectionOptions} config - The new connection options.\n */\n public updateConfig(config: SMTPConnectionOptions): void {\n this.customConfig = config;\n this.transporter = null; // Reset transporter so it will be recreated with new config\n }\n\n /**\n * Creates a new instance of EmailService with custom configuration.\n * @param {SMTPConnectionOptions} config - The connection options for the new instance.\n * @returns {EmailService} A new EmailService instance.\n */\n public static create(config: SMTPConnectionOptions): EmailService {\n return new EmailService(config);\n }\n}\n\nconst emailService = new EmailService();\n\nexport default emailService;\n"]}
|
|
@@ -186,7 +186,8 @@ export async function importModuleComponents(modelName, arkosConfig, moduleDirEx
|
|
|
186
186
|
? "schemas"
|
|
187
187
|
: "dtos"
|
|
188
188
|
: null;
|
|
189
|
-
const [
|
|
189
|
+
const [validators] = await Promise.all([
|
|
190
|
+
validationSubdir && processSubdir(modelName, validationSubdir),
|
|
190
191
|
...Object.entries(fileStructure.core).map(async ([key, fileName]) => {
|
|
191
192
|
if (["createMany", "findMany", "findOne", "updateMany"].includes(key) ||
|
|
192
193
|
!fileName)
|
|
@@ -226,7 +227,6 @@ export async function importModuleComponents(modelName, arkosConfig, moduleDirEx
|
|
|
226
227
|
killServerChildProcess();
|
|
227
228
|
}
|
|
228
229
|
}),
|
|
229
|
-
validationSubdir && processSubdir(modelName, validationSubdir),
|
|
230
230
|
]);
|
|
231
231
|
prismaModelsModules[pascalCase(modelName)] = {
|
|
232
232
|
...result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,UAAU,GACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,eAAe,MAAM,sCAAsC,CAAC;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACvD,CAAC;AAED,MAAM,UAA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GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,CACrB,CAAC;QACF,IAAI,MAAM,UAAU,CAAC,SAAS,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,UAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,MAAM,sBAAsB,CAC1B,SAAS,EACT,WAAW,EACX,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,eAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAC5B,GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n): any {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [_, validators] = await Promise.all([\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n validationSubdir && processSubdir(modelName, validationSubdir),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamic-loader.js","sourceRoot":"","sources":["../../../src/utils/dynamic-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,UAAU,GACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,eAAe,MAAM,sCAAsC,CAAC;AAMnE,IAAI,mBAAmB,GAAuC,EAAE,CAAC;AAGjE,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAA2B;IAE3B,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,GAAG,OA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AAI,CAAC,OAAO,CAC5B,GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,CACrB,CAAC;QACF,IAAI,MAAM,UAAU,CAAC,SAAS,CAAC;YAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,+BAA+B,GAAG,UAAU,CAAC,GAAG,CACpD,KAAK,EAAE,SAAS,EAAE,EAAE,CAClB,MAAM,sBAAsB,CAC1B,SAAS,EACT,WAAW,EACX,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CACpC,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7E,eAAe,CAAC,iCAAiC,CAC/C,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAC5B,GAAG,EAAE,EACL,KAAK,EACL,SAAS,EACT,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACpC,SAAS;YACT,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z, ZodTypeAny } from \"zod\";\nimport path from \"path\";\nimport { AuthConfigs } from \"../types/auth\";\nimport { killServerChildProcess } from \"./cli/utils/cli.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../exports\";\nimport sheu from \"./sheu\";\nimport {\n applyStrictRoutingRules,\n pathExists,\n} from \"./helpers/dynamic-loader.helpers\";\nimport { kebabCase, pascalCase } from \"./helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./helpers/fs.helpers\";\nimport { importModule } from \"./helpers/global.helpers\";\nimport prismaSchemaParser from \"./prisma/prisma-schema-parser\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\nimport { PrismaQueryOptions } from \"../types\";\nimport { ServiceHook } from \"../modules/base/utils/service-hooks-manager\";\n\ntype AppModuleComponent = Awaited<ReturnType<typeof importModuleComponents>>;\n\nlet prismaModelsModules: Record<string, AppModuleComponent> = {};\n\n/** This was a workaround when testing and also when cjs was generated while `prismaModelsModules` was exported there where some problems */\nexport function setModuleComponents(\n modelName: string,\n modules: AppModuleComponent\n): any {\n prismaModelsModules[pascalCase(modelName)] = modules;\n}\n\nexport function getModuleComponents(modelName: string) {\n return prismaModelsModules[pascalCase(modelName)];\n}\n\n/**\n * To be reused on other part of code for correct typing\n *\n * @param key\n * @param fileName\n * @param result\n */\nexport type ValidationFileMappingKey = keyof ReturnType<\n typeof getFileModuleComponentsFileStructure\n>[\"dtos\"];\n\nexport function getFileModuleComponentsFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n hooks: `${kebabModelName}.hooks.${ext}`,\n interceptors: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n getMe: `get-me.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createOne: `create-${kebabModelName}.dto.${ext}`, // just for sake of completion and reusability around other parts of code\n createMany: ``,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateOne: `update-${kebabModelName}.dto.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.dto.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n getMe: `get-me.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createOne: `create-${kebabModelName}.schema.${ext}`,\n createMany: ``, // just for sake of completion and reusability around other parts of code\n update: `update-${kebabModelName}.schema.${ext}`,\n updateOne: `update-${kebabModelName}.schema.${ext}`, // same as createOne\n updateMany: ``,\n query: `query-${kebabModelName}.schema.${ext}`,\n // looking for some better naming convetion\n findOne: ``,\n findMany: ``,\n },\n };\n}\n\nexport function isClass(value: any): boolean {\n return (\n typeof value === \"function\" &&\n /^class\\s/.test(Function.prototype.toString.call(value))\n );\n}\n\nexport function isZodSchema(value: any): value is ZodTypeAny {\n return value instanceof z.ZodType;\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n const result: Record<string, any> = {};\n\n if (!(await pathExists(subdir))) return result;\n\n try {\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n if (!fileName || !(await pathExists(filePath))) return;\n\n try {\n const module = await importModule(filePath).catch(\n async (err: any) => {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}: `);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n }\n );\n\n const cleanFilePath = `src/modules/${kebabCase(modelName)}/${fileName}`;\n if (type === \"dtos\" && !isClass(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid class under ${cleanFilePath}, in order to use as Dto.`\n );\n else if (type === \"schemas\" && !isZodSchema(module?.default))\n throw Error(\n `ValidationError: Please export as default a valid zod schema under ${cleanFilePath}, in order to use as Schema`\n );\n\n if (module && module?.default) result[key] = module.default;\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n })\n );\n } catch (err: any) {\n if (err?.message?.includes(\"ValidationError\")) throw err;\n console.error(err);\n }\n\n return result;\n}\n\nexport type ModuleComponents = Omit<\n ImportModuleComponentsReturnType,\n \"authConfigsNew\" | \"prismaQueryOptionsNew\"\n>;\n\ntype ImportModuleComponentsReturnType = {\n hooks?: Record<string, ServiceHook | ServiceHook[]>;\n interceptors?: Record<string, Function | Function[]>;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: PrismaQueryOptions<any>;\n prismaQueryOptionsNew?: PrismaQueryOptions<any>;\n router?: { config?: RouterConfig<any>; default: RouterConfig };\n dtos?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n schemas?: {\n create?: any;\n update?: any;\n signup?: any;\n login?: any;\n updatePassword?: any;\n updateMe?: any;\n };\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {ImportModuleComponentsReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: ImportModuleComponentsReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"prisma-query-options\", \"query\")}.`\n );\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n sheu.warn(\n `Found ${fileName} which will be deprecated from 1.4.0-beta, consider switching to ${fileName.replace(\"auth-configs\", \"auth\")}.`\n );\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {ImportModuleComponentsReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n appModule: string,\n key: string,\n module: any,\n result: ImportModuleComponentsReturnType,\n arkosConfig: ArkosConfig\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"interceptors\") {\n result[key] = module;\n } else if (key === \"router\") {\n result[key] = {\n ...module,\n config: applyStrictRoutingRules(\n appModule,\n arkosConfig,\n module?.config || {}\n ),\n };\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importModuleComponents(\n modelName: string,\n arkosConfig: ArkosConfig,\n moduleDirExists?: boolean\n): Promise<ImportModuleComponentsReturnType> {\n const result: ImportModuleComponentsReturnType = {\n dtos: {},\n schemas: {},\n };\n const usingStrictRouting = arkosConfig.routers?.strict;\n\n if (!moduleDirExists && !usingStrictRouting) return result;\n\n if (getModuleComponents(modelName)) return getModuleComponents(modelName);\n\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n const fileStructure = getFileModuleComponentsFileStructure(modelName);\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n const [validators] = await Promise.all([\n validationSubdir && processSubdir(modelName, validationSubdir),\n ...Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n if (\n [\"createMany\", \"findMany\", \"findOne\", \"updateMany\"].includes(key) ||\n !fileName\n )\n return;\n\n const filePath = path.join(moduleDir, fileName);\n\n if (\n key === \"router\" &&\n !usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n else if (\n key !== \"router\" &&\n usingStrictRouting &&\n !(await pathExists(filePath))\n )\n return;\n\n try {\n let module = await importModule(filePath).catch(async (err) => {\n try {\n if (await pathExists(filePath)) {\n sheu.error(`Failed to import ${fileName}`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n } catch (err) {}\n });\n\n if (!module && key === \"router\" && usingStrictRouting) module = {};\n\n if (module) {\n validateNamingConventions(key, fileName, result);\n assignModuleToResult(modelName, key, module, result, arkosConfig);\n }\n } catch (err: any) {\n if (err.message?.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n }),\n ]);\n\n prismaModelsModules[pascalCase(modelName)] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport const appModules = Array.from(\n new Set([\n \"auth\",\n \"file-upload\",\n ...prismaSchemaParser.getModelsAsArrayOfStrings(),\n ])\n);\n\n/**\n * Allows to asynchronously load all app modules components at once to speed up app start time.\n */\nexport async function loadAllModuleComponents(arkosConfig: ArkosConfig) {\n const moduleDirExists: string[] = [];\n await Promise.all(\n appModules.map(async (appModule) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModule)\n );\n if (await pathExists(moduleDir)) moduleDirExists.push(appModule);\n })\n );\n\n const modulesComponentsImportPromises = appModules.map(\n async (appModule) =>\n await importModuleComponents(\n appModule,\n arkosConfig,\n moduleDirExists.includes(appModule)\n )\n );\n\n const modulesComponents = await Promise.all(modulesComponentsImportPromises);\n debuggerService.logDynamicLoadedModulesComponents(\n modulesComponents.map((components, i) => {\n const moduleDir = path.resolve(\n crd(),\n \"src\",\n \"modules\",\n kebabCase(appModules[i])\n );\n\n return {\n moduleName: kebabCase(appModules[i]),\n moduleDir,\n components,\n };\n })\n );\n}\n"]}
|
|
@@ -26,7 +26,7 @@ export declare class EmailService {
|
|
|
26
26
|
send(options: EmailOptions, connectionOptions?: SMTPConnectionOptions, skipVerification?: boolean): Promise<{
|
|
27
27
|
success: boolean;
|
|
28
28
|
messageId?: string;
|
|
29
|
-
}
|
|
29
|
+
} & Record<string, any>>;
|
|
30
30
|
verifyConnection(transporterToVerify?: Transporter): Promise<boolean>;
|
|
31
31
|
updateConfig(config: SMTPConnectionOptions): void;
|
|
32
32
|
static create(config: SMTPConnectionOptions): EmailService;
|