arkos 1.4.1-canary.8 → 1.5.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 (126) hide show
  1. package/dist/cjs/modules/auth/auth.controller.js +13 -0
  2. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  3. package/dist/cjs/modules/auth/auth.service.js +40 -14
  4. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  5. package/dist/cjs/modules/auth/utils/services/auth-action.service.js +1 -1
  6. package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
  7. package/dist/cjs/modules/base/base.middlewares.js +6 -4
  8. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  9. package/dist/cjs/modules/base/utils/error-prettifier.js +185 -0
  10. package/dist/cjs/modules/base/utils/error-prettifier.js.map +1 -0
  11. package/dist/cjs/modules/email/email.service.js +4 -1
  12. package/dist/cjs/modules/email/email.service.js.map +1 -1
  13. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  14. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +9 -3
  15. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  16. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +27 -9
  17. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  18. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +28 -11
  19. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
  20. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +3 -0
  21. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -1
  22. package/dist/cjs/types/auth.js.map +1 -1
  23. package/dist/cjs/utils/arkos-router/index.js +7 -1
  24. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  25. package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
  26. package/dist/cjs/utils/arkos-router/utils/helpers/index.js +51 -0
  27. package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
  28. package/dist/cjs/utils/cli/generate.js +38 -0
  29. package/dist/cjs/utils/cli/generate.js.map +1 -1
  30. package/dist/cjs/utils/cli/index.js +37 -4
  31. package/dist/cjs/utils/cli/index.js.map +1 -1
  32. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  33. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js +70 -37
  34. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
  35. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +556 -0
  36. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +1 -0
  37. package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js +327 -0
  38. package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +1 -0
  39. package/dist/cjs/utils/cli/utils/template-generators.js +14 -8
  40. package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
  41. package/dist/cjs/utils/dynamic-loader.js +2 -2
  42. package/dist/cjs/utils/dynamic-loader.js.map +1 -1
  43. package/dist/cjs/utils/helpers/routers.helpers.js +2 -3
  44. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
  45. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +5 -5
  46. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  47. package/dist/esm/modules/auth/auth.controller.js +13 -0
  48. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  49. package/dist/esm/modules/auth/auth.service.js +40 -14
  50. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  51. package/dist/esm/modules/auth/utils/services/auth-action.service.js +1 -1
  52. package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
  53. package/dist/esm/modules/base/base.middlewares.js +6 -4
  54. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  55. package/dist/esm/modules/base/utils/error-prettifier.js +181 -0
  56. package/dist/esm/modules/base/utils/error-prettifier.js.map +1 -0
  57. package/dist/esm/modules/email/email.service.js +4 -1
  58. package/dist/esm/modules/email/email.service.js.map +1 -1
  59. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  60. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +9 -3
  61. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  62. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +27 -9
  63. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  64. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +28 -11
  65. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
  66. package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +3 -0
  67. package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -1
  68. package/dist/esm/types/auth.js.map +1 -1
  69. package/dist/esm/utils/arkos-router/index.js +8 -2
  70. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  71. package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
  72. package/dist/esm/utils/arkos-router/utils/helpers/index.js +50 -0
  73. package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
  74. package/dist/esm/utils/cli/generate.js +38 -0
  75. package/dist/esm/utils/cli/generate.js.map +1 -1
  76. package/dist/esm/utils/cli/index.js +37 -4
  77. package/dist/esm/utils/cli/index.js.map +1 -1
  78. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  79. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js +70 -37
  80. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
  81. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +549 -0
  82. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +1 -0
  83. package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js +320 -0
  84. package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +1 -0
  85. package/dist/esm/utils/cli/utils/template-generators.js +14 -8
  86. package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
  87. package/dist/esm/utils/dynamic-loader.js +2 -2
  88. package/dist/esm/utils/dynamic-loader.js.map +1 -1
  89. package/dist/esm/utils/helpers/routers.helpers.js +2 -3
  90. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
  91. package/dist/esm/utils/prisma/prisma-json-schema-generator.js +5 -5
  92. package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
  93. package/dist/types/modules/auth/auth.service.d.ts +5 -0
  94. package/dist/types/modules/auth/utils/services/auth-action.service.d.ts +1 -1
  95. package/dist/types/modules/base/utils/error-prettifier.d.ts +19 -0
  96. package/dist/types/modules/email/email.service.d.ts +4 -8
  97. package/dist/types/types/auth.d.ts +3 -3
  98. package/dist/types/utils/arkos-router/index.d.ts +3 -1
  99. package/dist/types/utils/arkos-router/types/index.d.ts +2 -2
  100. package/dist/types/utils/arkos-router/utils/helpers/index.d.ts +4 -0
  101. package/dist/types/utils/cli/generate.d.ts +4 -0
  102. package/dist/types/utils/cli/utils/template-generator/templates/auth-configs-template.d.ts +3 -1
  103. package/dist/types/utils/cli/utils/template-generator/templates/class-validator-dto-generator.d.ts +18 -0
  104. package/dist/types/utils/cli/utils/template-generator/templates/zod-schema-generator.d.ts +14 -0
  105. package/dist/types/utils/helpers/routers.helpers.d.ts +1 -1
  106. package/package.json +1 -1
  107. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +0 -187
  108. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +0 -1
  109. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +0 -181
  110. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +0 -1
  111. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +0 -106
  112. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +0 -1
  113. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +0 -104
  114. package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +0 -1
  115. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +0 -181
  116. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +0 -1
  117. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +0 -175
  118. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +0 -1
  119. package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +0 -100
  120. package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +0 -1
  121. package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +0 -98
  122. package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +0 -1
  123. package/dist/types/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.d.ts +0 -2
  124. package/dist/types/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.d.ts +0 -2
  125. package/dist/types/utils/cli/utils/template-generator/templates/zod/create-schema-template.d.ts +0 -2
  126. package/dist/types/utils/cli/utils/template-generator/templates/zod/update-schema-template.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/arkos-router/index.ts"],"names":[],"mappings":";;;;;AA2CA,8BAoHC;AAED,wDA4HC;AA7RD,qCAAgD;AAGhD,sFAA4D;AAC5D,oFAA0D;AAC1D,6CAIyB;AACzB,2CAA+C;AAC/C,+DAAyD;AAEzD,4EAAiD;AACjD,wIAA4G;AAC5G,4HAAkG;AAClG,oFAA2D;AAC3D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2BAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;gBACjD,CAAC,2BAA2B,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC;gBACvD,KAAK,CAAC,EAAE,KAAK,MAAM;gBAEnB,MAAM,IAAI,KAAK,CACb,qDAAqD,KAAK,CAAC,IAAI,4CAA4C,YAAY,EAAE,CAC1H,CAAC;QACN,CAAC;QAED,OAAO,gBAAgB,CAAC,UAAU,CAAC;QAElC,KAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG;YAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,GAAG,IAAI,EAAE;YACtC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE;YACxD,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;YACnC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE;YAC9C,UAAU,EAAE,aAAa;YACzB,GAAG,CAAC,CAAC,gBAAgB,CAAC,WAAW;gBAC/B,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI;gBAC1B,WAAW,EAAE;oBACX,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAW,CAAC;yBAC/D;qBACF;iBACF;aACF,CAAC;YACJ,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Router, RouterOptions } from \"express\";\nimport { IArkosRouter, ArkosRouteConfig } from \"./types\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport RouteConfigValidator from \"./route-config-validator\";\nimport RouteConfigRegistry from \"./route-config-registry\";\nimport {\n extractArkosRoutes,\n extractPathParams,\n getMiddlewareStack,\n} from \"./utils/helpers\";\nimport { getArkosConfig } from \"../../exports\";\nimport { catchAsync } from \"../../exports/error-handler\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport classValidatorToJsonSchema from \"../../modules/swagger/utils/helpers/class-validator-to-json-schema\";\nimport openApiSchemaConverter from \"../../modules/swagger/utils/helpers/openapi-schema-converter\";\nimport uploadManager from \"./utils/helpers/upload-manager\";\nimport { getUserFileExtension } from \"../helpers/fs.helpers\";\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * path: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport default function ArkosRouter(options?: RouterOptions): IArkosRouter {\n const router = Router(options);\n\n return new Proxy(router, {\n get(target, prop, receiver) {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n const httpMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"all\",\n \"head\",\n \"trace\",\n \"options\",\n ];\n\n type ArkosAnyRequestHandler =\n | ArkosRequestHandler\n | ArkosErrorRequestHandler;\n\n if (httpMethods.includes(prop as string)) {\n return function (\n config: ArkosRouteConfig,\n ...handlers: ArkosAnyRequestHandler[]\n ) {\n if (config.disabled) return;\n\n const path = config.path;\n\n if (!RouteConfigValidator.isArkosRouteConfig(config))\n throw Error(\n `First argument of ArkosRouter().${prop as string}() must be a valid ArkosRouteConfig object with path field, but recevied ${typeof config === \"object\" ? JSON.stringify(config, null, 2) : config}`\n );\n\n if ([null, undefined].includes(path as any))\n throw Error(\n \"Please pass valid value for path field to use in your route\"\n );\n\n const method = prop as string;\n\n if (handlers.length > 0) {\n handlers = handlers.map(\n (handler: ArkosAnyRequestHandler | ArkosAnyRequestHandler[]) => {\n return typeof handler === \"function\"\n ? catchAsync(handler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n })\n : Array.isArray(handler)\n ? handler.map((nesteHandler: any) => {\n if (typeof nesteHandler === \"function\") return;\n catchAsync(nesteHandler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n });\n return nesteHandler;\n })\n : handler;\n }\n );\n\n const finalHandler = handlers[handlers.length - 1];\n RouteConfigRegistry.register(finalHandler, config, method);\n }\n\n const arkosConfig = getArkosConfig();\n const validationConfig = arkosConfig.validation;\n const authenticationConfig = arkosConfig.authentication;\n const strictValidation = validationConfig?.strict;\n const route = `${method.toUpperCase()} ${path}`;\n\n if (\n strictValidation &&\n (!(\"validation\" in config) ||\n (\"validation\" in config &&\n !config.validation &&\n config.validation !== undefined))\n )\n throw Error(\n \"When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.\"\n );\n\n if (!validationConfig?.resolver && config.validation)\n throw Error(\n `Trying to pass validators into route ${route} config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })`\n );\n\n if (config.authentication && !authenticationConfig?.mode)\n throw Error(\n `Trying to authenticate route ${route} without choosing an authentication mode under arkos.config.${getUserFileExtension()}\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication-system.`\n );\n\n handlers = [...getMiddlewareStack(config), ...handlers];\n\n if (\n config.experimental?.uploads &&\n config.experimental.uploads.deleteOnError !== false\n )\n handlers.push(\n catchAsync(\n uploadManager.handleFileCleanup(config.experimental.uploads),\n { type: \"error\" }\n )\n );\n\n return originalMethod.call(target, path, ...handlers);\n };\n }\n // }\n return originalMethod;\n },\n }) as IArkosRouter;\n}\n\nexport function generateOpenAPIFromApp(app: any) {\n const routes = extractArkosRoutes(app);\n const arkosConfig = getArkosConfig();\n\n let paths: Record<\n string,\n Record<string, Partial<OpenAPIV3.OperationObject>>\n > = {};\n\n routes.forEach(({ path, method, config }) => {\n if (config?.experimental?.openapi === false) return;\n const originalPath = path;\n\n const pathParatemersFromRoutePath = extractPathParams(path);\n for (const parameter of pathParatemersFromRoutePath) {\n path = path.replaceAll(\n `:${parameter}`,\n parameter.endsWith(\"?\") ? `{${parameter}}?` : `{${parameter}}`\n );\n }\n\n if (!paths[path]) paths[path] = {};\n\n if (typeof config?.experimental?.openapi === \"boolean\") {\n config = {\n ...config,\n experimental: {\n ...config.experimental,\n openapi: {},\n },\n };\n }\n\n const openapi =\n typeof config?.experimental?.openapi === \"object\" &&\n config.experimental.openapi !== null\n ? config.experimental.openapi\n : {};\n\n const validatorToJsonSchema =\n arkosConfig?.validation?.resolver === \"zod\"\n ? zodToJsonSchema\n : classValidatorToJsonSchema;\n\n let parameters = [];\n const validationToParameterMapping = {\n query: \"query\",\n params: \"path\",\n headers: \"header\",\n cookies: \"cookie\",\n };\n\n if (typeof config?.validation !== \"boolean\" && config?.validation) {\n for (const [key, val] of Object.entries(config?.validation)) {\n if ([\"body\"].includes(key)) continue;\n if ((config?.validation as any)[key]) {\n const jsonSchema = validatorToJsonSchema(val as any);\n const params = openApiSchemaConverter.jsonSchemaToOpeApiParameters(\n (validationToParameterMapping as any)[key],\n jsonSchema\n );\n parameters.push(...params);\n }\n }\n }\n\n const convertedOpenAPI =\n openApiSchemaConverter.convertOpenAPIConfig(openapi);\n\n const allParameters: OpenAPIV3.ParameterObject[] = [\n ...(convertedOpenAPI.parameters || []),\n ...parameters,\n ];\n\n for (const parameter of pathParatemersFromRoutePath) {\n if (\n !allParameters.find(\n ({ name, in: paramIn }) =>\n name === parameter.replace(\"?\", \"\") && paramIn === \"path\"\n )\n )\n allParameters.push({\n name: parameter,\n in: \"path\",\n required: !parameter.includes(\"?\"),\n schema: { type: \"string\" },\n });\n }\n\n for (const param of allParameters) {\n if (\n !pathParatemersFromRoutePath.includes(param.name) &&\n !pathParatemersFromRoutePath.includes(`${param.name}?`) &&\n param.in === \"path\"\n )\n throw new Error(\n `ValidationError: Trying to define path parameter '${param.name}' but it is not present in your pathname ${originalPath}`\n );\n }\n\n delete convertedOpenAPI.parameters;\n\n (paths as any)[path][method.toLowerCase()] = {\n summary: openapi?.summary || `${path}`,\n description: openapi?.description || `${method} ${path}`,\n tags: openapi?.tags || [\"Defaults\"],\n operationId: `${method.toLowerCase()}:${path}`,\n parameters: allParameters,\n ...(!convertedOpenAPI.requestBody &&\n config?.validation &&\n config?.validation?.body && {\n requestBody: {\n content: {\n \"application/json\": {\n schema: validatorToJsonSchema(config?.validation?.body as any),\n },\n },\n },\n }),\n ...convertedOpenAPI,\n };\n });\n\n return paths;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/arkos-router/index.ts"],"names":[],"mappings":";;;;;AA4CA,8BAkIC;AAED,wDA4HC;AA5SD,qCAAgD;AAGhD,sFAA4D;AAC5D,oFAA0D;AAC1D,6CAKyB;AACzB,2CAA+C;AAC/C,+DAAyD;AAEzD,4EAAiD;AACjD,wIAA4G;AAC5G,4HAAkG;AAClG,oFAA2D;AAC3D,sDAA6D;AA0B7D,SAAwB,WAAW,CACjC,OAEC;IAED,MAAM,MAAM,GAAG,IAAA,gBAAM,EAAC,OAAO,CAAC,CAAC;IAE/B,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAE3D,MAAM,WAAW,GAAG;gBAClB,KAAK;gBACL,MAAM;gBACN,KAAK;gBACL,OAAO;gBACP,QAAQ;gBACR,KAAK;gBACL,MAAM;gBACN,OAAO;gBACP,SAAS;aACV,CAAC;YAMF,IAAI,WAAW,CAAC,QAAQ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2BAA2B,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC;gBACvD,KAAK,CAAC,EAAE,KAAK,MAAM;gBAEnB,MAAM,IAAI,KAAK,CACb,qDAAqD,KAAK,CAAC,IAAI,4CAA4C,YAAY,EAAE,CAC1H,CAAC;QACN,CAAC;QAED,OAAO,gBAAgB,CAAC,UAAU,CAAC;QAElC,KAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG;YAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,GAAG,IAAI,EAAE;YACtC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE;YACxD,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;YACnC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE;YAC9C,UAAU,EAAE,aAAa;YACzB,GAAG,CAAC,CAAC,gBAAgB,CAAC,WAAW;gBAC/B,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI;gBAC1B,WAAW,EAAE;oBACX,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAW,CAAC;yBAC/D;qBACF;iBACF;aACF,CAAC;YACJ,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Router, RouterOptions } from \"express\";\nimport { IArkosRouter, ArkosRouteConfig } from \"./types\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport RouteConfigValidator from \"./route-config-validator\";\nimport RouteConfigRegistry from \"./route-config-registry\";\nimport {\n applyPrefix,\n extractArkosRoutes,\n extractPathParams,\n getMiddlewareStack,\n} from \"./utils/helpers\";\nimport { getArkosConfig } from \"../../exports\";\nimport { catchAsync } from \"../../exports/error-handler\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport classValidatorToJsonSchema from \"../../modules/swagger/utils/helpers/class-validator-to-json-schema\";\nimport openApiSchemaConverter from \"../../modules/swagger/utils/helpers/openapi-schema-converter\";\nimport uploadManager from \"./utils/helpers/upload-manager\";\nimport { getUserFileExtension } from \"../helpers/fs.helpers\";\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * path: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport default function ArkosRouter(\n options?: RouterOptions & {\n prefix?: string | RegExp | Array<string | RegExp>;\n }\n): IArkosRouter {\n const router = Router(options);\n\n return new Proxy(router, {\n get(target, prop, receiver) {\n const originalMethod = Reflect.get(target, prop, receiver);\n\n const httpMethods = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"all\",\n \"head\",\n \"trace\",\n \"options\",\n ];\n\n type ArkosAnyRequestHandler =\n | ArkosRequestHandler\n | ArkosErrorRequestHandler;\n\n if (httpMethods.includes(prop as string)) {\n return function (\n config: ArkosRouteConfig,\n ...handlers: ArkosAnyRequestHandler[]\n ) {\n if (config.disabled) return;\n\n if (!RouteConfigValidator.isArkosRouteConfig(config))\n throw Error(\n `First argument of ArkosRouter().${prop as string}() must be a valid ArkosRouteConfig object with path field, but recevied ${typeof config === \"object\" ? JSON.stringify(config, null, 2) : config}`\n );\n\n const path = applyPrefix(options?.prefix, config.path);\n\n config = { ...config, path };\n\n if ([null, undefined].includes(path as any))\n throw Error(\n \"Please pass valid value for path field to use in your route\"\n );\n\n const method = prop as string;\n const UndefinedHandlerError = (handler: any) =>\n Error(\n `Wrong value for handler in route ${method.toUpperCase()} ${path}, recevied ${handler}.`\n );\n\n if (handlers.length > 0) {\n handlers = handlers.map(\n (handler: ArkosAnyRequestHandler | ArkosAnyRequestHandler[]) => {\n if (!handler) throw UndefinedHandlerError(handler);\n\n return typeof handler === \"function\"\n ? catchAsync(handler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n })\n : Array.isArray(handler)\n ? handler.map((nesteHandler: any) => {\n if (!handler) throw UndefinedHandlerError(nesteHandler);\n\n if (typeof nesteHandler === \"function\") return;\n catchAsync(nesteHandler, {\n type: handler.length > 3 ? \"error\" : \"normal\",\n });\n return nesteHandler;\n })\n : handler;\n }\n );\n\n const finalHandler = handlers[handlers.length - 1];\n RouteConfigRegistry.register(finalHandler, config, method);\n }\n\n const arkosConfig = getArkosConfig();\n const validationConfig = arkosConfig.validation;\n const authenticationConfig = arkosConfig.authentication;\n const strictValidation = validationConfig?.strict;\n const route = `${method.toUpperCase()} ${path}`;\n\n if (\n strictValidation &&\n (!(\"validation\" in config) ||\n (\"validation\" in config &&\n !config.validation &&\n config.validation !== undefined))\n )\n throw Error(\n \"When using strict validation you must either pass { validation: false } in order to explicitly tell that no input will be received, or pass `undefined` for each input type e.g { validation: { query: undefined } } in order to deny the input of given request input.\"\n );\n\n if (!validationConfig?.resolver && config.validation)\n throw Error(\n `Trying to pass validators into route ${route} config validation option without choosing a validation resolver under arkos.init({ validation: { resolver: '' } })`\n );\n\n if (config.authentication && !authenticationConfig?.mode)\n throw Error(\n `Trying to authenticate route ${route} without choosing an authentication mode under arkos.config.${getUserFileExtension()}\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication-system.`\n );\n\n handlers = [...getMiddlewareStack(config), ...handlers];\n\n if (\n config.experimental?.uploads &&\n config.experimental.uploads.deleteOnError !== false\n )\n handlers.push(\n catchAsync(\n uploadManager.handleFileCleanup(config.experimental.uploads),\n { type: \"error\" }\n )\n );\n\n return originalMethod.call(target, path, ...handlers);\n };\n }\n // }\n return originalMethod;\n },\n }) as IArkosRouter;\n}\n\nexport function generateOpenAPIFromApp(app: any) {\n const routes = extractArkosRoutes(app);\n const arkosConfig = getArkosConfig();\n\n let paths: Record<\n string,\n Record<string, Partial<OpenAPIV3.OperationObject>>\n > = {};\n\n routes.forEach(({ path, method, config }) => {\n if (config?.experimental?.openapi === false) return;\n const originalPath = path;\n\n const pathParatemersFromRoutePath = extractPathParams(path);\n for (const parameter of pathParatemersFromRoutePath) {\n path = path.replaceAll(\n `:${parameter}`,\n parameter.endsWith(\"?\") ? `{${parameter}}?` : `{${parameter}}`\n );\n }\n\n if (!paths[path]) paths[path] = {};\n\n if (typeof config?.experimental?.openapi === \"boolean\") {\n config = {\n ...config,\n experimental: {\n ...config.experimental,\n openapi: {},\n },\n };\n }\n\n const openapi =\n typeof config?.experimental?.openapi === \"object\" &&\n config.experimental.openapi !== null\n ? config.experimental.openapi\n : {};\n\n const validatorToJsonSchema =\n arkosConfig?.validation?.resolver === \"zod\"\n ? zodToJsonSchema\n : classValidatorToJsonSchema;\n\n let parameters = [];\n const validationToParameterMapping = {\n query: \"query\",\n params: \"path\",\n headers: \"header\",\n cookies: \"cookie\",\n };\n\n if (typeof config?.validation !== \"boolean\" && config?.validation) {\n for (const [key, val] of Object.entries(config?.validation)) {\n if ([\"body\"].includes(key)) continue;\n if ((config?.validation as any)[key]) {\n const jsonSchema = validatorToJsonSchema(val as any);\n const params = openApiSchemaConverter.jsonSchemaToOpeApiParameters(\n (validationToParameterMapping as any)[key],\n jsonSchema\n );\n parameters.push(...params);\n }\n }\n }\n\n const convertedOpenAPI =\n openApiSchemaConverter.convertOpenAPIConfig(openapi);\n\n const allParameters: OpenAPIV3.ParameterObject[] = [\n ...(convertedOpenAPI.parameters || []),\n ...parameters,\n ];\n\n for (const parameter of pathParatemersFromRoutePath) {\n if (\n !allParameters.find(\n ({ name, in: paramIn }) =>\n name === parameter.replace(\"?\", \"\") && paramIn === \"path\"\n )\n )\n allParameters.push({\n name: parameter,\n in: \"path\",\n required: !parameter.includes(\"?\"),\n schema: { type: \"string\" },\n });\n }\n\n for (const param of allParameters) {\n if (\n !pathParatemersFromRoutePath.includes(param.name) &&\n !pathParatemersFromRoutePath.includes(`${param.name}?`) &&\n param.in === \"path\"\n )\n throw new Error(\n `ValidationError: Trying to define path parameter '${param.name}' but it is not present in your pathname ${originalPath}`\n );\n }\n\n delete convertedOpenAPI.parameters;\n\n (paths as any)[path][method.toLowerCase()] = {\n summary: openapi?.summary || `${path}`,\n description: openapi?.description || `${method} ${path}`,\n tags: openapi?.tags || [\"Defaults\"],\n operationId: `${method.toLowerCase()}:${path}`,\n parameters: allParameters,\n ...(!convertedOpenAPI.requestBody &&\n config?.validation &&\n config?.validation?.body && {\n requestBody: {\n content: {\n \"application/json\": {\n schema: validatorToJsonSchema(config?.validation?.body as any),\n },\n },\n },\n }),\n ...convertedOpenAPI,\n };\n });\n\n return paths;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { IRouter } from \"express\";\nimport { ZodSchema } from \"zod\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { Options as QueryParserOptions } from \"../../../utils/helpers/query-parser.helpers\";\nimport { DetailedAccessControlRule } from \"../../../types/auth\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../../types\";\nimport compression from \"compression\";\nimport { OpenApiConfig } from \"./openapi-config\";\nimport { UploadConfig } from \"./upload-config\";\nimport { BodyParserConfig } from \"./body-parser-config\";\n\nexport type PathParams = string | RegExp | Array<string | RegExp>;\n\n/**\n * Handler function for HTTP methods that accepts route configuration and request handlers.\n *\n * @param {ArkosRouteConfig} config - The route configuration object.\n * @param {...(ArkosRequestHandler | ArkosErrorRequestHandler)[]} handlers - Request and error handlers for the route.\n * @returns {IRouter} The Express router instance.\n */\ntype MethodHandler<T> = (\n config: ArkosRouteConfig | PathParams,\n ...handlers: Array<\n | ArkosRequestHandler\n | ArkosErrorRequestHandler\n | Array<ArkosRequestHandler | ArkosErrorRequestHandler>\n >\n) => T;\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * path: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport interface IArkosRouter extends IRouter {\n /** GET method handler with route configuration support */\n get: MethodHandler<this>;\n /** POST method handler with route configuration support */\n post: MethodHandler<this>;\n /** PUT method handler with route configuration support */\n put: MethodHandler<this>;\n /** PATCH method handler with route configuration support */\n patch: MethodHandler<this>;\n /** DELETE method handler with route configuration support */\n delete: MethodHandler<this>;\n /** OPTIONS method handler with route configuration support */\n options: MethodHandler<this>;\n /** HEAD method handler with route configuration support */\n head: MethodHandler<this>;\n // /** TRACE method handler with route configuration support */\n trace: MethodHandler<this>;\n /** ALL methods handler with route configuration support */\n all: MethodHandler<this>;\n}\n\n/**\n * Configuration object for defining routes in Arkos.js.\n */\nexport type ArkosRouteConfig = {\n /**\n * Disables the route by not mounting it internally.\n */\n disabled?: boolean;\n /**\n * The URL path pattern for the route.\n *\n * @example \"/api/users/:id\"\n */\n path: PathParams;\n /**\n * Authentication and authorization configuration.\n *\n * @remarks\n * - Set to `true` to require authentication without specific permissions.\n * - Set to `false` or omit to allow unauthenticated access.\n * - Provide an object to specify resource-based access control with resource name, action, and optional custom rules.\n */\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: DetailedAccessControlRule | string[];\n };\n /**\n * Request validation configuration using Zod schemas or class constructors.\n *\n * @remarks\n * - Set to `false` to disable all validation.\n * - Provide an object with `query`, `body`, and/or `params` properties to validate specific parts of the request.\n * - Each property accepts a Zod schema, a class constructor, or `false` to disable validation for that part.\n */\n validation?:\n | false\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | false;\n body?: ZodSchema | (new (...args: any[]) => object) | false;\n params?: ZodSchema | (new (...args: any[]) => object) | false;\n };\n\n /**\n * Rate limiting configuration for this route.\n *\n * @see {@link https://www.npmjs.com/package/express-rate-limit express-rate-limit} for available options.\n */\n rateLimit?: Partial<RateLimitOptions>;\n\n /**\n * Allows to define options for npm package compression.\n * Nothing is passed by default.\n *\n * @see {@link https://www.npmjs.com/package/compression compression} for further details.\n */\n compression?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * @example\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n *\n * @default\n * ```\n * {\n * parseNull: true,\n * parseUndefined: true,\n * parseBoolean: true,\n * }\n * ```\n *\n * @remarks\n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n *\n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParser?: QueryParserOptions;\n /**\n * Configuration for request body parsing.\n *\n * @property {(\"json\" | \"urlencoded\" | \"raw\" | \"text\")} parser - The type of body parser to use.\n * @property {object} [options] - Parser-specific options passed to the corresponding Express body parser middleware.\n *\n * @remarks\n * - When `parser` is `\"json\"`, options are passed to `express.json()`.\n * - When `parser` is `\"urlencoded\"`, options are passed to `express.urlencoded()`.\n * - When `parser` is `\"raw\"`, options are passed to `express.raw()`.\n * - When `parser` is `\"text\"`, options are passed to `express.text()`.\n * - Set to `false` to disable body parsing for this route.\n *\n * @see {@link https://expressjs.com/en/api.html#express.json Express body parser documentation}\n */\n bodyParser?: BodyParserConfig | BodyParserConfig[] | false;\n /**\n * Experimental features to be battled tested before being stable\n *\n * PS: These features may be changed without any previous warning.\n */\n experimental?: {\n /**\n * OpenAPI specification for this route.\n *\n * @remarks\n * - Set to `false` to exclude this route from OpenAPI documentation.\n * - Provide a partial OpenAPI operation object to document the route.\n */\n openapi?: false | OpenApiConfig;\n /**\n * Configuration for file upload handling in routes.\n * Supports single file, multiple files from same field, or multiple fields with files.\n */\n uploads?: UploadConfig;\n };\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { IRouter } from \"express\";\nimport { ZodSchema } from \"zod\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { Options as QueryParserOptions } from \"../../../utils/helpers/query-parser.helpers\";\nimport {\n AccessControlConfig,\n AccessControlRules,\n DetailedAccessControlRule,\n} from \"../../../types/auth\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../../types\";\nimport compression from \"compression\";\nimport { OpenApiConfig } from \"./openapi-config\";\nimport { UploadConfig } from \"./upload-config\";\nimport { BodyParserConfig } from \"./body-parser-config\";\n\nexport type PathParams = string | RegExp | Array<string | RegExp>;\n\n/**\n * Handler function for HTTP methods that accepts route configuration and request handlers.\n *\n * @param {ArkosRouteConfig} config - The route configuration object.\n * @param {...(ArkosRequestHandler | ArkosErrorRequestHandler)[]} handlers - Request and error handlers for the route.\n * @returns {IRouter} The Express router instance.\n */\ntype MethodHandler<T> = (\n config: ArkosRouteConfig | PathParams,\n ...handlers: Array<\n | ArkosRequestHandler\n | ArkosErrorRequestHandler\n | Array<ArkosRequestHandler | ArkosErrorRequestHandler>\n >\n) => T;\n\n/**\n * Creates an enhanced Express Router with features like OpenAPI documentation capabilities and smart data validation.\n *\n * The ArkosRouter extends the standard Express Router with the ability to\n * automatically capture OpenAPI metadata from route configurations.\n *\n * @example\n * const router = ArkosRouter();\n *\n * router.get(\n * {\n * path: \"/users/:id\",\n * openapi: {\n * summary: \"Get user by ID\",\n * tags: [\"Users\"]\n * }\n * },\n * (req, res) => { ... }\n * );\n *\n * @returns {IArkosRouter} A proxied Express Router instance with enhanced OpenAPI capabilities\n *\n * @see {@link ArkosRouteConfig} for configuration options\n */\nexport interface IArkosRouter extends IRouter {\n /** GET method handler with route configuration support */\n get: MethodHandler<this>;\n /** POST method handler with route configuration support */\n post: MethodHandler<this>;\n /** PUT method handler with route configuration support */\n put: MethodHandler<this>;\n /** PATCH method handler with route configuration support */\n patch: MethodHandler<this>;\n /** DELETE method handler with route configuration support */\n delete: MethodHandler<this>;\n /** OPTIONS method handler with route configuration support */\n options: MethodHandler<this>;\n /** HEAD method handler with route configuration support */\n head: MethodHandler<this>;\n // /** TRACE method handler with route configuration support */\n trace: MethodHandler<this>;\n /** ALL methods handler with route configuration support */\n all: MethodHandler<this>;\n}\n\n/**\n * Configuration object for defining routes in Arkos.js.\n */\nexport type ArkosRouteConfig = {\n /**\n * Disables the route by not mounting it internally.\n */\n disabled?: boolean;\n /**\n * The URL path pattern for the route.\n *\n * @example \"/api/users/:id\"\n */\n path: PathParams;\n /**\n * Authentication and authorization configuration.\n *\n * @remarks\n * - Set to `true` to require authentication without specific permissions.\n * - Set to `false` or omit to allow unauthenticated access.\n * - Provide an object to specify resource-based access control with resource name, action, and optional custom rules.\n */\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: AccessControlConfig;\n };\n /**\n * Request validation configuration using Zod schemas or class constructors.\n *\n * @remarks\n * - Set to `false` to disable all validation.\n * - Provide an object with `query`, `body`, and/or `params` properties to validate specific parts of the request.\n * - Each property accepts a Zod schema, a class constructor, or `false` to disable validation for that part.\n */\n validation?:\n | false\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | false;\n body?: ZodSchema | (new (...args: any[]) => object) | false;\n params?: ZodSchema | (new (...args: any[]) => object) | false;\n };\n\n /**\n * Rate limiting configuration for this route.\n *\n * @see {@link https://www.npmjs.com/package/express-rate-limit express-rate-limit} for available options.\n */\n rateLimit?: Partial<RateLimitOptions>;\n\n /**\n * Allows to define options for npm package compression.\n * Nothing is passed by default.\n *\n * @see {@link https://www.npmjs.com/package/compression compression} for further details.\n */\n compression?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * @example\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n *\n * @default\n * ```\n * {\n * parseNull: true,\n * parseUndefined: true,\n * parseBoolean: true,\n * }\n * ```\n *\n * @remarks\n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n *\n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParser?: QueryParserOptions;\n /**\n * Configuration for request body parsing.\n *\n * @property {(\"json\" | \"urlencoded\" | \"raw\" | \"text\")} parser - The type of body parser to use.\n * @property {object} [options] - Parser-specific options passed to the corresponding Express body parser middleware.\n *\n * @remarks\n * - When `parser` is `\"json\"`, options are passed to `express.json()`.\n * - When `parser` is `\"urlencoded\"`, options are passed to `express.urlencoded()`.\n * - When `parser` is `\"raw\"`, options are passed to `express.raw()`.\n * - When `parser` is `\"text\"`, options are passed to `express.text()`.\n * - Set to `false` to disable body parsing for this route.\n *\n * @see {@link https://expressjs.com/en/api.html#express.json Express body parser documentation}\n */\n bodyParser?: BodyParserConfig | BodyParserConfig[] | false;\n /**\n * Experimental features to be battled tested before being stable\n *\n * PS: These features may be changed without any previous warning.\n */\n experimental?: {\n /**\n * OpenAPI specification for this route.\n *\n * @remarks\n * - Set to `false` to exclude this route from OpenAPI documentation.\n * - Provide a partial OpenAPI operation object to document the route.\n */\n openapi?: false | OpenApiConfig;\n /**\n * Configuration for file upload handling in routes.\n * Supports single file, multiple files from same field, or multiple fields with files.\n */\n uploads?: UploadConfig;\n };\n};\n"]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.extractArkosRoutes = extractArkosRoutes;
