@hedhog/setting 0.0.6 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/dist/index.d.ts +1 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/setting/dto/create.dto.d.ts +8 -0
  6. package/dist/setting/dto/create.dto.d.ts.map +1 -0
  7. package/dist/setting/dto/create.dto.js +36 -0
  8. package/dist/setting/dto/create.dto.js.map +1 -0
  9. package/dist/setting/dto/delete.dto.d.ts.map +1 -0
  10. package/dist/setting/dto/delete.dto.js.map +1 -0
  11. package/dist/setting/dto/setting-user.dto.d.ts +4 -0
  12. package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
  13. package/dist/{dto/create.dto.js → setting/dto/setting-user.dto.js} +6 -7
  14. package/dist/setting/dto/setting-user.dto.js.map +1 -0
  15. package/dist/setting/dto/setting.dto.d.ts +9 -0
  16. package/dist/setting/dto/setting.dto.d.ts.map +1 -0
  17. package/dist/setting/dto/setting.dto.js +34 -0
  18. package/dist/setting/dto/setting.dto.js.map +1 -0
  19. package/dist/setting/dto/update.dto.d.ts +6 -0
  20. package/dist/setting/dto/update.dto.d.ts.map +1 -0
  21. package/dist/{dto → setting/dto}/update.dto.js +2 -1
  22. package/dist/setting/dto/update.dto.js.map +1 -0
  23. package/dist/setting/setting.controller.d.ts +25 -0
  24. package/dist/setting/setting.controller.d.ts.map +1 -0
  25. package/dist/setting/setting.controller.js +149 -0
  26. package/dist/setting/setting.controller.js.map +1 -0
  27. package/dist/setting/setting.service.d.ts +28 -0
  28. package/dist/setting/setting.service.d.ts.map +1 -0
  29. package/dist/setting/setting.service.js +296 -0
  30. package/dist/setting/setting.service.js.map +1 -0
  31. package/dist/setting.module.d.ts +3 -0
  32. package/dist/setting.module.d.ts.map +1 -0
  33. package/dist/{settings.module.js → setting.module.js} +8 -8
  34. package/dist/setting.module.js.map +1 -0
  35. package/frontend/setting/components/create-panel.tsx +83 -0
  36. package/frontend/setting/components/setting.screen.tsx +105 -0
  37. package/frontend/setting/components/update-panel.tsx +96 -0
  38. package/frontend/setting/locales/en/setting.setting.json +11 -0
  39. package/frontend/setting/locales/pt/setting.setting.json +11 -0
  40. package/frontend/setting/react-query/handlers.ts +28 -0
  41. package/frontend/setting/react-query/requests.ts +55 -0
  42. package/frontend/setting-group/components/create-panel.tsx +62 -0
  43. package/frontend/setting-group/components/setting-group.screen.tsx +107 -0
  44. package/frontend/setting-group/components/update-panel.tsx +76 -0
  45. package/frontend/setting-group/locales/en/setting.setting-group.json +11 -0
  46. package/frontend/setting-group/locales/pt/setting.setting-group.json +11 -0
  47. package/frontend/setting-group/react-query/handlers.ts +28 -0
  48. package/frontend/setting-group/react-query/requests.ts +58 -0
  49. package/frontend/setting-user/components/create-panel.tsx +71 -0
  50. package/frontend/setting-user/components/setting-user.screen.tsx +107 -0
  51. package/frontend/setting-user/components/update-panel.tsx +85 -0
  52. package/frontend/setting-user/locales/en/setting.setting-user.json +11 -0
  53. package/frontend/setting-user/locales/pt/setting.setting-user.json +11 -0
  54. package/frontend/setting-user/react-query/handlers.ts +28 -0
  55. package/frontend/setting-user/react-query/requests.ts +57 -0
  56. package/hedhog.yaml +380 -0
  57. package/package.json +37 -29
  58. package/README.md +0 -108
  59. package/dist/dto/create.dto.d.ts +0 -4
  60. package/dist/dto/create.dto.d.ts.map +0 -1
  61. package/dist/dto/create.dto.js.map +0 -1
  62. package/dist/dto/delete.dto.d.ts.map +0 -1
  63. package/dist/dto/delete.dto.js.map +0 -1
  64. package/dist/dto/update.dto.d.ts +0 -4
  65. package/dist/dto/update.dto.d.ts.map +0 -1
  66. package/dist/dto/update.dto.js.map +0 -1
  67. package/dist/migrations/index.d.ts +0 -6
  68. package/dist/migrations/index.d.ts.map +0 -1
  69. package/dist/migrations/index.js +0 -67
  70. package/dist/migrations/index.js.map +0 -1
  71. package/dist/settings.controller.d.ts +0 -14
  72. package/dist/settings.controller.d.ts.map +0 -1
  73. package/dist/settings.controller.js +0 -95
  74. package/dist/settings.controller.js.map +0 -1
  75. package/dist/settings.module.d.ts +0 -3
  76. package/dist/settings.module.d.ts.map +0 -1
  77. package/dist/settings.module.js.map +0 -1
  78. package/dist/settings.service.d.ts +0 -19
  79. package/dist/settings.service.d.ts.map +0 -1
  80. package/dist/settings.service.js +0 -70
  81. package/dist/settings.service.js.map +0 -1
  82. package/src/dto/create.dto.ts +0 -7
  83. package/src/dto/delete.dto.ts +0 -8
  84. package/src/dto/update.dto.ts +0 -3
  85. package/src/index.ts +0 -2
  86. package/src/migrations/index.ts +0 -78
  87. package/src/settings.controller.ts +0 -65
  88. package/src/settings.module.ts +0 -18
  89. package/src/settings.service.ts +0 -75
  90. package/tsconfig.lib.json +0 -9
  91. package/tsconfig.production.json +0 -20
  92. /package/dist/{dto → setting/dto}/delete.dto.d.ts +0 -0
  93. /package/dist/{dto → setting/dto}/delete.dto.js +0 -0
