arkos 1.3.4-canary.9 → 1.3.5-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.
Files changed (70) hide show
  1. package/README.md +16 -6
  2. package/dist/cjs/exports/controllers/index.js +36 -5
  3. package/dist/cjs/exports/controllers/index.js.map +1 -1
  4. package/dist/cjs/modules/auth/auth.controller.js +22 -15
  5. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  6. package/dist/cjs/modules/base/base.controller.js +3 -0
  7. package/dist/cjs/modules/base/base.controller.js.map +1 -1
  8. package/dist/cjs/modules/base/base.middlewares.js +70 -12
  9. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  10. package/dist/cjs/modules/base/base.service.js +1 -2
  11. package/dist/cjs/modules/base/base.service.js.map +1 -1
  12. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +3 -6
  13. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  14. package/dist/cjs/modules/email/email.service.js +24 -27
  15. package/dist/cjs/modules/email/email.service.js.map +1 -1
  16. package/dist/cjs/modules/file-upload/file-upload.controller.js +6 -0
  17. package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
  18. package/dist/cjs/types/index.js.map +1 -1
  19. package/dist/cjs/utils/cli/generate.js +1 -2
  20. package/dist/cjs/utils/cli/generate.js.map +1 -1
  21. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  22. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js +1 -1
  23. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
  24. package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js +30 -7
  25. package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -1
  26. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +17 -17
  27. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  28. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js +4 -6
  29. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
  30. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +2 -4
  31. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  32. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js +33 -11
  33. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js.map +1 -1
  34. package/dist/esm/exports/controllers/index.js +2 -2
  35. package/dist/esm/exports/controllers/index.js.map +1 -1
  36. package/dist/esm/modules/auth/auth.controller.js +22 -15
  37. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  38. package/dist/esm/modules/base/base.controller.js +3 -0
  39. package/dist/esm/modules/base/base.controller.js.map +1 -1
  40. package/dist/esm/modules/base/base.middlewares.js +70 -11
  41. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  42. package/dist/esm/modules/base/base.service.js +1 -2
  43. package/dist/esm/modules/base/base.service.js.map +1 -1
  44. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +3 -6
  45. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  46. package/dist/esm/modules/email/email.service.js +24 -27
  47. package/dist/esm/modules/email/email.service.js.map +1 -1
  48. package/dist/esm/modules/file-upload/file-upload.controller.js +5 -1
  49. package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
  50. package/dist/esm/types/index.js.map +1 -1
  51. package/dist/esm/utils/cli/generate.js +1 -2
  52. package/dist/esm/utils/cli/generate.js.map +1 -1
  53. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  54. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js +1 -1
  55. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
  56. package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js +30 -7
  57. package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -1
  58. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +17 -17
  59. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  60. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js +4 -6
  61. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
  62. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +2 -4
  63. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  64. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js +33 -11
  65. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js.map +1 -1
  66. package/dist/types/exports/controllers/index.d.ts +2 -2
  67. package/dist/types/modules/base/base.middlewares.d.ts +0 -1
  68. package/dist/types/modules/file-upload/file-upload.controller.d.ts +1 -1
  69. package/dist/types/types/index.d.ts +13 -9
  70. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AA8LA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for Prisma query operations with flexible options\n * @template T - The Prisma model delegate type\n */\nexport type PrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n};\n\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n accessToken?: string;\n /**\n * This represents `req.query` after being handled and transformed.\n */\n transformedQuery?: Record<string, any>;\n /**\n * Return result of APIFeatures.filters\n */\n filters?: Record<string, any>;\n modelName?: string;\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\nexport interface ArkosErrorRequestHandler extends ErrorRequestHandler {}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AA6LA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for finding multiple auth actions\n */\n findManyAuthAction?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for finding a single auth action\n */\n findOneAuthAction?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n};\n\n/**\n * Base Prisma query options for standard CRUD operations\n * @template T - The Prisma model delegate type\n */\ntype BasePrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for Prisma query operations with flexible options\n * Conditionally provides auth-specific options when ModelName is \"auth\"\n * @template T - The Prisma model delegate type\n * @template ModelName - The model name (defaults to string for standard models)\n */\nexport type PrismaQueryOptions<\n T extends Record<string, any>,\n ModelName extends string = string,\n> = ModelName extends \"auth\"\n ? AuthPrismaQueryOptions<T>\n : BasePrismaQueryOptions<T>;\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n accessToken?: string;\n /**\n * This represents `req.query` after being handled and transformed.\n */\n transformedQuery?: Record<string, any>;\n /**\n * Return result of APIFeatures.filters\n */\n filters?: Record<string, any>;\n modelName?: string;\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\nexport interface ArkosErrorRequestHandler extends ErrorRequestHandler {}\n"]}
@@ -46,8 +46,7 @@ const generateFile = async (options, config) => {
46
46
  }
47
47
  catch (err) {
48
48
  console.info("");
49
- sheu_1.default.error(`${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? "under " + (0, fs_helpers_1.fullCleanCwd)(filePath) + "." : "."}`);
50
- console.info(`${sheu_1.default.bold("Reason: ")}${err?.message || "unknown"}`);
49
+ sheu_1.default.error(`Failed because of ${err?.message?.toLowerCase() || "unknown reason"}`);
51
50
  process.exit(1);
52
51
  }
