arkos 1.3.6-canary.2 → 1.3.7-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/app.js +1 -1
  2. package/dist/cjs/app.js.map +1 -1
  3. package/dist/cjs/modules/auth/auth.controller.js +1 -17
  4. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  5. package/dist/cjs/modules/auth/auth.service.js +27 -0
  6. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  7. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  8. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +22 -6
  9. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  10. package/dist/cjs/modules/debugger/debugger.service.js +11 -4
  11. package/dist/cjs/modules/debugger/debugger.service.js.map +1 -1
  12. package/dist/cjs/modules/error-handler/error-handler.controller.js +6 -1
  13. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  14. package/dist/cjs/modules/file-upload/file-upload.router.js +2 -2
  15. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  16. package/dist/cjs/modules/file-upload/file-upload.service.js +27 -26
  17. package/dist/cjs/modules/file-upload/file-upload.service.js.map +1 -1
  18. package/dist/cjs/modules/swagger/swagger.router.js +6 -2
  19. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  20. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -1
  21. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  22. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +419 -0
  23. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -0
  24. package/dist/cjs/utils/cli/start.js +3 -2
  25. package/dist/cjs/utils/cli/start.js.map +1 -1
  26. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  27. package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
  28. package/dist/esm/app.js +1 -1
  29. package/dist/esm/app.js.map +1 -1
  30. package/dist/esm/modules/auth/auth.controller.js +2 -18
  31. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  32. package/dist/esm/modules/auth/auth.service.js +27 -0
  33. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  34. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  35. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +22 -6
  36. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
  37. package/dist/esm/modules/debugger/debugger.service.js +11 -4
  38. package/dist/esm/modules/debugger/debugger.service.js.map +1 -1
  39. package/dist/esm/modules/error-handler/error-handler.controller.js +6 -1
  40. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  41. package/dist/esm/modules/file-upload/file-upload.router.js +2 -2
  42. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  43. package/dist/esm/modules/file-upload/file-upload.service.js +26 -25
  44. package/dist/esm/modules/file-upload/file-upload.service.js.map +1 -1
  45. package/dist/esm/modules/swagger/swagger.router.js +6 -2
  46. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  47. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -1
  48. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  49. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +413 -0
  50. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -0
  51. package/dist/esm/utils/cli/start.js +3 -2
  52. package/dist/esm/utils/cli/start.js.map +1 -1
  53. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  54. package/dist/esm/utils/dotenv.helpers.js.map +1 -1
  55. package/dist/types/modules/auth/auth.service.d.ts +6 -0
  56. package/dist/types/modules/debugger/debugger.service.d.ts +1 -1
  57. package/dist/types/modules/file-upload/file-upload.service.d.ts +22 -0
  58. package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +3 -0
  59. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"get-authentication-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-authentication-json-schema-paths.ts"],"names":[],"mappings":";;;AA8BA,mDA4UC;AAzWD,qEAGkC;AAElC,qEAAuE;AACvE,yFAAqF;AAE9E,MAAM,aAAa,GAAG,KAAK,EAChC,MAAc,EACd,WAAwB,EACuB,EAAE;IACjD,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC;IAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;IAE7C,IAAI,CAAC,WAAW;QAAE,OAAO,QAAQ,CAAC;IAClC,IAAI,QAAQ;QAAE,OAAO,WAAW,CAAC;IAEjC,MAAM,SAAS,GAAG,MAAa,CAAC;IAChC,MAAM,eAAe,GAAG,MAAM,IAAA,iDAAwB,EACpD,SAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAC;IAEF,IAAI,CAAC,eAAe;QAAE,OAAO,QAAQ,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAnBW,QAAA,aAAa,iBAmBxB;AAEa,KAAK,UAAU,gCAAgC,CAC5D,WAAwB;IAExB,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI;QAAE,OAAO,KAAK,CAAC;IAE7C,MAAM,oBAAoB,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,oBAAoB,EAAE,MAAM;QAC/C,EAAE,MAA8B,CAAC;IAEnC,IAAI,YAAY,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAEjD,MAAM,sBAAsB,GAAG,CAAC,QAAgB,EAAW,EAAE;QAC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AC,gBAAgB,CAAC;gBACxB,OAAO,EAAE,gCAAgC;gBACzC,WAAW,EACT,0EAA0E;gBAC5E,WAAW,EAAE,oBAAoB;gBACjC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;gBAC9B,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,WAAW,EAAE,qCAAqC;wBAClD,OAAO,EAAE;4BACP,kBAAkB,EAAE;gCAClB,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;oCACd,UAAU,EAAE;wCACV,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;4CACd,WAAW,EAAE,8BAA8B;yCAC5C;wCACD,OAAO,EAAE;4CACP,IAAI,EAAE,QAAQ;4CACd,WAAW,EAAE,iCAAiC;yCAC/C;wCACD,IAAI,EAAE;4CACJ,IAAI,EAAE,OAAO;4CACb,KAAK,EAAE;gDACL,IAAI,EAAE,qDAAqD;6CAC5D;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;oBACD,KAAK,EAAE;wBACL,WAAW,EAAE,yBAAyB;qBACvC;oBACD,KAAK,EAAE;wBACL,WAAW,EAAE,0BAA0B;qBACxC;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport {\n getSchemaRef,\n localValidatorFileExists,\n} from \"./swagger.router.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../../../../exports\";\nimport { getModuleComponents } from \"../../../../utils/dynamic-loader\";\nimport { isEndpointDisabled } from \"../../../base/utils/helpers/base.router.helpers\";\n\nexport const getSchemaMode = async (\n action: string,\n arkosConfig: ArkosConfig\n): Promise<\"prisma\" | \"zod\" | \"class-validator\"> => {\n const swaggerMode = arkosConfig.swagger?.mode;\n const isStrict = arkosConfig.swagger?.strict;\n\n if (!swaggerMode) return \"prisma\";\n if (isStrict) return swaggerMode;\n\n const actionKey = action as any;\n const localFileExists = await localValidatorFileExists(\n actionKey,\n \"user\",\n arkosConfig\n );\n\n if (!localFileExists) return \"prisma\";\n return swaggerMode;\n};\n\nexport default async function getAuthenticationJsonSchemaPaths(\n arkosConfig: ArkosConfig\n) {\n const paths: OpenAPIV3.PathsObject = {};\n\n if (!arkosConfig.swagger?.mode) return paths;\n\n const AuthModuleComponents = getModuleComponents(\"auth\");\n const routerConfig = AuthModuleComponents?.router\n ?.config as RouterConfig<\"auth\">;\n\n if (routerConfig?.disable === true) return paths;\n\n const isAuthEndpointDisabled = (endpoint: string): boolean => {\n return isEndpointDisabled(routerConfig, endpoint as any);\n };\n\n if (!isAuthEndpointDisabled(\"login\")) {\n const loginMode = await getSchemaMode(\"login\", arkosConfig);\n paths[\"/api/auth/login\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Login to the system\",\n description: \"Authenticates a user and returns an access token\",\n operationId: \"login\",\n requestBody: {\n description: \"User credentials\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Login\", loginMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Login successful\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n accessToken: {\n type: \"string\",\n description: \"JWT access token\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Invalid credentials\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"logout\")) {\n paths[\"/api/auth/logout\"] = {\n delete: {\n tags: [\"Authentication\"],\n summary: \"Logout from the system\",\n description: \"Invalidates the current user's JWT token\",\n operationId: \"logout\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"204\": {\n description: \"Logout successful\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"signup\")) {\n const signupMode = await getSchemaMode(\"signup\", arkosConfig);\n const userMode = await getSchemaMode(\"user\", arkosConfig);\n paths[\"/api/auth/signup\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Register a new user\",\n description: \"Creates a new user account\",\n operationId: \"signup\",\n requestBody: {\n description: \"User registration data\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Signup\", signupMode),\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: \"User created successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", userMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"409\": {\n description: \"User already exists\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"updatePassword\")) {\n const updatePasswordMode = await getSchemaMode(\n \"updatePassword\",\n arkosConfig\n );\n paths[\"/api/auth/update-password\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Update user password\",\n description: \"Changes the password for the authenticated user\",\n operationId: \"updatePassword\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"Current and new password\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdatePassword\", updatePasswordMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Password updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n status: {\n type: \"string\",\n example: \"success\",\n },\n message: {\n type: \"string\",\n example: \"Password updated successfully!\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data or current password incorrect\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"getMe\")) {\n const findMeMode = await getSchemaMode(\"getMe\", arkosConfig);\n paths[\"/api/users/me\"] = {\n get: {\n tags: [\"Authentication\"],\n summary: \"Get current user information\",\n description:\n \"Retrieves information about the currently authenticated user\",\n operationId: \"getMe\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"User information retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"GetMe\", findMeMode),\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"updateMe\")) {\n const updateMeMode = await getSchemaMode(\"updateMe\", arkosConfig);\n const userMode = await getSchemaMode(\"user\", arkosConfig);\n if (!paths[\"/api/users/me\"]) paths[\"/api/users/me\"] = {};\n paths[\"/api/users/me\"]!.patch = {\n tags: [\"Authentication\"],\n summary: \"Update current user information\",\n description: \"Updates information for the currently authenticated user\",\n operationId: \"updateMe\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"User data to update\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdateMe\", updateMeMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"User updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", userMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"deleteMe\")) {\n if (!paths[\"/api/users/me\"]) paths[\"/api/users/me\"] = {};\n paths[\"/api/users/me\"]!.delete = {\n tags: [\"Authentication\"],\n summary: \"Delete current user account\",\n description: \"Marks the current user's account as deleted\",\n operationId: \"deleteMe\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"Account deleted successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n message: {\n type: \"string\",\n example: \"Account deleted successfully\",\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"findManyAuthAction\")) {\n paths[\"/api/auth-actions\"] = {\n get: {\n tags: [\"Authentication\"],\n summary: \"Get all authentication actions\",\n description:\n \"Retrieves a list of all available authentication actions and permissions\",\n operationId: \"findManyAuthAction\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"Auth actions retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n total: {\n type: \"number\",\n description: \"Total number of auth actions\",\n },\n results: {\n type: \"number\",\n description: \"Number of auth actions returned\",\n },\n data: {\n type: \"array\",\n items: {\n $ref: \"#/components/schemas/FindManyAuthActionSystemSchema\",\n },\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n },\n },\n };\n }\n\n return paths;\n}\n"]}
