create-arkos 0.0.28-beta → 1.2.14-beta
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/README.md +2 -2
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/project-config-inquirer.js +8 -7
- package/dist/utils/project-config-inquirer.js.map +1 -1
- package/dist/utils/template-compiler.js +1 -1
- package/dist/utils/template-compiler.js.map +1 -1
- package/package.json +3 -2
- package/templates/basic/src/modules/auth/auth.query.ts.hbs +13 -7
- package/templates/basic/src/modules/auth/dtos/login.dto.ts.hbs +2 -2
- package/templates/basic/src/modules/auth/dtos/signup.dto.ts.hbs +2 -2
- package/templates/basic/src/modules/auth/dtos/update-me.dto.ts.hbs +20 -0
- package/templates/basic/src/modules/auth/dtos/update-password.dto.ts.hbs +2 -2
- package/templates/basic/src/modules/auth/schemas/update-me.schema.ts.hbs +12 -0
- package/templates/basic/src/modules/auth-permission/auth-permission.query.ts.hbs +7 -3
- package/templates/basic/src/modules/auth-permission/dtos/create-auth-permission.dto.ts.hbs +4 -4
- package/templates/basic/src/modules/auth-role/auth-role.query.ts.hbs +7 -3
- package/templates/basic/src/modules/auth-role/dtos/update-auth-role.dto.ts.hbs +4 -4
- package/templates/basic/src/modules/auth-role/schemas/create-auth-role.schema.ts.hbs +1 -1
- package/templates/basic/src/modules/auth-role/schemas/update-auth-role.schema.ts.hbs +9 -2
- package/templates/basic/src/modules/user/dtos/create-user.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/user/user.query.ts.hbs +7 -5
- /package/templates/basic/src/modules/auth-permission/schemas/{create-auth-permission.ts.hbs → create-auth-permission.schema.ts.hbs} +0 -0
- /package/templates/basic/src/modules/auth-permission/schemas/{update-auth-permission.ts.hbs → update-auth-permission.schema.ts.hbs} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The official CLI tool to quickly scaffold new Arkos.js API projects with interac
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`create-arkos` is the scaffolding tool for the Arkos.js framework (v1.2.
|
|
7
|
+
`create-arkos` is the scaffolding tool for the Arkos.js framework (v1.2.14-beta). It provides an interactive setup experience to generate a complete, production-ready RESTful API project with automatic CRUD operations, authentication, validation, and more - all built on top of Express.js and Prisma.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
@@ -178,7 +178,7 @@ arkos generate component-name -m model-name # generate components like controlle
|
|
|
178
178
|
|
|
179
179
|
## Version
|
|
180
180
|
|
|
181
|
-
Arkos.js version used on this `create-arkos` cli: v1.2.
|
|
181
|
+
Arkos.js version used on this `create-arkos` cli: v1.2.14-beta
|
|
182
182
|
|
|
183
183
|
## License
|
|
184
184
|
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ handlebars_1.default.registerHelper("eq", (a, b) => a === b);
|
|
|
17
17
|
handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
18
18
|
async function main() {
|
|
19
19
|
const config = await project_config_inquirer_1.default.run();
|
|
20
|
+
const argProjectName = config.argProjectName;
|
|
20
21
|
const projectPath = config.projectPath;
|
|
21
22
|
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
22
23
|
console.info(`\nCreating a new ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project under ${chalk_1.default.green(`./${config.projectName}`)}`);
|
|
@@ -25,9 +26,9 @@ async function main() {
|
|
|
25
26
|
process.chdir(projectPath);
|
|
26
27
|
const packageManager = (0, npm_helpers_1.detectPackageManagerFromUserAgent)();
|
|
27
28
|
const { dependencies, devDependencies } = (0, helpers_1.getProcjetPackageJsonDependecies)(projectPath);
|
|
28
|
-
console.info(chalk_1.default.bold("\ndependencies:"));
|
|
29
|
+
console.info(chalk_1.default.cyan(chalk_1.default.bold("\ndependencies:")));
|
|
29
30
|
dependencies.forEach((dependency) => console.info(`- ${dependency}`));
|
|
30
|
-
console.info(chalk_1.default.bold("\ndevDependencies:"));
|
|
31
|
+
console.info(chalk_1.default.cyan(chalk_1.default.bold("\ndevDependencies:")));
|
|
31
32
|
devDependencies.forEach((devDependency) => console.info(`- ${devDependency}`));
|
|
32
33
|
console.info(chalk_1.default.bold("\nInstalling dependencies..."));
|
|
33
34
|
console.info(`Using ${packageManager}.\n`);
|
|
@@ -38,11 +39,17 @@ async function main() {
|
|
|
38
39
|
console.info(`
|
|
39
40
|
${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project created successfully!
|
|
40
41
|
|
|
41
|
-
Next
|
|
42
|
-
|
|
42
|
+
${chalk_1.default.bold("Next Steps:")}
|
|
43
|
+
${argProjectName === "."
|
|
44
|
+
? `1. cd ${config.projectName}
|
|
43
45
|
2. setup your ${chalk_1.default.cyan("DATABASE_URL")} under .env
|
|
44
46
|
3. npx prisma db push
|
|
45
47
|
4. ${packageManager} run dev
|
|
48
|
+
`
|
|
49
|
+
: `1. setup your ${chalk_1.default.cyan("DATABASE_URL")} under .env
|
|
50
|
+
2. npx prisma db push
|
|
51
|
+
3. ${packageManager} run dev
|
|
52
|
+
`}
|
|
46
53
|
`);
|
|
47
54
|
}
|
|
48
55
|
main().catch(console.error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAyC;AACzC,8FAAoE;AACpE,kFAAyD;AACzD,4DAAoC;AACpC,6CAAmE;AACnE,6DAAgF;AAEhF,oBAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAyC;AACzC,8FAAoE;AACpE,kFAAyD;AACzD,4DAAoC;AACpC,6CAAmE;AACnE,6DAAgF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AK,UAAU,EAAE,CAAC,CAAC,CAAC;IAEtE,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC3D,eAAe,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CACxC,OAAO,CAAC,IAAI,CAAC,KAAK,aAAa,EAAE,CAAC,CACnC,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,SAAS,cAAc,KAAK,CAAC,CAAC;IAE3C,IAAA,wBAAQ,EAAC,GAAG,cAAc,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAE5D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACjD,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,OAAO,CAAC,IAAI,CAAC;IACX,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;IAElC,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC;IAEzB,cAAc,KAAK,GAAG;QACpB,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW;kBACjB,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;OAErC,cAAc;CACpB;QACK,CAAC,CAAC,iBAAiB,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;OAE5C,cAAc;CAEnB;KACG,CAAC,CAAC;AACP,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { execSync } from \"child_process\";\nimport projectConfigInquirer from \"./utils/project-config-inquirer\";\nimport templateCompiler from \"./utils/template-compiler\";\nimport Handlebars from \"handlebars\";\nimport { getProcjetPackageJsonDependecies } from \"./utils/helpers\";\nimport { detectPackageManagerFromUserAgent } from \"./utils/helpers/npm.helpers\";\n\nHandlebars.registerHelper(\"eq\", (a: any, b: any) => a === b);\nHandlebars.registerHelper(\"neq\", (a: any, b: any) => a !== b);\n\nasync function main() {\n const config = await projectConfigInquirer.run();\n const argProjectName = config.argProjectName;\n\n const projectPath = config.projectPath;\n\n fs.mkdirSync(projectPath, { recursive: true });\n\n console.info(\n `\\nCreating a new ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project under ${chalk.green(`./${config.projectName}`)}`\n );\n\n const templatesDir = path.join(__dirname, `../templates/basic`);\n await templateCompiler.compile(templatesDir, config);\n\n process.chdir(projectPath);\n\n const packageManager = detectPackageManagerFromUserAgent();\n const { dependencies, devDependencies } =\n getProcjetPackageJsonDependecies(projectPath);\n\n console.info(chalk.cyan(chalk.bold(\"\\ndependencies:\")));\n dependencies.forEach((dependency) => console.info(`- ${dependency}`));\n\n console.info(chalk.cyan(chalk.bold(\"\\ndevDependencies:\")));\n devDependencies.forEach((devDependency) =>\n console.info(`- ${devDependency}`)\n );\n\n console.info(chalk.bold(\"\\nInstalling dependencies...\"));\n console.info(`Using ${packageManager}.\\n`);\n\n execSync(`${packageManager} install`, { stdio: \"inherit\" });\n\n process.chdir(projectPath);\n console.info(\"\\nRunning npx prisma generate...\");\n execSync(`npx prisma generate`, { stdio: \"inherit\" });\n\n console.info(`\n ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project created successfully!\n\n ${chalk.bold(\"Next Steps:\")}\n ${\n argProjectName === \".\"\n ? `1. cd ${config.projectName}\n 2. setup your ${chalk.cyan(\"DATABASE_URL\")} under .env\n 3. npx prisma db push\n 4. ${packageManager} run dev\n`\n : `1. setup your ${chalk.cyan(\"DATABASE_URL\")} under .env\n 2. npx prisma db push\n 3. ${packageManager} run dev\n`\n }\n `);\n}\n\nmain().catch(console.error);\n"]}
|
|
@@ -25,7 +25,8 @@ class ProjectConfigInquirer {
|
|
|
25
25
|
return this.config;
|
|
26
26
|
}
|
|
27
27
|
async promptProjectName() {
|
|
28
|
-
let projectName = process
|
|
28
|
+
let projectName = process?.argv?.[2];
|
|
29
|
+
this.config.argProjectName = process?.argv?.[2];
|
|
29
30
|
if (!projectName) {
|
|
30
31
|
const result = await inquirer_1.default.prompt([
|
|
31
32
|
{
|
|
@@ -76,7 +77,7 @@ class ProjectConfigInquirer {
|
|
|
76
77
|
{
|
|
77
78
|
type: "confirm",
|
|
78
79
|
name: "typescript",
|
|
79
|
-
message: `Would you like to use ${chalk_1.default.
|
|
80
|
+
message: `Would you like to use ${chalk_1.default.cyan("TypeScript")}?`,
|
|
80
81
|
default: false,
|
|
81
82
|
},
|
|
82
83
|
]);
|
|
@@ -87,7 +88,7 @@ class ProjectConfigInquirer {
|
|
|
87
88
|
{
|
|
88
89
|
type: "list",
|
|
89
90
|
name: "prismaProvider",
|
|
90
|
-
message: `What db provider will be used for ${chalk_1.default.
|
|
91
|
+
message: `What db provider will be used for ${chalk_1.default.cyan("Prisma")}?`,
|
|
91
92
|
choices: [
|
|
92
93
|
"postgresql",
|
|
93
94
|
"mongodb",
|
|
@@ -140,7 +141,7 @@ class ProjectConfigInquirer {
|
|
|
140
141
|
{
|
|
141
142
|
type: "confirm",
|
|
142
143
|
name: "useValidation",
|
|
143
|
-
message: `Would you like to set up ${chalk_1.default.
|
|
144
|
+
message: `Would you like to set up ${chalk_1.default.cyan("Validation")}?`,
|
|
144
145
|
default: true,
|
|
145
146
|
},
|
|
146
147
|
]);
|
|
@@ -156,7 +157,7 @@ class ProjectConfigInquirer {
|
|
|
156
157
|
},
|
|
157
158
|
]);
|
|
158
159
|
else {
|
|
159
|
-
console.info(
|
|
160
|
+
console.info(`${chalk_1.default.bold(chalk_1.default.green("?"))} Validation library set to ${chalk_1.default.cyan("zod")} (class-validator is not supported on JavaScript).`);
|
|
160
161
|
}
|
|
161
162
|
this.config.validation = {
|
|
162
163
|
type: validationTypeResponse.validationType,
|
|
@@ -170,7 +171,7 @@ class ProjectConfigInquirer {
|
|
|
170
171
|
{
|
|
171
172
|
type: "confirm",
|
|
172
173
|
name: "useAuthentication",
|
|
173
|
-
message: `Would you like to set up ${chalk_1.default.
|
|
174
|
+
message: `Would you like to set up ${chalk_1.default.cyan("Authentication")}?`,
|
|
174
175
|
default: true,
|
|
175
176
|
},
|
|
176
177
|
]);
|
|
@@ -204,7 +205,7 @@ class ProjectConfigInquirer {
|
|
|
204
205
|
type: "confirm",
|
|
205
206
|
name: "multipleRoles",
|
|
206
207
|
default: true,
|
|
207
|
-
message: `Would you like to use authentication with ${chalk_1.default.
|
|
208
|
+
message: `Would you like to use authentication with ${chalk_1.default.cyan("Multiple Roles")}?`,
|
|
208
209
|
},
|
|
209
210
|
]);
|
|
210
211
|
this.config.authentication = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,wDAAgC;AAChC,kDAA0B;AA2B1B,MAAM,qBAAqB;IAGzB;QACE,IAAI,CAAC,MAAM,GAAG,EAAmB,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAGlC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,GAAG,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAA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,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n defaultDBurl: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n // If user passed \".\", use current directory name\n if (this.config.projectName === \".\") {\n this.config.projectName = path.basename(process.cwd());\n this.config.projectPath = path.resolve(process.cwd());\n } else\n this.config.projectPath = path.resolve(\n process.cwd(),\n this.config.projectName\n );\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process.argv[2];\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: this.validateProjectName,\n },\n ]);\n projectName = result.projectName;\n } else {\n // Validate the project name from command line args\n const validation = this.validateProjectName(projectName);\n if (validation !== true) {\n console.error(chalk.red(`\\nError: ${validation}`));\n process.exit(1);\n }\n }\n\n this.config.projectName = projectName;\n }\n\n private validateProjectName(input: string): boolean | string {\n if (input === \".\") return true;\n\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n // Check for valid characters (letters, numbers, hyphens, underscores)\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n // Check if it starts with a letter or number (not hyphen or underscore)\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n // Check if it ends with a letter or number (not hyphen or underscore)\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n // Check length (reasonable limits)\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\n // Check for reserved names\n const reservedNames = [\"node_modules\"];\n if (reservedNames.includes(input.toLowerCase())) {\n return \"Project name cannot be a reserved name\";\n }\n\n return true;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.blue(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.blue(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n\n // Set the correct idDatabaseType based on provider\n let idDatabaseType: string;\n let defaultDBurl: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n defaultDBurl = `mongodb://localhost:27017/${this.config.projectName}`;\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n defaultDBurl = \"file:../../file.db\";\n break;\n case \"mysql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `mysql://username:password@localhost:3306/${this.config.projectName}`;\n break;\n case \"postgresql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n break;\n case \"sqlserver\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `sqlserver://localhost:1433;database=${this.config.projectName};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;\n break;\n case \"cockroachdb\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:26257/${this.config.projectName}?sslmode=require`;\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: idDatabaseType,\n defaultDBurl: defaultDBurl,\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.blue(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n let validationTypeResponse: {\n validationType: \"zod\" | \"class-validator\";\n } = { validationType: \"zod\" };\n\n if (this.config.typescript)\n validationTypeResponse = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n else {\n console.info(\n `Validation library set as ${chalk.cyan(\"zod\")}, (class-validator is not supported on JavaScript).`\n );\n }\n this.config.validation = {\n type: validationTypeResponse.validationType,\n };\n } else if (!this.config.typescript) {\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.blue(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles: false,\n };\n\n if (\n authenticationType !== \"define later\" ||\n (this.config.prisma.provider !== \"sqlite\" &&\n authenticationType !== \"static\")\n ) {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.blue(\"Multiple Roles\")}?`,\n },\n ]);\n\n this.config.authentication = {\n ...this.config.authentication,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n console.info(\n `\\nSkipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`\n );\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
1
|
+
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,wDAAgC;AAChC,kDAA0B;AA4B1B,MAAM,qBAAqB;IAGzB;QACE,IAAI,CAAC,MAAM,GAAG,EAAmB,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAGlC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,GAAG,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;SACvD;;YACC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,cAAI,CAAC,OAAO,CACpC,OAAO,CAAC,GAAG,EAAE,EACb,IAAI,CAAC,MAAM,CA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alk\";\n\nexport interface ProjectConfig {\n projectName: string;\n argProjectName?: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n defaultDBurl: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n // If user passed \".\", use current directory name\n if (this.config.projectName === \".\") {\n this.config.projectName = path.basename(process.cwd());\n this.config.projectPath = path.resolve(process.cwd());\n } else\n this.config.projectPath = path.resolve(\n process.cwd(),\n this.config.projectName\n );\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process?.argv?.[2];\n this.config.argProjectName = process?.argv?.[2];\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: this.validateProjectName,\n },\n ]);\n projectName = result.projectName;\n } else {\n // Validate the project name from command line args\n const validation = this.validateProjectName(projectName);\n if (validation !== true) {\n console.error(chalk.red(`\\nError: ${validation}`));\n process.exit(1);\n }\n }\n\n this.config.projectName = projectName;\n }\n\n private validateProjectName(input: string): boolean | string {\n if (input === \".\") return true;\n\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n // Check for valid characters (letters, numbers, hyphens, underscores)\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n // Check if it starts with a letter or number (not hyphen or underscore)\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n // Check if it ends with a letter or number (not hyphen or underscore)\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n // Check length (reasonable limits)\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\n // Check for reserved names\n const reservedNames = [\"node_modules\"];\n if (reservedNames.includes(input.toLowerCase())) {\n return \"Project name cannot be a reserved name\";\n }\n\n return true;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.cyan(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.cyan(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n\n // Set the correct idDatabaseType based on provider\n let idDatabaseType: string;\n let defaultDBurl: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n defaultDBurl = `mongodb://localhost:27017/${this.config.projectName}`;\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n defaultDBurl = \"file:../../file.db\";\n break;\n case \"mysql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `mysql://username:password@localhost:3306/${this.config.projectName}`;\n break;\n case \"postgresql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n break;\n case \"sqlserver\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `sqlserver://localhost:1433;database=${this.config.projectName};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;\n break;\n case \"cockroachdb\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:26257/${this.config.projectName}?sslmode=require`;\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: idDatabaseType,\n defaultDBurl: defaultDBurl,\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.cyan(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n let validationTypeResponse: {\n validationType: \"zod\" | \"class-validator\";\n } = { validationType: \"zod\" };\n\n if (this.config.typescript)\n validationTypeResponse = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n else {\n console.info(\n `${chalk.bold(chalk.green(\"?\"))} Validation library set to ${chalk.cyan(\"zod\")} (class-validator is not supported on JavaScript).`\n );\n }\n this.config.validation = {\n type: validationTypeResponse.validationType,\n };\n } else if (!this.config.typescript) {\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.cyan(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles: false,\n };\n\n if (\n authenticationType !== \"define later\" ||\n (this.config.prisma.provider !== \"sqlite\" &&\n authenticationType !== \"static\")\n ) {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.cyan(\"Multiple Roles\")}?`,\n },\n ]);\n\n this.config.authentication = {\n ...this.config.authentication,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n console.info(\n `\\nSkipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`\n );\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
@@ -100,7 +100,7 @@ class TemplateCompiler {
|
|
|
100
100
|
else if (dirent.name.endsWith(".hbs")) {
|
|
101
101
|
const templatePath = fullPath;
|
|
102
102
|
const template = handlebars_1.default.compile(fs_1.default.readFileSync(templatePath, "utf8"));
|
|
103
|
-
let arkosCurrentVersion = "1.2.
|
|
103
|
+
let arkosCurrentVersion = "1.2.14-beta";
|
|
104
104
|
const content = template({ ...config, arkosCurrentVersion });
|
|
105
105
|
const ext = isTypescript ? ".ts" : ".js";
|
|
106
106
|
let outputPath = path_1.default.join(outputDir, relativePath.replace(".hbs", ""));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AAGpC,MAAM,gBAAgB;IACpB,KAAK,CAAC,iCAAiC,CAAC,MAAqB;QAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,MAAqB;QACpC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,qBAAqB,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAElD,MAAM,sBAAsB,GAAG;YAC7B,4BAA4B;YAC5B,sBAAsB;YACtB,sBAAsB;SACvB,CAAC;QAEF,MAAM,wBAAwB,GAAG;YAC/B,qBAAqB;YACrB,sBAAsB;YACtB,+BAA+B;YAC/B,yBAAyB;SAC1B,CAAC;QAEF,MAAM,yBAAyB,GAAG;YAChC,sCAAsC;YACtC,sCAAsC;YACtC,gCAAgC;YAChC,gCAAgC;SACjC,CAAC;QAEF,MAAM,kBAAkB,GAAG;YACzB,2BAA2B;YAC3B,2BAA2B;SAC5B,CAAC;QAEF,MAAM,0BAA0B,GAAG;YACjC,wBAAwB;YACxB,wBAAwB;SACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AAGpC,MAAM,gBAAgB;IACpB,KAAK,CAAC,iCAAiC,CAAC,MAAqB;QAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,MAAqB;QACpC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,qBAAqB,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAElD,MAAM,sBAAsB,GAAG;YAC7B,4BAA4B;YAC5B,sBAAsB;YACtB,sBAAsB;SACvB,CAAC;QAEF,MAAM,wBAAwB,GAAG;YAC/B,qBAAqB;YACrB,sBAAsB;YACtB,+BAA+B;YAC/B,yBAAyB;SAC1B,CAAC;QAEF,MAAM,yBAAyB,GAAG;YAChC,sCAAsC;YACtC,sCAAsC;YACtC,gCAAgC;YAChC,gCAAgC;SACjC,CAAC;QAEF,MAAM,kBAAkB,GAAG;YACzB,2BAA2B;YAC3B,2BAA2B;SAC5B,CAAC;QAEF,MAAM,0BAA0B,GAAG;YACjC,wBAAwB;YACxB,wBAAwB;SACzB,CAAC;QAEF,MAAM,gCAAgC,GAAG;YACvC,kBAAkB;YAClB,mBAAmB;YACnB,4BAA4B;YAC5B,sBAAsB;SACvB,CAAC;QAEF,MAAM,iCAAiC,G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mBAAmB,GAAG,yBAAyB,CAAC;oBAEpD,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,GAAG,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;oBAC7D,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;oBAEzC,IAAI,UAAU,GAAG,cAAI,CAAC,IAAI,CACxB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACjC,CAAC;oBACF,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;wBACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;oBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;iBACvC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEhD,kBAAe,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\nimport { getNpmPackageVersion } from \"./helpers/npm.helpers\";\n\nclass TemplateCompiler {\n async canCompileAuthenticationTemplates(config: ProjectConfig) {\n return !!config.authentication;\n }\n\n filesToBeSkipped(config: ProjectConfig) {\n const files: string[] = [];\n const authSharedPrismaFiles = [\"user.prisma.hbs\"];\n\n const dynamicAuthPrismaFiles = [\n \"auth-permission.prisma.hbs\",\n \"auth-role.prisma.hbs\",\n \"user-role.prisma.hbs\",\n ];\n\n const sharedAuthZodSchemaFiles = [\n \"login.schema.ts.hbs\",\n \"signup.schema.ts.hbs\",\n \"update-password.schema.ts.hbs\",\n \"update-me.schema.ts.hbs\",\n ];\n\n const dynamicAuthZodSchemaFiles = [\n \"create-auth-permission.schema.ts.hbs\",\n \"update-auth-permission.schema.ts.hbs\",\n \"create-auth-role.schema.ts.hbs\",\n \"update-auth-role.schema.ts.hbs\",\n ];\n\n const userZodSchemaFiles = [\n \"create-user.schema.ts.hbs\",\n \"update-user.schema.ts.hbs\",\n ];\n\n const userClassValidatorDtoFiles = [\n \"create-user.dto.ts.hbs\",\n \"update-user.dto.ts.hbs\",\n ];\n\n const sharedAuthClassValidatorDtoFiles = [\n \"login.dto.ts.hbs\",\n \"signup.dto.ts.hbs\",\n \"update-password.dto.ts.hbs\",\n \"update-me.dto.ts.hbs\",\n ];\n\n const dynamicAuthClassValidatorDtoFiles = [\n \"create-auth-permission.dto.ts.hbs\",\n \"update-auth-permission.dto.ts.hbs\",\n \"create-auth-role.dto.ts.hbs\",\n \"update-auth-role.dto.ts.hbs\",\n ];\n\n const authModuleComponents = [\n \"auth.middlewares.ts.hbs\",\n \"auth.query.ts.hbs\",\n ];\n\n const authPermissionModuleComponents = [\n \"auth-permission.auth.ts.hbs\",\n \"auth-permission.query.ts.hbs\",\n \"auth-permission.service.ts.hbs\",\n ];\n\n const authRoleModuleComponents = [\n \"auth-role.auth.ts.hbs\",\n \"auth-role.query.ts.hbs\",\n \"auth-role.service.ts.hbs\",\n ];\n\n const userModuleComponents = [\n \"user.middlewares.ts.hbs\",\n \"user.query.ts.hbs\",\n \"user.service.ts.hbs\",\n \"user.auth.ts.hbs\",\n ];\n\n // Ignoring auth relation files when auth is set to define later\n if (config.authentication?.type === \"define later\")\n files.push(\n ...authSharedPrismaFiles,\n ...dynamicAuthPrismaFiles,\n ...sharedAuthZodSchemaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...sharedAuthClassValidatorDtoFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...userModuleComponents,\n ...authModuleComponents,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents\n );\n\n // Ignoring files that are not required on static authentication\n if (config.authentication?.type === \"static\")\n files.push(\n ...dynamicAuthPrismaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents\n );\n\n // Ignore zod related files when validation is class-validator\n if (config.validation.type !== \"zod\")\n files.push(\n ...sharedAuthZodSchemaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...userZodSchemaFiles\n );\n\n // Ignore class-validator related files when validation is zod\n if (config.validation.type !== \"class-validator\")\n files.push(\n ...sharedAuthClassValidatorDtoFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...userClassValidatorDtoFiles\n );\n\n // Ignoring typescript related files when typescript false\n if (!config.typescript) files.push(...[\"tsconfig.json.hbs\"]);\n\n // Ignoring javascript related files when typescript true\n if (config?.typescript) files.push(...[\"jsconfig.json.hbs\"]);\n\n return files;\n }\n /**\n * Compiles the Arkos.js project with handlebars templates\n *\n * @param templatesDir {string} templates location\n * @param config {ProjectConfig} the project configuration\n * @returns void\n * */\n async compile(templatesDir: string, config: ProjectConfig) {\n const outputDir = config.projectPath;\n const isTypescript = config.typescript;\n const filesToBeSkipped = this.filesToBeSkipped(config);\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n if (filesToBeSkipped.includes(dirent.name)) return;\n\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n let arkosCurrentVersion = \"{{arkosCurrentVersion}}\";\n\n const content = template({ ...config, arkosCurrentVersion });\n const ext = isTypescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(\n outputDir,\n relativePath.replace(\".hbs\", \"\")\n );\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n }\n}\n\nconst templateCompiler = new TemplateCompiler();\n\nexport default templateCompiler;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arkos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.2.14-beta",
|
|
4
4
|
"description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-arkos": "./dist/index.js"
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"postbuild": "ts-node scripts/postbuild/index.ts",
|
|
12
12
|
"postpublish": "ts-node scripts/postpublish/index.ts",
|
|
13
13
|
"test:hbs": "ts-node src/utils/helpers/hbs-tester.helpers.ts",
|
|
14
|
-
"
|
|
14
|
+
"prepublishOnlyBak": "pnpm build",
|
|
15
|
+
"publish": "ts-node scripts/postbuild/index.ts && pnpm build && npm publish --tag latest"
|
|
15
16
|
},
|
|
16
17
|
"author": "Uanela Como",
|
|
17
18
|
"license": "MIT",
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{{#if typescript}}
|
|
2
|
-
import prisma from "../../utils/prisma";
|
|
2
|
+
import prisma from "../../utils/prisma/index.js";
|
|
3
3
|
import { AuthPrismaQueryOptions } from 'arkos/prisma';
|
|
4
4
|
|
|
5
5
|
const authQueryOptions: AuthPrismaQueryOptions<typeof prisma.user> = {
|
|
6
6
|
{{else}}
|
|
7
7
|
/**
|
|
8
|
-
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma').prisma.user>}
|
|
8
|
+
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma/index.js').prisma.user>}
|
|
9
9
|
*/
|
|
10
10
|
const authQueryOptions = {
|
|
11
11
|
{{/if}}
|
|
12
12
|
getMe: {
|
|
13
|
+
omit: {
|
|
14
|
+
password: true,
|
|
15
|
+
},
|
|
13
16
|
include: {
|
|
14
|
-
password: false,
|
|
15
17
|
{{#if (eq authentication.type "dynamic")}}
|
|
16
18
|
{{#if authentication.multipleRoles}}
|
|
17
19
|
roles: {
|
|
@@ -38,13 +40,17 @@ const authQueryOptions = {
|
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
42
|
updateMe: {
|
|
41
|
-
|
|
42
|
-
password:
|
|
43
|
-
},
|
|
43
|
+
omit: {
|
|
44
|
+
password: true,
|
|
45
|
+
},
|
|
44
46
|
},
|
|
45
47
|
deleteMe: {},
|
|
46
48
|
login: {},
|
|
47
|
-
signup: {
|
|
49
|
+
signup: {
|
|
50
|
+
omit: {
|
|
51
|
+
password: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
48
54
|
updatePassword: {},
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -3,11 +3,11 @@ import "reflect-metadata"
|
|
|
3
3
|
|
|
4
4
|
export default class LoginDto {
|
|
5
5
|
@IsString()
|
|
6
|
-
{{authentication.usernameField}}
|
|
6
|
+
{{authentication.usernameField}}!: string
|
|
7
7
|
|
|
8
8
|
@IsString()
|
|
9
9
|
@MinLength(8, { message: 'Password must be at least 8 characters long' })
|
|
10
10
|
@Matches(/[a-z]/, { message: 'Password must contain at least one lowercase letter' })
|
|
11
11
|
@Matches(/[A-Z]/, { message: 'Password must contain at least one uppercase letter' })
|
|
12
|
-
password
|
|
12
|
+
password!: string
|
|
13
13
|
}
|
|
@@ -4,11 +4,11 @@ import "reflect-metadata"
|
|
|
4
4
|
export default class SignupDto {
|
|
5
5
|
@IsString()
|
|
6
6
|
@IsNotEmpty({ message: '{{authentication.usernameField}} is required' })
|
|
7
|
-
{{authentication.usernameField}}
|
|
7
|
+
{{authentication.usernameField}}!: string
|
|
8
8
|
|
|
9
9
|
@IsString()
|
|
10
10
|
@MinLength(8, { message: 'Password must be at least 8 characters long' })
|
|
11
11
|
@Matches(/[a-z]/, { message: 'Password must contain at least one lowercase letter' })
|
|
12
12
|
@Matches(/[A-Z]/, { message: 'Password must contain at least one uppercase letter' })
|
|
13
|
-
password
|
|
13
|
+
password!: string
|
|
14
14
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import 'reflect-metadata'
|
|
2
|
+
import {
|
|
3
|
+
IsString,
|
|
4
|
+
MinLength,
|
|
5
|
+
Matches,
|
|
6
|
+
IsNotEmpty,
|
|
7
|
+
IsBoolean,
|
|
8
|
+
IsOptional,
|
|
9
|
+
IsArray,
|
|
10
|
+
ValidateNested,
|
|
11
|
+
Type,
|
|
12
|
+
IsEnum
|
|
13
|
+
} from 'class-validator'
|
|
14
|
+
|
|
15
|
+
export default class UpdateUserDto {
|
|
16
|
+
@IsString()
|
|
17
|
+
@IsNotEmpty({ message: '{{authentication.usernameField}} is required' })
|
|
18
|
+
@IsOptional()
|
|
19
|
+
{{authentication.usernameField}}!: string
|
|
20
|
+
}
|
|
@@ -4,11 +4,11 @@ import "reflect-metadata"
|
|
|
4
4
|
export default class UpdatePasswordDto {
|
|
5
5
|
@IsString()
|
|
6
6
|
@IsNotEmpty()
|
|
7
|
-
currentPassword
|
|
7
|
+
currentPassword!: string
|
|
8
8
|
|
|
9
9
|
@IsString()
|
|
10
10
|
@MinLength(8, { message: 'Password must be at least 8 characters long' })
|
|
11
11
|
@Matches(/[a-z]/, { message: 'Password must contain at least one lowercase letter' })
|
|
12
12
|
@Matches(/[A-Z]/, { message: 'Password must contain at least one uppercase letter' })
|
|
13
|
-
newPassword
|
|
13
|
+
newPassword!: string
|
|
14
14
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
const UpdateMeSchema = z.object({
|
|
4
|
+
{{authentication.usernameField}}: z.string()
|
|
5
|
+
.optional(),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export default UpdateMeSchema
|
|
9
|
+
|
|
10
|
+
{{#if typescript}}
|
|
11
|
+
export type UpdateMeSchemaType = z.infer<typeof UpdateMeSchema>
|
|
12
|
+
{{/if}}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{{#if typescript}}
|
|
2
|
-
import prisma from "../../utils/prisma";
|
|
2
|
+
import prisma from "../../utils/prisma/index.js";
|
|
3
3
|
import { PrismaQueryOptions } from 'arkos/prisma';
|
|
4
4
|
|
|
5
5
|
const authPermissionQueryOptions: PrismaQueryOptions<typeof prisma.authPermission> = {
|
|
6
6
|
{{else}}
|
|
7
7
|
/**
|
|
8
|
-
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma').prisma.authPermission>}
|
|
8
|
+
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma/index.js').prisma.authPermission>}
|
|
9
9
|
*/
|
|
10
10
|
const authPermissionQueryOptions = {
|
|
11
11
|
{{/if}}
|
|
12
12
|
global: {},
|
|
13
|
-
find: {
|
|
13
|
+
find: {
|
|
14
|
+
include: {
|
|
15
|
+
role: true
|
|
16
|
+
},
|
|
17
|
+
},
|
|
14
18
|
findOne: {},
|
|
15
19
|
findMany: {},
|
|
16
20
|
udpate: {},
|
|
@@ -16,21 +16,21 @@ import { AuthPermissionAction } from "@prisma/client"
|
|
|
16
16
|
class RoleConnectDto {
|
|
17
17
|
@IsString()
|
|
18
18
|
@IsNotEmpty({ message: 'Role ID is required' })
|
|
19
|
-
id
|
|
19
|
+
id!: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default class CreateAuthPermissionDto {
|
|
23
23
|
@IsString()
|
|
24
24
|
@IsNotEmpty({ message: 'Resource is required' })
|
|
25
|
-
resource
|
|
25
|
+
resource!: string;
|
|
26
26
|
|
|
27
27
|
@IsEnum(AuthPermissionAction)
|
|
28
28
|
@Transform(({ value }) => value || AuthPermissionAction.View)
|
|
29
|
-
action
|
|
29
|
+
action!: AuthPermissionAction = AuthPermissionAction.View;
|
|
30
30
|
|
|
31
31
|
@ValidateNested()
|
|
32
32
|
@Type(() => RoleConnectDto)
|
|
33
|
-
role
|
|
33
|
+
role!: RoleConnectDto;
|
|
34
34
|
|
|
35
35
|
@IsOptional()
|
|
36
36
|
@IsString()
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{{#if typescript}}
|
|
2
|
-
import prisma from "../../utils/prisma";
|
|
2
|
+
import prisma from "../../utils/prisma/index.js";
|
|
3
3
|
import { PrismaQueryOptions } from 'arkos/prisma';
|
|
4
4
|
|
|
5
5
|
const authRoleQueryOptions: PrismaQueryOptions<typeof prisma.authRole> = {
|
|
6
6
|
{{else}}
|
|
7
7
|
/**
|
|
8
|
-
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma').prisma.authRole>}
|
|
8
|
+
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma/index.js').prisma.authRole>}
|
|
9
9
|
*/
|
|
10
10
|
const authRoleQueryOptions = {
|
|
11
11
|
{{/if}}
|
|
12
12
|
global: {},
|
|
13
13
|
find: {},
|
|
14
|
-
findOne: {
|
|
14
|
+
findOne: {
|
|
15
|
+
include: {
|
|
16
|
+
permissions: true
|
|
17
|
+
},
|
|
18
|
+
},
|
|
15
19
|
findMany: {},
|
|
16
20
|
udpate: {},
|
|
17
21
|
updateMany: {},
|
|
@@ -21,11 +21,11 @@ export enum ApiAction {
|
|
|
21
21
|
class UpdatePermissionForRoleDto {
|
|
22
22
|
@IsString()
|
|
23
23
|
@IsNotEmpty({ message: 'Resource is required' })
|
|
24
|
-
resource
|
|
24
|
+
resource!: string;
|
|
25
25
|
|
|
26
26
|
@IsEnum(AuthPermissionAction)
|
|
27
27
|
@Transform(({ value }) => value || AuthPermissionAction.View)
|
|
28
|
-
action
|
|
28
|
+
action!: AuthPermissionAction = AuthPermissionAction.View;
|
|
29
29
|
|
|
30
30
|
@IsOptional()
|
|
31
31
|
@IsString()
|
|
@@ -34,13 +34,13 @@ class UpdatePermissionForRoleDto {
|
|
|
34
34
|
|
|
35
35
|
@IsEnum(ApiAction)
|
|
36
36
|
@IsOptional()
|
|
37
|
-
apiAction
|
|
37
|
+
apiAction!: ApiAction;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export default class UpdateAuthRoleDto {
|
|
41
41
|
@IsString()
|
|
42
42
|
@IsNotEmpty({ message: 'Role name is required' })
|
|
43
|
-
name
|
|
43
|
+
name!: string;
|
|
44
44
|
|
|
45
45
|
@IsOptional()
|
|
46
46
|
@IsString()
|
|
@@ -8,7 +8,7 @@ import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-aut
|
|
|
8
8
|
const CreateAuthRoleSchema = z.object({
|
|
9
9
|
name: z.string().min(1, 'Role name is required'),
|
|
10
10
|
description: z.string().optional(),
|
|
11
|
-
permissions: z.array(
|
|
11
|
+
permissions: z.array(CreateAuthPermissionSchema.omit({ role: true })).optional().default([]),
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
export default CreateAuthRoleSchema
|
|
@@ -6,9 +6,16 @@ import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-aut
|
|
|
6
6
|
{{/if}}
|
|
7
7
|
|
|
8
8
|
const UpdateAuthRoleSchema = z.object({
|
|
9
|
-
name: z.string().min(1,
|
|
9
|
+
name: z.string().min(1, "Role name is required"),
|
|
10
10
|
description: z.string().optional(),
|
|
11
|
-
permissions: z
|
|
11
|
+
permissions: z
|
|
12
|
+
.array(
|
|
13
|
+
CreateAuthPermissionSchema.extend({
|
|
14
|
+
apiAction: z.enum(["connect", "delete"]).optional(),
|
|
15
|
+
}).omit({ role: true })
|
|
16
|
+
)
|
|
17
|
+
.optional()
|
|
18
|
+
.default([]),
|
|
12
19
|
});
|
|
13
20
|
|
|
14
21
|
export default UpdateAuthRoleSchema
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{{#if typescript}}
|
|
2
|
-
import prisma from "../../utils/prisma";
|
|
2
|
+
import prisma from "../../utils/prisma/index.js";
|
|
3
3
|
import { PrismaQueryOptions } from 'arkos/prisma';
|
|
4
4
|
|
|
5
5
|
const userQueryOptions: PrismaQueryOptions<typeof prisma.user> = {
|
|
6
6
|
{{else}}
|
|
7
7
|
/**
|
|
8
|
-
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma').prisma.user>}
|
|
8
|
+
* @type {import("arkos/prisma").PrismaQueryOptions<typeof import('../../utils/prisma/index.js').prisma.user>}
|
|
9
9
|
*/
|
|
10
10
|
const userQueryOptions = {
|
|
11
11
|
{{/if}}
|
|
12
12
|
global: {},
|
|
13
13
|
find: {
|
|
14
|
+
omit: {
|
|
15
|
+
password: true,
|
|
16
|
+
},
|
|
14
17
|
include: {
|
|
15
|
-
password: false,
|
|
16
18
|
{{#if (eq authentication.type "dynamic")}}
|
|
17
19
|
{{#if authentication.multipleRoles}}
|
|
18
20
|
roles: {
|
|
@@ -65,8 +67,8 @@ const userQueryOptions = {
|
|
|
65
67
|
createMany: {},
|
|
66
68
|
createOne: {},
|
|
67
69
|
save: {
|
|
68
|
-
|
|
69
|
-
password:
|
|
70
|
+
omit: {
|
|
71
|
+
password: true,
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
74
|
saveMany: {},
|
|
File without changes
|