package/README.md DELETED
@@ -1,108 +0,0 @@
1
- # <p align="center">hedhog/setting</p>
2
-
3
- <p align="center">
4
- <img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" />
5
- </p>
6
-
7
- **Hedhog Setting** module provides a comprehensive solution for managing application settings. It includes functionalities to create, read, update, and delete settings, along with support for pagination and search capabilities. This module integrates with the HedHog ecosystem, utilizing @hedhog/auth for authentication, @hedhog/pagination for managing paginated results, and @hedhog/prisma for database interactions.
8
-
9
- ## Installation
10
-
11
- This library is an integral part of the HedHog framework and should be installed as a dependency in your HedHog project. Ensure that the necessary dependencies are configured in your HedHog project.
12
-
13
- ```bash
14
- npm i @hedhog/setting
15
- ```
16
-
17
- ## Controller Endpoints
18
-
19
- ### `GET /settings`
20
-
21
- - **Description**: Retrieve a paginated list of settings.
22
- - **Authentication**: Required (uses `AuthGuard`).
23
- - **Pagination**: Supports pagination through query parameters.
24
-
25
- ### `GET /settings/:settingId`
26
-
27
- - **Description**: Retrieve a specific setting by its ID.
28
- - **Authentication**: Required (uses AuthGuard).
29
- - **Parameters**:
30
- - **settingId** (number): The ID of the setting to retrieve.
31
-
32
- ### `POST /settings`
33
-
34
- - **Description**: Create a new setting.
35
- - **Authentication**: Required (uses AuthGuard).
36
- - **Body**:
37
- - **name** (string): Name of the setting.
38
-
39
- ### `PATCH /settings/:settingId`
40
-
41
- - **Description**: Update an existing setting.
42
- - **Authentication**: Required (uses AuthGuard).
43
- - **Parameters**:
44
- - **settingId** (number): The ID of the setting to update.
45
- - **Body**:
46
- - **name** (string, optional): Updated name of the setting.
47
-
48
- ### `DELETE /settings`
49
-
50
- - **Description**: Delete one or more settings.
51
- - **Authentication**: Required (uses AuthGuard).
52
- - **Body**:
53
- - **ids** (number[]): Array of setting IDs to delete.
54
-
55
- ## Service Methods
56
-
57
- - **getSettings(paginationParams: PaginationDTO)**
58
-
59
- - **Description**: Retrieves a paginated list of settings with optional search functionality.
60
- - **Parameters**:
61
- - **paginationParams**: Includes pagination and search criteria.
62
-
63
- - **get(settingId: number)**
64
-
65
- - **Description**: Retrieves a specific setting by its ID.
66
- - **Parameters**:
67
- - **settingId**: ID of the setting to retrieve.
68
-
69
- - **create(data: CreateDTO)**
70
-
71
- - **Description**: Creates a new setting.
72
- - **Parameters**:
73
- - **data**: Includes name of the setting.
74
-
75
- - **update(id: number, data: UpdateDTO)**
76
-
77
- - **Description**: Updates an existing setting.
78
- - **Parameters**:
79
- - **id**: ID of the setting to update.
80
- - **data**: Includes updated name of the setting.
81
-
82
- - **delete(data: DeleteDTO)**
83
- - **Description**: Deletes one or more settings.
84
- - **Parameters**:
85
- - **data**: Includes array of ids to delete.
86
-
87
- ## Folder Structure
88
-
89
- ```plaintext
90
- setting/
91
- ├── dist/ # Compiled JavaScript files from build
92
- ├── node_modules/ # Discardable folder with all module dependencies
93
- ├── src/
94
- │ ├── dto/ # Data Transfer Objects
95
- │ │ ├── create.dto.ts # DTO for creating settings
96
- │ │ ├── delete.dto.ts # DTO for deleting settings
97
- │ │ ├── update.dto.ts # DTO for updating settings
98
- │ ├── migrations/ # Database migrations
99
- │ ├── setting.controller.ts # Controller for settings
100
- │ ├── setting.module.ts # Module definition for settings
101
- │ ├── setting.service.ts # Service class for settings logic
102
- ├── .gitignore # Specifies which files Git should ignore
103
- ├── package.json # Manages dependencies and scripts for the module
104
- ├── package-lock.json # Lock file for dependencies
105
- ├── README.md # Documentation for the library
106
- ├── tsconfig.lib.json # TypeScript configuration for library builds
107
- ├── tsconfig.production.json # TypeScript configuration for production builds
108
- ```
@@ -1,4 +0,0 @@
1
- export declare class CreateDTO {
2
- name: string;
3
- }
4
- //# sourceMappingURL=create.dto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../src/dto/create.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAGpB,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../src/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,SAAS;CAIrB;AAJD,8BAIC;AADC;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;IACnD,IAAA,4BAAU,EAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;;uCACpC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete.dto.d.ts","sourceRoot":"","sources":["../../src/dto/delete.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAIpB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete.dto.js","sourceRoot":"","sources":["../../src/dto/delete.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA+D;AAE/D,MAAa,SAAS;CAKrB;AALD,8BAKC;AADC;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,8BAAY,EAAC,CAAC,CAAC;IACf,IAAA,uBAAK,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;sCACR"}
@@ -1,4 +0,0 @@
1
- import { CreateDTO } from './create.dto';
2
- export declare class UpdateDTO extends CreateDTO {
3
- }
4
- //# sourceMappingURL=update.dto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.dto.d.ts","sourceRoot":"","sources":["../../src/dto/update.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBAAa,SAAU,SAAQ,SAAS;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.dto.js","sourceRoot":"","sources":["../../src/dto/update.dto.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAEzC,MAAa,SAAU,SAAQ,sBAAS;CAAG;AAA3C,8BAA2C"}
@@ -1,6 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm';
2
- export declare class Migrate implements MigrationInterface {
3
- up(queryRunner: QueryRunner): Promise<void>;
4
- down(queryRunner: QueryRunner): Promise<void>;
5
- }
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,EAGZ,MAAM,SAAS,CAAC;AAGjB,qBAAa,OAAQ,YAAW,kBAAkB;IACnC,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAgE3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAI3D"}
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Migrate = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const utils_1 = require("@hedhog/utils");
6
- class Migrate {
7
- async up(queryRunner) {
8
- await queryRunner.createTable(new typeorm_1.Table({
9
- name: 'settings',
10
- columns: [
11
- (0, utils_1.idColumn)(),
12
- {
13
- name: 'name',
14
- type: 'varchar',
15
- },
16
- (0, utils_1.timestampColumn)(),
17
- (0, utils_1.timestampColumn)('updated_at'),
18
- ],
19
- }));
20
- await queryRunner.createTable(new typeorm_1.Table({
21
- name: 'setting_values',
22
- columns: [
23
- (0, utils_1.idColumn)(),
24
- {
25
- name: 'value',
26
- type: 'varchar',
27
- length: '1023',
28
- },
29
- {
30
- name: 'name',
31
- type: 'varchar',
32
- isUnique: true,
33
- },
34
- {
35
- name: 'description',
36
- type: 'varchar',
37
- isNullable: true,
38
- },
39
- {
40
- name: 'label',
41
- type: 'varchar',
42
- isNullable: true,
43
- },
44
- {
45
- name: 'setting_id',
46
- type: 'int',
47
- unsigned: true,
48
- },
49
- (0, utils_1.timestampColumn)(),
50
- (0, utils_1.timestampColumn)('updated_at'),
51
- ],
52
- }));
53
- // Criação das foreign keys
54
- await queryRunner.createForeignKey('setting_values', new typeorm_1.TableForeignKey({
55
- columnNames: ['setting_id'],
56
- referencedColumnNames: ['id'],
57
- referencedTableName: 'settings',
58
- onDelete: 'CASCADE',
59
- }));
60
- }
61
- async down(queryRunner) {
62
- await queryRunner.dropTable('setting_values');
63
- await queryRunner.dropTable('settings');
64
- }
65
- }
66
- exports.Migrate = Migrate;
67
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AAAA,qCAKiB;AACjB,yCAA0D;AAE1D,MAAa,OAAO;IACX,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,WAAW,CAC3B,IAAI,eAAK,CAAC;YACR,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP,IAAA,gBAAQ,GAAE;gBACV;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS;iBAChB;gBACD,IAAA,uBAAe,GAAE;gBACjB,IAAA,uBAAe,EAAC,YAAY,CAAC;aAC9B;SACF,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,CAAC,WAAW,CAC3B,IAAI,eAAK,CAAC;YACR,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE;gBACP,IAAA,gBAAQ,GAAE;gBACV;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,MAAM;iBACf;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD,IAAA,uBAAe,GAAE;gBACjB,IAAA,uBAAe,EAAC,YAAY,CAAC;aAC9B;SACF,CAAC,CACH,CAAC;QAEF,2BAA2B;QAC3B,MAAM,WAAW,CAAC,gBAAgB,CAChC,gBAAgB,EAChB,IAAI,yBAAe,CAAC;YAClB,WAAW,EAAE,CAAC,YAAY,CAAC;YAC3B,qBAAqB,EAAE,CAAC,IAAI,CAAC;YAC7B,mBAAmB,EAAE,UAAU;YAC/B,QAAQ,EAAE,SAAS;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC9C,MAAM,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;CACF;AArED,0BAqEC"}
@@ -1,14 +0,0 @@
1
- import { CreateDTO } from './dto/create.dto';
2
- import { DeleteDTO } from './dto/delete.dto';
3
- import { UpdateDTO } from './dto/update.dto';
4
- import { SettingsService } from './settings.service';
5
- export declare class SettingsController {
6
- private readonly settingsService;
7
- constructor(settingsService: SettingsService);
8
- getSettings(paginationParams: any): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
9
- show(settingId: number): Promise<any>;
10
- create(data: CreateDTO): Promise<any>;
11
- update(settingId: number, data: UpdateDTO): Promise<any>;
12
- delete(data: DeleteDTO): Promise<any>;
13
- }
14
- //# sourceMappingURL=settings.controller.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.controller.d.ts","sourceRoot":"","sources":["../src/settings.controller.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,qBAEa,kBAAkB;IAG3B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,eAAe;IAK7C,WAAW,CAAe,gBAAgB,KAAA;IAM1C,IAAI,CAAmC,SAAS,EAAE,MAAM;IAM9D,MAAM,CAAS,IAAI,EAAE,SAAS;IAMxB,MAAM,CACwB,SAAS,EAAE,MAAM,EAC3C,IAAI,EAAE,SAAS;IAUnB,MAAM,CAAS,IAAI,EAAE,SAAS;CAGrC"}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SettingsController = void 0;
16
- const auth_1 = require("@hedhog/auth");
17
- const pagination_1 = require("@hedhog/pagination");
18
- const common_1 = require("@nestjs/common");
19
- const create_dto_1 = require("./dto/create.dto");
20
- const delete_dto_1 = require("./dto/delete.dto");
21
- const update_dto_1 = require("./dto/update.dto");
22
- const settings_service_1 = require("./settings.service");
23
- const permission_1 = require("@hedhog/permission");
24
- let SettingsController = class SettingsController {
25
- constructor(settingsService) {
26
- this.settingsService = settingsService;
27
- }
28
- async getSettings(paginationParams) {
29
- return this.settingsService.getSettings(paginationParams);
30
- }
31
- async show(settingId) {
32
- return this.settingsService.get(settingId);
33
- }
34
- create(data) {
35
- return this.settingsService.create(data);
36
- }
37
- async update(settingId, data) {
38
- return this.settingsService.update({
39
- id: settingId,
40
- data,
41
- });
42
- }
43
- async delete(data) {
44
- return this.settingsService.delete(data);
45
- }
46
- };
47
- exports.SettingsController = SettingsController;
48
- __decorate([
49
- (0, common_1.UseGuards)(auth_1.AuthGuard),
50
- (0, common_1.Get)(),
51
- __param(0, (0, pagination_1.Pagination)()),
52
- __metadata("design:type", Function),
53
- __metadata("design:paramtypes", [Object]),
54
- __metadata("design:returntype", Promise)
55
- ], SettingsController.prototype, "getSettings", null);
56
- __decorate([
57
- (0, common_1.UseGuards)(auth_1.AuthGuard),
58
- (0, common_1.Get)(':settingId'),
59
- __param(0, (0, common_1.Param)('settingId', common_1.ParseIntPipe)),
60
- __metadata("design:type", Function),
61
- __metadata("design:paramtypes", [Number]),
62
- __metadata("design:returntype", Promise)
63
- ], SettingsController.prototype, "show", null);
64
- __decorate([
65
- (0, common_1.UseGuards)(auth_1.AuthGuard),
66
- (0, common_1.Post)(),
67
- __param(0, (0, common_1.Body)()),
68
- __metadata("design:type", Function),
69
- __metadata("design:paramtypes", [create_dto_1.CreateDTO]),
70
- __metadata("design:returntype", void 0)
71
- ], SettingsController.prototype, "create", null);
72
- __decorate([
73
- (0, common_1.UseGuards)(auth_1.AuthGuard),
74
- (0, common_1.Patch)(':settingId'),
75
- __param(0, (0, common_1.Param)('settingId', common_1.ParseIntPipe)),
76
- __param(1, (0, common_1.Body)()),
77
- __metadata("design:type", Function),
78
- __metadata("design:paramtypes", [Number, update_dto_1.UpdateDTO]),
79
- __metadata("design:returntype", Promise)
80
- ], SettingsController.prototype, "update", null);
81
- __decorate([
82
- (0, common_1.UseGuards)(auth_1.AuthGuard),
83
- (0, common_1.Delete)(),
84
- __param(0, (0, common_1.Body)()),
85
- __metadata("design:type", Function),
86
- __metadata("design:paramtypes", [delete_dto_1.DeleteDTO]),
87
- __metadata("design:returntype", Promise)
88
- ], SettingsController.prototype, "delete", null);
89
- exports.SettingsController = SettingsController = __decorate([
90
- (0, permission_1.Permission)(),
91
- (0, common_1.Controller)('settings'),
92
- __param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => settings_service_1.SettingsService))),
93
- __metadata("design:paramtypes", [settings_service_1.SettingsService])
94
- ], SettingsController);
95
- //# sourceMappingURL=settings.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.controller.js","sourceRoot":"","sources":["../src/settings.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAyC;AACzC,mDAAgD;AAChD,2CAYwB;AACxB,iDAA6C;AAC7C,iDAA6C;AAC7C,iDAA6C;AAC7C,yDAAqD;AACrD,mDAAgD;AAIzC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAEmB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAChD,CAAC;IAIE,AAAN,KAAK,CAAC,WAAW,CAAe,gBAAgB;QAC9C,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAIK,AAAN,KAAK,CAAC,IAAI,CAAmC,SAAiB;QAC5D,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAID,MAAM,CAAS,IAAe;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CACwB,SAAiB,EAC3C,IAAe;QAEvB,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;YACjC,EAAE,EAAE,SAAS;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CAAS,IAAe;QAClC,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAzCY,gDAAkB;AAQvB;IAFL,IAAA,kBAAS,EAAC,gBAAS,CAAC;IACpB,IAAA,YAAG,GAAE;IACa,WAAA,IAAA,uBAAU,GAAE,CAAA;;;;qDAE9B;AAIK;IAFL,IAAA,kBAAS,EAAC,gBAAS,CAAC;IACpB,IAAA,YAAG,EAAC,YAAY,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,WAAW,EAAE,qBAAY,CAAC,CAAA;;;;8CAE3C;AAID;IAFC,IAAA,kBAAS,EAAC,gBAAS,CAAC;IACpB,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;gDAE7B;AAIK;IAFL,IAAA,kBAAS,EAAC,gBAAS,CAAC;IACpB,IAAA,cAAK,EAAC,YAAY,CAAC;IAEjB,WAAA,IAAA,cAAK,EAAC,WAAW,EAAE,qBAAY,CAAC,CAAA;IAChC,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;gDAMxB;AAIK;IAFL,IAAA,kBAAS,EAAC,gBAAS,CAAC;IACpB,IAAA,eAAM,GAAE;IACK,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;gDAEnC;6BAxCU,kBAAkB;IAF9B,IAAA,uBAAU,GAAE;IACZ,IAAA,mBAAU,EAAC,UAAU,CAAC;IAGlB,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAe,CAAC,CAAC,CAAA;qCACR,kCAAe;GAHxC,kBAAkB,CAyC9B"}
@@ -1,3 +0,0 @@
1
- export declare class SettingModule {
2
- }
3
- //# sourceMappingURL=settings.module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.module.d.ts","sourceRoot":"","sources":["../src/settings.module.ts"],"names":[],"mappings":"AAOA,qBAUa,aAAa;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.module.js","sourceRoot":"","sources":["../src/settings.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAA0C;AAC1C,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAoD;AACpD,+DAA2D;AAC3D,yDAAqD;AAY9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAVzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,kCAAe,CAAC;QAC5B,OAAO,EAAE,CAAC,kCAAe,CAAC;QAC1B,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,iBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;SACnC;KACF,CAAC;GACW,aAAa,CAAG"}
@@ -1,19 +0,0 @@
1
- import { PaginationDTO, PaginationService } from '@hedhog/pagination';
2
- import { PrismaService } from '@hedhog/prisma';
3
- import { CreateDTO } from './dto/create.dto';
4
- import { DeleteDTO } from './dto/delete.dto';
5
- import { UpdateDTO } from './dto/update.dto';
6
- export declare class SettingsService {
7
- private readonly prismaService;
8
- private readonly paginationService;
9
- constructor(prismaService: PrismaService, paginationService: PaginationService);
10
- getSettings(paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
11
- get(settingId: number): Promise<any>;
12
- create({ name }: CreateDTO): Promise<any>;
13
- update({ id, data }: {
14
- id: number;
15
- data: UpdateDTO;
16
- }): Promise<any>;
17
- delete({ ids }: DeleteDTO): Promise<any>;
18
- }
19
- //# sourceMappingURL=settings.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.service.d.ts","sourceRoot":"","sources":["../src/settings.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,eAAe;IAGxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,WAAW,CAAC,gBAAgB,EAAE,aAAa;IAmB3C,GAAG,CAAC,SAAS,EAAE,MAAM;IAMrB,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;IAM1B,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IAOpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SettingsService = void 0;
16
- const pagination_1 = require("@hedhog/pagination");
17
- const prisma_1 = require("@hedhog/prisma");
18
- const common_1 = require("@nestjs/common");
19
- let SettingsService = class SettingsService {
20
- constructor(prismaService, paginationService) {
21
- this.prismaService = prismaService;
22
- this.paginationService = paginationService;
23
- }
24
- async getSettings(paginationParams) {
25
- const fields = ['name'];
26
- const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
27
- return this.paginationService.paginate(this.prismaService.settings, paginationParams, {
28
- where: {
29
- OR,
30
- },
31
- });
32
- }
33
- async get(settingId) {
34
- return this.prismaService.settings.findUnique({
35
- where: { id: settingId },
36
- });
37
- }
38
- async create({ name }) {
39
- return this.prismaService.settings.create({
40
- data: { name },
41
- });
42
- }
43
- async update({ id, data }) {
44
- return this.prismaService.settings.update({
45
- where: { id },
46
- data,
47
- });
48
- }
49
- async delete({ ids }) {
50
- if (ids == undefined || ids == null) {
51
- throw new common_1.BadRequestException(`You must select at least one setting to delete.`);
52
- }
53
- return this.prismaService.settings.deleteMany({
54
- where: {
55
- id: {
56
- in: ids,
57
- },
58
- },
59
- });
60
- }
61
- };
62
- exports.SettingsService = SettingsService;
63
- exports.SettingsService = SettingsService = __decorate([
64
- (0, common_1.Injectable)(),
65
- __param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
66
- __param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => pagination_1.PaginationService))),
67
- __metadata("design:paramtypes", [prisma_1.PrismaService,
68
- pagination_1.PaginationService])
69
- ], SettingsService);
70
- //# sourceMappingURL=settings.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.service.js","sourceRoot":"","sources":["../src/settings.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AAMjB,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,gBAA+B;QAC/C,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;QAExB,MAAM,EAAE,GAAU,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAC1D,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CACpC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,gBAAgB,EAChB;YACE,KAAK,EAAE;gBACL,EAAE;aACH;SACF,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC5C,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;SACzB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAa;QAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YACxC,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YACxC,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,iDAAiD,CAClD,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC5C,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA7DY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAL5C,eAAe,CA6D3B"}
@@ -1,7 +0,0 @@
1
- import { IsNotEmpty, IsString } from 'class-validator';
2
-
3
- export class CreateDTO {
4
- @IsString({ message: 'O nome deve ser uma string' })
5
- @IsNotEmpty({ message: 'O nome é obrigatório.' })
6
- name: string;
7
- }
@@ -1,8 +0,0 @@
1
- import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
2
-
3
- export class DeleteDTO {
4
- @IsArray()
5
- @ArrayMinSize(1)
6
- @IsInt({ each: true })
7
- ids: number[];
8
- }
@@ -1,3 +0,0 @@
1
- import { CreateDTO } from './create.dto';
2
-
3
- export class UpdateDTO extends CreateDTO {}
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './settings.module';
2
- export * from './settings.service';
@@ -1,78 +0,0 @@
1
- import {
2
- MigrationInterface,
3
- QueryRunner,
4
- Table,
5
- TableForeignKey,
6
- } from 'typeorm';
7
- import { idColumn, timestampColumn } from '@hedhog/utils';
8
-
9
- export class Migrate implements MigrationInterface {
10
- public async up(queryRunner: QueryRunner): Promise<void> {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'settings',
14
- columns: [
15
- idColumn(),
16
- {
17
- name: 'name',
18
- type: 'varchar',
19
- },
20
- timestampColumn(),
21
- timestampColumn('updated_at'),
22
- ],
23
- }),
24
- );
25
-
26
- await queryRunner.createTable(
27
- new Table({
28
- name: 'setting_values',
29
- columns: [
30
- idColumn(),
31
- {
32
- name: 'value',
33
- type: 'varchar',
34
- length: '1023',
35
- },
36
- {
37
- name: 'name',
38
- type: 'varchar',
39
- isUnique: true,
40
- },
41
- {
42
- name: 'description',
43
- type: 'varchar',
44
- isNullable: true,
45
- },
46
- {
47
- name: 'label',
48
- type: 'varchar',
49
- isNullable: true,
50
- },
51
- {
52
- name: 'setting_id',
53
- type: 'int',
54
- unsigned: true,
55
- },
56
- timestampColumn(),
57
- timestampColumn('updated_at'),
58
- ],
59
- }),
60
- );
61
-
62
- // Criação das foreign keys
63
- await queryRunner.createForeignKey(
64
- 'setting_values',
65
- new TableForeignKey({
66
- columnNames: ['setting_id'],
67
- referencedColumnNames: ['id'],
68
- referencedTableName: 'settings',
69
- onDelete: 'CASCADE',
70
- }),
71
- );
72
- }
73
-
74
- public async down(queryRunner: QueryRunner): Promise<void> {
75
- await queryRunner.dropTable('setting_values');
76
- await queryRunner.dropTable('settings');
77
- }
78
- }
@@ -1,65 +0,0 @@
1
- import { AuthGuard } from '@hedhog/auth';
2
- import { Pagination } from '@hedhog/pagination';
3
- import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- UseGuards,
14
- forwardRef,
15
- } from '@nestjs/common';
16
- import { CreateDTO } from './dto/create.dto';
17
- import { DeleteDTO } from './dto/delete.dto';
18
- import { UpdateDTO } from './dto/update.dto';
19
- import { SettingsService } from './settings.service';
20
- import { Permission } from '@hedhog/permission';
21
-
22
- @Permission()
23
- @Controller('settings')
24
- export class SettingsController {
25
- constructor(
26
- @Inject(forwardRef(() => SettingsService))
27
- private readonly settingsService: SettingsService,
28
- ) {}
29
-
30
- @UseGuards(AuthGuard)
31
- @Get()
32
- async getSettings(@Pagination() paginationParams) {
33
- return this.settingsService.getSettings(paginationParams);
34
- }
35
-
36
- @UseGuards(AuthGuard)
37
- @Get(':settingId')
38
- async show(@Param('settingId', ParseIntPipe) settingId: number) {
39
- return this.settingsService.get(settingId);
40
- }
41
-
42
- @UseGuards(AuthGuard)
43
- @Post()
44
- create(@Body() data: CreateDTO) {
45
- return this.settingsService.create(data);
46
- }
47
-
48
- @UseGuards(AuthGuard)
49
- @Patch(':settingId')
50
- async update(
51
- @Param('settingId', ParseIntPipe) settingId: number,
52
- @Body() data: UpdateDTO,
53
- ) {
54
- return this.settingsService.update({
55
- id: settingId,
56
- data,
57
- });
58
- }
59
-
60
- @UseGuards(AuthGuard)
61
- @Delete()
62
- async delete(@Body() data: DeleteDTO) {
63
- return this.settingsService.delete(data);
64
- }
65
- }
@@ -1,18 +0,0 @@
1
- import { AuthModule } from '@hedhog/auth';
2
- import { PaginationModule } from '@hedhog/pagination';
3
- import { PrismaModule } from '@hedhog/prisma';
4
- import { Module, forwardRef } from '@nestjs/common';
5
- import { SettingsController } from './settings.controller';
6
- import { SettingsService } from './settings.service';
7
-
8
- @Module({
9
- providers: [SettingsService],
10
- exports: [SettingsService],
11
- controllers: [SettingsController],
12
- imports: [
13
- forwardRef(() => AuthModule),
14
- forwardRef(() => PrismaModule),
15
- forwardRef(() => PaginationModule),
16
- ],
17
- })
18
- export class SettingModule {}