create-arkos 1.5.4-beta → 1.6.0-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/utils/template-compiler.js +9 -4
  2. package/dist/utils/template-compiler.js.map +1 -1
  3. package/package.json +1 -1
  4. package/templates/basic/arkos.config.ts.hbs +4 -9
  5. package/templates/basic/jsconfig.json.hbs +24 -5
  6. package/templates/basic/package.json.hbs +1 -4
  7. package/templates/basic/src/app.ts.hbs +5 -3
  8. package/templates/basic/src/modules/auth-permission/auth-permission.policy.ts.hbs +33 -0
  9. package/templates/basic/src/modules/auth-permission/auth-permission.router.ts.hbs +14 -0
  10. package/templates/basic/src/modules/auth-role/auth-role.policy.ts.hbs +33 -0
  11. package/templates/basic/src/modules/auth-role/auth-role.router.ts.hbs +14 -0
  12. package/templates/basic/src/modules/auth-role/schemas/create-auth-role.schema.ts.hbs +1 -5
  13. package/templates/basic/src/modules/auth-role/schemas/update-auth-role.schema.ts.hbs +1 -5
  14. package/templates/basic/src/modules/file-upload/file-upload.policy.ts.hbs +33 -0
  15. package/templates/basic/src/modules/file-upload/file-upload.router.ts.hbs +13 -0
  16. package/templates/basic/src/modules/user/dtos/update-user.dto.ts.hbs +1 -5
  17. package/templates/basic/src/modules/user/schemas/update-user.schema.ts.hbs +1 -5
  18. package/templates/basic/src/modules/user/user.interceptors.ts.hbs +0 -50
  19. package/templates/basic/src/modules/user/user.policy.ts.hbs +33 -0
  20. package/templates/basic/src/modules/user/user.router.ts.hbs +14 -0
  21. package/templates/basic/tsconfig.json.hbs +22 -10
  22. package/templates/basic/src/modules/auth-permission/auth-permission.auth.ts.hbs +0 -75
  23. package/templates/basic/src/modules/auth-role/auth-role.auth.ts.hbs +0 -75
  24. package/templates/basic/src/modules/file-upload/file-upload.auth.ts.hbs +0 -83
  25. package/templates/basic/src/modules/user/user.auth.ts.hbs +0 -75
@@ -50,12 +50,16 @@ class TemplateCompiler {
50
50
  "auth.query.ts.hbs",
51
51
  ];
52
52
  const authPermissionModuleComponents = [
53
- "auth-permission.auth.ts.hbs",
53
+ "auth-permission.router.ts.hbs",
54
+ "auth-permission.policy.ts.hbs",
55
+ "auth-permission.query.ts.hbs",
54
56
  "auth-permission.query.ts.hbs",
55
57
  "auth-permission.service.ts.hbs",
56
58
  ];
57
59
  const authRoleModuleComponents = [
58
- "auth-role.auth.ts.hbs",
60
+ "auth-role.router.ts.hbs",
61
+ "auth-role.policy.ts.hbs",
62
+ "auth-role.query.ts.hbs",
59
63
  "auth-role.query.ts.hbs",
60
64
  "auth-role.service.ts.hbs",
61
65
  ];
@@ -63,11 +67,12 @@ class TemplateCompiler {
63
67
  "user.interceptors.ts.hbs",
64
68
  "user.query.ts.hbs",
65
69
  "user.service.ts.hbs",
66
- "user.auth.ts.hbs",
70
+ "user.router.ts.hbs",
71
+ "user.policy.ts.hbs",
67
72
  ];
68
73
  if (!config.authentication?.type ||
69
74
  config.authentication?.type === "define later")
70
- files.push(...authSharedPrismaFiles, ...dynamicAuthPrismaFiles, ...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userModuleComponents, ...authModuleComponents, ...authPermissionModuleComponents, ...authRoleModuleComponents, ...userZodSchemaFiles, ...userClassValidatorDtoFiles, "file-upload.auth.ts.hbs");
75
+ files.push(...authSharedPrismaFiles, ...dynamicAuthPrismaFiles, ...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userModuleComponents, ...authModuleComponents, ...authPermissionModuleComponents, ...authRoleModuleComponents, ...userZodSchemaFiles, ...userClassValidatorDtoFiles, "file-upload.router.ts.hbs", "file-upload.policy.ts.hbs");
71
76
  if (config.authentication?.type === "static")
72
77
  files.push(...dynamicAuthPrismaFiles, ...dynamicAuthZodSchemaFiles, ...dynamicAuthClassValidatorDtoFiles, ...authPermissionModuleComponents, ...authRoleModuleComponents);