53
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,qEAA+D;AAC/D,qDAA4D;AAC5D,wEAIwC;AACxC,sDAA2E;AAC3E,mDAA2B;AAC3B,0DAAqD;AAcrD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,cAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,MAAM,CAAC,gBAAgB;QAAE,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAEhE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,IAAA,gCAAU,EAAC,SAAS,CAAC;QAC7B,KAAK,EAAE,IAAA,+BAAS,EAAC,SAAS,CAAC;QAC3B,KAAK,EAAE,IAAA,+BAAS,EAAC,SAAS,CAAC;KAC5B,CAAC;IAEF,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CACxB,UAAU,EACV,GAAG,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,EAAE,CAC7C,CAAC;IACF,MAAM,yBAAyB,GAC7B,MAAM,CAAC,YAAY,CAA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,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,cAAc;YAC5B,UAAU,EAAE,MAAM;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QACxC,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,OAAO;YACrB,UAAU,EAAE,OAAO;SACpB,CAAC,CAAC;IACL,CAAC;IAED,SAAS,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;IAED,SAAS,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;IAED,YAAY,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC/C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,eAAe;YAC7B,UAAU,EAAE,OAAO;YACnB,gBAAgB,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC9B,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;oBAChC,cAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n const modulePath = path.join(process.cwd(), customPath, names.kebab);\n const filePath = path.join(\n modulePath,\n `${names.kebab}.${config.fileSuffix}.${ext}`\n );\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"middlewares\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,qEAA+D;AAC/D,qDAA4D;AAC5D,wEAIwC;AACxC,sDAA2E;AAC3E,mDAA2B;AAC3B,0DAAqD;AAcrD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,cAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC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CAAC,SAAS,EAAE,EAAE;gBAC9B,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;oBAChC,cAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n const modulePath = path.join(process.cwd(), customPath, names.kebab);\n const filePath = path.join(\n modulePath,\n `${names.kebab}.${config.fileSuffix}.${ext}`\n );\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `Failed because of ${err?.message?.toLowerCase() || \"unknown reason\"}`\n );\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"middlewares\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.3.4-canary.9";
22
+ return "1.3.5-beta";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -8,7 +8,7 @@ function generateAuthConfigsTemplate(options) {
8
8
  const ext = (0, fs_helpers_1.getUserFileExtension)();
9
9
  const isTypeScript = ext === "ts";
10
10
  if (!modelName)
11
- throw new Error("Model name is required for auth config template");
11
+ throw new Error("Module name is required for auth config template");
12
12
  const imports = isTypeScript
13
13
  ? `import { AuthConfigs } from 'arkos/auth';\n`
14
14
  : "";
@@ -1 +1 @@
1
- {"version":3,"file":"auth-configs-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/auth-configs-template.ts"],"names":[],"mappings":";;AAIA,kEA2DC;AA/DD,+DAAsE;AACtE,mEAA8D;AAG9D,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAGrE,MAAM,OAAO,GAAG,YAAY;QAC1B,CAAC,CAAC,6CAA6C;QAC/C,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,GAAG,OAAO;;;eAGJ,SAAS,CAAC,KAAK;iDACmB,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;6CACnB,SAAS,CAAC,KAAK;;;QAGpD,SAAS,CAAC,KAAK,cAAc,cAAc;;;;;;;;;;yBAU1B,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;kDACtB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAI7D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;uDACjB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAIlE,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;8CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;uBAI3D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;4CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;;iBAK/D,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { capitalize } from \"../../../../helpers/text.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateAuthConfigsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for auth config template\");\n\n // Generate imports for TypeScript\n const imports = isTypeScript\n ? `import { AuthConfigs } from 'arkos/auth';\\n`\n : \"\";\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript ? `: AuthConfigs` : \"\";\n\n return `${imports}\nimport { authService } from \"arkos/services\";\n\nexport const ${modelName.camel}Permissions = {\n canCreate: authService.permission(\"Create\", \"${modelName.kebab}\"),\n canUpdate: authService.permission(\"Update\", \"${modelName.kebab}\"),\n canDelete: authService.permission(\"Delete\", \"${modelName.kebab}\"),\n canView: authService.permission(\"View\", \"${modelName.kebab}\"),\n}\n\nconst ${modelName.camel}AuthConfigs${typeAnnotation} = {\n authenticationControl: {\n Create: true,\n Update: true,\n Delete: true,\n View: true,\n },\n accessControl: {\n // Create: {\n // roles: [],\n // name: \"Create ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to create new ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Update: {\n // roles: [],\n // name: \"Update ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to update existing ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Delete: {\n // roles: [],\n // name: \"Delete ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to delete ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // View: {\n // roles: [],\n // name: \"View ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to view ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n },\n};\n\nexport default ${modelName.camel}AuthConfigs;\n`;\n}\n"]}
1
+ {"version":3,"file":"auth-configs-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/auth-configs-template.ts"],"names":[],"mappings":";;AAIA,kEAyDC;AA7DD,+DAAsE;AACtE,mEAA8D;AAG9D,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAEtE,MAAM,OAAO,GAAG,YAAY;QAC1B,CAAC,CAAC,6CAA6C;QAC/C,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,GAAG,OAAO;;;eAGJ,SAAS,CAAC,KAAK;iDACmB,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;6CACnB,SAAS,CAAC,KAAK;;;QAGpD,SAAS,CAAC,KAAK,cAAc,cAAc;;;;;;;;;;yBAU1B,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;kDACtB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAI7D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;uDACjB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAIlE,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;8CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;uBAI3D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;4CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;;iBAK/D,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { capitalize } from \"../../../../helpers/text.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateAuthConfigsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for auth config template\");\n\n const imports = isTypeScript\n ? `import { AuthConfigs } from 'arkos/auth';\\n`\n : \"\";\n\n const typeAnnotation = isTypeScript ? `: AuthConfigs` : \"\";\n\n return `${imports}\nimport { authService } from \"arkos/services\";\n\nexport const ${modelName.camel}Permissions = {\n canCreate: authService.permission(\"Create\", \"${modelName.kebab}\"),\n canUpdate: authService.permission(\"Update\", \"${modelName.kebab}\"),\n canDelete: authService.permission(\"Delete\", \"${modelName.kebab}\"),\n canView: authService.permission(\"View\", \"${modelName.kebab}\"),\n}\n\nconst ${modelName.camel}AuthConfigs${typeAnnotation} = {\n authenticationControl: {\n Create: true,\n Update: true,\n Delete: true,\n View: true,\n },\n accessControl: {\n // Create: {\n // roles: [],\n // name: \"Create ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to create new ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Update: {\n // roles: [],\n // name: \"Update ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to update existing ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Delete: {\n // roles: [],\n // name: \"Delete ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to delete ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // View: {\n // roles: [],\n // name: \"View ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to view ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n },\n};\n\nexport default ${modelName.camel}AuthConfigs;\n`;\n}\n"]}
@@ -4,14 +4,37 @@ exports.generateControllerTemplate = generateControllerTemplate;
4
4
  function generateControllerTemplate(options) {
5
5
  const { modelName, imports } = options;
6
6
  if (!modelName)
7
- throw new Error("Model name is required for controller template");
8
- return `import { BaseController } from "${imports?.baseController || "arkos/controllers"}";
7
+ throw new Error("Module name is required for controller template");
8
+ const camelName = modelName.camel.toLowerCase();
9
+ let controllerType;
10
+ let controllerName;
11
+ let controllerImport;
12
+ if (camelName === "fileupload") {
13
+ controllerType = "fileUpload";
14
+ controllerName = "FileUploadController";
15
+ controllerImport = imports?.fileUploadController || "arkos/controllers";
16
+ }
17
+ else if (camelName === "auth") {
18
+ controllerType = "auth";
19
+ controllerName = "AuthController";
20
+ controllerImport = imports?.authController || "arkos/controllers";
21
+ }
22
+ else if (camelName === "email") {
23
+ controllerType = "email";
24
+ controllerName = "EmailController";
25
+ controllerImport = imports?.emailController || "arkos/controllers";
26
+ }
27
+ else {
28
+ controllerType = "base";
29
+ controllerName = "BaseController";
30
+ controllerImport = imports?.baseController || "arkos/controllers";
31
+ }
32
+ const controllerClassImport = `import { ${controllerName} } from "${controllerImport}";`;
33
+ return `${controllerClassImport}
9
34
 
10
- class ${modelName.pascal}Controller extends BaseController {}
11
-
12
- const ${modelName.camel}Controller = new ${modelName.pascal}Controller("${modelName.kebab}");
13
-
35
+ class ${modelName.pascal}Controller extends ${controllerName} {}
36
+ const ${modelName.camel}Controller = new ${modelName.pascal}Controller(${controllerType === "base" ? `"${modelName.kebab}"` : ""});
14
37
  export default ${modelName.camel}Controller;
15
- `;
38
+ `;
16
39
  }
