@cccteam/ccc-lib 0.0.15 → 0.0.16

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 (221) hide show
  1. package/README.md +38 -13
  2. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +36 -0
  3. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -0
  4. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +25 -0
  5. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -0
  6. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +83 -0
  7. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -0
  8. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +44 -0
  9. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -0
  10. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +82 -0
  11. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -0
  12. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs +33 -0
  13. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs.map +1 -0
  14. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs +256 -0
  15. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs.map +1 -0
  16. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs +3129 -0
  17. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs.map +1 -0
  18. package/fesm2022/cccteam-ccc-lib-src-forms.mjs +79 -0
  19. package/fesm2022/cccteam-ccc-lib-src-forms.mjs.map +1 -0
  20. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs +6 -0
  21. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs.map +1 -0
  22. package/fesm2022/cccteam-ccc-lib-src-types.mjs +431 -0
  23. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -0
  24. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +48 -0
  25. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -0
  26. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs +41 -0
  27. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs.map +1 -0
  28. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs +157 -0
  29. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs.map +1 -0
  30. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +50 -0
  31. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -0
  32. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +63 -0
  33. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -0
  34. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +60 -0
  35. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -0
  36. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +19 -0
  37. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +1 -0
  38. package/fesm2022/cccteam-ccc-lib.mjs +4444 -0
  39. package/fesm2022/cccteam-ccc-lib.mjs.map +1 -0
  40. package/package.json +88 -5
  41. package/types/cccteam-ccc-lib-src-auth-authentication-guard.d.ts +6 -0
  42. package/types/cccteam-ccc-lib-src-auth-authorization-guard.d.ts +6 -0
  43. package/types/cccteam-ccc-lib-src-auth-forms.d.ts +28 -0
  44. package/types/cccteam-ccc-lib-src-auth-has-permission.d.ts +15 -0
  45. package/types/cccteam-ccc-lib-src-auth-service.d.ts +38 -0
  46. package/types/cccteam-ccc-lib-src-ccc-camel-case-to-title.d.ts +10 -0
  47. package/types/cccteam-ccc-lib-src-ccc-grid.d.ts +35 -0
  48. package/types/cccteam-ccc-lib-src-ccc-resource.d.ts +674 -0
  49. package/types/cccteam-ccc-lib-src-forms.d.ts +27 -0
  50. package/types/cccteam-ccc-lib-src-types.d.ts +934 -0
  51. package/types/cccteam-ccc-lib-src-ui-alert.d.ts +16 -0
  52. package/types/cccteam-ccc-lib-src-ui-core-service.d.ts +20 -0
  53. package/types/cccteam-ccc-lib-src-ui-idle-service.d.ts +49 -0
  54. package/types/cccteam-ccc-lib-src-ui-interceptor.d.ts +16 -0
  55. package/types/cccteam-ccc-lib-src-ui-notification-service.d.ts +33 -0
  56. package/types/cccteam-ccc-lib-src-ui-sidenav.d.ts +33 -0
  57. package/types/cccteam-ccc-lib-src-util-request-options.d.ts +12 -0
  58. package/types/cccteam-ccc-lib.d.ts +1877 -0
  59. package/eslint.config.js +0 -32
  60. package/ng-package.json +0 -11
  61. package/src/auth-authentication-guard/authentication.guard.ts +0 -40
  62. package/src/auth-authentication-guard/index.ts +0 -1
  63. package/src/auth-authentication-guard/ng-package.json +0 -6
  64. package/src/auth-authorization-guard/authorization.guard.ts +0 -17
  65. package/src/auth-authorization-guard/index.ts +0 -1
  66. package/src/auth-authorization-guard/ng-package.json +0 -6
  67. package/src/auth-forms/ccc-field/ccc-field.component.html +0 -1
  68. package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
  69. package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +0 -22
  70. package/src/auth-forms/ccc-field/ccc-field.component.ts +0 -74
  71. package/src/auth-forms/form-helpers.ts +0 -39
  72. package/src/auth-forms/index.ts +0 -3
  73. package/src/auth-forms/ng-package.json +0 -6
  74. package/src/auth-has-permission/has-permission.directive.ts +0 -34
  75. package/src/auth-has-permission/index.ts +0 -1
  76. package/src/auth-has-permission/ng-package.json +0 -6
  77. package/src/auth-service/auth.service.ts +0 -92
  78. package/src/auth-service/index.ts +0 -1
  79. package/src/auth-service/ng-package.json +0 -6
  80. package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +0 -23
  81. package/src/ccc-camel-case-to-title/index.ts +0 -1
  82. package/src/ccc-camel-case-to-title/ng-package.json +0 -6
  83. package/src/ccc-grid/ccc-grid.component.ts +0 -155
  84. package/src/ccc-grid/index.ts +0 -3
  85. package/src/ccc-grid/ng-package.json +0 -6
  86. package/src/ccc-grid/table-button/table-button.component.html +0 -16
  87. package/src/ccc-grid/table-button/table-button.component.scss +0 -5
  88. package/src/ccc-grid/table-button/table-button.component.spec.ts +0 -22
  89. package/src/ccc-grid/table-button/table-button.component.ts +0 -49
  90. package/src/ccc-resource/can-deactivate.guard.ts +0 -41
  91. package/src/ccc-resource/compound-resource/compound-resource.component.html +0 -57
  92. package/src/ccc-resource/compound-resource/compound-resource.component.scss +0 -86
  93. package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +0 -22
  94. package/src/ccc-resource/compound-resource/compound-resource.component.ts +0 -158
  95. package/src/ccc-resource/concat-fns.ts +0 -162
  96. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +0 -12
  97. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.scss +0 -0
  98. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.spec.ts +0 -23
  99. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +0 -17
  100. package/src/ccc-resource/form-state.service.ts +0 -24
  101. package/src/ccc-resource/format-fns.ts +0 -49
  102. package/src/ccc-resource/gui-constants.ts +0 -88
  103. package/src/ccc-resource/index.ts +0 -23
  104. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +0 -8
  105. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.scss +0 -0
  106. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.spec.ts +0 -22
  107. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +0 -12
  108. package/src/ccc-resource/ng-package.json +0 -6
  109. package/src/ccc-resource/operation-types.ts +0 -19
  110. package/src/ccc-resource/padding-element/padding-element.component.html +0 -1
  111. package/src/ccc-resource/padding-element/padding-element.component.scss +0 -3
  112. package/src/ccc-resource/padding-element/padding-element.component.spec.ts +0 -22
  113. package/src/ccc-resource/padding-element/padding-element.component.ts +0 -20
  114. package/src/ccc-resource/resource-array-view/resource-array-view.component.html +0 -81
  115. package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +0 -21
  116. package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +0 -22
  117. package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +0 -143
  118. package/src/ccc-resource/resource-base/resource-base.component.spec.ts +0 -22
  119. package/src/ccc-resource/resource-base/resource-base.component.ts +0 -11
  120. package/src/ccc-resource/resource-cache.service.ts +0 -232
  121. package/src/ccc-resource/resource-create/resource-create.component.html +0 -31
  122. package/src/ccc-resource/resource-create/resource-create.component.scss +0 -130
  123. package/src/ccc-resource/resource-create/resource-create.component.spec.ts +0 -22
  124. package/src/ccc-resource/resource-create/resource-create.component.ts +0 -303
  125. package/src/ccc-resource/resource-field/base-field.directive.ts +0 -102
  126. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +0 -16
  127. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.scss +0 -0
  128. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.spec.ts +0 -22
  129. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +0 -15
  130. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +0 -13
  131. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.scss +0 -0
  132. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.spec.ts +0 -23
  133. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +0 -50
  134. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +0 -22
  135. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.scss +0 -0
  136. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.spec.ts +0 -22
  137. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +0 -14
  138. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +0 -71
  139. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +0 -9
  140. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +0 -22
  141. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +0 -207
  142. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +0 -38
  143. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +0 -3
  144. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +0 -22
  145. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +0 -87
  146. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +0 -23
  147. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +0 -6
  148. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +0 -22
  149. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +0 -14
  150. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +0 -29
  151. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +0 -6
  152. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +0 -22
  153. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +0 -23
  154. package/src/ccc-resource/resource-field/resource-field.component.html +0 -112
  155. package/src/ccc-resource/resource-field/resource-field.component.scss +0 -7
  156. package/src/ccc-resource/resource-field/resource-field.component.spec.ts +0 -22
  157. package/src/ccc-resource/resource-field/resource-field.component.ts +0 -214
  158. package/src/ccc-resource/resource-layout/resource-layout.component.html +0 -73
  159. package/src/ccc-resource/resource-layout/resource-layout.component.scss +0 -26
  160. package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +0 -22
  161. package/src/ccc-resource/resource-layout/resource-layout.component.ts +0 -176
  162. package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +0 -22
  163. package/src/ccc-resource/resource-list/resource-list.component.html +0 -27
  164. package/src/ccc-resource/resource-list/resource-list.component.scss +0 -67
  165. package/src/ccc-resource/resource-list/resource-list.component.ts +0 -376
  166. package/src/ccc-resource/resource-list-create/resource-list-create.component.html +0 -71
  167. package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +0 -9
  168. package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +0 -22
  169. package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +0 -103
  170. package/src/ccc-resource/resource-resolver/resource-resolver.component.html +0 -1
  171. package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
  172. package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +0 -22
  173. package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +0 -69
  174. package/src/ccc-resource/resource-store.service.ts +0 -93
  175. package/src/ccc-resource/resource-view/resource-view.component.html +0 -133
  176. package/src/ccc-resource/resource-view/resource-view.component.scss +0 -150
  177. package/src/ccc-resource/resource-view/resource-view.component.spec.ts +0 -22
  178. package/src/ccc-resource/resource-view/resource-view.component.ts +0 -354
  179. package/src/ccc-resource/resources-helpers.ts +0 -262
  180. package/src/ccc-resource/utils/validator-utils.ts +0 -6
  181. package/src/index.ts +0 -44
  182. package/src/internal-types/ng-package.json +0 -6
  183. package/src/types/auth.actions.ts +0 -46
  184. package/src/types/configs.ts +0 -952
  185. package/src/types/constants.ts +0 -1
  186. package/src/types/core.actions.ts +0 -33
  187. package/src/types/index.ts +0 -9
  188. package/src/types/ng-package.json +0 -6
  189. package/src/types/notification-message.ts +0 -20
  190. package/src/types/permissions.ts +0 -17
  191. package/src/types/session-info.ts +0 -10
  192. package/src/types/tokens.ts +0 -20
  193. package/src/ui-alert/alert.component.html +0 -13
  194. package/src/ui-alert/alert.component.scss +0 -48
  195. package/src/ui-alert/alert.component.spec.ts +0 -22
  196. package/src/ui-alert/alert.component.ts +0 -35
  197. package/src/ui-alert/index.ts +0 -1
  198. package/src/ui-alert/ng-package.json +0 -6
  199. package/src/ui-core-service/index.ts +0 -1
  200. package/src/ui-core-service/ng-package.json +0 -6
  201. package/src/ui-core-service/ui-core.service.ts +0 -34
  202. package/src/ui-interceptor/api.interceptor.spec.ts +0 -16
  203. package/src/ui-interceptor/api.interceptor.ts +0 -45
  204. package/src/ui-interceptor/index.ts +0 -1
  205. package/src/ui-interceptor/ng-package.json +0 -6
  206. package/src/ui-notification-service/index.ts +0 -1
  207. package/src/ui-notification-service/ng-package.json +0 -6
  208. package/src/ui-notification-service/notification.service.ts +0 -59
  209. package/src/ui-sidenav/index.ts +0 -1
  210. package/src/ui-sidenav/ng-package.json +0 -6
  211. package/src/ui-sidenav/sidenav.component.html +0 -60
  212. package/src/ui-sidenav/sidenav.component.scss +0 -99
  213. package/src/ui-sidenav/sidenav.component.spec.ts +0 -22
  214. package/src/ui-sidenav/sidenav.component.ts +0 -64
  215. package/src/util-request-options/index.ts +0 -1
  216. package/src/util-request-options/ng-package.json +0 -6
  217. package/src/util-request-options/request-options.ts +0 -17
  218. package/tsconfig.lib.json +0 -13
  219. package/tsconfig.lib.prod.json +0 -11
  220. package/tsconfig.spec.json +0 -15
  221. /package/{src/internal-types/index.ts → types/cccteam-ccc-lib-src-internal-types.d.ts} +0 -0
