arkos 1.3.3-beta.1 → 1.3.3-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.
- package/dist/cjs/app.js +4 -39
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/modules/auth/auth.controller.js +0 -18
- package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
- package/dist/cjs/modules/auth/auth.router.js +0 -2
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +11 -49
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js +0 -108
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +14 -29
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +2 -2
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/router-validator.js +4 -1
- package/dist/cjs/modules/base/utils/router-validator.js.map +1 -1
- package/dist/cjs/modules/base/utils/service-hooks-manager.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.controller.js +0 -4
- package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.router.js +1 -3
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -2
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +3 -3
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +1 -2
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/cjs/server.js +0 -5
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/cli/prisma-generate.js +1 -1
- package/dist/cjs/utils/cli/prisma-generate.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js +4 -4
- package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js +6 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +2 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +10 -7
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/cjs/utils/dynamic-loader.js +2 -11
- package/dist/cjs/utils/dynamic-loader.js.map +1 -1
- package/dist/cjs/utils/features/api.features.js +6 -5
- package/dist/cjs/utils/features/api.features.js.map +1 -1
- package/dist/cjs/utils/helpers/deepmerge.helper.js.map +1 -1
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/cjs/utils/sheu.js +0 -11
- package/dist/cjs/utils/sheu.js.map +1 -1
- package/dist/esm/app.js +4 -6
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/modules/auth/auth.controller.js +0 -18
- package/dist/esm/modules/auth/auth.controller.js.map +1 -1
- package/dist/esm/modules/auth/auth.router.js +1 -3
- package/dist/esm/modules/auth/auth.router.js.map +1 -1
- package/dist/esm/modules/base/base.controller.js +11 -49
- package/dist/esm/modules/base/base.controller.js.map +1 -1
- package/dist/esm/modules/base/base.middlewares.js.map +1 -1
- package/dist/esm/modules/base/base.service.js +0 -108
- package/dist/esm/modules/base/base.service.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +15 -29
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +2 -2
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/esm/modules/base/utils/router-validator.js +4 -1
- package/dist/esm/modules/base/utils/router-validator.js.map +1 -1
- package/dist/esm/modules/base/utils/service-hooks-manager.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +0 -4
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +1 -3
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -2
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +3 -3
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +1 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/esm/server.js +0 -5
- package/dist/esm/server.js.map +1 -1
- package/dist/esm/types/arkos-config.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/cli/prisma-generate.js +1 -1
- package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js +4 -4
- package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js +6 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +2 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +7 -7
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/esm/utils/dynamic-loader.js +2 -11
- package/dist/esm/utils/dynamic-loader.js.map +1 -1
- package/dist/esm/utils/features/api.features.js +6 -5
- package/dist/esm/utils/features/api.features.js.map +1 -1
- package/dist/esm/utils/helpers/deepmerge.helper.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/esm/utils/sheu.js +0 -11
- package/dist/esm/utils/sheu.js.map +1 -1
- package/dist/types/modules/base/base.controller.d.ts +0 -2
- package/dist/types/modules/base/base.service.d.ts +0 -5
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +1 -3
- package/dist/types/modules/base/utils/service-hooks-manager.d.ts +1 -1
- package/dist/types/types/arkos-config.d.ts +0 -14
- package/dist/types/types/index.d.ts +0 -3
- package/dist/types/utils/dynamic-loader.d.ts +13 -33
- package/dist/types/utils/features/api.features.d.ts +1 -1
- package/dist/types/utils/sheu.d.ts +0 -8
- package/package.json +1 -1
- package/dist/cjs/modules/debugger/debugger.service.js +0 -82
- package/dist/cjs/modules/debugger/debugger.service.js.map +0 -1
- package/dist/cjs/modules/debugger/utils/loaded-components-logger.js +0 -55
- package/dist/cjs/modules/debugger/utils/loaded-components-logger.js.map +0 -1
- package/dist/esm/modules/debugger/debugger.service.js +0 -77
- package/dist/esm/modules/debugger/debugger.service.js.map +0 -1
- package/dist/esm/modules/debugger/utils/loaded-components-logger.js +0 -50
- package/dist/esm/modules/debugger/utils/loaded-components-logger.js.map +0 -1
- package/dist/types/modules/debugger/debugger.service.d.ts +0 -15
- package/dist/types/modules/debugger/utils/loaded-components-logger.d.ts +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\nimport { ModuleComponents } from \"../utils/dynamic-loader\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for 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 * 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 queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n /**\n * Helps in debugging some of the variables values that are used inside arkos from dynamic loaded components towhat is used into the generated api.\n *\n */\n debugging?: {\n /**\n * Controls debugging over HTTP request level\n */\n requests?: {\n level?: 0 | 1 | 2 | 3;\n filter?: (\n | \"Query\"\n | \"Body\"\n | \"TransformedQuery\"\n | \"ServiceArgs\"\n | \"FinalPrismaQueryArgs\"\n )[];\n };\n /**\n * Controls debugging over the dynamic loaded modules and it's components on app starting\n */\n dynamicLoader?: {\n /**\n * Adjusts logging details\n *\n * 1 - Loaded modules and list of it's components files\n * 2 - All from 1 and detailed inspection per module component\n * 3 - All from 1 and 2, plus the final router component after merged with autho generated router.\n */\n level?: 0 | 1 | 2 | 3;\n filters?: {\n /**\n * Allows filtering by specific modules.\n *\n * Supports only searching for the starting parts of the module name, e.g: If there is`user-profile`, `user`, `posts`, passing `[\"user\"]` will match both `user-profile` and `user`.\n */\n modules?: string[];\n /**\n * Allows filtering by component's names\n */\n components?: keyof ModuleComponents[];\n };\n };\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for 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 * 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 queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AA8LA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for Prisma query operations with flexible options\n * @template T - The Prisma model delegate type\n */\nexport type PrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n};\n\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n accessToken?: string;\n
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AA8LA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import {\n ErrorRequestHandler,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for Prisma query operations with flexible options\n * @template T - The Prisma model delegate type\n */\nexport type PrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n};\n\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n accessToken?: string;\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\nexport interface ArkosErrorRequestHandler extends ErrorRequestHandler {}\n"]}
|
|
@@ -115,6 +115,6 @@ export declare class BaseService<
|
|
|
115
115
|
fs_1.default.writeFileSync(filePath, content, {
|
|
116
116
|
encoding: "utf8",
|
|
117
117
|
});
|
|
118
|
-
sheu_1.default.done("Types for @prisma/client and
|
|
118
|
+
sheu_1.default.done("Types for @prisma/client and BaseService generated successfully!");
|
|
119
119
|
}
|
|
120
120
|
//# sourceMappingURL=prisma-generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":";;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"prisma-generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/prisma-generate.ts"],"names":[],"mappings":";;;;;AAOA,wCAmHC;AA1HD,0FAAgE;AAChE,wEAA2D;AAC3D,4CAAoB;AACpB,iDAAyC;AACzC,mDAA2B;AAC3B,gDAAwB;AAExB,SAAwB,qBAAqB;IACzC,MAAM,OAAO,GAAG;;;;;;EAMlB,8BAAkB,CAAC,MAAM,CAAC,GAAG,CAC3B,CAAC,KAAK,EAAE,EAAE,CACN;OACD,IAAA,+BAAS,EAAC,KAAK,CAAC,IAAI,CAAC;2BACD,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;+BACR,KAAK,CAAC,IAAI;gCACT,KAAK,CAAC,IAAI;6BACb,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;6BACd,KAAK,CAAC,IAAI;iCACN,KAAK,CAAC,IAAI;4BACf,KAAK,CAAC,IAAI;;CAErC,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EA,CAAC;IACE,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CACzB,SAAS,EACT,+CAA+C,CAClD,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IACH,cAAI,CAAC,IAAI,CACL,kEAAkE,CACrE,CAAC;AACN,CAAC","sourcesContent":["import prismaSchemaParser from \"../prisma/prisma-schema-parser\";\nimport { kebabCase } from \"../helpers/change-case.helpers\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport sheu from \"../sheu\";\nimport path from \"path\";\n\nexport default function prismaGenerateCommand() {\n const content = `\nimport { ModelGroupRelationFields } from \"./utils/helpers/base.service.helpers\";\nimport { ServiceBaseContext } from \"./types/base.service.types\";\nimport { Prisma } from \"@prisma/client\"\n\ndeclare type ModelsGetPayload<T extends Record<string, any>> = {\n${prismaSchemaParser.models.map(\n (model) =>\n `\n \"${kebabCase(model.name)}\": {\n Delegate: Prisma.${model.name}Delegate,\n GetPayload: Prisma.${model.name}GetPayload<T>,\n FindManyArgs: Prisma.${model.name}FindManyArgs,\n FindFirstArgs: Prisma.${model.name}FindFirstArgs,\n CreateArgs: Prisma.${model.name}CreateArgs,\n CreateManyArgs: Prisma.${model.name}CreateManyArgs,\n UpdateArgs: Prisma.${model.name}UpdateArgs,\n UpdateManyArgs: Prisma.${model.name}UpdateManyArgs,\n DeleteArgs: Prisma.${model.name}DeleteArgs,\n DeleteManyArgs: Prisma.${model.name}DeleteManyArgs,\n CountArgs: Prisma.${model.name}CountArgs\n }\n`\n)}\n}\n\nexport type ExtractFilters<T> = T extends { where?: infer W; [x: string]: any } ? W : any;\nexport type ExtractQueryOptions<T, K extends keyof T = never> = Omit<T, K>;\nexport type ExtractData<T> = T extends { data: infer D; [x: string]: any } ? D : any;\n\nexport declare class BaseService<\n TModelName extends keyof ModelsGetPayload<any>\n> {\n modelName: TModelName;\n relationFields: ModelGroupRelationFields;\n prisma: any;\n \n constructor(modelName: TModelName);\n \n createOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n createMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateManyArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n count<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CountArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['CountArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<number>;\n \n findMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindManyArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n \n findById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n id: string | number, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n findOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n \n updateOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n updateMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateManyArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n \n deleteOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n \n deleteMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteManyArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteManyArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n}\n`;\n execSync(\"npx prisma generate\", { stdio: \"inherit\" });\n\n const filePath = path.resolve(\n __dirname,\n `../../../types/modules/base/base.service.d.ts`\n );\n fs.writeFileSync(filePath, content, {\n encoding: \"utf8\",\n });\n sheu.done(\n \"Types for @prisma/client and BaseService generated successfully!\"\n );\n}\n"]}
|
|
@@ -32,22 +32,22 @@ const ${modelName.camel}AuthConfigs${typeAnnotation} = {
|
|
|
32
32
|
},
|
|
33
33
|
accessControl: {
|
|
34
34
|
// Create: {
|
|
35
|
-
// roles: [],
|
|
35
|
+
// roles: [], // only when using static authentication
|
|
36
36
|
// name: "Create ${(0, text_helpers_1.capitalize)(modelName.kebab.replaceAll("-", ""))}",
|
|
37
37
|
// description: "Permission to create new ${modelName.kebab.replaceAll("-", " ")} records"
|
|
38
38
|
// },
|
|
39
39
|
// Update: {
|
|
40
|
-
// roles: [],
|
|
40
|
+
// roles: [], // only when using static authentication
|
|
41
41
|
// name: "Update ${(0, text_helpers_1.capitalize)(modelName.kebab.replaceAll("-", ""))}",
|
|
42
42
|
// description: "Permission to update existing ${modelName.kebab.replaceAll("-", " ")} records"
|
|
43
43
|
// },
|
|
44
44
|
// Delete: {
|
|
45
|
-
// roles: [],
|
|
45
|
+
// roles: [], // only when using static authentication
|
|
46
46
|
// name: "Delete ${(0, text_helpers_1.capitalize)(modelName.kebab.replaceAll("-", ""))}",
|
|
47
47
|
// description: "Permission to delete ${modelName.kebab.replaceAll("-", " ")} records"
|
|
48
48
|
// },
|
|
49
49
|
// View: {
|
|
50
|
-
// roles: [],
|
|
50
|
+
// roles: [], // only when using static authentication
|
|
51
51
|
// name: "View ${(0, text_helpers_1.capitalize)(modelName.kebab.replaceAll("-", ""))}",
|
|
52
52
|
// description: "Permission to view ${modelName.kebab.replaceAll("-", " ")} records"
|
|
53
53
|
// },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-configs-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/auth-configs-template.ts"],"names":[],"mappings":";;AAIA,kEA2DC;AA/DD,+DAAsE;AACtE,mEAA8D;AAG9D,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAGrE,MAAM,OAAO,GAAG,YAAY;QAC1B,CAAC,CAAC,6CAA6C;QAC/C,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,GAAG,OAAO;;;eAGJ,SAAS,CAAC,KAAK;iDACmB,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;6CACnB,SAAS,CAAC,KAAK;;;QAGpD,SAAS,CAAC,KAAK,cAAc,cAAc;;;;;;;;;;yBAU1B,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;kDACtB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAI7D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;uDACjB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAIlE,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;8CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;uBAI3D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;4CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;;iBAK/D,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { capitalize } from \"../../../../helpers/text.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateAuthConfigsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for auth config template\");\n\n // Generate imports for TypeScript\n const imports = isTypeScript\n ? `import { AuthConfigs } from 'arkos/auth';\\n`\n : \"\";\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript ? `: AuthConfigs` : \"\";\n\n return `${imports}\nimport { authService } from \"arkos/services\";\n\nexport const ${modelName.camel}Permissions = {\n canCreate: authService.permission(\"Create\", \"${modelName.kebab}\"),\n canUpdate: authService.permission(\"Update\", \"${modelName.kebab}\"),\n canDelete: authService.permission(\"Delete\", \"${modelName.kebab}\"),\n canView: authService.permission(\"View\", \"${modelName.kebab}\"),\n}\n\nconst ${modelName.camel}AuthConfigs${typeAnnotation} = {\n authenticationControl: {\n Create: true,\n Update: true,\n Delete: true,\n View: true,\n },\n accessControl: {\n // Create: {\n // roles: []
|
|
1
|
+
{"version":3,"file":"auth-configs-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/auth-configs-template.ts"],"names":[],"mappings":";;AAIA,kEA2DC;AA/DD,+DAAsE;AACtE,mEAA8D;AAG9D,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAGrE,MAAM,OAAO,GAAG,YAAY;QAC1B,CAAC,CAAC,6CAA6C;QAC/C,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,GAAG,OAAO;;;eAGJ,SAAS,CAAC,KAAK;iDACmB,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;iDACf,SAAS,CAAC,KAAK;6CACnB,SAAS,CAAC,KAAK;;;QAGpD,SAAS,CAAC,KAAK,cAAc,cAAc;;;;;;;;;;yBAU1B,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;kDACtB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAI7D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;uDACjB,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;yBAIlE,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;8CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;uBAI3D,IAAA,yBAAU,EAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;4CAC1B,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;;;;;iBAK/D,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { capitalize } from \"../../../../helpers/text.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateAuthConfigsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for auth config template\");\n\n // Generate imports for TypeScript\n const imports = isTypeScript\n ? `import { AuthConfigs } from 'arkos/auth';\\n`\n : \"\";\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript ? `: AuthConfigs` : \"\";\n\n return `${imports}\nimport { authService } from \"arkos/services\";\n\nexport const ${modelName.camel}Permissions = {\n canCreate: authService.permission(\"Create\", \"${modelName.kebab}\"),\n canUpdate: authService.permission(\"Update\", \"${modelName.kebab}\"),\n canDelete: authService.permission(\"Delete\", \"${modelName.kebab}\"),\n canView: authService.permission(\"View\", \"${modelName.kebab}\"),\n}\n\nconst ${modelName.camel}AuthConfigs${typeAnnotation} = {\n authenticationControl: {\n Create: true,\n Update: true,\n Delete: true,\n View: true,\n },\n accessControl: {\n // Create: {\n // roles: [], // only when using static authentication\n // name: \"Create ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to create new ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Update: {\n // roles: [], // only when using static authentication\n // name: \"Update ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to update existing ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // Delete: {\n // roles: [], // only when using static authentication\n // name: \"Delete ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to delete ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n // View: {\n // roles: [], // only when using static authentication\n // name: \"View ${capitalize(modelName.kebab.replaceAll(\"-\", \"\"))}\",\n // description: \"Permission to view ${modelName.kebab.replaceAll(\"-\", \" \")} records\"\n // },\n },\n};\n\nexport default ${modelName.camel}AuthConfigs;\n`;\n}\n"]}
|
|
@@ -7,9 +7,13 @@ function generateControllerTemplate(options) {
|
|
|
7
7
|
throw new Error("Model name is required for controller template");
|
|
8
8
|
return `import { BaseController } from "${imports?.baseController || "arkos/controllers"}";
|
|
9
9
|
|
|
10
|
-
class ${modelName.pascal}Controller extends BaseController {
|
|
10
|
+
class ${modelName.pascal}Controller extends BaseController {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("${modelName.kebab}");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
const ${modelName.camel}Controller = new ${modelName.pascal}Controller(
|
|
16
|
+
const ${modelName.camel}Controller = new ${modelName.pascal}Controller();
|
|
13
17
|
|
|
14
18
|
export default ${modelName.camel}Controller;
|
|
15
19
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/controller-template.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"controller-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/controller-template.ts"],"names":[],"mappings":";;AAEA,gEAoBC;AApBD,SAAgB,0BAA0B,CAAC,OAAwB;IACjE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,OAAO,mCACL,OAAO,EAAE,cAAc,IAAI,mBAC7B;;QAEM,SAAS,CAAC,MAAM;;aAEX,SAAS,CAAC,KAAK;;;;QAIpB,SAAS,CAAC,KAAK,oBAAoB,SAAS,CAAC,MAAM;;iBAE1C,SAAS,CAAC,KAAK;GAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { TemplateOptions } from \"../../template-generators\";\n\nexport function generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \nclass ${modelName.pascal}Controller extends BaseController {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n}\n\nconst ${modelName.camel}Controller = new ${modelName.pascal}Controller();\n\nexport default ${modelName.camel}Controller;\n `;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ function generateHooksTemplate(options) {
|
|
|
7
7
|
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
8
8
|
const isTypeScript = ext === "ts";
|
|
9
9
|
if (!modelName)
|
|
10
|
-
throw new Error("
|
|
10
|
+
throw new Error("Model name is required for hooks template");
|
|
11
11
|
const baseImports = isTypeScript
|
|
12
12
|
? `// import {
|
|
13
13
|
// BeforeFindOneHookArgs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/hooks-template.ts"],"names":[],"mappings":";;AAIA,wCA6MC;AAjND,+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;;;OAIhE,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;OAIzE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;;CAEhF,CAAC;IAEA,OAAO,GAAG,WAAW;;YAEX,SAAS,CAAC,KAAK,gBAAgB,aAAa;;EAEtD,KAAK,EAAE,CAAC;AACV,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\n// Main function to generate hooks template based on provided options\nexport default function generateHooksTemplate(\n options: TemplateOptions\n): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName) throw new Error(\"Module name is required for hooks template\");\n\n const baseImports = isTypeScript\n ? `// import { \n// BeforeFindOneHookArgs, \n// AfterFindOneHookArgs, \n// BeforeUpdateOneHookArgs, \n// AfterUpdateOneHookArgs,\n// BeforeCreateOneHookArgs,\n// AfterCreateOneHookArgs,\n// BeforeCreateManyHookArgs,\n// AfterCreateManyHookArgs,\n// BeforeCountHookArgs,\n// AfterCountHookArgs,\n// BeforeFindManyHookArgs,\n// AfterFindManyHookArgs,\n// BeforeUpdateManyHookArgs,\n// AfterUpdateManyHookArgs,\n// BeforeDeleteOneHookArgs,\n// AfterDeleteOneHookArgs,\n// BeforeDeleteManyHookArgs,\n// AfterDeleteManyHookArgs,\n// OnCreateOneErrorHookArgs,\n// OnCreateManyErrorHookArgs,\n// OnCountErrorHookArgs,\n// OnFindManyErrorHookArgs,\n// OnFindByIdErrorHookArgs,\n// OnFindOneErrorHookArgs,\n// OnUpdateOneErrorHookArgs,\n// OnUpdateManyErrorHookArgs,\n// OnDeleteOneErrorHookArgs,\n// OnDeleteManyErrorHookArgs\n// } from \"arkos/services\";`\n : ``;\n\n const serviceImport = `\"./${modelName.kebab}.service${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n const getHookArgsType = (hookName: string) => {\n if (!isTypeScript) return \"\";\n\n const typeMap: Record<string, string> = {\n beforeFindOne: `BeforeFindOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterFindOne: `AfterFindOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeUpdateOne: `BeforeUpdateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterUpdateOne: `AfterUpdateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCreateOne: `BeforeCreateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCreateOne: `AfterCreateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCreateMany: `BeforeCreateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCreateMany: `AfterCreateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCount: `BeforeCountHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCount: `AfterCountHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeFindMany: `BeforeFindManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterFindMany: `AfterFindManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeUpdateMany: `BeforeUpdateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterUpdateMany: `AfterUpdateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeDeleteOne: `BeforeDeleteOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterDeleteOne: `AfterDeleteOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeDeleteMany: `BeforeDeleteManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterDeleteMany: `AfterDeleteManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n // Error hook types\n onCreateOneError: `OnCreateOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onCreateManyError: `OnCreateManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onCountError: `OnCountErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindManyError: `OnFindManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindByIdError: `OnFindByIdErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindOneError: `OnFindOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onUpdateOneError: `OnUpdateOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onUpdateManyError: `OnUpdateManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onDeleteOneError: `OnDeleteOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onDeleteManyError: `OnDeleteManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n };\n\n return typeMap[hookName];\n };\n\n const generateHookFunction = (hookName: string, params: string[]) => {\n const argsType = getHookArgsType(hookName);\n const args = isTypeScript\n ? `{ ${params.join(\", \")} }: ${argsType}`\n : `{ ${params.join(\", \")} }`;\n return `async function (${args}) {}`;\n };\n\n const hooks = `\n// export const beforeFindOne = [\n// ${generateHookFunction(\"beforeFindOne\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindOne = [\n// ${generateHookFunction(\"afterFindOne\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindOneError = [\n// ${generateHookFunction(\"onFindOneError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateOne = [\n// ${generateHookFunction(\"beforeUpdateOne\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateOne = [\n// ${generateHookFunction(\"afterUpdateOne\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateOneError = [\n// ${generateHookFunction(\"onUpdateOneError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateOne = [\n// ${generateHookFunction(\"beforeCreateOne\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateOne = [\n// ${generateHookFunction(\"afterCreateOne\", [\"context\", \"result\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onCreateOneError = [\n// ${generateHookFunction(\"onCreateOneError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateMany = [\n// ${generateHookFunction(\"beforeCreateMany\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateMany = [\n// ${generateHookFunction(\"afterCreateMany\", [\"context\", \"result\", \"queryOptions\"])}\n// ];\n\n// export const onCreateManyError = [\n// ${generateHookFunction(\"onCreateManyError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCount = [\n// ${generateHookFunction(\"beforeCount\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterCount = [\n// ${generateHookFunction(\"afterCount\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onCountError = [\n// ${generateHookFunction(\"onCountError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeFindMany = [\n// ${generateHookFunction(\"beforeFindMany\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindMany = [\n// ${generateHookFunction(\"afterFindMany\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindManyError = [\n// ${generateHookFunction(\"onFindManyError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateMany = [\n// ${generateHookFunction(\"beforeUpdateMany\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateMany = [\n// ${generateHookFunction(\"afterUpdateMany\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateManyError = [\n// ${generateHookFunction(\"onUpdateManyError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeDeleteOne = [\n// ${generateHookFunction(\"beforeDeleteOne\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteOne = [\n// ${generateHookFunction(\"afterDeleteOne\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteOneError = [\n// ${generateHookFunction(\"onDeleteOneError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeDeleteMany = [\n// ${generateHookFunction(\"beforeDeleteMany\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteMany = [\n// ${generateHookFunction(\"afterDeleteMany\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteManyError = [\n// ${generateHookFunction(\"onDeleteManyError\", [\"context\", \"error\", \"filters\"])}\n// ];\n`;\n\n return `${baseImports}\n// import { Prisma } from \"@prisma/client\"\n// import ${modelName.camel}Service from ${serviceImport}\n\n${hooks}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hooks-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/hooks-template.ts"],"names":[],"mappings":";;AAMA,wCA8NC;AAnOD,+DAAsE;AAKtE,SAAwB,qBAAqB,CAC3C,OAAwB;IAGxB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IAEnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAGlC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAG7E,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA6BsB;QACxB,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,KAAK,WAAW,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC;IAGzF,MAAM,eAAe,GAAG,CAAC,QAAgB,E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AAC;;;;OAIxF,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;;;;OAIxF,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;;;;OAIjG,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;;;;OAIlG,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;;;;OAI/D,oBAAoB,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;OAIxE,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;;;;OAIzE,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;;;;OAIhE,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;OAIzE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;;CAEhF,CAAC;IAGA,OAAO,GAAG,WAAW;;YAEX,SAAS,CAAC,KAAK,gBAAgB,aAAa;;EAEtD,KAAK,EAAE,CAAC;AACV,CAAC","sourcesContent":["// Import helper function to get user's file extension preference\nimport { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\n// Import template options interface\nimport { TemplateOptions } from \"../../template-generators\";\n\n// Main function to generate hooks template based on provided options\nexport default function generateHooksTemplate(\n options: TemplateOptions\n): string {\n // Destructure modelName from options\n const { modelName } = options;\n // Get user's preferred file extension (ts or js)\n const ext = getUserFileExtension();\n // Check if user is using TypeScript\n const isTypeScript = ext === \"ts\";\n\n // Throw error if modelName is not provided\n if (!modelName) throw new Error(\"Model name is required for hooks template\");\n\n // Define base imports for TypeScript - includes all hook argument types\n const baseImports = isTypeScript\n ? `// import { \n// BeforeFindOneHookArgs, \n// AfterFindOneHookArgs, \n// BeforeUpdateOneHookArgs, \n// AfterUpdateOneHookArgs,\n// BeforeCreateOneHookArgs,\n// AfterCreateOneHookArgs,\n// BeforeCreateManyHookArgs,\n// AfterCreateManyHookArgs,\n// BeforeCountHookArgs,\n// AfterCountHookArgs,\n// BeforeFindManyHookArgs,\n// AfterFindManyHookArgs,\n// BeforeUpdateManyHookArgs,\n// AfterUpdateManyHookArgs,\n// BeforeDeleteOneHookArgs,\n// AfterDeleteOneHookArgs,\n// BeforeDeleteManyHookArgs,\n// AfterDeleteManyHookArgs,\n// OnCreateOneErrorHookArgs,\n// OnCreateManyErrorHookArgs,\n// OnCountErrorHookArgs,\n// OnFindManyErrorHookArgs,\n// OnFindByIdErrorHookArgs,\n// OnFindOneErrorHookArgs,\n// OnUpdateOneErrorHookArgs,\n// OnUpdateManyErrorHookArgs,\n// OnDeleteOneErrorHookArgs,\n// OnDeleteManyErrorHookArgs\n// } from \"arkos/services\";`\n : ``;\n\n // Define service import path based on file extension\n const serviceImport = `\"./${modelName.kebab}.service${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n // Function to get the appropriate TypeScript type for each hook\n const getHookArgsType = (hookName: string) => {\n // Return empty string for JavaScript\n if (!isTypeScript) return \"\";\n\n // Map hook names to their corresponding TypeScript types\n const typeMap: Record<string, string> = {\n beforeFindOne: `BeforeFindOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterFindOne: `AfterFindOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeUpdateOne: `BeforeUpdateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterUpdateOne: `AfterUpdateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCreateOne: `BeforeCreateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCreateOne: `AfterCreateOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCreateMany: `BeforeCreateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCreateMany: `AfterCreateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeCount: `BeforeCountHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterCount: `AfterCountHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeFindMany: `BeforeFindManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterFindMany: `AfterFindManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeUpdateMany: `BeforeUpdateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterUpdateMany: `AfterUpdateManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeDeleteOne: `BeforeDeleteOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterDeleteOne: `AfterDeleteOneHookArgs<Prisma.${modelName.pascal}Delegate>`,\n beforeDeleteMany: `BeforeDeleteManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n afterDeleteMany: `AfterDeleteManyHookArgs<Prisma.${modelName.pascal}Delegate>`,\n // Error hook types\n onCreateOneError: `OnCreateOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onCreateManyError: `OnCreateManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onCountError: `OnCountErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindManyError: `OnFindManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindByIdError: `OnFindByIdErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onFindOneError: `OnFindOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onUpdateOneError: `OnUpdateOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onUpdateManyError: `OnUpdateManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onDeleteOneError: `OnDeleteOneErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n onDeleteManyError: `OnDeleteManyErrorHookArgs<Prisma.${modelName.pascal}Delegate>`,\n };\n\n // Return the corresponding type for the hook name\n return typeMap[hookName];\n };\n\n // Function to generate a hook function with proper TypeScript types\n const generateHookFunction = (hookName: string, params: string[]) => {\n // Get the TypeScript type for this hook\n const argsType = getHookArgsType(hookName);\n // Create function parameters with or without TypeScript types\n const args = isTypeScript\n ? `{ ${params.join(\", \")} }: ${argsType}`\n : `{ ${params.join(\", \")} }`;\n\n // Return the complete function definition\n return `async function (${args}) {}`;\n };\n\n // Generate all hook exports with their respective functions\n const hooks = `\n// export const beforeFindOne = [\n// ${generateHookFunction(\"beforeFindOne\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindOne = [\n// ${generateHookFunction(\"afterFindOne\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindOneError = [\n// ${generateHookFunction(\"onFindOneError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateOne = [\n// ${generateHookFunction(\"beforeUpdateOne\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateOne = [\n// ${generateHookFunction(\"afterUpdateOne\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateOneError = [\n// ${generateHookFunction(\"onUpdateOneError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateOne = [\n// ${generateHookFunction(\"beforeCreateOne\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateOne = [\n// ${generateHookFunction(\"afterCreateOne\", [\"context\", \"result\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onCreateOneError = [\n// ${generateHookFunction(\"onCreateOneError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateMany = [\n// ${generateHookFunction(\"beforeCreateMany\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateMany = [\n// ${generateHookFunction(\"afterCreateMany\", [\"context\", \"result\", \"queryOptions\"])}\n// ];\n\n// export const onCreateManyError = [\n// ${generateHookFunction(\"onCreateManyError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCount = [\n// ${generateHookFunction(\"beforeCount\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterCount = [\n// ${generateHookFunction(\"afterCount\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onCountError = [\n// ${generateHookFunction(\"onCountError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeFindMany = [\n// ${generateHookFunction(\"beforeFindMany\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindMany = [\n// ${generateHookFunction(\"afterFindMany\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindManyError = [\n// ${generateHookFunction(\"onFindManyError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateMany = [\n// ${generateHookFunction(\"beforeUpdateMany\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateMany = [\n// ${generateHookFunction(\"afterUpdateMany\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateManyError = [\n// ${generateHookFunction(\"onUpdateManyError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeDeleteOne = [\n// ${generateHookFunction(\"beforeDeleteOne\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteOne = [\n// ${generateHookFunction(\"afterDeleteOne\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteOneError = [\n// ${generateHookFunction(\"onDeleteOneError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeDeleteMany = [\n// ${generateHookFunction(\"beforeDeleteMany\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteMany = [\n// ${generateHookFunction(\"afterDeleteMany\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteManyError = [\n// ${generateHookFunction(\"onDeleteManyError\", [\"context\", \"error\", \"filters\"])}\n// ];\n`;\n\n // Return the complete template with imports, exports, and hook functions\n return `${baseImports}\n// import { Prisma } from \"@prisma/client\"\n// import ${modelName.camel}Service from ${serviceImport}\n\n${hooks}`;\n}\n"]}
|
|
@@ -109,6 +109,8 @@ function generateMiddlewaresTemplate(options) {
|
|
|
109
109
|
// next();
|
|
110
110
|
// }]
|
|
111
111
|
|
|
112
|
+
// There is not afterFindFile: because the main handler is handleded by express.static()
|
|
113
|
+
|
|
112
114
|
// export const onFindFileError =
|
|
113
115
|
// [async (${errorFunctionParams}) => {
|
|
114
116
|
// next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/middlewares-template.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"middlewares-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/middlewares-template.ts"],"names":[],"mappings":";;AAGA,kEAsSC;AAzSD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;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GD,OAAO,GAAG,WAAW;;;eAGR,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;;;eAKnB,cAAc;;;;;eAKd,cAAc;;;;;eAKd,mBAAmB;;;CAGjC,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Module name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n // Generate imports based on TypeScript/JavaScript\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";`\n : ``;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n const errorFunctionParams = isTypeScript\n ? `err: any, req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `err, req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterGetMe = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onGetMeError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogin = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLoginError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterLogout = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onLogoutError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeSignup = \n// [async (${functionParams}) => {\n// }]\n\n// export const afterSignup = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onSignupError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdatePassword = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdatePasswordError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindF]ile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// There is not afterFindFile: because the main handler is handleded by express.static()\n\n// export const onFindFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUploadFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUploadFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteFile = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteFileError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n }\n\n // Regular model interceptors\n return `${baseImports}\n\n// export const beforeCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterFindMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onFindManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteOne = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteOneError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterCreateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onCreateManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterUpdateMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onUpdateManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n\n// export const beforeDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const afterDeleteMany = \n// [async (${functionParams}) => {\n// next();\n// }]\n\n// export const onDeleteManyError =\n// [async (${errorFunctionParams}) => {\n// next();\n// }]\n`;\n}\n"]}
|
|
@@ -8,7 +8,7 @@ function generateQueryOptionsTemplate(options) {
|
|
|
8
8
|
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
9
9
|
const isTypeScript = ext === "ts";
|
|
10
10
|
if (!modelName)
|
|
11
|
-
throw new Error("
|
|
11
|
+
throw new Error("Model name is required for query config template");
|
|
12
12
|
const imports = isAuth
|
|
13
13
|
? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
|
|
14
14
|
: `import { PrismaQueryOptions } from 'arkos/prisma'`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-options-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/query-options-template.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"query-options-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/query-options-template.ts"],"names":[],"mappings":";;AAGA,oEAmEC;AAtED,+DAAsE;AAGtE,SAAgB,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAGtE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAGxD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;;;;;;;iBAmBnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n // Generate imports\n const imports = isAuth\n ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`\n : `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : \"\";\n\n // Generate prisma import if TypeScript\n const prismaImport = isTypeScript\n ? `import prisma from \"../../utils/prisma\";\\n`\n : \"\";\n\n if (isAuth) {\n // Auth template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n // Regular template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n global: {},\n find: {},\n findOne: {},\n findMany: {},\n update: {},\n updateMany: {},\n updateOne: {},\n create: {},\n createMany: {},\n createOne: {},\n save: {},\n saveMany: {},\n saveOne: {},\n delete: {},\n deleteMany: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.generateRouterTemplate = generateRouterTemplate;
|
|
7
|
+
const pluralize_1 = __importDefault(require("pluralize"));
|
|
4
8
|
const fs_helpers_1 = require("../../../../helpers/fs.helpers");
|
|
5
9
|
function generateRouterTemplate(options) {
|
|
6
10
|
const { modelName, imports } = options;
|
|
@@ -14,14 +18,13 @@ function generateRouterTemplate(options) {
|
|
|
14
18
|
const controllerImportLine = controllerExists
|
|
15
19
|
? `import ${modelName.camel}Controller from "${imports?.controller ||
|
|
16
20
|
`./${modelName.kebab}.controller${ext === "js" ? "." + "js" : ""}`}"`
|
|
17
|
-
:
|
|
21
|
+
: `// import ${modelName.camel}Controller from "${imports?.controller ||
|
|
18
22
|
`./${modelName.kebab}.controller${ext === "js" ? "." + "js" : ""}`}"`;
|
|
19
23
|
const controllerHandlerLine = controllerExists
|
|
20
|
-
?
|
|
21
|
-
:
|
|
24
|
+
? ` ${modelName.camel}Controller.someHandler`
|
|
25
|
+
: ` // ${modelName.camel}Controller.someHandler`;
|
|
22
26
|
return `import { Router } from 'express'
|
|
23
27
|
import { authService } from 'arkos/services'
|
|
24
|
-
import { catchAsync } from 'arkos/error-handler'
|
|
25
28
|
${controllerImportLine}
|
|
26
29
|
${routerConfigTsTypeImport}
|
|
27
30
|
|
|
@@ -29,11 +32,11 @@ export const config${routerConfigTsType} = { }
|
|
|
29
32
|
|
|
30
33
|
const ${modelName.camel}Router = Router()
|
|
31
34
|
|
|
32
|
-
${modelName.camel}Router.
|
|
33
|
-
'/custom-endpoint',
|
|
35
|
+
${modelName.camel}Router.post(
|
|
36
|
+
'/custom-endpoint', // resolves to /api/${(0, pluralize_1.default)(modelName.kebab)}/custom-endpoint
|
|
34
37
|
authService.authenticate,
|
|
35
38
|
authService.handleAccessControl('CustomAction', '${modelName.kebab}'),
|
|
36
|
-
|
|
39
|
+
${controllerHandlerLine}
|
|
37
40
|
)
|
|
38
41
|
|
|
39
42
|
export default ${modelName.camel}Router
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/router-template.ts"],"names":[],"mappings":";;;;;AAOA,wDAkDC;AAzDD,0DAAkC;AAClC,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG;QACL,CAAC,CAAC,aAAa,SAAS,CAAC,KAAK,oBAC1B,OAAO,EAAE,UAAU;YACnB,KAAK,SAAS,CAAC,KAAK,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAClE,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,wBAAwB;QAC9C,CAAC,CAAC,QAAQ,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEpD,OAAO;;EAEP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;4CAC2B,IAAA,mBAAS,EACjD,SAAS,CAAC,KAAK,CAChB;;qDAEkD,SAAS,CAAC,KAAK;EAClE,qBAAqB;;;iBAGN,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n // Check if controller file exists\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`\n : `// import ${modelName.camel}Controller from \"${\n imports?.controller ||\n `./${modelName.kebab}.controller${ext === \"js\" ? \".\" + \"js\" : \"\"}`\n }\"`;\n\n const controllerHandlerLine = controllerExists\n ? ` ${modelName.camel}Controller.someHandler`\n : ` // ${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.post(\n '/custom-endpoint', // resolves to /api/${pluralize(\n modelName.kebab\n )}/custom-endpoint\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
|