@cccteam/ccc-lib 0.0.14 → 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 (58) hide show
  1. package/README.md +38 -13
  2. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -1
  3. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -1
  4. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +15 -49
  5. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -1
  6. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +4 -4
  7. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -1
  8. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +16 -22
  9. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -1
  10. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs +33 -0
  11. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs.map +1 -0
  12. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs +256 -0
  13. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs.map +1 -0
  14. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs +3129 -0
  15. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs.map +1 -0
  16. package/fesm2022/cccteam-ccc-lib-src-forms.mjs +79 -0
  17. package/fesm2022/cccteam-ccc-lib-src-forms.mjs.map +1 -0
  18. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs +6 -0
  19. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs.map +1 -0
  20. package/fesm2022/cccteam-ccc-lib-src-types.mjs +406 -112
  21. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -1
  22. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +3 -3
  23. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -1
  24. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs +7 -7
  25. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs.map +1 -1
  26. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs +157 -0
  27. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs.map +1 -0
  28. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +4 -4
  29. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -1
  30. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +5 -5
  31. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -1
  32. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +4 -4
  33. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -1
  34. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +1 -1
  35. package/fesm2022/cccteam-ccc-lib.mjs +4434 -12
  36. package/fesm2022/cccteam-ccc-lib.mjs.map +1 -1
  37. package/package.json +44 -18
  38. package/{src/auth-forms/index.d.ts → types/cccteam-ccc-lib-src-auth-forms.d.ts} +1 -18
  39. package/{src/auth-service/index.d.ts → types/cccteam-ccc-lib-src-auth-service.d.ts} +3 -1
  40. package/types/cccteam-ccc-lib-src-ccc-camel-case-to-title.d.ts +10 -0
  41. package/types/cccteam-ccc-lib-src-ccc-grid.d.ts +35 -0
  42. package/types/cccteam-ccc-lib-src-ccc-resource.d.ts +674 -0
  43. package/types/cccteam-ccc-lib-src-forms.d.ts +27 -0
  44. package/types/cccteam-ccc-lib-src-internal-types.d.ts +1 -0
  45. package/types/cccteam-ccc-lib-src-types.d.ts +934 -0
  46. package/types/cccteam-ccc-lib-src-ui-idle-service.d.ts +49 -0
  47. package/types/cccteam-ccc-lib.d.ts +1877 -0
  48. package/index.d.ts +0 -12
  49. package/src/types/index.d.ts +0 -133
  50. /package/{src/auth-authentication-guard/index.d.ts → types/cccteam-ccc-lib-src-auth-authentication-guard.d.ts} +0 -0
  51. /package/{src/auth-authorization-guard/index.d.ts → types/cccteam-ccc-lib-src-auth-authorization-guard.d.ts} +0 -0
  52. /package/{src/auth-has-permission/index.d.ts → types/cccteam-ccc-lib-src-auth-has-permission.d.ts} +0 -0
  53. /package/{src/ui-alert/index.d.ts → types/cccteam-ccc-lib-src-ui-alert.d.ts} +0 -0
  54. /package/{src/ui-core-service/index.d.ts → types/cccteam-ccc-lib-src-ui-core-service.d.ts} +0 -0
  55. /package/{src/ui-interceptor/index.d.ts → types/cccteam-ccc-lib-src-ui-interceptor.d.ts} +0 -0
  56. /package/{src/ui-notification-service/index.d.ts → types/cccteam-ccc-lib-src-ui-notification-service.d.ts} +0 -0
  57. /package/{src/ui-sidenav/index.d.ts → types/cccteam-ccc-lib-src-ui-sidenav.d.ts} +0 -0
  58. /package/{src/util-request-options/index.d.ts → types/cccteam-ccc-lib-src-util-request-options.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
+ ```
@@ -1 +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 './public-api';\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,CAAc,WAAA,EAAA,UAAU,EAAE;AAC9E,KAAC;AAED,IAAA,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE;AAC/B,QAAA,OAAO,EAAE,CAAC,IAAI,CAAC;;AAGjB,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;;AAGb,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,KAAK;AACd,KAAC,CAAC,EACF,UAAU,CAAC,MAAK;AACd,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,EAAE,CAAC,KAAK,CAAC;KACjB,CAAC,CACH;AACH;;ACvCA;;AAEG;;;;"}
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;;;;"}
@@ -1 +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 './public-api';\n"],"names":[],"mappings":";;;;AAIa,MAAA,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;;aACN;AACL,YAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;AACtB,YAAA,OAAO,KAAK;;AAEhB,KAAC,CAAC;AACJ;;AChBA;;AAEG;;;;"}
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;;;;"}
@@ -6,7 +6,6 @@ import * as i2 from '@angular/material/input';
6
6
  import { MatInputModule } from '@angular/material/input';
7
7
  import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
8
8
  import { ReadPermission, UpdatePermission } from '@cccteam/ccc-lib/src/types';
9
- import { isEqual } from 'lodash-es';
10
9
 
11
10
  var InputMode;
12
11
  (function (InputMode) {
@@ -15,16 +14,16 @@ var InputMode;
15
14
  })(InputMode || (InputMode = {}));
16
15
  class CccInputFieldComponent {
17
16
  auth = inject(AuthService);
18
- className = input();
19
- mode = input.required();
20
- resource = input.required();
21
- domain = input.required();
22
- value = input.required();
23
- name = input.required();
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" } : {}) });
24
23
  inputMode = InputMode;
25
- canEdit = signal(false);
24
+ canEdit = signal(false, { ...(ngDevMode ? { debugName: "canEdit" } : {}) });
26
25
  canEditSelector = false;
27
- canRead = signal(false);
26
+ canRead = signal(false, { ...(ngDevMode ? { debugName: "canRead" } : {}) });
28
27
  canReadSelector = false;
29
28
  ngOnInit() {
30
29
  this.canEditSelector = this.auth.hasPermission({
@@ -46,7 +45,7 @@ class CccInputFieldComponent {
46
45
  return this.canReadSelector;
47
46
  }
48
47
  return false;
49
- });
48
+ }, { ...(ngDevMode ? { debugName: "canRead" } : {}) });
50
49
  this.canEdit = computed(() => {
51
50
  const res = this.resource();
52
51
  if (!res) {
@@ -56,17 +55,17 @@ class CccInputFieldComponent {
56
55
  return this.canEditSelector;
57
56
  }
58
57
  return false;
59
- });
58
+ }, { ...(ngDevMode ? { debugName: "canEdit" } : {}) });
60
59
  }
61
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CccInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
62
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.0.0", 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: `
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: `
63
62
  <mat-form-field [class]="className()">
64
63
  <mat-label>{{ name() }}</mat-label>
65
64
  <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
66
65
  </mat-form-field>
67
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"] }] });
68
67
  }
69
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CccInputFieldComponent, decorators: [{
68
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: CccInputFieldComponent, decorators: [{
70
69
  type: Component,
71
70
  args: [{ selector: 'ccc-input-field', imports: [MatFormFieldModule, MatInputModule], template: `
72
71
  <mat-form-field [class]="className()">
@@ -74,44 +73,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
74
73
  <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
75
74
  </mat-form-field>
76
75
  ` }]
77
- }] });
78
-
79
- /**
80
- * Accepts a FormGroup and compares it to an object to return the dirty form values
81
- * as a sparse object
82
- * @param form - FormGroup
83
- * @param compareData - object to compare form values against
84
- * @returns Partial<T>
85
- * @example sparseFormData<UserCreate>(this.userForm, initUser)
86
- */
87
- function sparseFormData(form, compareData) {
88
- const sparseFormData = {};
89
- for (const [key, control] of Object.entries(form.controls)) {
90
- const controlValue = control.value;
91
- const compareValue = compareData[key];
92
- if (!isEqual(controlValue, compareValue)) {
93
- sparseFormData[key] = controlValue;
94
- }
95
- }
96
- return sparseFormData;
97
- }
98
- /**
99
- * Accepts a FormArray and removes empty strings
100
- * @param formArray - FormArray
101
- * @returns FormArray
102
- */
103
- function cleanStringFormArray(formArray) {
104
- for (let i = formArray.controls.length - 1; i >= 0; i--) {
105
- if (formArray.at(i).value === '') {
106
- formArray.removeAt(i);
107
- }
108
- }
109
- return formArray;
110
- }
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 }] }] } });
111
77
 
112
78
  /**
113
79
  * Generated bundle index. Do not edit.
114
80
  */
115
81
 
116
- export { CccInputFieldComponent, InputMode, cleanStringFormArray, sparseFormData };
82
+ export { CccInputFieldComponent, InputMode };
117
83
  //# sourceMappingURL=cccteam-ccc-lib-src-auth-forms.mjs.map
@@ -1 +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/form-helpers.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","import { FormArray, FormGroup } from '@angular/forms';\nimport { isEqual } from 'lodash-es';\n\n/**\n * Accepts a FormGroup and compares it to an object to return the dirty form values\n * as a sparse object\n * @param form - FormGroup\n * @param compareData - object to compare form values against\n * @returns Partial<T>\n * @example sparseFormData<UserCreate>(this.userForm, initUser)\n */\nexport function sparseFormData<T>(form: FormGroup, compareData: T): T {\n const sparseFormData: T = {} as T;\n\n for (const [key, control] of Object.entries(form.controls)) {\n const controlValue = control.value;\n const compareValue = compareData[key as keyof T];\n\n if (!isEqual(controlValue, compareValue)) {\n sparseFormData[key as keyof T] = controlValue as T[keyof T];\n }\n }\n\n return sparseFormData;\n}\n\n/**\n * Accepts a FormArray and removes empty strings\n * @param formArray - FormArray\n * @returns FormArray\n */\nexport function cleanStringFormArray(formArray: FormArray): FormArray {\n for (let i = formArray.controls.length - 1; i >= 0; i--) {\n if (formArray.at(i).value === '') {\n formArray.removeAt(i);\n }\n }\n return formArray;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\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,GAGpB,EAAA,CAAA,CAAA;MAaY,sBAAsB,CAAA;AACjC,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAC1B,SAAS,GAAG,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,YAAY,GAAG,OAAO,CAAC,KAAK;AAClC,QAAA,MAAM,YAAY,GAAG,WAAW,CAAC,GAAc,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE;AACxC,YAAA,cAAc,CAAC,GAAc,CAAC,GAAG,YAA0B;;;AAI/D,IAAA,OAAO,cAAc;AACvB;AAEA;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,SAAoB,EAAA;AACvD,IAAA,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACvD,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,EAAE;AAChC,YAAA,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;;;AAGzB,IAAA,OAAO,SAAS;AAClB;;ACtCA;;AAEG;;;;"}
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,KA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AA,iBAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EARvB;;;;;GAKT,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EANS,kBAAkB,0SAAE,cAAc,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,QAAA,EAAA,QAAA,EAAA,yHAAA,EAAA,MAAA,EAAA,CAAA,UAAA,EAAA,IAAA,EAAA,aAAA,EAAA,MAAA,EAAA,UAAA,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;;;;"}
@@ -6,7 +6,7 @@ class HasPermissionDirective {
6
6
  auth = inject(AuthService);
7
7
  templateRef = inject((TemplateRef));
8
8
  viewContainer = inject(ViewContainerRef);
9
- scope = signal(undefined);
9
+ scope = signal(undefined, { ...(ngDevMode ? { debugName: "scope" } : {}) });
10
10
  set cccHasPermission(scope) {
11
11
  this.scope.set(scope);
12
12
  }
@@ -23,10 +23,10 @@ class HasPermissionDirective {
23
23
  }
24
24
  });
25
25
  }
26
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: HasPermissionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
27
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0", type: HasPermissionDirective, isStandalone: true, selector: "[cccHasPermission]", inputs: { cccHasPermission: "cccHasPermission" }, ngImport: i0 });
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
28
  }
29
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: HasPermissionDirective, decorators: [{
29
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: HasPermissionDirective, decorators: [{
30
30
  type: Directive,
31
31
  args: [{
32
32
  selector: '[cccHasPermission]',
@@ -1 +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 './public-api';\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,CAAC;IAE9D,IACI,gBAAgB,CAAC,KAAsB,EAAA;AACzC,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;;AAGvB,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;;;iBAEpD;AACL,gBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;;AAE9B,SAAC,CAAC;;uGAvBO,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;wDASK,gBAAgB,EAAA,CAAA;sBADnB;;;ACfH;;AAEG;;;;"}
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;;;;"}
@@ -1,24 +1,21 @@
1
1
  import { HttpClient } from '@angular/common/http';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, signal, Inject, Injectable } from '@angular/core';
4
- import { PERMISSION_REQUIRED, API_URL } from '@cccteam/ccc-lib/src/types';
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
5
  import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
6
6
  import { map, tap } from 'rxjs';
7
7
 
8
- const routes = {
9
- login: (rootUrl) => `${rootUrl}/user/login`,
10
- session: (rootUrl) => `${rootUrl}/user/session`,
11
- };
12
8
  class AuthService {
13
- apiUrl;
9
+ apiUrl = inject(API_URL);
10
+ loginUrl = inject(FRONTEND_LOGIN_PATH);
11
+ sessionUrl = inject(SESSION_PATH);
14
12
  http = inject(HttpClient);
15
- authenticatedSignal = signal(false);
16
- sessionInfoSignal = signal({});
17
- redirectUrl = signal('');
13
+ authenticatedSignal = signal(false, { ...(ngDevMode ? { debugName: "authenticatedSignal" } : {}) });
14
+ sessionInfoSignal = signal({}, { ...(ngDevMode ? { debugName: "sessionInfoSignal" } : {}) });
15
+ redirectUrl = signal('', { ...(ngDevMode ? { debugName: "redirectUrl" } : {}) });
18
16
  authenticated = this.authenticatedSignal.asReadonly();
19
17
  sessionInfo = this.sessionInfoSignal.asReadonly();
20
- constructor(apiUrl) {
21
- this.apiUrl = apiUrl;
18
+ constructor() {
22
19
  this.initializePermissionFn();
23
20
  }
24
21
  static permissionFn;
@@ -46,7 +43,7 @@ class AuthService {
46
43
  */
47
44
  logout() {
48
45
  return this.http
49
- .delete(routes.session(this.apiUrl), errorOptions(false))
46
+ .delete(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false))
50
47
  .pipe(map(() => true))
51
48
  .pipe(tap(() => {
52
49
  this.authenticatedSignal.set(false);
@@ -59,26 +56,23 @@ class AuthService {
59
56
  * @returns Observable with the user session info
60
57
  */
61
58
  checkUserSession() {
62
- return this.http.get(routes.session(this.apiUrl), errorOptions(false)).pipe(tap((sessionInfo) => {
59
+ return this.http.get(`${this.apiUrl}/${this.sessionUrl}`, errorOptions(false)).pipe(tap((sessionInfo) => {
63
60
  this.authenticatedSignal.set(!!sessionInfo?.authenticated);
64
61
  this.sessionInfoSignal.set(sessionInfo);
65
62
  }));
66
63
  }
67
64
  loginRoute() {
68
- return routes.login(this.apiUrl);
65
+ return this.loginUrl;
69
66
  }
70
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, deps: [{ token: API_URL }], target: i0.ɵɵFactoryTarget.Injectable });
71
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, providedIn: 'root' });
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' });
72
69
  }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, decorators: [{
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AuthService, decorators: [{
74
71
  type: Injectable,
75
72
  args: [{
76
73
  providedIn: 'root',
77
74
  }]
78
- }], ctorParameters: () => [{ type: undefined, decorators: [{
79
- type: Inject,
80
- args: [API_URL]
81
- }] }] });
75
+ }], ctorParameters: () => [] });
82
76
 
83
77
  /**
84
78
  * Generated bundle index. Do not edit.
@@ -1 +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, Inject, Injectable, signal } from '@angular/core';\nimport {\n API_URL,\n Permission,\n PERMISSION_REQUIRED,\n PermissionScope,\n Resource,\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\nconst routes = {\n login: (rootUrl: string): string => `${rootUrl}/user/login`,\n session: (rootUrl: string): string => `${rootUrl}/user/session`,\n};\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\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(@Inject(API_URL) private apiUrl: string) {\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(routes.session(this.apiUrl), 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>(routes.session(this.apiUrl), 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 routes.login(this.apiUrl);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\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AA,EAAA,CAAA;AAThB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,cAFV,MAAM,EAAA,CAAA;;2FAEP,WAAW,EAAA,UAAA,EAAA,CAAA;kBAHvB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;0BAUc,MAAM;2BAAC,OAAO;;;AC9B7B;;AAEG;;;;"}
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;AACtC,IAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC;AAEzC,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACjB,IAAA,mBAAmB,GAAG,MAAM,CAAC,KAAK,iEAAC;AACnC,IAAA,iBAAiB,GAAG,MAAM,CAAC,EAAiB,+DAAC;AAErD,IAAA,WAAW,GAAG,MAAM,CAAC,EAAE,yDAAC;AACxB,IAAA,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAA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BAAiB,CAAC,GAAG,CAAC,EAAiB,CAAC;QAC/C,CAAC,CAAC,CACH;IACL;AAEA;;;;AAIG;IACH,gBAAgB,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,CAAA,EAAG,IAAI,CAAC,MAAM,CAAA,CAAA,EAAI,IAAI,CAAC,UAAU,CAAA,CAAE,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC9F,GAAG,CAAC,CAAC,WAAW,KAAI;YAClB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,aAAa,CAAC;AAC1D,YAAA,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC;QACzC,CAAC,CAAC,CACH;IACH;IAEA,UAAU,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ;IACtB;uGAzEW,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAX,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,cAFV,MAAM,EAAA,CAAA;;2FAEP,WAAW,EAAA,UAAA,EAAA,CAAA;kBAHvB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,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;;;;"}