@seniorsistemas/exclusion-process-component 0.0.1-c049d10c-e93a-4d63-9c2a-b17bca40c324 → 0.6.0-44030ff3-2eeb-49f7-8927-0920cc01a805

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 (200) hide show
  1. package/.editorconfig +19 -0
  2. package/.gitlab-ci.yml +74 -0
  3. package/.prettierrc +8 -0
  4. package/.senior-ci-extensions.sh +21 -0
  5. package/.vscode/settings.json +6 -0
  6. package/CHANGELOG.md +22 -0
  7. package/README.md +16 -0
  8. package/angular.json +144 -0
  9. package/archive.tar.gz +0 -0
  10. package/e2e/app.e2e-spec.ts +14 -0
  11. package/e2e/app.po.ts +11 -0
  12. package/e2e/tsconfig.e2e.json +14 -0
  13. package/karma.conf.js +53 -0
  14. package/lib/.browserslistrc +5 -0
  15. package/lib/package.json +19 -0
  16. package/{enums/enum-exclusion-process-status.d.ts → lib/src/enums/enum-exclusion-process-status.ts} +1 -1
  17. package/lib/src/exclusion-details/exclusion-details.component.html +84 -0
  18. package/lib/src/exclusion-details/exclusion-details.component.scss +47 -0
  19. package/lib/src/exclusion-details/exclusion-details.component.spec.ts +171 -0
  20. package/lib/src/exclusion-details/exclusion-details.component.ts +235 -0
  21. package/lib/src/exclusion-details/exclusion-details.module.ts +23 -0
  22. package/{exclusion-details/protocols/exclusion-details.d.ts → lib/src/exclusion-details/protocols/exclusion-details.ts} +1 -0
  23. package/{exclusion-details/protocols/show-details-information.d.ts → lib/src/exclusion-details/protocols/show-details-information.ts} +1 -1
  24. package/lib/src/exclusions-list/exclusions-list.component.html +157 -0
  25. package/lib/src/exclusions-list/exclusions-list.component.spec.ts +526 -0
  26. package/lib/src/exclusions-list/exclusions-list.component.ts +335 -0
  27. package/lib/src/exclusions-list/exclusions-list.module.ts +52 -0
  28. package/lib/src/exclusions-list/exclusions-list.routing.ts +89 -0
  29. package/lib/src/exclusions-list/index.ts +2 -0
  30. package/lib/src/logical-delete.module.ts +22 -0
  31. package/{models/exclusion-process-step-group.d.ts → lib/src/models/exclusion-process-step-group.ts} +1 -0
  32. package/{models/exclusion-process-step.d.ts → lib/src/models/exclusion-process-step.ts} +1 -0
  33. package/{models/exclusion-process.d.ts → lib/src/models/exclusion-process.ts} +1 -0
  34. package/{models/list-params.d.ts → lib/src/models/list-params.ts} +1 -0
  35. package/{models/project-config.d.ts → lib/src/models/project-config.ts} +3 -1
  36. package/lib/src/services/filter.service.spec.ts +290 -0
  37. package/lib/src/services/filter.service.ts +109 -0
  38. package/lib/src/services/index.ts +1 -0
  39. package/lib/src/services/logical-delete-config.service.spec.ts +59 -0
  40. package/lib/src/services/logical-delete-config.service.ts +25 -0
  41. package/lib/src/services/logical-delete.service.spec.ts +322 -0
  42. package/lib/src/services/logical-delete.service.ts +122 -0
  43. package/lib/test.ts +14 -0
  44. package/lib/tsconfig.lib.json +19 -0
  45. package/lib/tsconfig.lib.prod.json +6 -0
  46. package/lib/tsconfig.spec.json +12 -0
  47. package/lib/tslint.json +19 -0
  48. package/package.json +59 -18
  49. package/protractor.conf.js +28 -0
  50. package/senior-ci/.devcontainer/Dockerfile +27 -0
  51. package/senior-ci/.devcontainer/devcontainer.json +71 -0
  52. package/senior-ci/.editorconfig +14 -0
  53. package/senior-ci/.gitattributes +5 -0
  54. package/senior-ci/.gitlab-ci.yml +53 -0
  55. package/senior-ci/.pylintrc +562 -0
  56. package/senior-ci/.vscode/launch.json +102 -0
  57. package/senior-ci/CHANGELOG.md +1564 -0
  58. package/senior-ci/CONTRIBUTING.md +31 -0
  59. package/senior-ci/README.md +26 -0
  60. package/senior-ci/ci/ci.sh +74 -0
  61. package/senior-ci/ci/sonar_scanner.py +48 -0
  62. package/senior-ci/common/__init__.py +250 -0
  63. package/senior-ci/common/default-files/pom.xml +10 -0
  64. package/senior-ci/common/docker-helpers.sh +57 -0
  65. package/senior-ci/common/extensions.py +88 -0
  66. package/senior-ci/common/flutter-helpers.sh +3 -0
  67. package/senior-ci/common/getopt_helper.py +168 -0
  68. package/senior-ci/common/graphql_client.py +40 -0
  69. package/senior-ci/common/helm_helpers.py +40 -0
  70. package/senior-ci/common/notification-helpers.sh +15 -0
  71. package/senior-ci/common/npm-helper.sh +4 -0
  72. package/senior-ci/common/parallel-helper.sh +8 -0
  73. package/senior-ci/common/release-helpers.sh +196 -0
  74. package/senior-ci/common/s3cache-helpers.sh +47 -0
  75. package/senior-ci/common/senior-ci-extensions-helpers.sh +15 -0
  76. package/senior-ci/common/sonar_helper.py +203 -0
  77. package/senior-ci/common/validations/buildable_project.py +61 -0
  78. package/senior-ci/common/validations/check_deprecated_primitives.py +49 -0
  79. package/senior-ci/common/validations/check_project_path.py +40 -0
  80. package/senior-ci/common/validations/check_sonar_config_files.py +41 -0
  81. package/senior-ci/common/validations/check_tags.py +41 -0
  82. package/senior-ci/common/validations/validate_changelog.py +151 -0
  83. package/senior-ci/common/validations/validate_issues.py +320 -0
  84. package/senior-ci/docker/build.sh +18 -0
  85. package/senior-ci/docker/config-host.sh +29 -0
  86. package/senior-ci/docker/deploy-service.sh +79 -0
  87. package/senior-ci/docker/push.sh +22 -0
  88. package/senior-ci/frontend/npm/bibliotecas/ci.sh +149 -0
  89. package/senior-ci/frontend/npm/ci.sh +370 -0
  90. package/senior-ci/frontend/npm/release-translations.sh +164 -0
  91. package/senior-ci/helm/deploy.py +56 -0
  92. package/senior-ci/helm/publish.py +41 -0
  93. package/senior-ci/hook/release_notification.sh +88 -0
  94. package/senior-ci/hook/text_notification.sh +10 -0
  95. package/senior-ci/java/bibliotecas/ci.sh +215 -0
  96. package/senior-ci/java/sdl/ci.sh +372 -0
  97. package/senior-ci/java/sdl/scripts/hotfix.sh +78 -0
  98. package/senior-ci/mobile/flutter/apps/__main__.py +5 -0
  99. package/senior-ci/mobile/flutter/apps/ci.py +193 -0
  100. package/senior-ci/mobile/flutter/libs/__main__.py +5 -0
  101. package/senior-ci/mobile/flutter/libs/ci.py +178 -0
  102. package/senior-ci/mobile/flutter/scripts/release.sh +54 -0
  103. package/senior-ci/release-candidate/backend/get_version.sh +64 -0
  104. package/senior-ci/release-candidate/close_branch.sh +113 -0
  105. package/senior-ci/release-candidate/common/create_hotfix.sh +28 -0
  106. package/senior-ci/release-candidate/common/create_release.sh +30 -0
  107. package/senior-ci/release-candidate/create_branch.sh +64 -0
  108. package/senior-ci/release-candidate/frontend/get_version.sh +43 -0
  109. package/senior-ci/requirements-dev.txt +5 -0
  110. package/senior-ci/requirements.txt +5 -0
  111. package/senior-ci/scripts/apply_yamls.py +229 -0
  112. package/senior-ci/scripts/create_sre_issue/__main__.py +7 -0
  113. package/senior-ci/scripts/create_sre_issue/create_sre_issue.py +267 -0
  114. package/senior-ci/scripts/create_sre_issue/helpers.py +166 -0
  115. package/senior-ci/scripts/create_sre_issue/jira_manager.py +37 -0
  116. package/senior-ci/scripts/validate_changelog.sh +3 -0
  117. package/senior-ci/sonar-project.properties +1 -0
  118. package/server.js +5 -0
  119. package/sonar-project.properties +10 -0
  120. package/src/app/app.component.html +43 -0
  121. package/src/app/app.component.scss +36 -0
  122. package/src/app/app.component.ts +56 -0
  123. package/src/app/app.module.ts +64 -0
  124. package/src/app/shared/shared.module.ts +28 -0
  125. package/src/environments/environment.default.ts +3 -0
  126. package/src/environments/environment.prod.ts +6 -0
  127. package/src/environments/environment.ts +7 -0
  128. package/src/favicon.ico +0 -0
  129. package/src/index.html +17 -0
  130. package/src/locale/en-US.json +3 -0
  131. package/src/locale/es-ES.json +3 -0
  132. package/src/locale/pt-BR.json +3 -0
  133. package/src/main.ts +13 -0
  134. package/src/polyfills.ts +58 -0
  135. package/src/styles.scss +11 -0
  136. package/src/tsconfig.app.json +21 -0
  137. package/src/typings.d.ts +15 -0
  138. package/tsconfig.json +39 -0
  139. package/tslint.json +80 -0
  140. package/bundles/seniorsistemas-exclusion-process-component.umd.js +0 -747
  141. package/bundles/seniorsistemas-exclusion-process-component.umd.js.map +0 -1
  142. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js +0 -16
  143. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js.map +0 -1
  144. package/esm2015/enums/enum-exclusion-process-status.js +0 -8
  145. package/esm2015/exclusion-details/exclusion-details.component.js +0 -216
  146. package/esm2015/exclusion-details/exclusion-details.module.js +0 -28
  147. package/esm2015/exclusion-details/index.js +0 -3
  148. package/esm2015/exclusion-details/protocols/exclusion-details.js +0 -1
  149. package/esm2015/exclusion-details/protocols/index.js +0 -2
  150. package/esm2015/exclusion-details/protocols/show-details-information.js +0 -3
  151. package/esm2015/logical-delete.module.js +0 -27
  152. package/esm2015/models/exclusion-process-step-group.js +0 -1
  153. package/esm2015/models/exclusion-process-step.js +0 -1
  154. package/esm2015/models/exclusion-process.js +0 -1
  155. package/esm2015/models/index.js +0 -1
  156. package/esm2015/models/list-params.js +0 -1
  157. package/esm2015/models/list-result.js +0 -1
  158. package/esm2015/models/project-config.js +0 -3
  159. package/esm2015/public-api.js +0 -3
  160. package/esm2015/seniorsistemas-exclusion-process-component.js +0 -9
  161. package/esm2015/services/filter.service.js +0 -104
  162. package/esm2015/services/logical-delete-config.service.js +0 -29
  163. package/esm2015/services/logical-delete.service.js +0 -109
  164. package/esm5/enums/enum-exclusion-process-status.js +0 -8
  165. package/esm5/exclusion-details/exclusion-details.component.js +0 -235
  166. package/esm5/exclusion-details/exclusion-details.module.js +0 -31
  167. package/esm5/exclusion-details/index.js +0 -3
  168. package/esm5/exclusion-details/protocols/exclusion-details.js +0 -1
  169. package/esm5/exclusion-details/protocols/index.js +0 -2
  170. package/esm5/exclusion-details/protocols/show-details-information.js +0 -7
  171. package/esm5/logical-delete.module.js +0 -31
  172. package/esm5/models/exclusion-process-step-group.js +0 -1
  173. package/esm5/models/exclusion-process-step.js +0 -1
  174. package/esm5/models/exclusion-process.js +0 -1
  175. package/esm5/models/index.js +0 -1
  176. package/esm5/models/list-params.js +0 -1
  177. package/esm5/models/list-result.js +0 -1
  178. package/esm5/models/project-config.js +0 -3
  179. package/esm5/public-api.js +0 -3
  180. package/esm5/seniorsistemas-exclusion-process-component.js +0 -9
  181. package/esm5/services/filter.service.js +0 -109
  182. package/esm5/services/logical-delete-config.service.js +0 -30
  183. package/esm5/services/logical-delete.service.js +0 -112
  184. package/exclusion-details/exclusion-details.component.d.ts +0 -49
  185. package/exclusion-details/exclusion-details.module.d.ts +0 -2
  186. package/fesm2015/seniorsistemas-exclusion-process-component.js +0 -495
  187. package/fesm2015/seniorsistemas-exclusion-process-component.js.map +0 -1
  188. package/fesm5/seniorsistemas-exclusion-process-component.js +0 -530
  189. package/fesm5/seniorsistemas-exclusion-process-component.js.map +0 -1
  190. package/logical-delete.module.d.ts +0 -5
  191. package/seniorsistemas-exclusion-process-component.d.ts +0 -8
  192. package/seniorsistemas-exclusion-process-component.metadata.json +0 -1
  193. package/services/filter.service.d.ts +0 -19
  194. package/services/logical-delete-config.service.d.ts +0 -8
  195. package/services/logical-delete.service.d.ts +0 -20
  196. /package/{exclusion-details/index.d.ts → lib/src/exclusion-details/index.ts} +0 -0
  197. /package/{exclusion-details/protocols/index.d.ts → lib/src/exclusion-details/protocols/index.ts} +0 -0
  198. /package/{models/index.d.ts → lib/src/models/index.ts} +0 -0
  199. /package/{models/list-result.d.ts → lib/src/models/list-result.ts} +0 -0
  200. /package/{public-api.d.ts → lib/src/public-api.ts} +0 -0