7
7
  exports.getMiddlewareStack = getMiddlewareStack;
8
8
  exports.extractPathParams = extractPathParams;
9
+ exports.applyPrefix = applyPrefix;
9
10
  const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
10
11
  const auth_service_1 = __importDefault(require("../../../../modules/auth/auth.service"));
11
12
  const base_middlewares_1 = require("../../../../modules/base/base.middlewares");
@@ -107,4 +108,54 @@ function extractPathParams(path) {
107
108
  }
108
109
  return params;
109
110
  }
111
+ function applyPrefix(prefix = "", path) {
112
+ if (!prefix)
113
+ return path;
114
+ const prefixArr = Array.isArray(prefix) ? prefix : [prefix];
115
+ const pathArr = Array.isArray(path) ? path : [path];
116
+ const result = [];
117
+ for (const pfx of prefixArr) {
118
+ for (const pth of pathArr) {
119
+ result.push(applySinglePrefix(pfx, pth));
120
+ }
121
+ }
122
+ return result.length === 1 ? result[0] : result;
123
+ }
124
+ function applySinglePrefix(prefix, path) {
125
+ const isPrefixRegex = prefix instanceof RegExp;
126
+ const isPathRegex = path instanceof RegExp;
127
+ if (typeof prefix === "string" && typeof path === "string") {
128
+ const normalizedPrefix = prefix.endsWith("/")
129
+ ? prefix.slice(0, -1)
130
+ : prefix;
131
+ return `${normalizedPrefix}${path.startsWith("/") ? "" : "/"}${path}`;
132
+ }
133
+ if (typeof prefix === "string" && isPathRegex) {
134
+ const escapedPrefix = prefix
135
+ .replace(/\/$/, "")
136
+ .replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
137
+ const source = path.source.startsWith("^")
138
+ ? path.source.slice(1)
139
+ : path.source;
140
+ return new RegExp(`^${escapedPrefix}${source}`, path.flags);
141
+ }
142
+ if (isPrefixRegex && typeof path === "string") {
143
+ const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
144
+ const prefixSource = prefix.source.endsWith("$")
145
+ ? prefix.source.slice(0, -1)
146
+ : prefix.source;
147
+ return new RegExp(`^${prefixSource}${escapedPath}`, prefix.flags);
148
+ }
149
+ if (isPrefixRegex && isPathRegex) {
150
+ const prefixSource = prefix.source.endsWith("$")
151
+ ? prefix.source.slice(0, -1)
152
+ : prefix.source;
153
+ const pathSource = path.source.startsWith("^")
154
+ ? path.source.slice(1)
155
+ : path.source;
156
+ const flags = Array.from(new Set([...prefix.flags, ...path.flags])).join("");
157
+ return new RegExp(`^${prefixSource}${pathSource}`, flags);
158
+ }
159
+ throw new TypeError("Invalid prefix or path");
160
+ }
110
161
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/arkos-router/utils/helpers/index.ts"],"names":[],"mappings":";;;;;AAYA,gDA+DC;AAED,gDAiDC;AAaD,8CAWC;AAtJD,4EAA2C;AAC3C,yFAAgE;AAChE,gFAAkF;AAClF,wFAA8D;AAE9D,sDAA8B;AAC9B,8DAAsC;AACtC,gFAAoE;AACpE,sEAA6C;AAC7C,oDAA4B;AAC5B,qEAA+D;AAE/D,SAAgB,kBAAkB,CAChC,GAAQ,EACR,QAAQ,GAAG,EAAE;IAMb,MAAM,MAAM,GAIP,EAAE,CAAC;IAER,SAAS,gBAAgB,CAAC,KAAY,EAAE,MAAM,GAAG,EAAE;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;YAC3B,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAEjD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;oBACzC,IAAI,MAAoC,CAAC;oBAEzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;wBAC/B,MAAM,WAAW,GAAG,+BAAmB,CAAC,GA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../modules/auth/auth.service\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport express from \"express\";\nimport compression from \"compression\";\nimport { queryParser } from \"../../../helpers/query-parser.helpers\";\nimport uploadManager from \"./upload-manager\";\nimport multer from \"multer\";\nimport { catchAsync } from \"../../../../exports/error-handler\";\n\nexport function extractArkosRoutes(\n app: any,\n basePath = \"\"\n): Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n}> {\n const routes: Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n }> = [];\n\n function extractFromStack(stack: any[], prefix = \"\") {\n stack.forEach((layer: any) => {\n if (layer.route) {\n const fullPath = prefix + layer.route.path;\n const methods = Object.keys(layer.route.methods);\n\n methods.forEach((method) => {\n const handlers = layer.route.stack || [];\n let config: ArkosRouteConfig | undefined;\n\n for (const handler of handlers) {\n const foundConfig = RouteConfigRegistry.get(handler.handle);\n\n if (foundConfig) {\n config = foundConfig;\n routes.push({\n path: fullPath,\n method: method.toUpperCase(),\n config,\n });\n\n break;\n }\n }\n });\n } else if (layer.name === \"router\" && layer.handle?.stack) {\n let nestedPrefix = prefix;\n\n if (layer.regexp) {\n const match = layer.regexp\n .toString()\n .match(/\\/\\^?(\\\\\\/[^?]+|\\/[^?]+)/);\n if (match) {\n nestedPrefix = prefix + \"/\" + match[1].replace(/\\\\\\//g, \"/\");\n nestedPrefix = nestedPrefix\n .replace(/\\/\\//g, \"/\")\n .replace(/\\/$/, \"\");\n }\n }\n\n extractFromStack(layer.handle.stack, nestedPrefix);\n }\n });\n }\n\n const stack = app._router?.stack || app.stack;\n if (stack) extractFromStack(stack, basePath);\n\n return routes;\n}\n\nexport function getMiddlewareStack(config: ArkosRouteConfig) {\n const middlewares = [];\n\n if (config.authentication) middlewares.push(authService.authenticate);\n\n if (\n typeof config.authentication === \"object\" &&\n config.authentication.action &&\n config.authentication.resource\n )\n middlewares.push(\n authService.handleAccessControl(\n config.authentication.action,\n config.authentication.resource,\n { [config.authentication.action]: config.authentication?.rule }\n )\n );\n\n if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n if (config.compression) middlewares.push(compression(config.compression));\n if (config.queryParser) middlewares.push(queryParser(config.queryParser));\n\n if (config?.bodyParser) {\n const parsers = Array.isArray(config.bodyParser)\n ? config.bodyParser\n : [config.bodyParser];\n\n parsers.forEach((parser) => {\n if (typeof parser === \"object\" && parser.parser)\n if (parser.parser !== \"multipart\")\n middlewares.push(catchAsync(express[parser.parser](parser.options)));\n else if (parser.parser === \"multipart\")\n middlewares.push(\n catchAsync(multer({ limits: parser.options }).none())\n );\n });\n }\n\n if (config.experimental?.uploads) {\n middlewares.push(uploadManager.handleUpload(config.experimental.uploads));\n\n middlewares.push(validateRequestInputs(config));\n\n middlewares.push(\n uploadManager.handlePostUpload(config.experimental.uploads)\n );\n } else middlewares.push(validateRequestInputs(config));\n\n return middlewares;\n}\n\n/**\n * Extracts path parameters from an Express route path\n *\n * @param path - Express route path with :param syntax\n * @returns Array of parameter names\n *\n * @example\n * extractPathParams('/api/users/:userId/posts/:postId')\n * // => ['userId', 'postId']\n *\n */\nexport function extractPathParams(path: string): string[] {\n const params: string[] = [];\n const segments = path.split(\"/\");\n\n for (const segment of segments) {\n if (segment.startsWith(\":\")) {\n params.push(segment.substring(1));\n }\n }\n\n return params;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/arkos-router/utils/helpers/index.ts"],"names":[],"mappings":";;;;;AAYA,gDA+DC;AAED,gDAiDC;AAaD,8CAWC;AAKD,kCAkBC;AA7KD,4EAA2C;AAC3C,yFAAgE;AAChE,gFAAkF;AAClF,wFAA8D;AAE9D,sDAA8B;AAC9B,8DAAsC;AACtC,gFAAoE;AACpE,sEAA6C;AAC7C,oDAA4B;AAC5B,qEAA+D;AAE/D,SAAgB,kBAAkB,CAChC,GAAQ,EACR,QAAQ,GAA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AAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC9C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QAElB,OAAO,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,WAAW,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,aAAa,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC9C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QAElB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;YAC5C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAEhB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CACtE,EAAE,CACH,CAAC;QAEF,OAAO,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import rateLimit from \"express-rate-limit\";\nimport authService from \"../../../../modules/auth/auth.service\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport express from \"express\";\nimport compression from \"compression\";\nimport { queryParser } from \"../../../helpers/query-parser.helpers\";\nimport uploadManager from \"./upload-manager\";\nimport multer from \"multer\";\nimport { catchAsync } from \"../../../../exports/error-handler\";\n\nexport function extractArkosRoutes(\n app: any,\n basePath = \"\"\n): Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n}> {\n const routes: Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n }> = [];\n\n function extractFromStack(stack: any[], prefix = \"\") {\n stack.forEach((layer: any) => {\n if (layer.route) {\n const fullPath = prefix + layer.route.path;\n const methods = Object.keys(layer.route.methods);\n\n methods.forEach((method) => {\n const handlers = layer.route.stack || [];\n let config: ArkosRouteConfig | undefined;\n\n for (const handler of handlers) {\n const foundConfig = RouteConfigRegistry.get(handler.handle);\n\n if (foundConfig) {\n config = foundConfig;\n routes.push({\n path: fullPath,\n method: method.toUpperCase(),\n config,\n });\n\n break;\n }\n }\n });\n } else if (layer.name === \"router\" && layer.handle?.stack) {\n let nestedPrefix = prefix;\n\n if (layer.regexp) {\n const match = layer.regexp\n .toString()\n .match(/\\/\\^?(\\\\\\/[^?]+|\\/[^?]+)/);\n if (match) {\n nestedPrefix = prefix + \"/\" + match[1].replace(/\\\\\\//g, \"/\");\n nestedPrefix = nestedPrefix\n .replace(/\\/\\//g, \"/\")\n .replace(/\\/$/, \"\");\n }\n }\n\n extractFromStack(layer.handle.stack, nestedPrefix);\n }\n });\n }\n\n const stack = app._router?.stack || app.stack;\n if (stack) extractFromStack(stack, basePath);\n\n return routes;\n}\n\nexport function getMiddlewareStack(config: ArkosRouteConfig) {\n const middlewares = [];\n\n if (config.authentication) middlewares.push(authService.authenticate);\n\n if (\n typeof config.authentication === \"object\" &&\n config.authentication.action &&\n config.authentication.resource\n )\n middlewares.push(\n authService.handleAccessControl(\n config.authentication.action,\n config.authentication.resource,\n { [config.authentication.action]: config.authentication?.rule }\n )\n );\n\n if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n if (config.compression) middlewares.push(compression(config.compression));\n if (config.queryParser) middlewares.push(queryParser(config.queryParser));\n\n if (config?.bodyParser) {\n const parsers = Array.isArray(config.bodyParser)\n ? config.bodyParser\n : [config.bodyParser];\n\n parsers.forEach((parser) => {\n if (typeof parser === \"object\" && parser.parser)\n if (parser.parser !== \"multipart\")\n middlewares.push(catchAsync(express[parser.parser](parser.options)));\n else if (parser.parser === \"multipart\")\n middlewares.push(\n catchAsync(multer({ limits: parser.options }).none())\n );\n });\n }\n\n if (config.experimental?.uploads) {\n middlewares.push(uploadManager.handleUpload(config.experimental.uploads));\n\n middlewares.push(validateRequestInputs(config));\n\n middlewares.push(\n uploadManager.handlePostUpload(config.experimental.uploads)\n );\n } else middlewares.push(validateRequestInputs(config));\n\n return middlewares;\n}\n\n/**\n * Extracts path parameters from an Express route path\n *\n * @param path - Express route path with :param syntax\n * @returns Array of parameter names\n *\n * @example\n * extractPathParams('/api/users/:userId/posts/:postId')\n * // => ['userId', 'postId']\n *\n */\nexport function extractPathParams(path: string): string[] {\n const params: string[] = [];\n const segments = path.split(\"/\");\n\n for (const segment of segments) {\n if (segment.startsWith(\":\")) {\n params.push(segment.substring(1));\n }\n }\n\n return params;\n}\n\ntype PathLike = string | RegExp;\ntype PathInput = PathLike | PathLike[];\n\nexport function applyPrefix(\n prefix: PathInput = \"\",\n path: PathInput\n): PathInput {\n if (!prefix) return path;\n\n const prefixArr = Array.isArray(prefix) ? prefix : [prefix];\n const pathArr = Array.isArray(path) ? path : [path];\n\n const result: PathLike[] = [];\n\n for (const pfx of prefixArr) {\n for (const pth of pathArr) {\n result.push(applySinglePrefix(pfx, pth));\n }\n }\n\n return result.length === 1 ? result[0] : result;\n}\n\nfunction applySinglePrefix(prefix: PathLike, path: PathLike): PathLike {\n const isPrefixRegex = prefix instanceof RegExp;\n const isPathRegex = path instanceof RegExp;\n\n if (typeof prefix === \"string\" && typeof path === \"string\") {\n const normalizedPrefix = prefix.endsWith(\"/\")\n ? prefix.slice(0, -1)\n : prefix;\n\n return `${normalizedPrefix}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n }\n\n if (typeof prefix === \"string\" && isPathRegex) {\n const escapedPrefix = prefix\n .replace(/\\/$/, \"\")\n .replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n const source = path.source.startsWith(\"^\")\n ? path.source.slice(1)\n : path.source;\n\n return new RegExp(`^${escapedPrefix}${source}`, path.flags);\n }\n\n if (isPrefixRegex && typeof path === \"string\") {\n const escapedPath = path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n const prefixSource = prefix.source.endsWith(\"$\")\n ? prefix.source.slice(0, -1)\n : prefix.source;\n\n return new RegExp(`^${prefixSource}${escapedPath}`, prefix.flags);\n }\n\n if (isPrefixRegex && isPathRegex) {\n const prefixSource = prefix.source.endsWith(\"$\")\n ? prefix.source.slice(0, -1)\n : prefix.source;\n\n const pathSource = path.source.startsWith(\"^\")\n ? path.source.slice(1)\n : path.source;\n\n const flags = Array.from(new Set([...prefix.flags, ...path.flags])).join(\n \"\"\n );\n\n return new RegExp(`^${prefixSource}${pathSource}`, flags);\n }\n\n throw new TypeError(\"Invalid prefix or path\");\n}\n"]}
@@ -49,8 +49,10 @@ const generateFile = async (options, config) => {
49
49
  config.templateName.slice(1).replaceAll("-", " ");
50
50
  try {
51
51
  (0, cli_helpers_1.ensureDirectoryExists)(modulePath);
52
+ const { model, ...restOfOptions } = options;
52
53
  const templateData = {
53
54
  modelName: names,
55
+ ...restOfOptions,
54
56
  ...(config.customImports && { imports: config.customImports(names) }),
55
57
  };
56
58
  const content = (0, template_generators_1.generateTemplate)(config.templateName, templateData);
@@ -137,6 +139,24 @@ exports.generateCommand = {
137
139
  allowedModules: models,
138
140
  });
139
141
  },