package/README.md CHANGED
@@ -1,24 +1,49 @@
1
- # CccLib
1
+ # ccc-lib
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0.
3
+ **ccc-lib** is a comprehensive Angular library developed by the [cccteam](https://cloudcomputingconsultants.com/). It is designed to provide a consistent and configurable foundation for building enterprise-level data-driven applications. By defining a configuration, you can dynamically generate entire application pages.
4
4
 
5
- ## Code scaffolding
5
+ ## Core Features
6
6
 
7
- Run `ng generate component component-name --project ccc-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ccc-lib`.
8
- > Note: Don't forget to add `--project ccc-lib` or else it will be added to the default project in your `angular.json` file.
7
+ - **Dynamic Page Generation**: Define a `resourceConfig` to dynamically render components and build complex layouts. For example, the `resource-resolver` can switch between components based on your data.
8
+ - **Authentication & Authorization**: A set of services and guards for managing user authentication and permissions.
9
+ - **Rich UI Components**: A collection of UI components, including a grid wrapper for Kendo UI, alert services, and more.
10
+ - **Utility Functions**: A set of helper functions for various tasks, such as data manipulation and request customization. Also included are tools for handling PATCH requests per the JSON Patch standard [RFC 6902](https://tools.ietf.org/html/rfc6902).
9
11
 
10
- ## Build
12
+ ## Getting Started
11
13
 
12
- Run `ng build ccc-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
14
+ To install **ccc-lib** in your project, run the following command:
13
15
 
14
- ## Publishing
16
+ ```bash
17
+ npm install ccc-lib
18
+ ```
15
19
 
16
- After building your library with `ng build ccc-lib`, go to the dist folder `cd dist/ccc-lib` and run `npm publish`.
20
+ ## Core Concepts
17
21
 
18
- ## Running unit tests
22
+ The central concept of **ccc-lib** is the `resourceConfig`. This configuration object defines the structure and behavior of a page or a part of a page. It specifies which components to render, how they are connected, and how they interact with data.
19
23
 
20
- Run `ng test ccc-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
24
+ The `compound-component` component is the engine that brings the `resourceConfig` to life. It dynamically creates and configures components based on the provided configuration, allowing for highly flexible and data-driven UIs.
21
25
 
22
- ## Further help
26
+ ## Modules Overview
23
27
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
28
+ - **`ccc-resource`**: The core module of the library. It contains the components and services related to dynamic page generation and data management.
29
+ - **`auth`**: This module provides authentication and authorization, including login forms, route guards, and permission directives.
30
+ - **`ui`**: This module contains UI components and services, such as alerts, notifications, and sidenav components. It also includes the `ccc-grid` component, a wrapper for the Kendo UI grid that allows for dynamic configuration.
31
+ - **`utils`**: A collection of utility pipes and functions for various purposes.
32
+
33
+ ## Development
34
+
35
+ ### Building the Library
36
+
37
+ To build the library locally, use the Angular CLI:
38
+
39
+ ```bash
40
+ ng build ccc-lib
41
+ ```
42
+
43
+ ### Running Tests
44
+
45
+ To run the library's tests, use the following command:
46
+
47
+ ```bash
48
+ ng test ccc-lib
49
+ ```
@@ -0,0 +1,36 @@
1
+ import { inject } from '@angular/core';
2
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
3
+ import { BASE_URL } from '@cccteam/ccc-lib/src/types';
4
+ import { of } from 'rxjs';
5
+ import { map, catchError } from 'rxjs/operators';
6
+
7
+ const AuthenticationGuard = (route, routerState) => {
8
+ const authService = inject(AuthService);
9
+ const baseUrl = inject(BASE_URL);
10
+ const authenticate = () => {
11
+ const url = routerState.url;
12
+ const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);
13
+ const encodedUrl = encodeURIComponent(absoluteUrl);
14
+ window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;
15
+ };
16
+ if (authService.authenticated()) {
17
+ return of(true);
18
+ }
19
+ return authService.checkUserSession().pipe(map((sessionInfo) => {
20
+ if (sessionInfo?.authenticated) {
21
+ return true;
22
+ }
23
+ authenticate();
24
+ return false;
25
+ }), catchError(() => {
26
+ authenticate();
27
+ return of(false);
28
+ }));
29
+ };
30
+
31
+ /**
32
+ * Generated bundle index. Do not edit.
33
+ */
34
+
35
+ export { AuthenticationGuard };
36
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-authentication-guard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-authentication-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authentication-guard/authentication.guard.ts","../../../projects/ccc-lib/src/auth-authentication-guard/cccteam-ccc-lib-src-auth-authentication-guard.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { BASE_URL } from '@cccteam/ccc-lib/src/types';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\nexport const AuthenticationGuard = (\n route: ActivatedRouteSnapshot,\n routerState: RouterStateSnapshot,\n): Observable<boolean> => {\n const authService = inject(AuthService);\n const baseUrl = inject(BASE_URL);\n\n const authenticate = (): void => {\n const url = routerState.url;\n const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);\n const encodedUrl = encodeURIComponent(absoluteUrl);\n window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;\n };\n\n if (authService.authenticated()) {\n return of(true);\n }\n\n return authService.checkUserSession().pipe(\n map((sessionInfo) => {\n if (sessionInfo?.authenticated) {\n return true;\n }\n\n authenticate();\n return false;\n }),\n catchError(() => {\n authenticate();\n return of(false);\n }),\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAOa,mBAAmB,GAAG,CACjC,KAA6B,EAC7B,WAAgC,KACT;AACvB,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACvC,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEhC,MAAM,YAAY,GAAG,MAAW;AAC9B,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG;QAC3B,MAAM,WAAW,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACjF,QAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,CAAC;AAClD,QAAA,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAA,EAAG,WAAW,CAAC,UAAU,EAAE,CAAA,WAAA,EAAc,UAAU,EAAE;AAC9E,IAAA,CAAC;AAED,IAAA,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE;AAC/B,QAAA,OAAO,EAAE,CAAC,IAAI,CAAC;IACjB;AAEA,IAAA,OAAO,WAAW,CAAC,gBAAgB,EAAE,CAAC,IAAI,CACxC,GAAG,CAAC,CAAC,WAAW,KAAI;AAClB,QAAA,IAAI,WAAW,EAAE,aAAa,EAAE;AAC9B,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,CAAC,EACF,UAAU,CAAC,MAAK;AACd,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,EAAE,CAAC,KAAK,CAAC;IAClB,CAAC,CAAC,CACH;AACH;;ACvCA;;AAEG;;;;"}
@@ -0,0 +1,25 @@
1
+ import { inject, computed } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
4
+
5
+ const AuthorizationGuard = (route) => {
6
+ const router = inject(Router);
7
+ const auth = inject(AuthService);
8
+ return computed(() => {
9
+ const hasPermission = auth.hasPermission(route.data['scope']);
10
+ if (hasPermission) {
11
+ return true;
12
+ }
13
+ else {
14
+ router.navigate(['/']);
15
+ return false;
16
+ }
17
+ });
18
+ };
19
+
20
+ /**
21
+ * Generated bundle index. Do not edit.
22
+ */
23
+
24
+ export { AuthorizationGuard };
25
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-authorization-guard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-authorization-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authorization-guard/authorization.guard.ts","../../../projects/ccc-lib/src/auth-authorization-guard/cccteam-ccc-lib-src-auth-authorization-guard.ts"],"sourcesContent":["import { computed, inject, Signal } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\n\nexport const AuthorizationGuard = (route: ActivatedRouteSnapshot): Signal<boolean> => {\n const router = inject(Router);\n const auth = inject(AuthService);\n return computed(() => {\n const hasPermission = auth.hasPermission(route.data['scope']);\n if (hasPermission) {\n return true;\n } else {\n router.navigate(['/']);\n return false;\n }\n });\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAIO,MAAM,kBAAkB,GAAG,CAAC,KAA6B,KAAqB;AACnF,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAChC,OAAO,QAAQ,CAAC,MAAK;AACnB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7D,IAAI,aAAa,EAAE;AACjB,YAAA,OAAO,IAAI;QACb;aAAO;AACL,YAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;AACtB,YAAA,OAAO,KAAK;QACd;AACF,IAAA,CAAC,CAAC;AACJ;;AChBA;;AAEG;;;;"}
@@ -0,0 +1,83 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, input, signal, computed, Component } from '@angular/core';
3
+ import * as i1 from '@angular/material/form-field';
4
+ import { MatFormFieldModule } from '@angular/material/form-field';
5
+ import * as i2 from '@angular/material/input';
6
+ import { MatInputModule } from '@angular/material/input';
7
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
8
+ import { ReadPermission, UpdatePermission } from '@cccteam/ccc-lib/src/types';
9
+
10
+ var InputMode;
11
+ (function (InputMode) {
12
+ InputMode["Read"] = "read";
13
+ InputMode["Edit"] = "edit";
14
+ })(InputMode || (InputMode = {}));
15
+ class CccInputFieldComponent {
16
+ auth = inject(AuthService);
17
+ className = input(undefined, { ...(ngDevMode ? { debugName: "className" } : {}) });
18
+ mode = input.required({ ...(ngDevMode ? { debugName: "mode" } : {}) });
19
+ resource = input.required({ ...(ngDevMode ? { debugName: "resource" } : {}) });
20
+ domain = input.required({ ...(ngDevMode ? { debugName: "domain" } : {}) });
21
+ value = input.required({ ...(ngDevMode ? { debugName: "value" } : {}) });
22
+ name = input.required({ ...(ngDevMode ? { debugName: "name" } : {}) });
23
+ inputMode = InputMode;
24
+ canEdit = signal(false, { ...(ngDevMode ? { debugName: "canEdit" } : {}) });
25
+ canEditSelector = false;
26
+ canRead = signal(false, { ...(ngDevMode ? { debugName: "canRead" } : {}) });
27
+ canReadSelector = false;
28
+ ngOnInit() {
29
+ this.canEditSelector = this.auth.hasPermission({
30
+ resource: this.resource(),
31
+ permission: ReadPermission,
32
+ domain: this.domain(),
33
+ });
34
+ this.canReadSelector = this.auth.hasPermission({
35
+ resource: this.resource(),
36
+ permission: UpdatePermission,
37
+ domain: this.domain(),
38
+ });
39
+ this.canRead = computed(() => {
40
+ const res = this.resource();
41
+ if (!res) {
42
+ return false;
43
+ }
44
+ if (AuthService.requiresPermission(this.resource(), ReadPermission)) {
45
+ return this.canReadSelector;
46
+ }
47
+ return false;
48
+ }, { ...(ngDevMode ? { debugName: "canRead" } : {}) });
49
+ this.canEdit = computed(() => {
50
+ const res = this.resource();
51
+ if (!res) {
52
+ return false;
53
+ }
54
+ if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {
55
+ return this.canEditSelector;
56
+ }
57
+ return false;
58
+ }, { ...(ngDevMode ? { debugName: "canEdit" } : {}) });
59
+ }
60
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: CccInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
61
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.2", type: CccInputFieldComponent, isStandalone: true, selector: "ccc-input-field", inputs: { className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: true, transformFunction: null }, resource: { classPropertyName: "resource", publicName: "resource", isSignal: true, isRequired: true, transformFunction: null }, domain: { classPropertyName: "domain", publicName: "domain", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
62
+ <mat-form-field [class]="className()">
63
+ <mat-label>{{ name() }}</mat-label>
64
+ <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
65
+ </mat-form-field>
66
+ `, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }] });
67
+ }
68
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: CccInputFieldComponent, decorators: [{
69
+ type: Component,
70
+ args: [{ selector: 'ccc-input-field', imports: [MatFormFieldModule, MatInputModule], template: `
71
+ <mat-form-field [class]="className()">
72
+ <mat-label>{{ name() }}</mat-label>
73
+ <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
74
+ </mat-form-field>
75
+ ` }]
76
+ }], propDecorators: { className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: true }] }], resource: [{ type: i0.Input, args: [{ isSignal: true, alias: "resource", required: true }] }], domain: [{ type: i0.Input, args: [{ isSignal: true, alias: "domain", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }] } });
77
+
78
+ /**
79
+ * Generated bundle index. Do not edit.
80
+ */
81
+
82
+ export { CccInputFieldComponent, InputMode };
83
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-forms.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-forms.mjs","sources":["../../../projects/ccc-lib/src/auth-forms/ccc-field/ccc-field.component.ts","../../../projects/ccc-lib/src/auth-forms/cccteam-ccc-lib-src-auth-forms.ts"],"sourcesContent":["import { Component, computed, inject, input, OnInit, signal, Signal } from '@angular/core';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { Domain, ReadPermission, Resource, UpdatePermission } from '@cccteam/ccc-lib/src/types';\n\nexport enum InputMode {\n Read = 'read',\n Edit = 'edit',\n}\n\n@Component({\n selector: 'ccc-input-field',\n imports: [MatFormFieldModule, MatInputModule],\n template: `\n <mat-form-field [class]=\"className()\">\n <mat-label>{{ name() }}</mat-label>\n <input matInput [disabled]=\"mode() === inputMode.Edit && canEdit()\" [value]=\"value()\" />\n </mat-form-field>\n `,\n styleUrl: './ccc-field.component.scss',\n})\nexport class CccInputFieldComponent implements OnInit {\n auth = inject(AuthService);\n className = input();\n mode = input.required<InputMode>();\n resource = input.required<Resource>();\n domain = input.required<Domain>();\n value = input.required();\n name = input.required<string>();\n\n inputMode = InputMode;\n\n canEdit: Signal<boolean> = signal(false);\n canEditSelector = false;\n\n canRead: Signal<boolean> = signal(false);\n canReadSelector = false;\n\n ngOnInit(): void {\n this.canEditSelector = this.auth.hasPermission({\n resource: this.resource(),\n permission: ReadPermission,\n domain: this.domain(),\n });\n this.canReadSelector = this.auth.hasPermission({\n resource: this.resource(),\n permission: UpdatePermission,\n domain: this.domain(),\n });\n\n this.canRead = computed(() => {\n const res = this.resource();\n if (!res) {\n return false;\n }\n if (AuthService.requiresPermission(this.resource(), ReadPermission)) {\n return this.canReadSelector;\n }\n return false;\n });\n\n this.canEdit = computed(() => {\n const res = this.resource();\n if (!res) {\n return false;\n }\n if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {\n return this.canEditSelector;\n }\n return false;\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;IAMY;AAAZ,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAHW,SAAS,KAAT,SAAS,GAAA,EAAA,CAAA,CAAA;MAgBR,sBAAsB,CAAA;AACjC,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAC1B,SAAS,GAAG,KAAK,CAAA,SAAA,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,WAAA,EAAA,GAAA,EAAA,CAAA,EAAA,CAAE;AACnB,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,iDAAa;AAClC,IAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,qDAAY;AACrC,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,mDAAU;AACjC,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,kDAAE;AACxB,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,iDAAU;IAE/B,SAAS,GAAG,SAAS;AAErB,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,qDAAC;IACxC,eAAe,GAAG,KAAK;AAEvB,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,qDAAC;IACxC,eAAe,GAAG,KAAK;IAEvB,QAAQ,GAAA;QACN,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;AAC7C,YAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;AACzB,YAAA,UAAU,EAAE,cAAc;AAC1B,YAAA,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;AACtB,SAAA,CAAC;QACF,IAAI,CAAC,eAAe,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EAAA,MAAA,EAAA,mBAAA,EAAA,kBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,qBAAA,CAAA,EAAA,QAAA,EAAA,CAAA,UAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FASjC,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAXlC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,iBAAiB,WAClB,CAAC,kBAAkB,EAAE,cAAc,CAAC,EAAA,QAAA,EACnC;;;;;AAKT,EAAA,CAAA,EAAA;;;ACnBH;;AAEG;;;;"}
@@ -0,0 +1,44 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, TemplateRef, ViewContainerRef, signal, effect, Input, Directive } from '@angular/core';
3
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
4
+
5
+ class HasPermissionDirective {
6
+ auth = inject(AuthService);
7
+ templateRef = inject((TemplateRef));
8
+ viewContainer = inject(ViewContainerRef);
9
+ scope = signal(undefined, { ...(ngDevMode ? { debugName: "scope" } : {}) });
10
+ set cccHasPermission(scope) {
11
+ this.scope.set(scope);
12
+ }
13
+ constructor() {
14
+ effect(() => {
15
+ const scope = this.scope();
16
+ if (this.auth.hasPermission(scope) && this.auth.authenticated()) {
17
+ if (!this.viewContainer.get(0)) {
18
+ this.viewContainer.createEmbeddedView(this.templateRef);
19
+ }
20
+ }
21
+ else {
22
+ this.viewContainer.clear();
23
+ }
24
+ });
25
+ }
26
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: HasPermissionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
27
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.2", type: HasPermissionDirective, isStandalone: true, selector: "[cccHasPermission]", inputs: { cccHasPermission: "cccHasPermission" }, ngImport: i0 });
28
+ }
29
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: HasPermissionDirective, decorators: [{
30
+ type: Directive,
31
+ args: [{
32
+ selector: '[cccHasPermission]',
33
+ standalone: true,
34
+ }]
35
+ }], ctorParameters: () => [], propDecorators: { cccHasPermission: [{
36
+ type: Input
37
+ }] } });
38
+
39
+ /**
40
+ * Generated bundle index. Do not edit.
41
+ */
42
+
43
+ export { HasPermissionDirective };
44
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-has-permission.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-has-permission.mjs","sources":["../../../projects/ccc-lib/src/auth-has-permission/has-permission.directive.ts","../../../projects/ccc-lib/src/auth-has-permission/cccteam-ccc-lib-src-auth-has-permission.ts"],"sourcesContent":["import { Directive, Input, TemplateRef, ViewContainerRef, effect, inject, signal } from '@angular/core';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { PermissionScope } from '@cccteam/ccc-lib/src/types';\n\n@Directive({\n selector: '[cccHasPermission]',\n standalone: true,\n})\nexport class HasPermissionDirective {\n private auth = inject(AuthService);\n private templateRef = inject(TemplateRef<unknown>);\n private viewContainer = inject(ViewContainerRef);\n\n private scope = signal<PermissionScope | undefined>(undefined);\n\n @Input()\n set cccHasPermission(scope: PermissionScope) {\n this.scope.set(scope);\n }\n\n constructor() {\n effect(() => {\n const scope = this.scope();\n\n if (this.auth.hasPermission(scope) && this.auth.authenticated()) {\n if (!this.viewContainer.get(0)) {\n this.viewContainer.createEmbeddedView(this.templateRef);\n }\n } else {\n this.viewContainer.clear();\n }\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAQa,sBAAsB,CAAA;AACzB,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAC1B,IAAA,WAAW,GAAG,MAAM,EAAC,WAAoB,EAAC;AAC1C,IAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAExC,IAAA,KAAK,GAAG,MAAM,CAA8B,SAAS,mDAAC;IAE9D,IACI,gBAAgB,CAAC,KAAsB,EAAA;AACzC,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;IACvB;AAEA,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE;AAE1B,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE;gBAC/D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBAC9B,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC;gBACzD;YACF;iBAAO;AACL,gBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;YAC5B;AACF,QAAA,CAAC,CAAC;IACJ;uGAxBW,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAtB,sBAAsB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,EAAA,gBAAA,EAAA,kBAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAJlC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;;sBAQE;;;ACfH;;AAEG;;;;"}
@@ -0,0 +1,82 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, signal, Injectable } from '@angular/core';
4
+ import { API_URL, FRONTEND_LOGIN_PATH, SESSION_PATH, PERMISSION_REQUIRED } from '@cccteam/ccc-lib/src/types';
5
+ import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
6
+ import { map, tap } from 'rxjs';
7
+
8
+ class AuthService {
9
+ apiUrl = inject(API_URL);
10
+ loginUrl = inject(FRONTEND_LOGIN_PATH);
11
+ sessionUrl = inject(SESSION_PATH);
12
+ http = inject(HttpClient);
13
+ authenticatedSignal = signal(false, { ...(ngDevMode ? { debugName: "authenticatedSignal" } : {}) });
14
+ sessionInfoSignal = signal({}, { ...(ngDevMode ? { debugName: "sessionInfoSignal" } : {}) });
15
+ redirectUrl = signal('', { ...(ngDevMode ? { debugName: "redirectUrl" } : {}) });
16
+ authenticated = this.authenticatedSignal.asReadonly();
17
+ sessionInfo = this.sessionInfoSignal.asReadonly();
18
+ constructor() {
19
+ this.initializePermissionFn();
20
+ }
21
+ static permissionFn;
22
+ hasPermission(scope) {
23
+ if (!scope)
24
+ return true;
25
+ const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];
26
+ return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);
27
+ }
28
+ static requiresPermission(resource, permission) {
29
+ if (!AuthService.permissionFn) {
30
+ throw new Error(`AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`);
31
+ }
32
+ return AuthService.permissionFn(resource, permission);
33
+ }
34
+ initializePermissionFn() {
35
+ if (!AuthService.permissionFn) {
36
+ AuthService.permissionFn = inject(PERMISSION_REQUIRED);
37
+ }
38
+ }
39
+ /**
40
+ * Logs a user out.
41
+ *
42
+ * @returns Observable with a boolean indicating whether they were logged out.
43
+ */
44
+ logout() {
45
+ return this.http
46
+ .delete(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false))
47
+ .pipe(map(() => true))
48
+ .pipe(tap(() => {
49
+ this.authenticatedSignal.set(false);
50
+ this.sessionInfoSignal.set({});
51
+ }));
52
+ }
53
+ /**
54
+ * Checks a user's session with the server.
55
+ *
56
+ * @returns Observable with the user session info
57
+ */
58
+ checkUserSession() {
59
+ return this.http.get(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false)).pipe(tap((sessionInfo) => {
60
+ this.authenticatedSignal.set(!!sessionInfo?.authenticated);
61
+ this.sessionInfoSignal.set(sessionInfo);
62
+ }));
63
+ }
64
+ loginRoute() {
65
+ return this.loginUrl;
66
+ }
67
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
68
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AuthService, providedIn: 'root' });
69
+ }
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AuthService, decorators: [{
71
+ type: Injectable,
72
+ args: [{
73
+ providedIn: 'root',
74
+ }]
75
+ }], ctorParameters: () => [] });
76
+
77
+ /**
78
+ * Generated bundle index. Do not edit.
79
+ */
80
+
81
+ export { AuthService };
82
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-service.mjs","sources":["../../../projects/ccc-lib/src/auth-service/auth.service.ts","../../../projects/ccc-lib/src/auth-service/cccteam-ccc-lib-src-auth-service.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { inject, Injectable, signal } from '@angular/core';\nimport {\n API_URL,\n FRONTEND_LOGIN_PATH,\n Permission,\n PERMISSION_REQUIRED,\n PermissionScope,\n Resource,\n SESSION_PATH,\n SessionInfo\n} from '@cccteam/ccc-lib/src/types';\nimport { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';\nimport { map, Observable, tap } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n private apiUrl = inject(API_URL);\n private loginUrl = inject(FRONTEND_LOGIN_PATH);\n private sessionUrl = inject(SESSION_PATH);\n\n http = inject(HttpClient);\n private authenticatedSignal = signal(false);\n private sessionInfoSignal = signal({} as SessionInfo);\n\n redirectUrl = signal('');\n authenticated = this.authenticatedSignal.asReadonly();\n sessionInfo = this.sessionInfoSignal.asReadonly();\n\n constructor() {\n this.initializePermissionFn();\n }\n\n private static permissionFn: (resource: Resource, permission: Permission) => boolean;\n\n hasPermission(scope?: PermissionScope): boolean {\n if (!scope) return true;\n const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];\n return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);\n }\n\n static requiresPermission(resource: Resource, permission: Permission): boolean {\n if (!AuthService.permissionFn) {\n throw new Error(\n `AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`,\n );\n }\n return AuthService.permissionFn(resource, permission);\n }\n\n private initializePermissionFn(): void {\n if (!AuthService.permissionFn) {\n AuthService.permissionFn = inject(PERMISSION_REQUIRED);\n }\n }\n\n /**\n * Logs a user out.\n *\n * @returns Observable with a boolean indicating whether they were logged out.\n */\n logout(): Observable<boolean> {\n return this.http\n .delete(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false))\n .pipe(map(() => true))\n .pipe(\n tap(() => {\n this.authenticatedSignal.set(false);\n this.sessionInfoSignal.set({} as SessionInfo);\n }),\n );\n }\n\n /**\n * Checks a user's session with the server.\n *\n * @returns Observable with the user session info\n */\n checkUserSession(): Observable<SessionInfo> {\n return this.http.get<SessionInfo>(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false)).pipe(\n tap((sessionInfo) => {\n this.authenticatedSignal.set(!!sessionInfo?.authenticated);\n this.sessionInfoSignal.set(sessionInfo);\n }),\n );\n }\n\n loginRoute(): string {\n return this.loginUrl;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAkBa,WAAW,CAAA;AACd,IAAA,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;AACxB,IAAA,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACt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E,MAAM;AACnB,iBAAA;;;ACjBD;;AAEG;;;;"}
@@ -0,0 +1,33 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Pipe } from '@angular/core';
3
+
4
+ class CamelCaseToTitlePipe {
5
+ transform(value) {
6
+ if (!value) {
7
+ return value;
8
+ }
9
+ if (value === value.toUpperCase() && !/[0-9]/.test(value)) {
10
+ return value;
11
+ }
12
+ let transformed = value.replace(/([A-Z])/g, ' $1');
13
+ transformed = transformed.replace(/([a-zA-Z])([0-9])/g, '$1 $2');
14
+ transformed = transformed.trim();
15
+ transformed = transformed.charAt(0).toUpperCase() + transformed.slice(1);
16
+ return transformed;
17
+ }
18
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: CamelCaseToTitlePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
19
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.2", ngImport: i0, type: CamelCaseToTitlePipe, isStandalone: true, name: "camelCaseToTitle" });
20
+ }
21
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: CamelCaseToTitlePipe, decorators: [{
22
+ type: Pipe,
23
+ args: [{
24
+ name: 'camelCaseToTitle',
25
+ }]
26
+ }] });
27
+
28
+ /**
29
+ * Generated bundle index. Do not edit.
30
+ */
31
+
32
+ export { CamelCaseToTitlePipe };
33
+ //# sourceMappingURL=cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs","sources":["../../../projects/ccc-lib/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts","../../../projects/ccc-lib/src/ccc-camel-case-to-title/cccteam-ccc-lib-src-ccc-camel-case-to-title.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'camelCaseToTitle',\n})\nexport class CamelCaseToTitlePipe implements PipeTransform {\n transform(value: string): string {\n if (!value) {\n return value;\n }\n\n if (value === value.toUpperCase() && !/[0-9]/.test(value)) {\n return value;\n }\n\n let transformed = value.replace(/([A-Z])/g, ' $1');\n transformed = transformed.replace(/([a-zA-Z])([0-9])/g, '$1 $2');\n transformed = transformed.trim();\n transformed = transformed.charAt(0).toUpperCase() + transformed.slice(1);\n\n return transformed;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAKa,oBAAoB,CAAA;AAC/B,IAAA,SAAS,CAAC,KAAa,EAAA;QACrB,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACzD,YAAA,OAAO,KAAK;QACd;QAEA,IAAI,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;QAClD,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;AAChE,QAAA,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE;AAChC,QAAA,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAExE,QAAA,OAAO,WAAW;IACpB;uGAhBW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAApB,oBAAoB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,kBAAA,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAHhC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,kBAAkB;AACzB,iBAAA;;;ACJD;;AAEG;;;;"}