@@ -0,0 +1,322 @@
1
+ import { HttpClient } from "@angular/common/http";
2
+ import { TestBed } from "@angular/core/testing";
3
+ import { HttpTestingController, HttpClientTestingModule } from "@angular/common/http/testing";
4
+ import { TranslateModule, TranslateService } from "@ngx-translate/core";
5
+ import { MessageService } from "primeng/api";
6
+ import { LogicalDeleteConfigService } from "./logical-delete-config.service";
7
+ import { LogicalDeleteService } from "./logical-delete.service";
8
+ import { ProjectConfigs, ProjectConfigsInjectionToken } from "../models/project-config";
9
+
10
+ describe("LogicalDeleteService", () => {
11
+ let service: LogicalDeleteService;
12
+ let httpMock: HttpTestingController;
13
+ let httpClient: HttpClient;
14
+ let messageService: MessageService;
15
+ let translateService: TranslateService;
16
+ let logicalDeleteConfigService: LogicalDeleteConfigService;
17
+
18
+ const defaultProjectConfigs: ProjectConfigs = {
19
+ domain: "domain",
20
+ service: "service"
21
+ };
22
+
23
+ beforeEach(() => {
24
+ TestBed.configureTestingModule({
25
+ imports: [HttpClientTestingModule, TranslateModule.forRoot()],
26
+ providers: [
27
+ HttpClient,
28
+ MessageService,
29
+ TranslateService,
30
+ LogicalDeleteConfigService,
31
+ {
32
+ provide: ProjectConfigsInjectionToken,
33
+ useValue: defaultProjectConfigs
34
+ }
35
+ ]
36
+ });
37
+ httpMock = TestBed.inject(HttpTestingController);
38
+ httpClient = TestBed.inject(HttpClient);
39
+ messageService = TestBed.inject(MessageService);
40
+ translateService = TestBed.inject(TranslateService);
41
+ logicalDeleteConfigService = TestBed.inject(LogicalDeleteConfigService);
42
+ service = new LogicalDeleteService(httpClient, messageService, translateService, logicalDeleteConfigService);
43
+ });
44
+
45
+ afterEach(() => {
46
+ httpMock.verify();
47
+ });
48
+
49
+ it("should be created", () => {
50
+ expect(service).toBeTruthy();
51
+ });
52
+
53
+ describe("defaultCatch", () => {
54
+ it("should call messageService.add if there was an error", done => {
55
+ const mockErrorResponse = { status: 400, statusText: "Bad request" };
56
+ const addSpy = spyOn(messageService, "add");
57
+ service.listExclusions("entity name", {}).subscribe(
58
+ () => {},
59
+ () => {
60
+ expect(addSpy).toHaveBeenCalledWith({
61
+ severity: "error",
62
+ summary: "400",
63
+ detail: "Bad request"
64
+ });
65
+ done();
66
+ }
67
+ );
68
+
69
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('entity%20name')");
70
+ req.flush(null, mockErrorResponse);
71
+ });
72
+
73
+ it("should call messageService.add setting the summary as Error if no status is provided", done => {
74
+ const mockErrorResponse = { status: 0, statusText: "Bad request" };
75
+ const addSpy = spyOn(messageService, "add");
76
+ service.listExclusions("entity name", {}).subscribe(
77
+ () => {},
78
+ () => {
79
+ expect(addSpy).toHaveBeenCalledWith({
80
+ severity: "error",
81
+ summary: "Error",
82
+ detail: "Bad request"
83
+ });
84
+ done();
85
+ }
86
+ );
87
+
88
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('entity%20name')");
89
+ req.flush(null, mockErrorResponse);
90
+ });
91
+
92
+ it("should call messageService.add setting the detail as the error message", done => {
93
+ const mockErrorResponse = {
94
+ status: 400,
95
+ statusText: "Bad request"
96
+ };
97
+ const addSpy = spyOn(messageService, "add");
98
+ service.listExclusions("entity name", {}).subscribe(
99
+ () => {},
100
+ () => {
101
+ expect(addSpy).toHaveBeenCalledWith({
102
+ severity: "error",
103
+ summary: "400",
104
+ detail: "Some error"
105
+ });
106
+ done();
107
+ }
108
+ );
109
+
110
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('entity%20name')");
111
+ req.flush(
112
+ {
113
+ message: "Some error"
114
+ },
115
+ mockErrorResponse
116
+ );
117
+ });
118
+
119
+ it("should call messageService.add setting the default message for unauthorized", done => {
120
+ spyOn(translateService, "instant").and
121
+ .callFake((val: any) => `translated_${val}`);
122
+
123
+ const mockErrorResponse = {
124
+ status: 401,
125
+ statusText: "Unauthorized"
126
+ };
127
+ const addSpy = spyOn(messageService, "add");
128
+ service.listExclusions("entity name", {}).subscribe(
129
+ () => {},
130
+ () => {
131
+ expect(addSpy).toHaveBeenCalledWith({
132
+ severity: "error",
133
+ summary: "translated_domain.service.error_unauthorized_title",
134
+ detail: "translated_domain.service.error_unauthorized_description"
135
+ });
136
+ done();
137
+ }
138
+ );
139
+
140
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('entity%20name')");
141
+ req.flush(null, mockErrorResponse);
142
+ });
143
+ });
144
+
145
+ describe("getListQueryParams", () => {
146
+ it("should set default page and size", () => {
147
+ const result = service.getListQueryParams({});
148
+ expect(result.get("offset")).toBe("0");
149
+ expect(result.get("size")).toBe("10");
150
+ });
151
+
152
+ it("should set page and size as string parameters", () => {
153
+ const result = service.getListQueryParams({ page: 1, size: 25 });
154
+ expect(result.get("offset")).toBe("1");
155
+ expect(result.get("size")).toBe("25");
156
+ });
157
+
158
+ it("should set the filterQuery as filter if the param is set", () => {
159
+ const result = service.getListQueryParams({ filterQuery: "valid filter info" });
160
+ expect(result.get("filter")).toBe("valid filter info");
161
+ });
162
+
163
+ it("should set the display fields separated by comma if the param is set", () => {
164
+ const result = service.getListQueryParams({ displayFields: ["field1", "field2"] });
165
+ expect(result.get("displayfields")).toBe("field1,field2");
166
+ });
167
+
168
+ it("should set the orderBy param when sort is set", () => {
169
+ const result = service.getListQueryParams({ sort: [{ field: "field1", order: 1 }, { field: "field2", order: -1 }] });
170
+ expect(result.get("orderby")).toBe("field1 asc, field2 desc");
171
+ });
172
+ });
173
+
174
+ describe("getProcessDetails", () => {
175
+ it("should filter by recordId", done => {
176
+ const httpGetSpy = spyOn(httpClient, "get").and.callThrough();
177
+
178
+ service.getProcessDetails("valid recordId").subscribe(
179
+ () => {
180
+ expect(httpGetSpy).toHaveBeenCalledWith("domain/service/entities/exclusionProcess", { params: { filter: "recordId eq 'valid recordId'" } });
181
+ done();
182
+ }
183
+ );
184
+
185
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?filter=recordId%20eq%20'valid%20recordId'");
186
+ req.flush({ contents: [] }, { status: 200, statusText: "Ok" });
187
+ });
188
+
189
+ it("should return null if record not found", done => {
190
+ service.getProcessDetails("valid recordId").subscribe(
191
+ value => {
192
+ expect(value).toBeNull();
193
+ done();
194
+ }
195
+ );
196
+
197
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?filter=recordId%20eq%20'valid%20recordId'");
198
+ req.flush({ contents: [] }, { status: 200, statusText: "Ok" });
199
+ });
200
+
201
+ it("should return the record if it was found", done => {
202
+ service.getProcessDetails("valid recordId").subscribe(
203
+ value => {
204
+ expect(value.id).toBe("valid id");
205
+ done();
206
+ }
207
+ );
208
+
209
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?filter=recordId%20eq%20'valid%20recordId'");
210
+ req.flush({ contents: [{id: 'valid id'}] }, { status: 200, statusText: "Ok" });
211
+ });
212
+
213
+ it("should call defaultCatch in case of an error", done => {
214
+ spyOn(service, "defaultCatch").and.callThrough();
215
+
216
+ service.getProcessDetails("valid recordId").subscribe(
217
+ () => {},
218
+ () => {
219
+ done();
220
+ }
221
+ );
222
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?filter=recordId%20eq%20'valid%20recordId'");
223
+ req.flush(null, { status: 400, statusText: "Some error message" });
224
+
225
+ expect(service.defaultCatch).toHaveBeenCalled();
226
+ });
227
+ });
228
+
229
+ describe("listExclusions", () => {
230
+ it("should filter by entityName", done => {
231
+ service.listExclusions("valid entityName").subscribe(
232
+ () => {
233
+ done();
234
+ }
235
+ );
236
+
237
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('valid%20entityName')");
238
+ req.flush({ contents: [] }, { status: 200, statusText: "Ok" });
239
+ });
240
+
241
+ it("should add filter by entityName with other filter already exists", done => {
242
+ const params = { filterQuery: 'status eq test' };
243
+ service.listExclusions("valid entityName", params).subscribe(
244
+ () => {
245
+ done();
246
+ }
247
+ );
248
+
249
+ const req = httpMock.expectOne(
250
+ "domain/service/entities/exclusionProcess?size=10&offset=0&filter=status%20eq%20test%20and%20lower(entityName)%20eq%20lower('valid%20entityName')");
251
+ req.flush({ contents: [] }, { status: 200, statusText: "Ok" });
252
+ });
253
+
254
+ it("should call getListQueryParams to create the http filters", done => {
255
+ const getListQueryParamsSpy = spyOn(service, 'getListQueryParams').and.callThrough();
256
+ const params = { filterQuery: 'status eq test', page: 1, orderBy: 'id asc' };
257
+
258
+ service.listExclusions("valid entityName", params).subscribe(
259
+ () => {
260
+ expect(getListQueryParamsSpy).toHaveBeenCalledWith(params);
261
+ done();
262
+ }
263
+ );
264
+
265
+ const req = httpMock.match(() => true)[0];
266
+ req.flush({ contents: [] }, { status: 200, statusText: "Ok" });
267
+ });
268
+
269
+ it("should call defaultCatch in case of an error", done => {
270
+ spyOn(service, "defaultCatch").and.callThrough();
271
+
272
+ service.listExclusions("valid entityName").subscribe(
273
+ () => {},
274
+ () => {
275
+ done();
276
+ }
277
+ );
278
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('valid%20entityName')");
279
+ req.flush(null, { status: 400, statusText: "Some error message" });
280
+
281
+ expect(service.defaultCatch).toHaveBeenCalled();
282
+ });
283
+
284
+ it("should return the list on data", done => {
285
+ service.listExclusions("valid entityName").subscribe(
286
+ value => {
287
+ expect(value.contents.length).toBe(2);
288
+ expect(value.contents[0].id).toBe("1");
289
+ expect(value.contents[0].startDate).toBeFalsy();
290
+ expect(value.contents[0].finishDate).toBeFalsy();
291
+ done();
292
+ }
293
+ );
294
+
295
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('valid%20entityName')");
296
+ req.flush({ contents: [{id: "1"}, {id: "2"}] }, { status: 200, statusText: "Ok" });
297
+ });
298
+
299
+ it("should return the starDate and finishDate converted to date when present", done => {
300
+ service.listExclusions("valid entityName").subscribe(
301
+ value => {
302
+ const startDate = value.contents[0].startDate;
303
+ expect(startDate.toISOString()).toContain("2023-02-10");
304
+ const finishDate = value.contents[0].finishDate;
305
+ expect(finishDate.toISOString()).toContain("2023-05-05");
306
+ done();
307
+ }
308
+ );
309
+
310
+ const req = httpMock.expectOne("domain/service/entities/exclusionProcess?size=10&offset=0&filter=lower(entityName)%20eq%20lower('valid%20entityName')");
311
+ const reqResponse = {
312
+ contents: [
313
+ {
314
+ startDate: "2023-02-10",
315
+ finishDate: "2023-05-05"
316
+ }
317
+ ]
318
+ };
319
+ req.flush(reqResponse, { status: 200, statusText: "Ok" });
320
+ });
321
+ });
322
+ });
@@ -0,0 +1,122 @@
1
+ import * as moment from "moment";
2
+ import { HttpClient, HttpParams } from "@angular/common/http";
3
+ import { Injectable } from "@angular/core";
4
+ import { TranslateService } from "@ngx-translate/core";
5
+ import { MessageService } from "primeng/api";
6
+ import { Observable, throwError } from "rxjs";
7
+ import { catchError, map } from "rxjs/operators";
8
+ import { ListResult, ExclusionProcess } from "../models/index";
9
+ import { LogicalDeleteConfigService } from "./logical-delete-config.service";
10
+ import { ListParams } from "../models/list-params";
11
+
12
+ @Injectable()
13
+ export class LogicalDeleteService {
14
+ private exclusionProcessUrl: string;
15
+ private listExclusionsUrl: string;
16
+
17
+ constructor(
18
+ private readonly http: HttpClient,
19
+ private readonly messageService: MessageService,
20
+ private readonly translate: TranslateService,
21
+ private readonly projectConfigs: LogicalDeleteConfigService) {
22
+
23
+ const entityUrl = `${projectConfigs.getDomain()}/${projectConfigs.getService()}`;
24
+ this.exclusionProcessUrl = `${entityUrl}/entities/exclusionProcess`;
25
+ this.listExclusionsUrl = `${entityUrl}/entities/exclusionProcess`;
26
+ this.defaultCatch = this.defaultCatch.bind(this);
27
+ }
28
+
29
+ public defaultCatch() {
30
+ return catchError<any, any>((err: any) => {
31
+ if (err) {
32
+ let summary = err.status ? String(err.status) : "Error";
33
+ let detail = (err.error && err.error.message) || err.statusText || err.message || "Error";
34
+
35
+ if (err.status === 401) {
36
+ const prefix = this.projectConfigs.getTranslationPrefix();
37
+ summary = this.translate.instant(`${prefix}.error_unauthorized_title`);
38
+ detail = this.translate.instant(`${prefix}.error_unauthorized_description`);
39
+ }
40
+
41
+ this.messageService.add({
42
+ severity: "error",
43
+ summary,
44
+ detail
45
+ });
46
+ }
47
+
48
+ return throwError(err);
49
+ });
50
+ }
51
+
52
+ public getListQueryParams(listParams: ListParams) {
53
+ const { page = 0, size = 10, sort = [], filterQuery = "", displayFields = [] } = listParams;
54
+
55
+ let params = new HttpParams();
56
+ params = params.append("size", String(size));
57
+ params = params.append("offset", String(page));
58
+
59
+ if (sort && sort.length) {
60
+ params = params.append(
61
+ "orderby",
62
+ sort
63
+ .map(s => {
64
+ if (s.order === -1) {
65
+ return `${s.field} desc`;
66
+ }
67
+
68
+ return `${s.field} asc`;
69
+ })
70
+ .join(", ")
71
+ );
72
+ }
73
+
74
+ if (filterQuery) {
75
+ params = params.append("filter", filterQuery);
76
+ }
77
+
78
+ if (displayFields && displayFields.length) {
79
+ params = params.append("displayfields", displayFields.join());
80
+ }
81
+
82
+ return params;
83
+ }
84
+
85
+ public getProcessDetails(recordId: string): Observable<ExclusionProcess> {
86
+ const filterParams = {
87
+ filter: `recordId eq '${recordId}'`
88
+ };
89
+
90
+ return this.http.get<ListResult<ExclusionProcess>>(this.exclusionProcessUrl, { params: filterParams })
91
+ .pipe<ListResult<ExclusionProcess>>(this.defaultCatch())
92
+ .pipe(map(value => {
93
+ if (!value.contents?.length) {
94
+ return null;
95
+ }
96
+ return value.contents[0];
97
+ }));
98
+ }
99
+
100
+ public listExclusions(entityName: string, params: ListParams = {}): Observable<ListResult<ExclusionProcess>> {
101
+ if (params.filterQuery) {
102
+ params.filterQuery += ` and lower(entityName) eq lower('${entityName}')`;
103
+ } else {
104
+ params.filterQuery = `lower(entityName) eq lower('${entityName}')`;
105
+ }
106
+
107
+ return this.http.get<ListResult<ExclusionProcess>>(this.exclusionProcessUrl, { params: this.getListQueryParams(params) })
108
+ .pipe<ListResult<ExclusionProcess>>(this.defaultCatch())
109
+ .pipe<ListResult<ExclusionProcess>>(map(value => {
110
+ value.contents.forEach(p => {
111
+ if (p.startDate) {
112
+ p.startDate = moment(p.startDate).toDate();
113
+ }
114
+
115
+ if (p.finishDate) {
116
+ p.finishDate = moment(p.finishDate).toDate();
117
+ }
118
+ });
119
+ return value;
120
+ }));
121
+ }
122
+ }
package/lib/test.ts ADDED
@@ -0,0 +1,14 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import "zone.js/dist/zone-testing";
4
+ import { getTestBed } from "@angular/core/testing";
5
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing";
6
+
7
+ declare const require: any;
8
+
9
+ // First, initialize the Angular testing environment.
10
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
11
+ // Then we find all the tests.
12
+ const context = require.context("./", true, /\.spec\.ts$/);
13
+ // And load the modules.
14
+ context.keys().map(context);
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../out-tsc/lib",
5
+ "target": "es2015",
6
+ "declaration": true,
7
+ "inlineSources": true,
8
+ "types": [],
9
+ "lib": [
10
+ "dom",
11
+ "es2017"
12
+ ]
13
+ },
14
+ "angularCompilerOptions": {
15
+ "skipTemplateCodegen": true,
16
+ "strictMetadataEmit": true,
17
+ "enableResourceInlining": true
18
+ }
19
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "angularCompilerOptions": {
4
+ "enableIvy": false
5
+ }
6
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../out-tsc/spec",
5
+ "baseUrl": "./",
6
+ "types": ["jasmine", "node"]
7
+ },
8
+ "files": ["./test.ts", "../src/polyfills.ts"],
9
+ "include": ["../**/*.spec.ts", "../**/*.d.ts"]
10
+ }
11
+
12
+
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../tslint.json",
3
+ "rules": {
4
+ "directive-selector": [
5
+ true,
6
+ "attribute",
7
+ "erp",
8
+ "s",
9
+ "camelCase"
10
+ ],
11
+ "component-selector": [
12
+ true,
13
+ "element",
14
+ "erp",
15
+ "s",
16
+ "kebab-case"
17
+ ]
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
- "$schema": "../node_modules/ng-packagr/package.schema.json",
3
2
  "name": "@seniorsistemas/exclusion-process-component",
4
- "version": "0.0.1-c049d10c-e93a-4d63-9c2a-b17bca40c324",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://git.senior.com.br/one-senior/exclusion-process-component"
3
+ "version": "0.6.0-44030ff3-2eeb-49f7-8927-0920cc01a805",
4
+ "engines": {
5
+ "node": ">=10.14.0",
6
+ "npm": ">=6.4.1"
8
7
  },
9
- "peerDependencies": {
8
+ "scripts": {
9
+ "ng": "ng",
10
+ "start": "node server.js --project=exclusion-process-component-app",
11
+ "build": "ng-packagr -p lib/package.json",
12
+ "test": "ng test --watch=false",
13
+ "test:dev": "ng test",
14
+ "test:coverage": "ng test --watch=false --code-coverage && npx http-server coverage -o",
15
+ "lint": "ng lint",
16
+ "e2e": "ng e2e"
17
+ },
18
+ "project": {
19
+ "app": "exclusion-process-component",
20
+ "domain": "platform",
21
+ "service": "exclusion-process-component"
22
+ },
23
+ "private": false,
24
+ "dependencies": {
10
25
  "@angular/animations": "~9.1.13",
11
26
  "@angular/cdk": "~9.2.4",
12
27
  "@angular/common": "~9.1.13",
@@ -44,20 +59,46 @@
44
59
  "quill": "^1.3.7",
45
60
  "rxjs": "~6.6.3",
46
61
  "rxjs-compat": "^6.6.7",
62
+ "tslib": "^1.10.0",
47
63
  "web-animations-js": "^2.3.2",
48
64
  "zone.js": "~0.10.2"
49
65
  },
50
- "main": "bundles/seniorsistemas-exclusion-process-component.umd.js",
51
- "module": "fesm5/seniorsistemas-exclusion-process-component.js",
52
- "es2015": "fesm2015/seniorsistemas-exclusion-process-component.js",
53
- "esm5": "esm5/seniorsistemas-exclusion-process-component.js",
54
- "esm2015": "esm2015/seniorsistemas-exclusion-process-component.js",
55
- "fesm5": "fesm5/seniorsistemas-exclusion-process-component.js",
56
- "fesm2015": "fesm2015/seniorsistemas-exclusion-process-component.js",
57
- "typings": "seniorsistemas-exclusion-process-component.d.ts",
58
- "metadata": "seniorsistemas-exclusion-process-component.metadata.json",
59
- "sideEffects": false,
60
- "dependencies": {
61
- "tslib": "^1.10.0"
66
+ "devDependencies": {
67
+ "@angular-devkit/build-angular": "~0.901.15",
68
+ "@angular/cli": "~9.1.15",
69
+ "@angular/compiler-cli": "~9.1.13",
70
+ "@angular/language-service": "~9.1.13",
71
+ "@babel/core": "^7.12.3",
72
+ "@compodoc/compodoc": "^1.1.11",
73
+ "@storybook/addon-actions": "^6.0.27",
74
+ "@storybook/addon-essentials": "^6.0.27",
75
+ "@storybook/addon-links": "^6.0.27",
76
+ "@storybook/angular": "^6.0.27",
77
+ "@types/cropperjs": "~1.1.3",
78
+ "@types/element-resize-detector": "~1.1.2",
79
+ "@types/jasmine": "~3.3.8",
80
+ "@types/jasminewd2": "~2.0.3",
81
+ "@types/node": "^12.11.1",
82
+ "babel-loader": "^8.1.0",
83
+ "codelyzer": "^5.1.2",
84
+ "core-js": "^3.0.1",
85
+ "jasmine-core": "~3.4.0",
86
+ "jasmine-spec-reporter": "~4.2.1",
87
+ "karma": "~4.1.0",
88
+ "karma-chrome-launcher": "~2.2.0",
89
+ "karma-coverage-istanbul-reporter": "~2.0.1",
90
+ "karma-jasmine": "~2.0.1",
91
+ "karma-jasmine-html-reporter": "^1.4.0",
92
+ "karma-parallel": "~0.3.1",
93
+ "karma-spec-reporter": "~0.0.32",
94
+ "ng-packagr": "^9.0.0",
95
+ "ngx-cookie-service": "^10.1.1",
96
+ "prettier": "~1.14.0",
97
+ "protractor": "~5.4.0",
98
+ "react-is": "^17.0.1",
99
+ "ts-node": "~7.0.0",
100
+ "tslint": "~5.11.0",
101
+ "tslint-config-prettier": "~1.14.0",
102
+ "typescript": "~3.8.3"
62
103
  }
63
104
  }
@@ -0,0 +1,28 @@
1
+ // Protractor configuration file, see link for more information
2
+ // https://github.com/angular/protractor/blob/master/lib/config.ts
3
+
4
+ const { SpecReporter } = require('jasmine-spec-reporter');
5
+
6
+ exports.config = {
7
+ allScriptsTimeout: 11000,
8
+ specs: [
9
+ './e2e/**/*.e2e-spec.ts'
10
+ ],
11
+ capabilities: {
12
+ 'browserName': 'chrome'
13
+ },
14
+ directConnect: true,
15
+ baseUrl: 'http://localhost:4200/',
16
+ framework: 'jasmine',
17
+ jasmineNodeOpts: {
18
+ showColors: true,
19
+ defaultTimeoutInterval: 30000,
20
+ print: function() {}
21
+ },
22
+ onPrepare() {
23
+ require('ts-node').register({
24
+ project: 'e2e/tsconfig.e2e.json'
25
+ });
26
+ jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27
+ }
28
+ };
@@ -0,0 +1,27 @@
1
+ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/python-3/.devcontainer/base.Dockerfile
2
+
3
+ # [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
4
+ ARG VARIANT="3.9"
5
+ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6
+
7
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8
+ ARG NODE_VERSION="lts/*"
9
+ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10
+
11
+ # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
12
+ COPY requirements.txt /tmp/pip-tmp/
13
+ COPY requirements-dev.txt /tmp/pip-tmp/
14
+ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements-dev.txt \
15
+ && rm -rf /tmp/pip-tmp
16
+
17
+ # Install Helm
18
+ RUN curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
19
+
20
+ # [Optional] Uncomment this section to install additional OS packages.
21
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
22
+ && apt-get -y install --no-install-recommends default-jdk
23
+
24
+ # [Optional] Uncomment this line to install global node packages.
25
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
26
+
27
+ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java