@avleon/core 0.0.4

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 (44) hide show
  1. package/README.md +1 -0
  2. package/dist/config.d.ts +30 -0
  3. package/dist/config.js +19 -0
  4. package/dist/container.d.ts +19 -0
  5. package/dist/container.js +51 -0
  6. package/dist/controller.d.ts +47 -0
  7. package/dist/controller.js +38 -0
  8. package/dist/decorators.d.ts +8 -0
  9. package/dist/decorators.js +25 -0
  10. package/dist/exceptions/http-exceptions.d.ts +21 -0
  11. package/dist/exceptions/http-exceptions.js +38 -0
  12. package/dist/exceptions/index.d.ts +1 -0
  13. package/dist/exceptions/index.js +17 -0
  14. package/dist/exceptions/system-exception.d.ts +13 -0
  15. package/dist/exceptions/system-exception.js +18 -0
  16. package/dist/helpers.d.ts +24 -0
  17. package/dist/helpers.js +192 -0
  18. package/dist/icore.d.ts +58 -0
  19. package/dist/icore.js +239 -0
  20. package/dist/index.d.ts +10 -0
  21. package/dist/index.js +33 -0
  22. package/dist/map-types.d.ts +12 -0
  23. package/dist/map-types.js +85 -0
  24. package/dist/openapi.d.ts +333 -0
  25. package/dist/openapi.js +27 -0
  26. package/dist/params.d.ts +16 -0
  27. package/dist/params.js +48 -0
  28. package/dist/queue.d.ts +0 -0
  29. package/dist/queue.js +1 -0
  30. package/dist/repository.d.ts +0 -0
  31. package/dist/repository.js +1 -0
  32. package/dist/response.d.ts +9 -0
  33. package/dist/response.js +36 -0
  34. package/dist/results.d.ts +20 -0
  35. package/dist/results.js +32 -0
  36. package/dist/route-methods.d.ts +56 -0
  37. package/dist/route-methods.js +83 -0
  38. package/dist/swagger-schema.d.ts +1 -0
  39. package/dist/swagger-schema.js +29 -0
  40. package/dist/validator-extend.d.ts +1 -0
  41. package/dist/validator-extend.js +22 -0
  42. package/jest.config.ts +9 -0
  43. package/package.json +39 -0
  44. package/tsconfig.json +25 -0
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSwaggerSchema = generateSwaggerSchema;
4
+ function generateSwaggerSchema(classType) {
5
+ const { getMetadataStorage } = require("class-validator");
6
+ const { plainToInstance } = require("class-transformer");
7
+ const metadataStorage = getMetadataStorage();
8
+ const validationMetadata = metadataStorage.getTargetValidationMetadatas(classType, "", true);
9
+ const schema = {
10
+ type: "object",
11
+ properties: {},
12
+ required: [],
13
+ };
14
+ validationMetadata.forEach((meta) => {
15
+ const propertyName = meta.propertyName;
16
+ // Infer the type dynamically using Reflect metadata
17
+ const propertyType = Reflect.getMetadata("design:type", classType.prototype, propertyName);
18
+ schema.properties[propertyName] = {
19
+ type: (propertyType === null || propertyType === void 0 ? void 0 : propertyType.name.toLowerCase()) || "string", // Default to string if type cannot be inferred
20
+ };
21
+ if (meta.name === "isNotEmpty") {
22
+ schema.required.push(propertyName);
23
+ }
24
+ if (meta.name === "minLength") {
25
+ schema.properties[propertyName].minLength = meta.constraints[0];
26
+ }
27
+ });
28
+ return schema;
29
+ }
@@ -0,0 +1 @@
1
+ export declare function IsArrayNotEmpty(validationOptions?: any): (object: Object, propertyName: string) => void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsArrayNotEmpty = IsArrayNotEmpty;
4
+ function IsArrayNotEmpty(validationOptions) {
5
+ const { registerDecorator, ValidationArguments } = require('class-validator');
6
+ return function (object, propertyName) {
7
+ registerDecorator({
8
+ name: 'isArrayWithAtLeastOneElement',
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ options: validationOptions,
12
+ validator: {
13
+ validate(value, args) {
14
+ return Array.isArray(value) && value.length > 0;
15
+ },
16
+ defaultMessage(args) {
17
+ return `${args.property} must contain at least one item.`;
18
+ },
19
+ },
20
+ });
21
+ };
22
+ }
package/jest.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { Config } from 'jest'
2
+
3
+ const config: Config = {
4
+ preset: "ts-jest",
5
+ testEnvironment: "node",
6
+ }
7
+
8
+
9
+ export default config;
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@avleon/core",
3
+ "version": "0.0.4",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "rimraf dist && tsc",
8
+ "watch": "tsc-watch",
9
+ "test": "jest",
10
+ "test:watch": "jest --watch"
11
+ },
12
+ "keywords": [],
13
+ "author": "Tareq Hossain",
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "@types/jest": "^29.5.14",
17
+ "jest": "^29.7.0",
18
+ "nodemon": "^3.1.7",
19
+ "ts-jest": "^29.2.5",
20
+ "tsc-watch": "^6.2.1",
21
+ "typescript": "^5.7.2"
22
+ },
23
+ "dependencies": {
24
+ "@fastify/swagger": "^9.4.0",
25
+ "@fastify/swagger-ui": "^5.1.0",
26
+ "class-transformer": "^0.5.1",
27
+ "fastify": "^5.1.0",
28
+ "reflect-metadata": "^0.2.2",
29
+ "typedi": "^0.10.0"
30
+ },
31
+ "directories": {
32
+ "test": "tests"
33
+ },
34
+ "description": "avleon core",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/xtareq/avleon-core"
38
+ }
39
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "module": "CommonJS",
5
+ "strict": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "outDir": "./dist",
9
+ "declaration": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "moduleResolution": "node",
13
+ "allowSyntheticDefaultImports": true,
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": [
17
+ "src/**/*"
18
+ ],
19
+ "exclude": [
20
+ "node_modules",
21
+ "dist",
22
+ "scripts",
23
+ "jest.config.ts"
24
+ ]
25
+ }