1
+ {"version":3,"file":"get-authentication-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-authentication-json-schema-paths.ts"],"names":[],"mappings":";;;AA8BA,mDA4UC;AAzWD,qEAGkC;AAElC,qEAAuE;AACvE,yFAAqF;AAE9E,MAAM,aAAa,GAAG,KAAK,EAChC,MAAc,EACd,WAAwB,EACuB,EAAE;IACjD,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC;IAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;IAE7C,IAAI,CAAC,WAAW;QAAE,OAAO,QAAQ,CAAC;IAClC,IAAI,QAAQ;QAAE,OAAO,WAAW,CAAC;IAEjC,MAAM,SAAS,GAAG,MAAa,CAAC;IAChC,MAAM,eAAe,GAAG,MAAM,IAAA,iDAAwB,EACpD,SAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAC;IAEF,IAAI,CAAC,eAAe;QAAE,OAAO,QAAQ,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAnBW,QAAA,aAAa,iBAmBxB;AAEa,KAAK,UAAU,gCAAgC,CAC5D,WAAwB;IAExB,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI;QAAE,OAAO,KAAK,CAAC;IAE7C,MAAM,oBAAoB,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;IACzD,MAAM,YAA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yBAAyB;iBACvC;aACF;SACF,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAClD,KAAK,CAAC,mBAAmB,CAAC,GAAG;YAC3B,GAAG,EAAE;gBACH,IAAI,EAAE,CAAC,gBAAgB,CAAC;gBACxB,OAAO,EAAE,gCAAgC;gBACzC,WAAW,EACT,0EAA0E;gBAC5E,WAAW,EAAE,oBAAoB;gBACjC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;gBAC9B,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,WAAW,EAAE,qCAAqC;wBAClD,OAAO,EAAE;4BACP,kBAAkB,EAAE;gCAClB,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;oCACd,UAAU,EAAE;wCACV,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;4CACd,WAAW,EAAE,8BAA8B;yCAC5C;wCACD,OAAO,EAAE;4CACP,IAAI,EAAE,QAAQ;4CACd,WAAW,EAAE,iCAAiC;yCAC/C;wCACD,IAAI,EAAE;4CACJ,IAAI,EAAE,OAAO;4CACb,KAAK,EAAE;gDACL,IAAI,EAAE,qDAAqD;6CAC5D;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;oBACD,KAAK,EAAE;wBACL,WAAW,EAAE,yBAAyB;qBACvC;oBACD,KAAK,EAAE;wBACL,WAAW,EAAE,0BAA0B;qBACxC;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport {\n getSchemaRef,\n localValidatorFileExists,\n} from \"./swagger.router.helpers\";\nimport { ArkosConfig, RouterConfig } from \"../../../../exports\";\nimport { getModuleComponents } from \"../../../../utils/dynamic-loader\";\nimport { isEndpointDisabled } from \"../../../base/utils/helpers/base.router.helpers\";\n\nexport const getSchemaMode = async (\n action: string,\n arkosConfig: ArkosConfig\n): Promise<\"prisma\" | \"zod\" | \"class-validator\"> => {\n const swaggerMode = arkosConfig.swagger?.mode;\n const isStrict = arkosConfig.swagger?.strict;\n\n if (!swaggerMode) return \"prisma\";\n if (isStrict) return swaggerMode;\n\n const actionKey = action as any;\n const localFileExists = await localValidatorFileExists(\n actionKey,\n \"auth\",\n arkosConfig\n );\n\n if (!localFileExists) return \"prisma\";\n return swaggerMode;\n};\n\nexport default async function getAuthenticationJsonSchemaPaths(\n arkosConfig: ArkosConfig\n) {\n const paths: OpenAPIV3.PathsObject = {};\n\n if (!arkosConfig.swagger?.mode) return paths;\n\n const AuthModuleComponents = getModuleComponents(\"auth\");\n const routerConfig = AuthModuleComponents?.router\n ?.config as RouterConfig<\"auth\">;\n\n if (routerConfig?.disable === true) return paths;\n\n const isAuthEndpointDisabled = (endpoint: string): boolean => {\n return isEndpointDisabled(routerConfig, endpoint as any);\n };\n\n if (!isAuthEndpointDisabled(\"login\")) {\n const loginMode = await getSchemaMode(\"login\", arkosConfig);\n paths[\"/api/auth/login\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Login to the system\",\n description: \"Authenticates a user and returns an access token\",\n operationId: \"login\",\n requestBody: {\n description: \"User credentials\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Login\", loginMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Login successful\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n accessToken: {\n type: \"string\",\n description: \"JWT access token\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Invalid credentials\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"logout\")) {\n paths[\"/api/auth/logout\"] = {\n delete: {\n tags: [\"Authentication\"],\n summary: \"Logout from the system\",\n description: \"Invalidates the current user's JWT token\",\n operationId: \"logout\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"204\": {\n description: \"Logout successful\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"signup\")) {\n const signupMode = await getSchemaMode(\"signup\", arkosConfig);\n const userMode = await getSchemaMode(\"user\", arkosConfig);\n paths[\"/api/auth/signup\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Register a new user\",\n description: \"Creates a new user account\",\n operationId: \"signup\",\n requestBody: {\n description: \"User registration data\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Signup\", signupMode),\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: \"User created successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", userMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"409\": {\n description: \"User already exists\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"updatePassword\")) {\n const updatePasswordMode = await getSchemaMode(\n \"updatePassword\",\n arkosConfig\n );\n paths[\"/api/auth/update-password\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Update user password\",\n description: \"Changes the password for the authenticated user\",\n operationId: \"updatePassword\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"Current and new password\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdatePassword\", updatePasswordMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Password updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n status: {\n type: \"string\",\n example: \"success\",\n },\n message: {\n type: \"string\",\n example: \"Password updated successfully!\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data or current password incorrect\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"getMe\")) {\n const findMeMode = await getSchemaMode(\"getMe\", arkosConfig);\n paths[\"/api/users/me\"] = {\n get: {\n tags: [\"Authentication\"],\n summary: \"Get current user information\",\n description:\n \"Retrieves information about the currently authenticated user\",\n operationId: \"getMe\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"User information retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"GetMe\", findMeMode),\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"updateMe\")) {\n const updateMeMode = await getSchemaMode(\"updateMe\", arkosConfig);\n const userMode = await getSchemaMode(\"user\", arkosConfig);\n if (!paths[\"/api/users/me\"]) paths[\"/api/users/me\"] = {};\n paths[\"/api/users/me\"]!.patch = {\n tags: [\"Authentication\"],\n summary: \"Update current user information\",\n description: \"Updates information for the currently authenticated user\",\n operationId: \"updateMe\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"User data to update\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdateMe\", updateMeMode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"User updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", userMode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"deleteMe\")) {\n if (!paths[\"/api/users/me\"]) paths[\"/api/users/me\"] = {};\n paths[\"/api/users/me\"]!.delete = {\n tags: [\"Authentication\"],\n summary: \"Delete current user account\",\n description: \"Marks the current user's account as deleted\",\n operationId: \"deleteMe\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"Account deleted successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n message: {\n type: \"string\",\n example: \"Account deleted successfully\",\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n };\n }\n\n if (!isAuthEndpointDisabled(\"findManyAuthAction\")) {\n paths[\"/api/auth-actions\"] = {\n get: {\n tags: [\"Authentication\"],\n summary: \"Get all authentication actions\",\n description:\n \"Retrieves a list of all available authentication actions and permissions\",\n operationId: \"findManyAuthAction\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"Auth actions retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n total: {\n type: \"number\",\n description: \"Total number of auth actions\",\n },\n results: {\n type: \"number\",\n description: \"Number of auth actions returned\",\n },\n data: {\n type: \"array\",\n items: {\n $ref: \"#/components/schemas/FindManyAuthActionSystemSchema\",\n },\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n \"403\": {\n description: \"Insufficient permissions\",\n },\n },\n },\n };\n }\n\n return paths;\n}\n"]}
@@ -0,0 +1,419 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = getFileUploadJsonSchemaPaths;
7
+ const dynamic_loader_1 = require("../../../../utils/dynamic-loader");
8
+ const base_router_helpers_1 = require("../../../base/utils/helpers/base.router.helpers");
9
+ const deepmerge_helper_1 = __importDefault(require("../../../../utils/helpers/deepmerge.helper"));
10
+ const file_upload_service_1 = require("../../../file-upload/file-upload.service");
11
+ function getFileUploadJsonSchemaPaths(arkosConfig) {
12
+ const paths = {};
13
+ if (!arkosConfig.fileUpload)
14
+ return paths;
15
+ const FileUploadModuleComponents = (0, dynamic_loader_1.getModuleComponents)("file-upload");
16
+ const routerConfig = FileUploadModuleComponents?.router
17
+ ?.config;
18
+ const authConfigs = FileUploadModuleComponents?.authConfigs;
19
+ if (routerConfig?.disable === true)
20
+ return paths;
21
+ const isFileUploadEndpointDisabled = (endpoint) => {
22
+ return (0, base_router_helpers_1.isEndpointDisabled)(routerConfig, endpoint);
23
+ };
24
+ const basePathname = arkosConfig.fileUpload?.baseRoute || "/api/uploads/";
25
+ const baseUploadDir = arkosConfig.fileUpload?.baseUploadDir || "uploads";
26
+ const restrictions = (0, deepmerge_helper_1.default)(file_upload_service_1.fileUploadDefaultRestrictions, arkosConfig.fileUpload?.restrictions || {});
27
+ const formatBytes = (bytes) => {
28
+ if (bytes === 0)
29
+ return "0 Bytes";
30
+ const k = 1024;
31
+ const sizes = ["Bytes", "KB", "MB", "GB"];
32
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
33
+ return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
34
+ };
35
+ const getFileTypeDescription = (fileType) => {
36
+ const restriction = restrictions[fileType];
37
+ if (!restriction)
38
+ return "";
39
+ const maxSize = formatBytes(restriction.maxSize);
40
+ const maxCount = restriction.maxCount;
41
+ const formats = restriction.supportedFilesRegex
42
+ ?.toString()
43
+ .replace(/\|/g, ", ")
44
+ .replace(/\//g, "")
45
+ .replace(/\.\*/g, "any format");
46
+ return `Maximum file size: ${maxSize}. Maximum files per upload: ${maxCount}. Supported formats: ${formats}`;
47
+ };
48
+ const shouldIncludeSecurity = (action) => {
49
+ const authControl = authConfigs?.authenticationControl;
50
+ if (!authControl)
51
+ return false;
52
+ if (typeof authControl === "boolean")
53
+ return authControl;
54
+ if (typeof authControl === "object") {
55
+ return authControl[action] === true;
56
+ }
57
+ return false;
58
+ };
59
+ if (!isFileUploadEndpointDisabled("findFile")) {
60
+ const cleanBasePath = basePathname.endsWith("/")
61
+ ? basePathname.slice(0, -1)
62
+ : basePathname;
63
+ paths[`${cleanBasePath}/{filePath*}`] = {
64
+ get: {
65
+ tags: ["File Upload"],
66
+ summary: "Retrieve uploaded file",
67
+ description: `Serves static files from the upload directory (${baseUploadDir}). This endpoint uses wildcard path matching to serve files from any subdirectory.`,
68
+ operationId: "findFile",
69
+ ...(shouldIncludeSecurity("View") && {
70
+ security: [{ BearerAuth: [] }],
71
+ }),
72
+ parameters: [
73
+ {
74
+ name: "filePath",
75
+ in: "path",
76
+ required: true,
77
+ schema: { type: "string" },
78
+ description: "Path to the file including file type directory (e.g., images/photo.jpg, videos/clip.mp4)",
79
+ },
80
+ ],
81
+ responses: {
82
+ "200": {
83
+ description: "File retrieved successfully",
84
+ content: {
85
+ "application/octet-stream": {
86
+ schema: {
87
+ type: "string",
88
+ format: "binary",
89
+ },
90
+ },
91
+ },
92
+ },
93
+ "404": {
94
+ description: "File not found",
95
+ },
96
+ ...(shouldIncludeSecurity("View") && {
97
+ "401": { description: "Authentication required" },
98
+ "403": { description: "Insufficient permissions to view files" },
99
+ }),
100
+ },
101
+ },
102
+ };
103
+ }
104
+ if (!isFileUploadEndpointDisabled("uploadFile")) {
105
+ const cleanBasePath = basePathname.endsWith("/")
106
+ ? basePathname.slice(0, -1)
107
+ : basePathname;
108
+ paths[`${cleanBasePath}/{fileType}`] = {
109
+ post: {
110
+ tags: ["File Upload"],
111
+ summary: "Upload file(s)",
112
+ description: "Upload one or multiple files. Supports image processing options for image uploads.",
113
+ operationId: "uploadFile",
114
+ ...(shouldIncludeSecurity("Create") && {
115
+ security: [{ BearerAuth: [] }],
116
+ }),
117
+ parameters: [
118
+ {
119
+ name: "fileType",
120
+ in: "path",
121
+ required: true,
122
+ schema: {
123
+ type: "string",
124
+ enum: ["images", "videos", "documents", "files"],
125
+ },
126
+ description: "Type of file being uploaded",
127
+ },
128
+ {
129
+ name: "format",
130
+ in: "query",
131
+ required: false,
132
+ schema: {
133
+ type: "string",
134
+ enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
135
+ },
136
+ description: "Image format for conversion (only applicable for fileType=images)",
137
+ },
138
+ {
139
+ name: "width",
140
+ in: "query",
141
+ required: false,
142
+ schema: { type: "integer", minimum: 1 },
143
+ description: "Target width for image resize (only applicable for fileType=images)",
144
+ },
145
+ {
146
+ name: "height",
147
+ in: "query",
148
+ required: false,
149
+ schema: { type: "integer", minimum: 1 },
150
+ description: "Target height for image resize (only applicable for fileType=images)",
151
+ },
152
+ {
153
+ name: "resizeTo",
154
+ in: "query",
155
+ required: false,
156
+ schema: {
157
+ type: "string",
158
+ enum: ["cover", "contain", "fill", "inside", "outside"],
159
+ },
160
+ description: "Resize strategy (only applicable for fileType=images)",
161
+ },
162
+ ],
163
+ requestBody: {
164
+ required: true,
165
+ content: {
166
+ "multipart/form-data": {
167
+ schema: {
168
+ type: "object",
169
+ properties: {
170
+ images: {
171
+ type: "array",
172
+ items: { type: "string", format: "binary" },
173
+ description: getFileTypeDescription("images"),
174
+ },
175
+ videos: {
176
+ type: "array",
177
+ items: { type: "string", format: "binary" },
178
+ description: getFileTypeDescription("videos"),
179
+ },
180
+ documents: {
181
+ type: "array",
182
+ items: { type: "string", format: "binary" },
183
+ description: getFileTypeDescription("documents"),
184
+ },
185
+ files: {
186
+ type: "array",
187
+ items: { type: "string", format: "binary" },
188
+ description: getFileTypeDescription("files"),
189
+ },
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ responses: {
196
+ "200": {
197
+ description: "File(s) uploaded successfully",
198
+ content: {
199
+ "application/json": {
200
+ schema: {
201
+ type: "object",
202
+ properties: {
203
+ success: { type: "boolean", example: true },
204
+ data: {
205
+ oneOf: [
206
+ { type: "string", description: "URL of uploaded file" },
207
+ {
208
+ type: "array",
209
+ items: { type: "string" },
210
+ description: "URLs of uploaded files",
211
+ },
212
+ ],
213
+ },
214
+ message: { type: "string" },
215
+ },
216
+ },
217
+ },
218
+ },
219
+ },
220
+ "400": {
221
+ description: "Invalid file type, size limit exceeded, or no file uploaded",
222
+ },
223
+ ...(shouldIncludeSecurity("Create") && {
224
+ "401": { description: "Authentication required" },
225
+ "403": { description: "Insufficient permissions to upload files" },
226
+ }),
227
+ },
228
+ },
229
+ };
230
+ }
231
+ if (!isFileUploadEndpointDisabled("updateFile")) {
232
+ const cleanBasePath = basePathname.endsWith("/")
233
+ ? basePathname.slice(0, -1)
234
+ : basePathname;
235
+ paths[`${cleanBasePath}/{fileType}/{fileName}`] = {
236
+ ...(paths[`${cleanBasePath}/{fileType}/{fileName}`] || {}),
237
+ patch: {
238
+ tags: ["File Upload"],
239
+ summary: "Update existing file",
240
+ description: "Replace an existing file with a new one. Deletes the old file and uploads the new one.",
241
+ operationId: "updateFile",
242
+ ...(shouldIncludeSecurity("Update") && {
243
+ security: [{ BearerAuth: [] }],
244
+ }),
245
+ parameters: [
246
+ {
247
+ name: "fileType",
248
+ in: "path",
249
+ required: true,
250
+ schema: {
251
+ type: "string",
252
+ enum: ["images", "videos", "documents", "files"],
253
+ },
254
+ description: "Type of file being updated",
255
+ },
256
+ {
257
+ name: "fileName",
258
+ in: "path",
259
+ required: true,
260
+ schema: { type: "string" },
261
+ description: "Name of the file to update",
262
+ },
263
+ {
264
+ name: "format",
265
+ in: "query",
266
+ required: false,
267
+ schema: {
268
+ type: "string",
269
+ enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
270
+ },
271
+ description: "Image format for conversion (only applicable for fileType=images)",
272
+ },
273
+ {
274
+ name: "width",
275
+ in: "query",
276
+ required: false,
277
+ schema: { type: "integer", minimum: 1 },
278
+ description: "Target width for image resize (only applicable for fileType=images)",
279
+ },
280
+ {
281
+ name: "height",
282
+ in: "query",
283
+ required: false,
284
+ schema: { type: "integer", minimum: 1 },
285
+ description: "Target height for image resize (only applicable for fileType=images)",
286
+ },
287
+ {
288
+ name: "resizeTo",
289
+ in: "query",
290
+ required: false,
291
+ schema: {
292
+ type: "string",
293
+ enum: ["cover", "contain", "fill", "inside", "outside"],
294
+ },
295
+ description: "Resize strategy (only applicable for fileType=images)",
296
+ },
297
+ ],
298
+ requestBody: {
299
+ required: true,
300
+ content: {
301
+ "multipart/form-data": {
302
+ schema: {
303
+ type: "object",
304
+ properties: {
305
+ images: {
306
+ type: "array",
307
+ items: { type: "string", format: "binary" },
308
+ description: getFileTypeDescription("images"),
309
+ },
310
+ videos: {
311
+ type: "array",
312
+ items: { type: "string", format: "binary" },
313
+ description: getFileTypeDescription("videos"),
314
+ },
315
+ documents: {
316
+ type: "array",
317
+ items: { type: "string", format: "binary" },
318
+ description: getFileTypeDescription("documents"),
319
+ },
320
+ files: {
321
+ type: "array",
322
+ items: { type: "string", format: "binary" },
323
+ description: getFileTypeDescription("files"),
324
+ },
325
+ },
326
+ },
327
+ },
328
+ },
329
+ },
330
+ responses: {
331
+ "200": {
332
+ description: "File updated successfully",
333
+ content: {
334
+ "application/json": {
335
+ schema: {
336
+ type: "object",
337
+ properties: {
338
+ success: { type: "boolean", example: true },
339
+ data: {
340
+ oneOf: [
341
+ { type: "string", description: "URL of updated file" },
342
+ {
343
+ type: "array",
344
+ items: { type: "string" },
345
+ description: "URLs of updated files",
346
+ },
347
+ ],
348
+ },
349
+ message: { type: "string" },
350
+ },
351
+ },
352
+ },
353
+ },
354
+ },
355
+ "400": {
356
+ description: "Invalid file type, size limit exceeded, or no file uploaded",
357
+ },
358
+ "404": {
359
+ description: "Original file not found",
360
+ },
361
+ ...(shouldIncludeSecurity("Update") && {
362
+ "401": { description: "Authentication required" },
363
+ "403": { description: "Insufficient permissions to update files" },
364
+ }),
365
+ },
366
+ },
367
+ };
368
+ }
369
+ if (!isFileUploadEndpointDisabled("deleteFile")) {
370
+ const cleanBasePath = basePathname.endsWith("/")
371
+ ? basePathname.slice(0, -1)
372
+ : basePathname;
373
+ if (!paths[`${cleanBasePath}/{fileType}/{fileName}`]) {
374
+ paths[`${cleanBasePath}/{fileType}/{fileName}`] = {};
375
+ }
376
+ paths[`${cleanBasePath}/{fileType}/{fileName}`].delete = {
377
+ tags: ["File Upload"],
378
+ summary: "Delete file",
379
+ description: "Delete an uploaded file from the server",
380
+ operationId: "deleteFile",
381
+ ...(shouldIncludeSecurity("Delete") && {
382
+ security: [{ BearerAuth: [] }],
383
+ }),
384
+ parameters: [
385
+ {
386
+ name: "fileType",
387
+ in: "path",
388
+ required: true,
389
+ schema: {
390
+ type: "string",
391
+ enum: ["images", "videos", "documents", "files"],
392
+ },
393
+ description: "Type of file being deleted",
394
+ },
395
+ {
396
+ name: "fileName",
397
+ in: "path",
398
+ required: true,
399
+ schema: { type: "string" },
400
+ description: "Name of the file to delete",
401
+ },
402
+ ],
403
+ responses: {
404
+ "204": {
405
+ description: "File deleted successfully",
406
+ },
407
+ "404": {
408
+ description: "File not found",
409
+ },
410
+ ...(shouldIncludeSecurity("Delete") && {
411
+ "401": { description: "Authentication required" },
412
+ "403": { description: "Insufficient permissions to delete files" },
413
+ }),
414
+ },
415
+ };
416
+ }
417
+ return paths;
418
+ }
419
+ //# sourceMappingURL=get-file-upload-json-schema-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-upload-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.ts"],"names":[],"mappings":";;;;;AAOA,+CA0bC;AA/bD,qEAAuE;AACvE,yFAAqF;AACrF,kGAAmE;AACnE,kFAAyF;AAEzF,SAAwB,4BAA4B,CAAC,WAAwB;IAC3E,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,IAAI,CAAC,WAAW,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAE1C,MAAM,0BAA0B,GAAG,IAAA,oCAAmB,EAAC,aAAa,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,0BAA0B,EAAE,MAAM;QACrD,EAAE,MAAqC,CAAC;IAC1C,MAAM,WAAW,GAAG,0BAA0B,EAAE,WAAW,CAAC;IAE5D,IAAI,YAAY,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAEjD,MAAM,4BAA4B,GAAG,CAAC,QAAgB,EAAW,EAAE;QACjE,OAAO,IAAA,wCAAkB,EAAC,YAAY,EAAE,QAAe,CAAC,CAAC;IAC3D,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAAC,UAAU,EAAE,SAAS,IAAI,eAAe,CAAC;IAC1E,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,EAAE,aAAa,IAAI,SAAS,CAAC;IAEzE,MAAM,YAAY,GAAG,IAAA,0BAAS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E;oBACjD,KAAK,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE;iBACnE,CAAC;aACH;SACF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport { ArkosConfig, RouterConfig } from \"../../../../exports\";\nimport { getModuleComponents } from \"../../../../utils/dynamic-loader\";\nimport { isEndpointDisabled } from \"../../../base/utils/helpers/base.router.helpers\";\nimport deepmerge from \"../../../../utils/helpers/deepmerge.helper\";\nimport { fileUploadDefaultRestrictions } from \"../../../file-upload/file-upload.service\";\n\nexport default function getFileUploadJsonSchemaPaths(arkosConfig: ArkosConfig) {\n const paths: OpenAPIV3.PathsObject = {};\n\n if (!arkosConfig.fileUpload) return paths;\n\n const FileUploadModuleComponents = getModuleComponents(\"file-upload\");\n const routerConfig = FileUploadModuleComponents?.router\n ?.config as RouterConfig<\"file-upload\">;\n const authConfigs = FileUploadModuleComponents?.authConfigs;\n\n if (routerConfig?.disable === true) return paths;\n\n const isFileUploadEndpointDisabled = (endpoint: string): boolean => {\n return isEndpointDisabled(routerConfig, endpoint as any);\n };\n\n const basePathname = arkosConfig.fileUpload?.baseRoute || \"/api/uploads/\";\n const baseUploadDir = arkosConfig.fileUpload?.baseUploadDir || \"uploads\";\n\n const restrictions = deepmerge(\n fileUploadDefaultRestrictions,\n arkosConfig.fileUpload?.restrictions || {}\n );\n\n const formatBytes = (bytes: number): string => {\n if (bytes === 0) return \"0 Bytes\";\n const k = 1024;\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + \" \" + sizes[i];\n };\n\n const getFileTypeDescription = (fileType: string): string => {\n const restriction = restrictions[fileType as keyof typeof restrictions];\n if (!restriction) return \"\";\n\n const maxSize = formatBytes(restriction.maxSize!);\n const maxCount = restriction.maxCount;\n const formats = restriction.supportedFilesRegex\n ?.toString()\n .replace(/\\|/g, \", \")\n .replace(/\\//g, \"\")\n .replace(/\\.\\*/g, \"any format\");\n\n return `Maximum file size: ${maxSize}. Maximum files per upload: ${maxCount}. Supported formats: ${formats}`;\n };\n\n const shouldIncludeSecurity = (\n action: \"View\" | \"Create\" | \"Update\" | \"Delete\"\n ): boolean => {\n const authControl = authConfigs?.authenticationControl;\n if (!authControl) return false;\n\n if (typeof authControl === \"boolean\") return authControl;\n if (typeof authControl === \"object\") {\n return authControl[action] === true;\n }\n\n return false;\n };\n\n if (!isFileUploadEndpointDisabled(\"findFile\")) {\n const cleanBasePath = basePathname.endsWith(\"/\")\n ? basePathname.slice(0, -1)\n : basePathname;\n\n paths[`${cleanBasePath}/{filePath*}`] = {\n get: {\n tags: [\"File Upload\"],\n summary: \"Retrieve uploaded file\",\n description: `Serves static files from the upload directory (${baseUploadDir}). This endpoint uses wildcard path matching to serve files from any subdirectory.`,\n operationId: \"findFile\",\n ...(shouldIncludeSecurity(\"View\") && {\n security: [{ BearerAuth: [] }],\n }),\n parameters: [\n {\n name: \"filePath\",\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n description:\n \"Path to the file including file type directory (e.g., images/photo.jpg, videos/clip.mp4)\",\n },\n ],\n responses: {\n \"200\": {\n description: \"File retrieved successfully\",\n content: {\n \"application/octet-stream\": {\n schema: {\n type: \"string\",\n format: \"binary\",\n },\n },\n },\n },\n \"404\": {\n description: \"File not found\",\n },\n ...(shouldIncludeSecurity(\"View\") && {\n \"401\": { description: \"Authentication required\" },\n \"403\": { description: \"Insufficient permissions to view files\" },\n }),\n },\n },\n };\n }\n\n if (!isFileUploadEndpointDisabled(\"uploadFile\")) {\n const cleanBasePath = basePathname.endsWith(\"/\")\n ? basePathname.slice(0, -1)\n : basePathname;\n\n paths[`${cleanBasePath}/{fileType}`] = {\n post: {\n tags: [\"File Upload\"],\n summary: \"Upload file(s)\",\n description:\n \"Upload one or multiple files. Supports image processing options for image uploads.\",\n operationId: \"uploadFile\",\n ...(shouldIncludeSecurity(\"Create\") && {\n security: [{ BearerAuth: [] }],\n }),\n parameters: [\n {\n name: \"fileType\",\n in: \"path\",\n required: true,\n schema: {\n type: \"string\",\n enum: [\"images\", \"videos\", \"documents\", \"files\"],\n },\n description: \"Type of file being uploaded\",\n },\n {\n name: \"format\",\n in: \"query\",\n required: false,\n schema: {\n type: \"string\",\n enum: [\"jpeg\", \"jpg\", \"png\", \"webp\", \"gif\", \"avif\"],\n },\n description:\n \"Image format for conversion (only applicable for fileType=images)\",\n },\n {\n name: \"width\",\n in: \"query\",\n required: false,\n schema: { type: \"integer\", minimum: 1 },\n description:\n \"Target width for image resize (only applicable for fileType=images)\",\n },\n {\n name: \"height\",\n in: \"query\",\n required: false,\n schema: { type: \"integer\", minimum: 1 },\n description:\n \"Target height for image resize (only applicable for fileType=images)\",\n },\n {\n name: \"resizeTo\",\n in: \"query\",\n required: false,\n schema: {\n type: \"string\",\n enum: [\"cover\", \"contain\", \"fill\", \"inside\", \"outside\"],\n },\n description:\n \"Resize strategy (only applicable for fileType=images)\",\n },\n ],\n requestBody: {\n required: true,\n content: {\n \"multipart/form-data\": {\n schema: {\n type: \"object\",\n properties: {\n images: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"images\"),\n },\n videos: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"videos\"),\n },\n documents: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"documents\"),\n },\n files: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"files\"),\n },\n },\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"File(s) uploaded successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", example: true },\n data: {\n oneOf: [\n { type: \"string\", description: \"URL of uploaded file\" },\n {\n type: \"array\",\n items: { type: \"string\" },\n description: \"URLs of uploaded files\",\n },\n ],\n },\n message: { type: \"string\" },\n },\n },\n },\n },\n },\n \"400\": {\n description:\n \"Invalid file type, size limit exceeded, or no file uploaded\",\n },\n ...(shouldIncludeSecurity(\"Create\") && {\n \"401\": { description: \"Authentication required\" },\n \"403\": { description: \"Insufficient permissions to upload files\" },\n }),\n },\n },\n };\n }\n\n if (!isFileUploadEndpointDisabled(\"updateFile\")) {\n const cleanBasePath = basePathname.endsWith(\"/\")\n ? basePathname.slice(0, -1)\n : basePathname;\n\n paths[`${cleanBasePath}/{fileType}/{fileName}`] = {\n ...(paths[`${cleanBasePath}/{fileType}/{fileName}`] || {}),\n patch: {\n tags: [\"File Upload\"],\n summary: \"Update existing file\",\n description:\n \"Replace an existing file with a new one. Deletes the old file and uploads the new one.\",\n operationId: \"updateFile\",\n ...(shouldIncludeSecurity(\"Update\") && {\n security: [{ BearerAuth: [] }],\n }),\n parameters: [\n {\n name: \"fileType\",\n in: \"path\",\n required: true,\n schema: {\n type: \"string\",\n enum: [\"images\", \"videos\", \"documents\", \"files\"],\n },\n description: \"Type of file being updated\",\n },\n {\n name: \"fileName\",\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n description: \"Name of the file to update\",\n },\n {\n name: \"format\",\n in: \"query\",\n required: false,\n schema: {\n type: \"string\",\n enum: [\"jpeg\", \"jpg\", \"png\", \"webp\", \"gif\", \"avif\"],\n },\n description:\n \"Image format for conversion (only applicable for fileType=images)\",\n },\n {\n name: \"width\",\n in: \"query\",\n required: false,\n schema: { type: \"integer\", minimum: 1 },\n description:\n \"Target width for image resize (only applicable for fileType=images)\",\n },\n {\n name: \"height\",\n in: \"query\",\n required: false,\n schema: { type: \"integer\", minimum: 1 },\n description:\n \"Target height for image resize (only applicable for fileType=images)\",\n },\n {\n name: \"resizeTo\",\n in: \"query\",\n required: false,\n schema: {\n type: \"string\",\n enum: [\"cover\", \"contain\", \"fill\", \"inside\", \"outside\"],\n },\n description:\n \"Resize strategy (only applicable for fileType=images)\",\n },\n ],\n requestBody: {\n required: true,\n content: {\n \"multipart/form-data\": {\n schema: {\n type: \"object\",\n properties: {\n images: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"images\"),\n },\n videos: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"videos\"),\n },\n documents: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"documents\"),\n },\n files: {\n type: \"array\",\n items: { type: \"string\", format: \"binary\" },\n description: getFileTypeDescription(\"files\"),\n },\n },\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"File updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", example: true },\n data: {\n oneOf: [\n { type: \"string\", description: \"URL of updated file\" },\n {\n type: \"array\",\n items: { type: \"string\" },\n description: \"URLs of updated files\",\n },\n ],\n },\n message: { type: \"string\" },\n },\n },\n },\n },\n },\n \"400\": {\n description:\n \"Invalid file type, size limit exceeded, or no file uploaded\",\n },\n \"404\": {\n description: \"Original file not found\",\n },\n ...(shouldIncludeSecurity(\"Update\") && {\n \"401\": { description: \"Authentication required\" },\n \"403\": { description: \"Insufficient permissions to update files\" },\n }),\n },\n },\n };\n }\n\n if (!isFileUploadEndpointDisabled(\"deleteFile\")) {\n const cleanBasePath = basePathname.endsWith(\"/\")\n ? basePathname.slice(0, -1)\n : basePathname;\n\n if (!paths[`${cleanBasePath}/{fileType}/{fileName}`]) {\n paths[`${cleanBasePath}/{fileType}/{fileName}`] = {};\n }\n\n paths[`${cleanBasePath}/{fileType}/{fileName}`]!.delete = {\n tags: [\"File Upload\"],\n summary: \"Delete file\",\n description: \"Delete an uploaded file from the server\",\n operationId: \"deleteFile\",\n ...(shouldIncludeSecurity(\"Delete\") && {\n security: [{ BearerAuth: [] }],\n }),\n parameters: [\n {\n name: \"fileType\",\n in: \"path\",\n required: true,\n schema: {\n type: \"string\",\n enum: [\"images\", \"videos\", \"documents\", \"files\"],\n },\n description: \"Type of file being deleted\",\n },\n {\n name: \"fileName\",\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n description: \"Name of the file to delete\",\n },\n ],\n responses: {\n \"204\": {\n description: \"File deleted successfully\",\n },\n \"404\": {\n description: \"File not found\",\n },\n ...(shouldIncludeSecurity(\"Delete\") && {\n \"401\": { description: \"Authentication required\" },\n \"403\": { description: \"Insufficient permissions to delete files\" },\n }),\n },\n };\n }\n\n return paths;\n}\n"]}
@@ -16,7 +16,8 @@ const watermark_stamper_1 = __importDefault(require("./utils/watermark-stamper")
16
16
  let child = null;
17
17
  let envFiles;
18
18
  async function startCommand(options = {}) {
19
- process.env.NODE_ENV = "production";
19
+ if (process.env.NODE_ENV === "test")
20
+ process.env.NODE_ENV = "production";
20
21
  envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
21
22
  try {
22
23
  const { port, host } = options;
@@ -26,8 +27,8 @@ async function startCommand(options = {}) {
26
27
  process.exit(1);
27
28
  }
28
29
  const env = {
29
- ...process.env,
30
30
  NODE_ENV: "production",
31
+ ...process.env,
31
32
  ...(port && { CLI_PORT: port }),
32
33
  ...(host && { CLI_HOST: host }),
33
34
  ARKOS_BUILD: "true",
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;AAoBA,oCA8FC;AAKD,4EAGC;AA1HD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAoD;AACpD,sDAA6D;AAC7D,8DAAyD;AACzD,sDAAqD;AACrD,kGAAuE;AACvE,kFAAyD;AAOzD,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,QAA8B,CAAC;AAK5B,KAAK,UAAU,YAAY,CAAC,UAAwB,EAAE;IAC3D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IAEtC,IAAI,CAAC;Q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oBACrB,QAAQ;oBACR,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;oBAC9B,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAKD,SAAgB,gCAAgC;IAC7C,KAAsB,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { ChildProcess, spawn } from \"child_process\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\nimport portAndHostAllocator from \"../features/port-and-host-allocator\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n process.env.NODE_ENV = \"production\";\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n const entryPoint = path.join(process.cwd(), \".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${fullCleanCwd(entryPoint)}`\n );\n process.exit(1);\n }\n\n const env: { [x: string]: string } = {\n ...process.env,\n NODE_ENV: \"production\",\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n // Handle process exit\n process.on(\"SIGINT\", () => {\n if (child) child.kill();\n\n process.exit(0);\n });\n\n const checkConfig = async () => {\n try {\n const { getArkosConfig } = await importModule(\"../../server\");\n\n const config = getArkosConfig();\n\n if (config && config.available) {\n const hostAndPort =\n await portAndHostAllocator.getHostAndAvailablePort(env, {\n ...config,\n logWarning: true,\n });\n\n watermarkStamper.stamp({\n envFiles,\n port:\n \"port\" in config && config?.port !== undefined\n ? hostAndPort.port\n : undefined,\n host: hostAndPort.host,\n });\n return true;\n }\n return false;\n } catch (err: any) {\n if (!err?.message?.includes(\"../../server\")) console.error(err);\n return false;\n }\n };\n\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n await new Promise((resolve) => setTimeout(resolve, 100));\n attempts++;\n }\n\n if (attempts >= maxAttempts) {\n if (env.CLI_PORT || env.PORT) portAndHostAllocator.logWarnings();\n\n watermarkStamper.stamp({\n envFiles,\n host: env.CLI_HOST || env.HOST,\n port: env.CLI_PORT || env.PORT,\n });\n }\n };\n\n waitForConfig();\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;AAoBA,oCA6FC;AAKD,4EAGC;AAzHD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAoD;AACpD,sDAA6D;AAC7D,8DAAyD;AACzD,sDAAqD;AACrD,kGAAuE;AACvE,kFAAyD;AAOzD,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,QAA8B,CAAC;AAK5B,KAAK,UAAU,YAAY,CAAC,UAAwB,EAAE;IAC3D,IAAI,OAAO,CAA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AAI,WAAW,EAAE,CAAC;gBAC5B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;oBAAE,iCAAoB,CAAC,WAAW,EAAE,CAAC;gBAEjE,2BAAgB,CAAC,KAAK,CAAC;oBACrB,QAAQ;oBACR,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;oBAC9B,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAKD,SAAgB,gCAAgC;IAC7C,KAAsB,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { ChildProcess, spawn } from \"child_process\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\nimport portAndHostAllocator from \"../features/port-and-host-allocator\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n if (process.env.NODE_ENV === \"test\") process.env.NODE_ENV = \"production\";\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n const entryPoint = path.join(process.cwd(), \".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${fullCleanCwd(entryPoint)}`\n );\n process.exit(1);\n }\n\n const env: { [x: string]: string } = {\n NODE_ENV: \"production\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n process.on(\"SIGINT\", () => {\n if (child) child.kill();\n\n process.exit(0);\n });\n\n const checkConfig = async () => {\n try {\n const { getArkosConfig } = await importModule(\"../../server\");\n\n const config = getArkosConfig();\n\n if (config && config.available) {\n const hostAndPort =\n await portAndHostAllocator.getHostAndAvailablePort(env, {\n ...config,\n logWarning: true,\n });\n\n watermarkStamper.stamp({\n envFiles,\n port:\n \"port\" in config && config?.port !== undefined\n ? hostAndPort.port\n : undefined,\n host: hostAndPort.host,\n });\n return true;\n }\n return false;\n } catch (err: any) {\n if (!err?.message?.includes(\"../../server\")) console.error(err);\n return false;\n }\n };\n\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n await new Promise((resolve) => setTimeout(resolve, 100));\n attempts++;\n }\n\n if (attempts >= maxAttempts) {\n if (env.CLI_PORT || env.PORT) portAndHostAllocator.logWarnings();\n\n watermarkStamper.stamp({\n envFiles,\n host: env.CLI_HOST || env.HOST,\n port: env.CLI_PORT || env.PORT,\n });\n }\n };\n\n waitForConfig();\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.3.6-canary.2";
22
+ return "1.3.7-beta";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map