142
+ baseSchema: async (options) => {
143
+ await generateFile(options, {
144
+ templateName: "schema",
145
+ fileSuffix: "schema",
146
+ customPath: "src/modules/{{module-name}}/schemas",
147
+ prefix: "",
148
+ allowedModules: models,
149
+ });
150
+ },
151
+ querySchema: async (options) => {
152
+ await generateFile(options, {
153
+ templateName: "query-schema",
154
+ fileSuffix: "schema",
155
+ customPath: "src/modules/{{module-name}}/schemas",
156
+ prefix: "query-",
157
+ allowedModules: models,
158
+ });
159
+ },
140
160
  createDto: async (options) => {
141
161
  await generateFile(options, {
142
162
  templateName: "create-dto",
@@ -155,6 +175,24 @@ exports.generateCommand = {
155
175
  allowedModules: models,
156
176
  });
157
177
  },
178
+ baseDto: async (options) => {
179
+ await generateFile(options, {
180
+ templateName: "dto",
181
+ fileSuffix: "dto",
182
+ customPath: "src/modules/{{module-name}}/dtos",
183
+ prefix: "",
184
+ allowedModules: models,
185
+ });
186
+ },
187
+ queryDto: async (options) => {
188
+ await generateFile(options, {
189
+ templateName: "query-dto",
190
+ fileSuffix: "dto",
191
+ customPath: "src/modules/{{module-name}}/dtos",
192
+ prefix: "query-",
193
+ allowedModules: models,
194
+ });
195
+ },
158
196
  queryOptions: async (options) => {
159
197
  await generateFile(options, {
160
198
  templateName: "query-options",
@@ -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,0FAAgE;AAChE,uGAA0F;AAE1F,MAAM,MAAM,GAAG,8BAAkB;KAC9B,yBAAyB,EAAE;KAC3B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,+BAAS,EAAC,GAAG,CAAC,CAAC,CAAC;AAEhC,MAAM,YAAY,GAAG,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;AAkBxD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CA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KAAK,EAAE,OAAwB,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,kCAAkC;YAC9C,MAAM,EAAE,SAAS;YACjB,cAAc,EAAE,MAAM;SACvB,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;YACjB,UAAU,EAAE,kCAAkC;YAC9C,MAAM,EAAE,SAAS;YACjB,cAAc,EAAE,MAAM;SACvB,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,cAAc,EAAE,YAAY;SAC7B,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\";\nimport prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabToHuman } from \"../../modules/swagger/utils/helpers/swagger.router.helpers\";\n\nconst models = prismaSchemaParser\n .getModelsAsArrayOfStrings()\n .map((val) => kebabCase(val));\n\nconst knownModules = [...models, \"file-upload\", \"auth\"];\n\ninterface GenerateOptions {\n path?: string;\n model?: string;\n module?: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n prefix?: string;\n allowedModules: string[];\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.module || options.model;\n\n if (options.module && options.model)\n throw Error(\n \"You must either pass --module or --model, prefer --module to align with future updates.\"\n );\n\n if (!modelName?.trim()) throw new Error(\"Module name is required!\");\n\n const isAllowedModule = config.allowedModules.includes(kebabCase(modelName));\n const isKnowModule = config.allowedModules.includes(kebabCase(modelName));\n\n if (!isKnowModule)\n throw new Error(\n `Generate command are only available for know modules such as all prisma models, file-upload and auth. And you passed ${modelName}.`\n );\n else if (!isAllowedModule)\n throw Error(\n `${kebabToHuman(kebabCase(config.templateName))} are not available for module ${modelName}`\n );\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n const fileName = config.prefix\n ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\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 ${names.kebab.replace(\"-\", \"\")} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${names.kebab.replace(\"-\", \"\")} 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 allowedModules: knownModules,\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 allowedModules: [...knownModules, \"email\"],\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 allowedModules: knownModules,\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n allowedModules: knownModules,\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n allowedModules: knownModules,\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n allowedModules: knownModules,\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"create-\",\n allowedModules: models,\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"update-\",\n allowedModules: models,\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"create-\",\n allowedModules: models,\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"update-\",\n allowedModules: models,\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n allowedModules: knownModules,\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,0FAAgE;AAChE,uGAA0F;AAE1F,MAAM,MAAM,GAAG,8BAAkB;KAC9B,yBAAyB,EAAE;KAC3B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,+BAAS,EAAC,GAAG,CAAC,CAAC,CAAC;AAEhC,MAAM,YAAY,GAAG,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;AAkBxD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC;IAElD,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK;QACjC,MAAM,KAAK,CACT,yFAAyF,CAC1F,CAAC;IAEJ,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEpE,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAA,+BAAS,EAAC,SAAS,CAAC,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAA,+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,OAAO;YACnB,cAAc,EAAE,YAAY;SAC7B,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\";\nimport prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabToHuman } from \"../../modules/swagger/utils/helpers/swagger.router.helpers\";\n\nconst models = prismaSchemaParser\n .getModelsAsArrayOfStrings()\n .map((val) => kebabCase(val));\n\nconst knownModules = [...models, \"file-upload\", \"auth\"];\n\ninterface GenerateOptions {\n path?: string;\n model?: string;\n module?: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n prefix?: string;\n allowedModules: string[];\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.module || options.model;\n\n if (options.module && options.model)\n throw Error(\n \"You must either pass --module or --model, prefer --module to align with future updates.\"\n );\n\n if (!modelName?.trim()) throw new Error(\"Module name is required!\");\n\n const isAllowedModule = config.allowedModules.includes(kebabCase(modelName));\n const isKnowModule = config.allowedModules.includes(kebabCase(modelName));\n\n if (!isKnowModule)\n throw new Error(\n `Generate command are only available for know modules such as all prisma models, file-upload and auth. And you passed ${modelName}.`\n );\n else if (!isAllowedModule)\n throw Error(\n `${kebabToHuman(kebabCase(config.templateName))} are not available for module ${modelName}`\n );\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n const fileName = config.prefix\n ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\n\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n const { model, ...restOfOptions } = options;\n\n const templateData = {\n modelName: names,\n ...restOfOptions,\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 ${names.kebab.replace(\"-\", \"\")} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${names.kebab.replace(\"-\", \"\")} 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 allowedModules: knownModules,\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 allowedModules: [...knownModules, \"email\"],\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 allowedModules: knownModules,\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n allowedModules: knownModules,\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n allowedModules: knownModules,\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n allowedModules: knownModules,\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"create-\",\n allowedModules: models,\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"update-\",\n allowedModules: models,\n });\n },\n\n baseSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"\",\n allowedModules: models,\n });\n },\n\n querySchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"query-\",\n allowedModules: models,\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"create-\",\n allowedModules: models,\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"update-\",\n allowedModules: models,\n });\n },\n\n baseDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"\",\n allowedModules: models,\n });\n },\n\n queryDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"query-\",\n allowedModules: models,\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n allowedModules: knownModules,\n });\n },\n};\n"]}
@@ -70,6 +70,7 @@ generate
70
70
  .description("Generate auth configuration")
71
71
  .option("-m, --module <name>", "Module name")
72
72
  .option("--model <name>", "Module name (alias for --module)")
73
+ .option("-a, --advanced", "Advanced code structure")
73
74
  .option("-p, --path <path>", "Custom path for the router", "src/modules/{{module-name}}")
74
75
  .action(generate_1.generateCommand.authConfigs);
75
76
  generate
@@ -104,7 +105,7 @@ generate
104
105
  .description("Generate a new zod create schema file for a prisma model")
105
106
  .option("-m, --module <name>", "Module name")
106
107
  .option("--model <name>", "Module name (alias for --module)")
107
- .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
108
+ .option("-p, --path <path>", "Custom path for schema", "src/modules/{{module-name}}")
108
109
  .action(generate_1.generateCommand.createSchema);
109
110
  generate
110
111
  .command("update-schema")
@@ -112,15 +113,31 @@ generate
112
113
  .description("Generate a new zod update schema file for a prisma model")
113
114
  .option("-m, --module <name>", "Module name")
114
115
  .option("--model <name>", "Module name (alias for --module)")
115
- .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
116
+ .option("-p, --path <path>", "Custom path for schema", "src/modules/{{module-name}}")
116
117
  .action(generate_1.generateCommand.updateSchema);
118
+ generate
119
+ .command("schema")
120
+ .alias("sc")
121
+ .description("Generate a new zod create schema file for a prisma model")
122
+ .option("-m, --module <name>", "Module name")
123
+ .option("--model <name>", "Module name (alias for --module)")
124
+ .option("-p, --path <path>", "Custom path for schema", "src/modules/{{module-name}}")
125
+ .action(generate_1.generateCommand.baseSchema);
126
+ generate
127
+ .command("query-schema")
128
+ .alias("qs")
129
+ .description("Generate a new zod update schema file for a prisma model")
130
+ .option("-m, --module <name>", "Module name")
131
+ .option("--model <name>", "Module name (alias for --module)")
132
+ .option("-p, --path <path>", "Custom path for schema", "src/modules/{{module-name}}")
133
+ .action(generate_1.generateCommand.querySchema);
117
134
  generate
118
135
  .command("create-dto")
119
136
  .alias("cd")
120
137
  .description("Generate a new class-validator create dto file for a prisma model")
121
138
  .option("-m, --module <name>", "Module name")
122
139
  .option("--model <name>", "Module name (alias for --module)")
123
- .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
140
+ .option("-p, --path <path>", "Custom path for dto", "src/modules/{{module-name}}")
124
141
  .action(generate_1.generateCommand.createDto);
125
142
  generate
126
143
  .command("update-dto")
@@ -128,8 +145,24 @@ generate
128
145
  .description("Generate a new class-validator update dto file for a prisma model")
129
146
  .option("-m, --module <name>", "Module name")
130
147
  .option("--model <name>", "Module name (alias for --module)")
131
- .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
148
+ .option("-p, --path <path>", "Custom path for dto", "src/modules/{{module-name}}")
132
149
  .action(generate_1.generateCommand.updateDto);
150
+ generate
151
+ .command("dto")
152
+ .alias("d")
153
+ .description("Generate a new class-validator base dto file for a prisma model")
154
+ .option("-m, --module <name>", "Module name")
155
+ .option("--model <name>", "Module name (alias for --module)")
156
+ .option("-p, --path <path>", "Custom path for dto", "src/modules/{{module-name}}")
157
+ .action(generate_1.generateCommand.baseDto);
158
+ generate
159
+ .command("query-dto")
160
+ .alias("qd")
161
+ .description("Generate a new class-validator base dto file for a prisma model")
162
+ .option("-m, --module <name>", "Module name")
163
+ .option("--model <name>", "Module name (alias for --module)")
164
+ .option("-p, --path <path>", "Custom path for dto", "src/modules/{{module-name}}")
165
+ .action(generate_1.generateCommand.queryDto);
133
166
  program
134
167
  .command("prisma")
135
168
  .command("generate")
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[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,CACL,mBAAmB,EACnB,8BAA8B,EAC9B,wBAAwB,CACzB;KACA,MAAM,CAAC,4BAAuB,CAAC,CAAC;AAEnC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\nimport exportAuthActionCommand from \"./export-auth-action\";\n\nconst program = new Command();\n\nprogram.name(\"arkos\").description(\"Arkos.js CLI\").version(getVersion());\n\nprogram\n .command(\"build\")\n .description(\"Build your Arkos project\")\n .option(\"-m, --module <type>\", \"Module type (cjs or esm)\", \"cjs\")\n .action(buildCommand);\n\nprogram\n .command(\"dev\")\n .description(\"Run development server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(devCommand);\n\nprogram\n .command(\"start\")\n .description(\"Run production server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(startCommand);\n\nconst generate = program\n .command(\"generate\")\n .alias(\"g\")\n .description(\"Generate arkos components\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the controller\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the service\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for query options\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .alias(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new interceptors file\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for interceptors\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram\n .command(\"export\")\n .command(\"auth-action\")\n .description(\"Export file with an array containing all auth-actions\")\n .option(\"-o, --overwrite\", \"Overwrites all the changes on the object\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for auth-actions\",\n \"src/modules/auth/utils\"\n )\n .action(exportAuthActionCommand);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,mCAAuC;AAwQrB,6FAxQT,oBAAY,OAwQS;AAvQ9B,+BAAmC;AAuQH,2FAvQvB,gBAAU,OAuQuB;AAtQ1C,mCAAuC;AAsQK,6FAtQnC,oBA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,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\nimport exportAuthActionCommand from \"./export-auth-action\";\n\nconst program = new Command();\n\nprogram.name(\"arkos\").description(\"Arkos.js CLI\").version(getVersion());\n\nprogram\n .command(\"build\")\n .description(\"Build your Arkos project\")\n .option(\"-m, --module <type>\", \"Module type (cjs or esm)\", \"cjs\")\n .action(buildCommand);\n\nprogram\n .command(\"dev\")\n .description(\"Run development server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(devCommand);\n\nprogram\n .command(\"start\")\n .description(\"Run production server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(startCommand);\n\nconst generate = program\n .command(\"generate\")\n .alias(\"g\")\n .description(\"Generate arkos components\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the controller\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the service\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\"-a, --advanced\", \"Advanced code structure\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for query options\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .alias(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new interceptors file\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for interceptors\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for schema\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for schema\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"schema\")\n .alias(\"sc\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for schema\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.baseSchema);\n\ngenerate\n .command(\"query-schema\")\n .alias(\"qs\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for schema\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.querySchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for dto\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for dto\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateDto);\n\ngenerate\n .command(\"dto\")\n .alias(\"d\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for dto\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.baseDto);\n\ngenerate\n .command(\"query-dto\")\n .alias(\"qd\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .option(\"-m, --module <name>\", \"Module name\")\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for dto\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.queryDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram\n .command(\"export\")\n .command(\"auth-action\")\n .description(\"Export file with an array containing all auth-actions\")\n .option(\"-o, --overwrite\", \"Overwrites all the changes on the object\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for auth-actions\",\n \"src/modules/auth/utils\"\n )\n .action(exportAuthActionCommand);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.4.1-canary.8";
22
+ return "1.5.0-canary.2";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map