73
78
  if (config.validation?.type !== "zod")
@@ -1 +1 @@
1
- {"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,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,GAAG;YACxC,mCAAmC;YACnC,mCAAmC;YACnC,6BAA6B;YAC7B,6BAA6B;SAC9B,CAAC;QAEF,MAAM,oBAAoB,GAAG;YAC3B,0BAA0B;YAC1B,mBAAmB;SACpB,CAAC;QAEF,MAAM,8BAA8B,GAAG;YACrC,6BAA6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EF,IAAI,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,IAAI,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,IAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;oBAEJ,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC5D,EAAE,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,eAAe,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\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.interceptors.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.interceptors.ts.hbs\",\n \"user.query.ts.hbs\",\n \"user.service.ts.hbs\",\n \"user.auth.ts.hbs\",\n ];\n\n if (\n !config.authentication?.type ||\n config.authentication?.type === \"define later\"\n )\n files.push(\n ...authSharedPrismaFiles,\n ...dynamicAuthPrismaFiles,\n ...sharedAuthZodSchemaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...sharedAuthClassValidatorDtoFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...userModuleComponents,\n ...authModuleComponents,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents,\n ...userZodSchemaFiles,\n ...userClassValidatorDtoFiles,\n \"file-upload.auth.ts.hbs\"\n );\n\n if (config.authentication?.type === \"static\")\n files.push(\n ...dynamicAuthPrismaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents\n );\n\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 (\n filesToBeSkipped.includes(dirent.name) ||\n dirent.name === \"__tests__\" ||\n dirent.name?.includes(\".test.ts\")\n )\n 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"]}
1
+ {"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,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,mB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} from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\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.interceptors.ts.hbs\",\n \"auth.query.ts.hbs\",\n ];\n\n const authPermissionModuleComponents = [\n \"auth-permission.router.ts.hbs\",\n \"auth-permission.policy.ts.hbs\",\n \"auth-permission.query.ts.hbs\",\n\n \"auth-permission.query.ts.hbs\",\n \"auth-permission.service.ts.hbs\",\n ];\n\n const authRoleModuleComponents = [\n \"auth-role.router.ts.hbs\",\n \"auth-role.policy.ts.hbs\",\n \"auth-role.query.ts.hbs\",\n\n \"auth-role.query.ts.hbs\",\n \"auth-role.service.ts.hbs\",\n ];\n\n const userModuleComponents = [\n \"user.interceptors.ts.hbs\",\n \"user.query.ts.hbs\",\n \"user.service.ts.hbs\",\n \"user.router.ts.hbs\",\n \"user.policy.ts.hbs\",\n ];\n\n if (\n !config.authentication?.type ||\n config.authentication?.type === \"define later\"\n )\n files.push(\n ...authSharedPrismaFiles,\n ...dynamicAuthPrismaFiles,\n ...sharedAuthZodSchemaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...sharedAuthClassValidatorDtoFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...userModuleComponents,\n ...authModuleComponents,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents,\n ...userZodSchemaFiles,\n ...userClassValidatorDtoFiles,\n \"file-upload.router.ts.hbs\",\n \"file-upload.policy.ts.hbs\"\n );\n\n if (config.authentication?.type === \"static\")\n files.push(\n ...dynamicAuthPrismaFiles,\n ...dynamicAuthZodSchemaFiles,\n ...dynamicAuthClassValidatorDtoFiles,\n ...authPermissionModuleComponents,\n ...authRoleModuleComponents\n );\n\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 (\n filesToBeSkipped.includes(dirent.name) ||\n dirent.name === \"__tests__\" ||\n dirent.name?.includes(\".test.ts\")\n )\n 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": "1.5.4-beta",
3
+ "version": "1.6.0-canary.2",
4
4
  "type": "module",
5
5
  "description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com",
6
6
  "bin": {
@@ -1,11 +1,6 @@
1
- {{#if typescript}}
2
- import { ArkosConfig } from 'arkos'
1
+ import { defineConfig } from "arkos/config"
3
2
 
4
- const config: ArkosConfig = {
5
- {{else}}
6
- /** @type {import('arkos').ArkosConfig} */
7
- const config = {
8
- {{/if}}
3
+ const arkosConfig = defineConfig({
9
4
  {{#if authentication.type}}
10
5
  authentication: {
11
6
  mode: '{{authentication.type}}',
@@ -39,6 +34,6 @@ const config = {
39
34
  allowedOrigins: process.env.NODE_ENV !== "production" ? "*" : "your-production-url"
40
35
  },
41
36
  }
42
- }
37
+ })
43
38
 
44
- export default config
39
+ export default arkosConfig
@@ -1,15 +1,34 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES6",
4
- "module": "Node16",
5
- "moduleResolution": "node16",
4
+ "module": "es2020",
5
+ "moduleResolution": "bundler",
6
6
  "rootDir": ".",
7
+ "baseUrl": ".",
7
8
  "sourceMap": true,
8
9
  "esModuleInterop": true,
10
+ "isolatedModules": true,
11
+ "skipLibCheck": true,
9
12
  "forceConsistentCasingInFileNames": true,
13
+ "experimentalDecorators": true,
14
+ "emitDecoratorMetadata": true,
15
+ "lib": ["es6", "dom"],
10
16
  "allowJs": true,
11
- "checkJs": false
17
+ "checkJs": false,
18
+ "paths": {
19
+ "@/*": ["./*"]
20
+ }
12
21
  },
13
- "include": ["src/**/*.js", "src/**/*.jsx", "arkos.config.js"],
14
- "exclude": ["node_modules", ".build", "src/**/__tests__/**", "src/**/*.test.js"]
22
+ "include": ["src/**/*.js", "src/**/*.jsx", "packages/**/*.js", "arkos.config.js"],
23
+ "exclude": [
24
+ "**/node_modules",
25
+ "node_modules",
26
+ ".build",
27
+ "build",
28
+ "temp",
29
+ "dist",
30
+ "uploads",
31
+ "src/**/__tests__/**",
32
+ "src/**/*.test.js"
33
+ ]
15
34
  }
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
3
  "version": "1.0.0",
4
- {{#if typescript}}
5
- {{else}}
6
4
  "type": "module",
7
- {{/if}}
8
5
  "description": "This RESTful API was generated by create-arkos, read more about Arkos.js at www.arkosjs.com",
9
6
  "scripts": {
10
7
  "dev": "arkos dev",
@@ -26,7 +23,7 @@
26
23
  "prisma": "^6.19.2"
27
24
  },
28
25
  "dependencies": {
29
- "arkos": "^1.5.4-beta",
26
+ "arkos": "^1.6.0-canary.22",
30
27
  "express": "^4.22.1",
31
28
  "@scalar/express-api-reference": "^0.8.35",
32
29
  "@prisma/client": "^6.19.2"{{#if validation.type}},{{/if}}
@@ -1,5 +1,7 @@
1
1
  import arkos from 'arkos';
2
2
 
3
- arkos.init({
4
- use: [], // pass your additional middlewares/routers here
5
- });
3
+ const app = arkos()
4
+
5
+ app.set("trust proxy", 1)
6
+
7
+ app.listen()
@@ -0,0 +1,33 @@
1
+ import { ArkosPolicy } from "arkos";
2
+
3
+ const authPermissionPolicy = ArkosPolicy("auth-permission")
4
+ .rule("Create", {
5
+ {{#if (eq authentication.type "static")}}
6
+ roles: [],
7
+ {{/if}}
8
+ name: "Create Auth Permission",
9
+ description: "Permission to create new auth permission records",
10
+ })
11
+ .rule("View", {
12
+ {{#if (eq authentication.type "static")}}
13
+ roles: [],
14
+ {{/if}}
15
+ name: "View Auth Permission",
16
+ description: "Permission to view auth permission records",
17
+ })
18
+ .rule("Update", {
19
+ {{#if (eq authentication.type "static")}}
20
+ roles: [],
21
+ {{/if}}
22
+ name: "Update Auth Permission",
23
+ description: "Permission to update existing auth permission records",
24
+ })
25
+ .rule("Delete", {
26
+ {{#if (eq authentication.type "static")}}
27
+ roles: [],
28
+ {{/if}}
29
+ name: "Delete Auth Permission",
30
+ description: "Permission to delete auth permission records",
31
+ });
32
+
33
+ export default authPermissionPolicy;
@@ -0,0 +1,14 @@
1
+ import { ArkosRouter{{#if typescript}}, RouterConfig{{/if}} } from "arkos";
2
+ import authPermissionPolicy from "@/src/modules/auth-permission/auth-permission.policy";
3
+
4
+ export const config{{#if typescript}}: RouterConfig{{/if}} = {
5
+ createOne: { authentication: authPermissionPolicy.Create },
6
+ findMany: { authentication: authPermissionPolicy.View },
7
+ findOne: { authentication: authPermissionPolicy.View },
8
+ updateOne: { authentication: authPermissionPolicy.Update },
9
+ deleteOne: { authentication: authPermissionPolicy.Delete },
10
+ };
11
+
12
+ const authPermissionRouter = ArkosRouter({ openapi: { tags: ["Auth Permissions"] } });
13
+
14
+ export default authPermissionRouter;
@@ -0,0 +1,33 @@
1
+ import { ArkosPolicy } from "arkos";
2
+
3
+ const authRolePolicy = ArkosPolicy("auth-role")
4
+ .rule("Create", {
5
+ {{#if (eq authentication.type "static")}}
6
+ roles: [],
7
+ {{/if}}
8
+ name: "Create Auth Role",
9
+ description: "Permission to create new auth role records",
10
+ })
11
+ .rule("View", {
12
+ {{#if (eq authentication.type "static")}}
13
+ roles: [],
14
+ {{/if}}
15
+ name: "View Auth Role",
16
+ description: "Permission to view auth role records",
17
+ })
18
+ .rule("Update", {
19
+ {{#if (eq authentication.type "static")}}
20
+ roles: [],
21
+ {{/if}}
22
+ name: "Update Auth Role",
23
+ description: "Permission to update existing auth role records",
24
+ })
25
+ .rule("Delete", {
26
+ {{#if (eq authentication.type "static")}}
27
+ roles: [],
28
+ {{/if}}
29
+ name: "Delete Auth Role",
30
+ description: "Permission to delete auth role records",
31
+ });
32
+
33
+ export default authRolePolicy;
@@ -0,0 +1,14 @@
1
+ import { ArkosRouter{{#if typescript}}, RouterConfig{{/if}} } from "arkos";
2
+ import authRolePolicy from "@/src/modules/auth-role/auth-role.policy";
3
+
4
+ export const config{{#if typescript}}: RouterConfig{{/if}} = {
5
+ createOne: { authentication: authRolePolicy.Create },
6
+ findMany: { authentication: authRolePolicy.View },
7
+ findOne: { authentication: authRolePolicy.View },
8
+ updateOne: { authentication: authRolePolicy.Update },
9
+ deleteOne: { authentication: authRolePolicy.Delete },
10
+ };
11
+
12
+ const authRoleRouter = ArkosRouter({ openapi: { tags: ["Auth Roles"] } });
13
+
14
+ export default authRoleRouter;
@@ -1,9 +1,5 @@
1
1
  import { z } from 'zod';
2
- {{#if typescript}}
3
- import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-auth-permission.schema"
4
- {{else}}
5
- import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-auth-permission.schema.js"
6
- {{/if}}
2
+ import CreateAuthPermissionSchema from "@/src/modules/auth-permission/schemas/create-auth-permission.schema"
7
3
 
8
4
  const CreateAuthRoleSchema = z.object({
9
5
  name: z.string().min(1, 'Role name is required'),
@@ -1,9 +1,5 @@
1
1
  import { z } from 'zod';
2
- {{#if typescript}}
3
- import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-auth-permission.schema"
4
- {{else}}
5
- import CreateAuthPermissionSchema from "../../auth-permission/schemas/create-auth-permission.schema.js"
6
- {{/if}}
2
+ import CreateAuthPermissionSchema from "@/src/modules/auth-permission/schemas/create-auth-permission.schema"
7
3
 
8
4
  const UpdateAuthRoleSchema = z.object({
9
5
  name: z.string().min(1, "Role name is required"),
@@ -0,0 +1,33 @@
1
+ import { ArkosPolicy } from "arkos";
2
+
3
+ const fileUploadPolicy = ArkosPolicy("file-upload")
4
+ .rule("Create", {
5
+ {{#if (eq authentication.type "static")}}
6
+ roles: [],
7
+ {{/if}}
8
+ name: "Upload File",
9
+ description: "Permission to upload new files",
10
+ })
11
+ .rule("View", {
12
+ {{#if (eq authentication.type "static")}}
13
+ roles: [],
14
+ {{/if}}
15
+ name: "View File",
16
+ description: "Permission to view uploaded files",
17
+ })
18
+ .rule("Update", {
19
+ {{#if (eq authentication.type "static")}}
20
+ roles: [],
21
+ {{/if}}
22
+ name: "Update File",
23
+ description: "Permission to update file metadata",
24
+ })
25
+ .rule("Delete", {
26
+ {{#if (eq authentication.type "static")}}
27
+ roles: [],
28
+ {{/if}}
29
+ name: "Delete File",
30
+ description: "Permission to delete uploaded files",
31
+ });
32
+
33
+ export default fileUploadPolicy;
@@ -0,0 +1,13 @@
1
+ import { ArkosRouter{{#if typescript}}, RouterConfig{{/if}} } from "arkos";
2
+ import fileUploadPolicy from "@/src/modules/file-upload/file-upload.policy";
3
+
4
+ export const config{{#if typescript}}: RouterConfig{{/if}} = {
5
+ findFile: { authentication: fileUploadPolicy.View },
6
+ uploadFile: { authentication: fileUploadPolicy.Create },
7
+ updateFile: { authentication: fileUploadPolicy.Update },
8
+ deleteFile: { authentication: fileUploadPolicy.Delete },
9
+ };
10
+
11
+ const fileUploadRouter = ArkosRouter({ openapi: { tags: ["File Uploads"] } });
12
+
13
+ export default fileUploadRouter;
@@ -11,11 +11,7 @@ import {
11
11
  IsEnum
12
12
  } from 'class-validator'
13
13
  import { Type } from 'class-transformer'
14
- {{#if typescript}}
15
- import apiActions from "../../../utils/validation/api-actions"
16
- {{else}}
17
- import apiActions from "../../../utils/validation/api-actions.js"
18
- {{/if}}
14
+ import apiActions from "@/src/utils/validation/api-actions"
19
15
  {{#if (eq authentication.type "static")}}
20
16
  {{#if (neq prisma.provider "sqlite")}}
21
17
  import { UserRole } from "@prisma/client"
@@ -1,9 +1,5 @@
1
1
  import { z } from "zod"
2
- {{#if typescript}}
3
- import apiActions from "../../../utils/validation/api-actions"
4
- {{else}}
5
- import apiActions from "../../../utils/validation/api-actions.js"
6
- {{/if}}
2
+ import apiActions from "@/src/utils/validation/api-actions"
7
3
  {{#if (eq authentication.type "static")}}
8
4
  {{#if (neq prisma.provider "sqlite")}}
9
5
  import { UserRole } from "@prisma/client"
@@ -1,4 +1,3 @@
1
- {{#if typescript}}
2
1
  export const beforeCreateOne = [];
3
2
 
4
3
  export const afterCreateOne = [];
@@ -46,52 +45,3 @@ export const beforeDeleteMany = [];
46
45
  export const afterDeleteMany = [];
47
46
 
48
47
  export const onDeleteManyError = [];
49
- {{else}}
50
- export const beforeCreateOne = [];
51
-
52
- export const afterCreateOne = [];
53
-
54
- export const onCreateOneError = [];
55
-
56
- export const beforeFindOne = [];
57
-
58
- export const afterFindOne = [];
59
-
60
- export const onFindOneError = [];
61
-
62
- export const beforeFindMany = [];
63
-
64
- export const afterFindMany = [];
65
-
66
- export const onFindManyError = [];
67
-
68
- export const beforeUpdateOne = [];
69
-
70
- export const afterUpdateOne = [];
71
-
72
- export const onUpdateOneError = [];
73
-
74
- export const beforeDeleteOne = [];
75
-
76
- export const afterDeleteOne = [];
77
-
78
- export const onDeleteOneError = [];
79
-
80
- export const beforeCreateMany = [];
81
-
82
- export const afterCreateMany = [];
83
-
84
- export const onCreateManyError = [];
85
-
86
- export const beforeUpdateMany = [];
87
-
88
- export const afterUpdateMany = [];
89
-
90
- export const onUpdateManyError = [];
91
-
92
- export const beforeDeleteMany = [];
93
-
94
- export const afterDeleteMany = [];
95
-
96
- export const onDeleteManyError = [];
97
- {{/if}}
@@ -0,0 +1,33 @@
1
+ import { ArkosPolicy } from "arkos";
2
+
3
+ const userPolicy = ArkosPolicy("user")
4
+ .rule("Create", {
5
+ {{#if (eq authentication.type "static")}}
6
+ roles: [],
7
+ {{/if}}
8
+ name: "Create User",
9
+ description: "Permission to create new user records",
10
+ })
11
+ .rule("View", {
12
+ {{#if (eq authentication.type "static")}}
13
+ roles: [],
14
+ {{/if}}
15
+ name: "View User",
16
+ description: "Permission to view user records",
17
+ })
18
+ .rule("Update", {
19
+ {{#if (eq authentication.type "static")}}
20
+ roles: [],
21
+ {{/if}}
22
+ name: "Update User",
23
+ description: "Permission to update existing user records",
24
+ })
25
+ .rule("Delete", {
26
+ {{#if (eq authentication.type "static")}}
27
+ roles: [],
28
+ {{/if}}
29
+ name: "Delete User",
30
+ description: "Permission to delete user records",
31
+ });
32
+
33
+ export default userPolicy;
@@ -0,0 +1,14 @@
1
+ import { ArkosRouter{{#if typescript}}, RouterConfig{{/if}} } from "arkos";
2
+ import userPolicy from "@/src/modules/user/user.policy";
3
+
4
+ export const config{{#if typescript}}: RouterConfig{{/if}} = {
5
+ createOne: { authentication: userPolicy.Create },
6
+ findMany: { authentication: userPolicy.View },
7
+ findOne: { authentication: userPolicy.View },
8
+ updateOne: { authentication: userPolicy.Update },
9
+ deleteOne: { authentication: userPolicy.Delete },
10
+ };
11
+
12
+ const userRouter = ArkosRouter({ openapi: { tags: ["Users"] } });
13
+
14
+ export default userRouter;
@@ -1,22 +1,34 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES6",
4
- "module": "Node16",
5
- "moduleResolution": "node16",
4
+ "module": "es2020",
5
+ "moduleResolution": "bundler",
6
6
  "rootDir": ".",
7
+ "baseUrl": ".",
7
8
  "strict": true,
8
- "sourceMap": true,
9
- "inlineSources": true,
10
- "removeComments": true,
11
- "skipLibCheck": true,
12
9
  "esModuleInterop": true,
10
+ "isolatedModules": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
13
  "experimentalDecorators": true,
14
14
  "emitDecoratorMetadata": true,
15
- "forceConsistentCasingInFileNames": true
15
+ "lib": ["es6", "dom"],
16
+ "noImplicitAny": true,
17
+ "paths": {
18
+ "@/*": ["./*"]
19
+ }
16
20
  },
17
- "include": ["src/**/*.ts", "src/**/*.tsx", "arkos.config.ts"],
18
- "exclude": ["node_modules", ".build", "src/**/__tests__/**", "src/**/*.test.ts"],
21
+ "include": ["src/**/*.ts", "packages/**/*.ts", "arkos.config.ts"],
22
+ "exclude": [
23
+ "**/node_modules",
24
+ "node_modules",
25
+ ".build",
26
+ "build",
27
+ "temp",
28
+ "dist",
29
+ "uploads"
30
+ ],
19
31
  "watchOptions": {
20
- "excludeDirectories": ["**/node_modules", "dist", "temp", "build", ".build"]
32
+ "excludeDirectories": ["**/node_modules", "node_modules"]
21
33
  }
22
34
  }
@@ -1,75 +0,0 @@
1
- {{#if typescript}}
2
- import { AuthConfigs } from "arkos/auth";
3
- {{/if}}
4
- import { authService } from "arkos/services";
5
-
6
- export const authPermissionAccessControl = {
7
- Create: {
8
- roles: [],
9
- name: "Create Auth Permission",
10
- description: "Permission to create new auth permission records",
11
- },
12
- Update: {
13
- roles: [],
14
- name: "Update Auth Permission",
15
- description: "Permission to update existing auth permission records",
16
- },
17
- Delete: {
18
- roles: [],
19
- name: "Delete Auth Permission",
20
- description: "Permission to delete auth permission records",
21
- },
22
- View: {
23
- roles: [],
24
- name: "View Auth Permission",
25
- description: "Permission to view auth permission records",
26
- },
27
- }{{#if typescript}} as const satisfies AuthConfigs["accessControl"]{{/if}};
28
-
29
- {{#if advanced}}
30
- {{#if typescript}}
31
- type AuthPermissionPermissionName = `can${keyof typeof authPermissionAccessControl & string}`;
32
-
33
- {{/if}}
34
- export const authPermissionPermissions = Object.keys(authPermissionAccessControl).reduce(
35
- (acc, key) => {
36
- acc[`can${key}`{{#if typescript}} as AuthPermissionPermissionName{{/if}}] = authService.permission(
37
- key,
38
- "auth-permission",
39
- authPermissionAccessControl
40
- );
41
- return acc;
42
- },
43
- {}{{#if typescript}} as Record<AuthPermissionPermissionName, ReturnType<typeof authService.permission>>{{/if}}
44
- ){{#if typescript}} as {
45
- [K in keyof typeof authPermissionAccessControl as `can${K & string}`]: ReturnType<
46
- typeof authService.permission
47
- >;
48
- }{{/if}};
49
- {{else}}
50
- export const authPermissionPermissions = {
51
- canCreate: authService.permission("Create", "auth-permission"),
52
- canUpdate: authService.permission("Update", "auth-permission"),
53
- canDelete: authService.permission("Delete", "auth-permission"),
54
- canView: authService.permission("View", "auth-permission"),
55
- };
56
- {{/if}}
57
-
58
- export const authPermissionAuthenticationControl = {
59
- Create: true,
60
- Update: true,
61
- Delete: true,
62
- View: true,
63
- };
64
-
65
- {{#if typescript}}
66
- const authPermissionAuthConfigs: AuthConfigs = {
67
- {{else}}
68
- /** @type {import('arkos/auth').AuthConfigs} */
69
- const authPermissionAuthConfigs = {
70
- {{/if}}
71
- authenticationControl: authPermissionAuthenticationControl,
72
- accessControl: authPermissionAccessControl,
73
- };
74
-
75
- export default authPermissionAuthConfigs;
@@ -1,75 +0,0 @@
1
- {{#if typescript}}
2
- import { AuthConfigs } from "arkos/auth";
3
- {{/if}}
4
- import { authService } from "arkos/services";
5
-
6
- export const authRoleAccessControl = {
7
- Create: {
8
- roles: [],
9
- name: "Create Role Permission",
10
- description: "Permission to create new auth permission records",
11
- },
12
- Update: {
13
- roles: [],
14
- name: "Update Role Permission",
15
- description: "Permission to update existing auth permission records",
16
- },
17
- Delete: {
18
- roles: [],
19
- name: "Delete Role Permission",
20
- description: "Permission to delete auth permission records",
21
- },
22
- View: {
23
- roles: [],
24
- name: "View Role Permission",
25
- description: "Permission to view auth permission records",
26
- },
27
- }{{#if typescript}} as const satisfies AuthConfigs["accessControl"]{{/if}};
28
-
29
- {{#if advanced}}
30
- {{#if typescript}}
31
- type AuthRolePermissionName = `can${keyof typeof authRoleAccessControl & string}`;
32
-
33
- {{/if}}
34
- export const authRolePermissions = Object.keys(authRoleAccessControl).reduce(
35
- (acc, key) => {
36
- acc[`can${key}`{{#if typescript}} as AuthRolePermissionName{{/if}}] = authService.permission(
37
- key,
38
- "auth-role",
39
- authRoleAccessControl
40
- );
41
- return acc;
42
- },
43
- {}{{#if typescript}} as Record<AuthRolePermissionName, ReturnType<typeof authService.permission>>{{/if}}
44
- ){{#if typescript}} as {
45
- [K in keyof typeof authRoleAccessControl as `can${K & string}`]: ReturnType<
46
- typeof authService.permission
47
- >;
48
- }{{/if}};
49
- {{else}}
50
- export const authRolePermissions = {
51
- canCreate: authService.permission("Create", "auth-role"),
52
- canUpdate: authService.permission("Update", "auth-role"),
53
- canDelete: authService.permission("Delete", "auth-role"),
54
- canView: authService.permission("View", "auth-role"),
55
- };
56
- {{/if}}
57
-
58
- export const authRoleAuthenticationControl = {
59
- Create: true,
60
- Update: true,
61
- Delete: true,
62
- View: true,
63
- };
64
-
65
- {{#if typescript}}
66
- const authRoleAuthConfigs: AuthConfigs = {
67
- {{else}}
68
- /** @type {import('arkos/auth').AuthConfigs} */
69
- const authRoleAuthConfigs = {
70
- {{/if}}
71
- authenticationControl: authRoleAuthenticationControl,
72
- accessControl: authRoleAccessControl,
73
- };
74
-
75
- export default authRoleAuthConfigs;
@@ -1,83 +0,0 @@
1
- {{#if typescript}}
2
- import { AuthConfigs } from "arkos/auth";
3
- {{/if}}
4
- import { authService } from "arkos/services";
5
-
6
- export const fileUploadAccessControl = {
7
- Create: {
8
- {{#if (eq authentication.type "static")}}
9
- roles: [],
10
- {{/if}}
11
- name: "Upload File",
12
- description: "Permission to upload file"
13
- },
14
- Update: {
15
- {{#if (eq authentication.type "static")}}
16
- roles: [],
17
- {{/if}}
18
- name: "Update File",
19
- description: "Permission to update file"
20
- },
21
- Delete: {
22
- {{#if (eq authentication.type "static")}}
23
- roles: [],
24
- {{/if}}
25
- name: "Delete File",
26
- description: "Permission to delete file"
27
- },
28
- View: {
29
- {{#if (eq authentication.type "static")}}
30
- roles: [],
31
- {{/if}}
32
- name: "View File",
33
- description: "Permission to view file"
34
- },
35
- }{{#if typescript}} as const satisfies AuthConfigs["accessControl"]{{/if}};
36
-
37
- {{#if advanced}}
38
- {{#if typescript}}
39
- type FileUploadPermissionName = `can${keyof typeof fileUploadAccessControl & string}`;
40
-
41
- {{/if}}
42
- export const fileUploadPermissions = Object.keys(fileUploadAccessControl).reduce(
43
- (acc, key) => {
44
- acc[`can${key}`{{#if typescript}} as FileUploadPermissionName{{/if}}] = authService.permission(
45
- key,
46
- "file-upload",
47
- fileUploadAccessControl
48
- );
49
- return acc;
50
- },
51
- {}{{#if typescript}} as Record<FileUploadPermissionName, ReturnType<typeof authService.permission>>{{/if}}
52
- ){{#if typescript}} as {
53
- [K in keyof typeof fileUploadAccessControl as `can${K & string}`]: ReturnType<
54
- typeof authService.permission
55
- >;
56
- }{{/if}};
57
- {{else}}
58
- export const fileUploadPermissions = {
59
- canCreate: authService.permission("Create", "file-upload"),
60
- canUpdate: authService.permission("Update", "file-upload"),
61
- canDelete: authService.permission("Delete", "file-upload"),
62
- canView: authService.permission("View", "file-upload"),
63
- };
64
- {{/if}}
65
-
66
- export const fileUploadAuthenticationControl = {
67
- Create: true,
68
- Update: true,
69
- Delete: true,
70
- View: true,
71
- };
72
-
73
- {{#if typescript}}
74
- const fileUploadAuthConfigs: AuthConfigs = {
75
- {{else}}
76
- /** @type {import('arkos/auth').AuthConfigs} */
77
- const fileUploadAuthConfigs = {
78
- {{/if}}
79
- authenticationControl: fileUploadAuthenticationControl,
80
- accessControl: fileUploadAccessControl,
81
- };
82
-
83
- export default fileUploadAuthConfigs;
@@ -1,75 +0,0 @@
1
- {{#if typescript}}
2
- import { AuthConfigs } from "arkos/auth";
3
- {{/if}}
4
- import { authService } from "arkos/services";
5
-
6
- export const userAccessControl = {
7
- Create: {
8
- roles: [],
9
- name: "Create User",
10
- description: "Permission to create new user records",
11
- },
12
- Update: {
13
- roles: [],
14
- name: "Update User",
15
- description: "Permission to update existing user records",
16
- },
17
- Delete: {
18
- roles: [],
19
- name: "Delete User",
20
- description: "Permission to delete user records",
21
- },
22
- View: {
23
- roles: [],
24
- name: "View User",
25
- description: "Permission to view user records",
26
- },
27
- }{{#if typescript}} as const satisfies AuthConfigs["accessControl"]{{/if}};
28
-
29
- {{#if advanced}}
30
- {{#if typescript}}
31
- type UserPermissionName = `can${keyof typeof userAccessControl & string}`;
32
-
33
- {{/if}}
34
- export const userPermissions = Object.keys(userAccessControl).reduce(
35
- (acc, key) => {
36
- acc[`can${key}`{{#if typescript}} as UserPermissionName{{/if}}] = authService.permission(
37
- key,
38
- "user",
39
- userAccessControl
40
- );
41
- return acc;
42
- },
43
- {}{{#if typescript}} as Record<UserPermissionName, ReturnType<typeof authService.permission>>{{/if}}
44
- ){{#if typescript}} as {
45
- [K in keyof typeof userAccessControl as `can${K & string}`]: ReturnType<
46
- typeof authService.permission
47
- >;
48
- }{{/if}};
49
- {{else}}
50
- export const userPermissions = {
51
- canCreate: authService.permission("Create", "user"),
52
- canUpdate: authService.permission("Update", "user"),
53
- canDelete: authService.permission("Delete", "user"),
54
- canView: authService.permission("View", "user"),
55
- };
56
- {{/if}}
57
-
58
- export const userAuthenticationControl = {
59
- Create: true,
60
- Update: true,
61
- Delete: true,
62
- View: true,
63
- };
64
-
65
- {{#if typescript}}
66
- const userAuthConfigs: AuthConfigs = {
67
- {{else}}
68
- /** @type {import('arkos/auth').AuthConfigs} */
69
- const userAuthConfigs = {
70
- {{/if}}
71
- authenticationControl: userAuthenticationControl,
72
- accessControl: userAccessControl,
73
- };
74
-
75
- export default userAuthConfigs;