17
40
  //# sourceMappingURL=controller-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/controller-template.ts"],"names":[],"mappings":";;AAEA,gEAgBC;AAhBD,SAAgB,0BAA0B,CAAC,OAAwB;IACjE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,OAAO,mCACL,OAAO,EAAE,cAAc,IAAI,mBAC7B;;QAEM,SAAS,CAAC,MAAM;;QAEhB,SAAS,CAAC,KAAK,oBAAoB,SAAS,CAAC,MAAM,eAAe,SAAS,CAAC,KAAK;;iBAExE,SAAS,CAAC,KAAK;GAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { TemplateOptions } from \"../../template-generators\";\n\nexport function generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \nclass ${modelName.pascal}Controller extends BaseController {}\n\nconst ${modelName.camel}Controller = new ${modelName.pascal}Controller(\"${modelName.kebab}\");\n\nexport default ${modelName.camel}Controller;\n `;\n}\n"]}
1
+ {"version":3,"file":"controller-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/controller-template.ts"],"names":[],"mappings":";;AAEA,gEAsCC;AAtCD,SAAgB,0BAA0B,CAAC,OAAwB;IACjE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAGrE,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAChD,IAAI,cAAwD,CAAC;IAC7D,IAAI,cAAsB,CAAC;IAC3B,IAAI,gBAAwB,CAAC;IAE7B,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,cAAc,GAAG,YAAY,CAAC;QAC9B,cAAc,GAAG,sBAAsB,CAAC;QACxC,gBAAgB,GAAG,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,CAAC;IAC1E,CAAC;SAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QAChC,cAAc,GAAG,MAAM,CAAC;QACxB,cAAc,GAAG,gBAAgB,CAAC;QAClC,gBAAgB,GAAG,OAAO,EAAE,cAAc,IAAI,mBAAmB,CAAC;IACpE,CAAC;SAAM,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QACjC,cAAc,GAAG,OAAO,CAAC;QACzB,cAAc,GAAG,iBAAiB,CAAC;QACnC,gBAAgB,GAAG,OAAO,EAAE,eAAe,IAAI,mBAAmB,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,cAAc,GAAG,MAAM,CAAC;QACxB,cAAc,GAAG,gBAAgB,CAAC;QAClC,gBAAgB,GAAG,OAAO,EAAE,cAAc,IAAI,mBAAmB,CAAC;IACpE,CAAC;IAED,MAAM,qBAAqB,GAAG,YAAY,cAAc,YAAY,gBAAgB,IAAI,CAAC;IAEzF,OAAO,GAAG,qBAAqB;;QAEzB,SAAS,CAAC,MAAM,sBAAsB,cAAc;QACpD,SAAS,CAAC,KAAK,oBAAoB,SAAS,CAAC,MAAM,cAAc,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;iBAC/G,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { TemplateOptions } from \"../../template-generators\";\n\nexport function generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for controller template\");\n\n // Determine which controller to extend based on model name\n const camelName = modelName.camel.toLowerCase();\n let controllerType: \"fileUpload\" | \"auth\" | \"email\" | \"base\";\n let controllerName: string;\n let controllerImport: string;\n\n if (camelName === \"fileupload\") {\n controllerType = \"fileUpload\";\n controllerName = \"FileUploadController\";\n controllerImport = imports?.fileUploadController || \"arkos/controllers\";\n } else if (camelName === \"auth\") {\n controllerType = \"auth\";\n controllerName = \"AuthController\";\n controllerImport = imports?.authController || \"arkos/controllers\";\n } else if (camelName === \"email\") {\n controllerType = \"email\";\n controllerName = \"EmailController\";\n controllerImport = imports?.emailController || \"arkos/controllers\";\n } else {\n controllerType = \"base\";\n controllerName = \"BaseController\";\n controllerImport = imports?.baseController || \"arkos/controllers\";\n }\n\n const controllerClassImport = `import { ${controllerName} } from \"${controllerImport}\";`;\n\n return `${controllerClassImport}\n \nclass ${modelName.pascal}Controller extends ${controllerName} {}\nconst ${modelName.camel}Controller = new ${modelName.pascal}Controller(${controllerType === \"base\" ? `\"${modelName.kebab}\"` : \"\"});\nexport default ${modelName.camel}Controller;\n`;\n}\n"]}
@@ -37,7 +37,7 @@ function generateMiddlewaresTemplate(options) {
37
37
 
38
38
  // export const onGetMeError =
39
39
  // [async (${errorFunctionParams}) => {
40
- // next();
40
+ // next(err);
41
41
  // }]
42
42
 
43
43
  // export const beforeLogin =
@@ -52,7 +52,7 @@ function generateMiddlewaresTemplate(options) {
52
52
 
53
53
  // export const onLoginError =
54
54
  // [async (${errorFunctionParams}) => {
55
- // next();
55
+ // next(err);
56
56
  // }]
57
57
 
58
58
  // export const beforeLogout =
@@ -67,7 +67,7 @@ function generateMiddlewaresTemplate(options) {
67
67
 
68
68
  // export const onLogoutError =
69
69
  // [async (${errorFunctionParams}) => {
70
- // next();
70
+ // next(err);
71
71
  // }]
72
72
 
73
73
  // export const beforeSignup =
@@ -81,7 +81,7 @@ function generateMiddlewaresTemplate(options) {
81
81
 
82
82
  // export const onSignupError =
83
83
  // [async (${errorFunctionParams}) => {
84
- // next();
84
+ // next(err);
85
85
  // }]
86
86
 
87
87
  // export const beforeUpdatePassword =
@@ -96,7 +96,7 @@ function generateMiddlewaresTemplate(options) {
96
96
 
97
97
  // export const onUpdatePasswordError =
98
98
  // [async (${errorFunctionParams}) => {
99
- // next();
99
+ // next(err);
100
100
  // }]
101
101
  `;
102
102
  }
@@ -111,7 +111,7 @@ function generateMiddlewaresTemplate(options) {
111
111
 
112
112
  // export const onFindFileError =
113
113
  // [async (${errorFunctionParams}) => {
114
- // next();
114
+ // next(err);
115
115
  // }]
116
116
 
117
117
  // export const beforeUploadFile =
@@ -126,7 +126,7 @@ function generateMiddlewaresTemplate(options) {
126
126
 
127
127
  // export const onUploadFileError =
128
128
  // [async (${errorFunctionParams}) => {
129
- // next();
129
+ // next(err);
130
130
  // }]
131
131
 
132
132
  // export const beforeUpdateFile =
@@ -141,7 +141,7 @@ function generateMiddlewaresTemplate(options) {
141
141
 
142
142
  // export const onUpdateFileError =
143
143
  // [async (${errorFunctionParams}) => {
144
- // next();
144
+ // next(err);
145
145
  // }]
146
146
 
147
147
  // export const beforeDeleteFile =
@@ -156,7 +156,7 @@ function generateMiddlewaresTemplate(options) {
156
156
 
157
157
  // export const onDeleteFileError =
158
158
  // [async (${errorFunctionParams}) => {
159
- // next();
159
+ // next(err);
160
160
  // }]
161
161
  `;
162
162
  }
@@ -174,7 +174,7 @@ function generateMiddlewaresTemplate(options) {
174
174
 
175
175
  // export const onCreateOneError =
176
176
  // [async (${errorFunctionParams}) => {
177
- // next();
177
+ // next(err);
178
178
  // }]
179
179
 
180
180
  // export const beforeFindOne =
@@ -189,7 +189,7 @@ function generateMiddlewaresTemplate(options) {
189
189
 
190
190
  // export const onFindOneError =
191
191
  // [async (${errorFunctionParams}) => {
192
- // next();
192
+ // next(err);
193
193
  // }]
194
194
 
195
195
  // export const beforeFindMany =
@@ -204,7 +204,7 @@ function generateMiddlewaresTemplate(options) {
204
204
 
205
205
  // export const onFindManyError =
206
206
  // [async (${errorFunctionParams}) => {
207
- // next();
207
+ // next(err);
208
208
  // }]
209
209
 
210
210
  // export const beforeUpdateOne =
@@ -219,7 +219,7 @@ function generateMiddlewaresTemplate(options) {
219
219
 
220
220
  // export const onUpdateOneError =
221
221
  // [async (${errorFunctionParams}) => {
222
- // next();
222
+ // next(err);
223
223
  // }]
224
224
 
225
225
  // export const beforeDeleteOne =
@@ -234,7 +234,7 @@ function generateMiddlewaresTemplate(options) {
234
234
 
235
235
  // export const onDeleteOneError =
236
236
  // [async (${errorFunctionParams}) => {
237
- // next();
237
+ // next(err);
238
238
  // }]
239
239
 
240
240
  // export const beforeCreateMany =
@@ -249,7 +249,7 @@ function generateMiddlewaresTemplate(options) {
249
249
 
250
250
  // export const onCreateManyError =
251
251
  // [async (${errorFunctionParams}) => {
252
- // next();
252
+ // next(err);
253
253
  // }]
254
254
 
255
255
  // export const beforeUpdateMany =
@@ -264,7 +264,7 @@ function generateMiddlewaresTemplate(options) {
264
264
 
265
265
  // export const onUpdateManyError =
266
266
  // [async (${errorFunctionParams}) => {
267
- // next();
267
+ // next(err);
268
268
  // }]
269
269
 
270
270
  // export const beforeDeleteMany =
@@ -279,7 +279,7 @@ function generateMiddlewaresTemplate(options) {
279
279
 
280
280
  // export const onDeleteManyError =
281
281
  // [async (${errorFunctionParams}) => {
282
- // next();
282
+ // next(err);
283
283
  // }]
284
284
  `;
285
285
  }
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/middlewares-template.ts"],"names":[],"mappings":";;AAGA,kEAmSC;AAtSD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;IAExE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7D,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC,yEAAyE;QAC3E,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,QAAQ,WAAW,UAAU,YAAY,WAAW,QAAQ,EAAE;QAChE,CAA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AGjC,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";`\n : ``;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n const errorFunctionParams = isTypeScript\n ? `err: any, req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `err, req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onGetMeError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLoginError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLogoutError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeSignup = \n// [async (${functionParams}) => {\n// }]\n\n// export const afterSignup = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onSignupError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdatePasswordError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindF]ile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUploadFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n }\n\n // Regular model interceptors\n return `${baseImports}\n\n// export const beforeCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n}\n"]}
1
+ {"version":3,"file":"middlewares-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/middlewares-template.ts"],"names":[],"mappings":";;AAGA,kEAmSC;AAtSD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG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AKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;CAGjC,CAAC;IACA,CAAC;IAGD,OAAO,GAAG,WAAW;;;eAGR,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;CAGjC,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";`\n : ``;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n const errorFunctionParams = isTypeScript\n ? `err: any, req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `err, req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onGetMeError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLoginError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLogoutError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeSignup = \n// [async (${functionParams}) => {\n// }]\n\n// export const afterSignup = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onSignupError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdatePasswordError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindF]ile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindFileError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUploadFileError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateFileError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteFileError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n`;\n }\n\n // Regular model interceptors\n return `${baseImports}\n\n// export const beforeCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateOneError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindOneError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindManyError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateOneError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteOneError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateManyError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateManyError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n\n// export const beforeDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteManyError =\n// [async (${errorFunctionParams}) => {\n// next(err);\n// }]\n`;\n}\n"]}
@@ -9,16 +9,14 @@ function generateQueryOptionsTemplate(options) {
9
9
  const isTypeScript = ext === "ts";
10
10
  if (!modelName)
11
11
  throw new Error("Module name is required for query config template");
12
- const imports = isAuth
13
- ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
14
- : `import { PrismaQueryOptions } from 'arkos/prisma'`;
12
+ const imports = `import { PrismaQueryOptions } from 'arkos/prisma'`;
15
13
  const typeAnnotation = isTypeScript
16
14
  ? isAuth
17
- ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`
18
- : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
15
+ ? `: PrismaQueryOptions<Prisma.UserDelegate, "auth">`
16
+ : `: PrismaQueryOptions<Prisma.${modelName.pascal}Delegate>`
19
17
  : "";
20
18
  const prismaImport = isTypeScript
21
- ? `import prisma from "../../utils/prisma.js";\n`
19
+ ? `import { Prisma } from "@prisma/client";\n`
22
20
  : "";
23
21
  if (isAuth) {
24
22
  return `${prismaImport}${imports};
@@ -1 +1 @@
1
- {"version":3,"file":"query-options-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/query-options-template.ts"],"names":[],"mappings":";;AAGA,oEA8DC;AAjED,+DAAsE;AAGtE,SAAgB,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAExD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;;;;;;;iBAmBnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for query config template\");\n\n const imports = isAuth\n ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`\n : `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : \"\";\n\n const prismaImport = isTypeScript\n ? `import prisma from \"../../utils/prisma\";\\n`\n : \"\";\n\n if (isAuth) {\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n global: {},\n find: {},\n findOne: {},\n findMany: {},\n update: {},\n updateMany: {},\n updateOne: {},\n create: {},\n createMany: {},\n createOne: {},\n save: {},\n saveMany: {},\n saveOne: {},\n delete: {},\n deleteMany: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
1
+ {"version":3,"file":"query-options-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/query-options-template.ts"],"names":[],"mappings":";;AAGA,oEA4DC;AA/DD,+DAAsE;AAGtE,SAAgB,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,mDAAmD,CAAC;IAEpE,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,mDAAmD;YACrD,CAAC,CAAC,+BAA+B,SAAS,CAAC,MAAM,WAAW;QAC9D,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;;;;;;;iBAmBnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for query config template\");\n\n const imports = `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: PrismaQueryOptions<Prisma.UserDelegate, \"auth\">`\n : `: PrismaQueryOptions<Prisma.${modelName.pascal}Delegate>`\n : \"\";\n\n const prismaImport = isTypeScript\n ? `import { Prisma } from \"@prisma/client\";\\n`\n : \"\";\n\n if (isAuth) {\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n global: {},\n find: {},\n findOne: {},\n findMany: {},\n update: {},\n updateMany: {},\n updateOne: {},\n create: {},\n createMany: {},\n createOne: {},\n save: {},\n saveMany: {},\n saveOne: {},\n delete: {},\n deleteMany: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
@@ -5,7 +5,7 @@ const fs_helpers_1 = require("../../../../helpers/fs.helpers");
5
5
  function generateRouterTemplate(options) {
6
6
  const { modelName, imports } = options;
7
7
  if (!modelName)
8
- throw new Error("Model name is required for router template");
8
+ throw new Error("Module name is required for router template");
9
9
  const ext = (0, fs_helpers_1.getUserFileExtension)();
10
10
  const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
11
11
  const routerConfigTsType = ext === "ts" ? ": RouterConfig" : "";
@@ -16,9 +16,7 @@ function generateRouterTemplate(options) {
16
16
  `./${modelName.kebab}.controller${ext === "js" ? "." + "js" : ""}`}"`
17
17
  : `import ${modelName.camel}Controller from "${imports?.controller ||
18
18
  `./${modelName.kebab}.controller${ext === "js" ? "." + "js" : ""}`}"`;
19
- const controllerHandlerLine = controllerExists
20
- ? `${modelName.camel}Controller.someHandler`
21
- : `${modelName.camel}Controller.someHandler`;
19
+ const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;
22
20
  return `import { Router } from 'express'
23
21
  import { authService } from 'arkos/services'
24
22
  import { catchAsync } from 'arkos/error-handler'
@@ -1 +1 @@
1
- {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":";;AAMA,wDAiDC;AAvDD,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,wBAAwB;QAC5C,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAE/C,OAAO;;;EAGP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;qDAGoC,SAAS,CAAC,KAAK;eACrD,qBAAqB;;;iBAGnB,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n // Check if controller file exists\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = controllerExists\n ? `${modelName.camel}Controller.someHandler`\n : `${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\nimport { catchAsync } from 'arkos/error-handler'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.get(\n '/custom-endpoint',\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n catchAsync(${controllerHandlerLine})\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
1
+ {"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":";;AAMA,wDA+CC;AArDD,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,GAAG,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEzE,OAAO;;;EAGP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;;;qDAGoC,SAAS,CAAC,KAAK;eACrD,qBAAqB;;;iBAGnB,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Module name is required for router template\");\n\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = `${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\nimport { catchAsync } from 'arkos/error-handler'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.get(\n '/custom-endpoint',\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n catchAsync(${controllerHandlerLine})\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
@@ -7,21 +7,43 @@ function generateServiceTemplate(options) {
7
7
  const ext = (0, fs_helpers_1.getUserFileExtension)();
8
8
  const isTypeScript = ext === "ts";
9
9
  if (!modelName)
10
- throw new Error("Model name is required for service template");
11
- const prismaImport = isTypeScript
12
- ? `"../../utils/prisma${ext === "ts" ? "" : "." + "js"}";\n`
10
+ throw new Error("Module name is required for service template");
11
+ const camelName = modelName.camel.toLowerCase();
12
+ let serviceType;
13
+ let serviceName;
14
+ let serviceImport;
15
+ if (camelName === "fileupload") {
16
+ serviceType = "fileUpload";
17
+ serviceName = "FileUploadService";
18
+ serviceImport = imports?.fileUploadService || "arkos/services";
19
+ }
20
+ else if (camelName === "auth") {
21
+ serviceType = "auth";
22
+ serviceName = "AuthService";
23
+ serviceImport = imports?.authService || "arkos/services";
24
+ }
25
+ else if (camelName === "email") {
26
+ serviceType = "email";
27
+ serviceName = "EmailService";
28
+ serviceImport = imports?.emailService || "arkos/services";
29
+ }
30
+ else {
31
+ serviceType = "base";
32
+ serviceName = "BaseService";
33
+ serviceImport = imports?.baseService || "arkos/services";
34
+ }
35
+ const prismaImport = isTypeScript && serviceType === "base"
36
+ ? `import { Prisma } from "@prisma/client";\n`
13
37
  : "";
14
- const baseServiceImport = isTypeScript
15
- ? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
16
- : `import { BaseService } from "${imports?.baseService || "arkos/services"}";`;
17
- const typeParameter = isTypeScript
18
- ? `<typeof prisma.${modelName.camel}>`
38
+ const serviceClassImport = `import { ${serviceName} } from "${serviceImport}";`;
39
+ const typeParameter = isTypeScript && serviceType === "base"
40
+ ? `<Prisma.${modelName.pascal}Delegate>`
19
41
  : "";
20
- return `${isTypeScript && "import prisma from "}${prismaImport}${baseServiceImport}
42
+ return `${prismaImport}${serviceClassImport}
21
43
 
22
- class ${modelName.pascal}Service extends BaseService${typeParameter} {}
44
+ class ${modelName.pascal}Service extends ${serviceName}${typeParameter} {}
23
45
 
24
- const ${modelName.camel}Service = new ${modelName.pascal}Service("${modelName.kebab}");
46
+ const ${modelName.camel}Service = new ${modelName.pascal}Service(${serviceType === "base" ? `"${modelName.kebab}"` : ""});
25
47
 
26
48
  export default ${modelName.camel}Service;
27
49
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"service-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/service-template.ts"],"names":[],"mappings":";;AAGA,0DAkCC;AArCD,+DAAsE;AAGtE,SAAgB,uBAAuB,CAAC,OAAwB;IAC9D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAGjE,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,sBAAsB,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM;QAC5D,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,iBAAiB,GAAG,YAAY;QACpC,CAAC,CAAC,gCACE,OAAO,EAAE,WAAW,IAAI,gBAC1B,IAAI;QACN,CAAC,CAAC,gCACE,OAAO,EAAE,WAAW,IAAI,gBAC1B,IAAI,CAAC;IAGT,MAAM,aAAa,GAAG,YAAY;QAChC,CAAC,CAAC,kBAAkB,SAAS,CAAC,KAAK,GAAG;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,YAAY,IAAI,qBAAqB,GAAG,YAAY,GAAG,iBAAiB;;QAE5E,SAAS,CAAC,MAAM,8BAA8B,aAAa;;QAE3D,SAAS,CAAC,KAAK,iBAAiB,SAAS,CAAC,MAAM,YAAY,SAAS,CAAC,KAAK;;iBAElE,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for service template\");\n\n // Generate imports\n const prismaImport = isTypeScript\n ? `\"../../utils/prisma${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";\\n`\n : \"\";\n\n const baseServiceImport = isTypeScript\n ? `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";`\n : `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";`;\n\n // Generate type parameter for TypeScript\n const typeParameter = isTypeScript\n ? `<typeof prisma.${modelName.camel}>`\n : \"\";\n\n return `${isTypeScript && \"import prisma from \"}${prismaImport}${baseServiceImport}\n \nclass ${modelName.pascal}Service extends BaseService${typeParameter} {}\n\nconst ${modelName.camel}Service = new ${modelName.pascal}Service(\"${modelName.kebab}\");\n\nexport default ${modelName.camel}Service;\n`;\n}\n"]}
1
+ {"version":3,"file":"service-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/service-template.ts"],"names":[],"mappings":";;AAGA,0DAmDC;AAtDD,+DAAsE;AAGtE,SAAgB,uBAAuB,CAAC,OAAwB;IAC9D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAChD,IAAI,WAAqD,CAAC;IAC1D,IAAI,WAAmB,CAAC;IACxB,IAAI,aAAqB,CAAC;IAE1B,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,WAAW,GAAG,YAAY,CAAC;QAC3B,WAAW,GAAG,mBAAmB,CAAC;QAClC,aAAa,GAAG,OAAO,EAAE,iBAAiB,IAAI,gBAAgB,CAAC;IACjE,CAAC;SAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QAChC,WAAW,GAAG,MAAM,CAAC;QACrB,WAAW,GAAG,aAAa,CAAC;QAC5B,aAAa,GAAG,OAAO,EAAE,WAAW,IAAI,gBAAgB,CAAC;IAC3D,CAAC;SAAM,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QACjC,WAAW,GAAG,OAAO,CAAC;QACtB,WAAW,GAAG,cAAc,CAAC;QAC7B,aAAa,GAAG,OAAO,EAAE,YAAY,IAAI,gBAAgB,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,MAAM,CAAC;QACrB,WAAW,GAAG,aAAa,CAAC;QAC5B,aAAa,GAAG,OAAO,EAAE,WAAW,IAAI,gBAAgB,CAAC;IAC3D,CAAC;IAED,MAAM,YAAY,GAChB,YAAY,IAAI,WAAW,KAAK,MAAM;QACpC,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,kBAAkB,GAAG,YAAY,WAAW,YAAY,aAAa,IAAI,CAAC;IAEhF,MAAM,aAAa,GACjB,YAAY,IAAI,WAAW,KAAK,MAAM;QACpC,CAAC,CAAC,WAAW,SAAS,CAAC,MAAM,WAAW;QACxC,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,GAAG,YAAY,GAAG,kBAAkB;;QAErC,SAAS,CAAC,MAAM,mBAAmB,WAAW,GAAG,aAAa;;QAE9D,SAAS,CAAC,KAAK,iBAAiB,SAAS,CAAC,MAAM,WAAW,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;;iBAEtG,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for service template\");\n\n const camelName = modelName.camel.toLowerCase();\n let serviceType: \"fileUpload\" | \"auth\" | \"email\" | \"base\";\n let serviceName: string;\n let serviceImport: string;\n\n if (camelName === \"fileupload\") {\n serviceType = \"fileUpload\";\n serviceName = \"FileUploadService\";\n serviceImport = imports?.fileUploadService || \"arkos/services\";\n } else if (camelName === \"auth\") {\n serviceType = \"auth\";\n serviceName = \"AuthService\";\n serviceImport = imports?.authService || \"arkos/services\";\n } else if (camelName === \"email\") {\n serviceType = \"email\";\n serviceName = \"EmailService\";\n serviceImport = imports?.emailService || \"arkos/services\";\n } else {\n serviceType = \"base\";\n serviceName = \"BaseService\";\n serviceImport = imports?.baseService || \"arkos/services\";\n }\n\n const prismaImport =\n isTypeScript && serviceType === \"base\"\n ? `import { Prisma } from \"@prisma/client\";\\n`\n : \"\";\n\n const serviceClassImport = `import { ${serviceName} } from \"${serviceImport}\";`;\n\n const typeParameter =\n isTypeScript && serviceType === \"base\"\n ? `<Prisma.${modelName.pascal}Delegate>`\n : \"\";\n\n return `${prismaImport}${serviceClassImport}\n \nclass ${modelName.pascal}Service extends ${serviceName}${typeParameter} {}\n\nconst ${modelName.camel}Service = new ${modelName.pascal}Service(${serviceType === \"base\" ? `\"${modelName.kebab}\"` : \"\"});\n\nexport default ${modelName.camel}Service;\n`;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import { BaseController } from "./../../modules/base/base.controller.js";
2
- import fileUploadController from "../../modules/file-upload/file-upload.controller.js";
3
- export { fileUploadController, BaseController };
2
+ import fileUploadController, { FileUploadController, } from "../../modules/file-upload/file-upload.controller.js";
3
+ export { fileUploadController, FileUploadController, BaseController };
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/exports/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,oBAAoB,MAAM,kDAAkD,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { BaseController } from \"./../../modules/base/base.controller\";\nimport fileUploadController from \"../../modules/file-upload/file-upload.controller\";\n\nexport { fileUploadController, BaseController };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/exports/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,oBAAoB,EAAE,EAC3B,oBAAoB,GACrB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { BaseController } from \"./../../modules/base/base.controller\";\nimport fileUploadController, {\n FileUploadController,\n} from \"../../modules/file-upload/file-upload.controller\";\n\nexport { fileUploadController, FileUploadController, BaseController };\n"]}