@cccteam/ccc-lib 0.0.11 → 0.0.12

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 (77) hide show
  1. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +44 -0
  2. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -0
  3. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +24 -0
  4. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -0
  5. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +118 -0
  6. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -0
  7. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +51 -0
  8. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -0
  9. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +56 -0
  10. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -0
  11. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs +109 -0
  12. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs.map +1 -0
  13. package/fesm2022/cccteam-ccc-lib-src-types.mjs +137 -0
  14. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -0
  15. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +48 -0
  16. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -0
  17. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs +100 -0
  18. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs.map +1 -0
  19. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +48 -0
  20. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -0
  21. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +57 -0
  22. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -0
  23. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +70 -0
  24. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -0
  25. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +19 -0
  26. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +1 -0
  27. package/fesm2022/cccteam-ccc-lib.mjs +13 -729
  28. package/fesm2022/cccteam-ccc-lib.mjs.map +1 -1
  29. package/package.json +54 -2
  30. package/public-api.d.ts +13 -19
  31. package/src/auth-authentication-guard/index.d.ts +5 -0
  32. package/src/auth-authentication-guard/public-api.d.ts +1 -0
  33. package/src/auth-authorization-guard/index.d.ts +5 -0
  34. package/src/auth-authorization-guard/public-api.d.ts +1 -0
  35. package/{lib/auth/forms → src/auth-forms}/ccc-field/ccc-field.component.d.ts +1 -1
  36. package/src/auth-forms/index.d.ts +5 -0
  37. package/src/auth-forms/public-api.d.ts +2 -0
  38. package/{lib/auth/directives → src/auth-has-permission}/has-permission.directive.d.ts +1 -1
  39. package/src/auth-has-permission/index.d.ts +5 -0
  40. package/src/auth-has-permission/public-api.d.ts +1 -0
  41. package/{lib/auth/services → src/auth-service}/auth.service.d.ts +1 -1
  42. package/src/auth-service/index.d.ts +5 -0
  43. package/src/auth-service/public-api.d.ts +1 -0
  44. package/{lib/auth/state → src/auth-state}/auth.state.d.ts +1 -2
  45. package/src/auth-state/index.d.ts +5 -0
  46. package/src/auth-state/public-api.d.ts +1 -0
  47. package/{lib/auth/state → src/types}/auth.actions.d.ts +1 -1
  48. package/{lib/ui/state → src/types}/core.actions.d.ts +1 -1
  49. package/src/types/index.d.ts +5 -0
  50. package/src/types/public-api.d.ts +6 -0
  51. package/{lib/types/base → src/types}/tokens.d.ts +1 -1
  52. package/{lib/ui/components/alert → src/ui-alert}/alert.component.d.ts +2 -2
  53. package/src/ui-alert/index.d.ts +5 -0
  54. package/src/ui-alert/public-api.d.ts +1 -0
  55. package/{lib/ui/state → src/ui-core-state}/core.state.d.ts +1 -2
  56. package/src/ui-core-state/index.d.ts +5 -0
  57. package/src/ui-core-state/public-api.d.ts +1 -0
  58. package/src/ui-interceptor/index.d.ts +5 -0
  59. package/src/ui-interceptor/public-api.d.ts +1 -0
  60. package/src/ui-notification-service/index.d.ts +5 -0
  61. package/{lib/ui/services → src/ui-notification-service}/notification.service.d.ts +1 -1
  62. package/src/ui-notification-service/public-api.d.ts +1 -0
  63. package/src/ui-sidenav/index.d.ts +5 -0
  64. package/src/ui-sidenav/public-api.d.ts +1 -0
  65. package/{lib/ui/components/sidenav → src/ui-sidenav}/sidenav.component.d.ts +1 -1
  66. package/src/util-request-options/index.d.ts +5 -0
  67. package/src/util-request-options/public-api.d.ts +1 -0
  68. package/cccteam-ccc-lib-0.0.10.tgz +0 -0
  69. package/cccteam-ccc-lib-0.0.11.tgz +0 -0
  70. /package/{lib/auth/guards → src/auth-authentication-guard}/authentication.guard.d.ts +0 -0
  71. /package/{lib/auth/guards → src/auth-authorization-guard}/authorization.guard.d.ts +0 -0
  72. /package/{lib/auth/forms → src/auth-forms}/form-helpers.d.ts +0 -0
  73. /package/{lib → src}/types/notification-message.d.ts +0 -0
  74. /package/{lib → src}/types/permissions.d.ts +0 -0
  75. /package/{lib → src}/types/session-info.d.ts +0 -0
  76. /package/{lib/ui/interceptor → src/ui-interceptor}/api.interceptor.d.ts +0 -0
  77. /package/{lib/auth/services → src/util-request-options}/request-options.d.ts +0 -0
@@ -0,0 +1,44 @@
1
+ import { inject } from '@angular/core';
2
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
3
+ import { AuthState } from '@cccteam/ccc-lib/src/auth-state';
4
+ import { BASE_URL, AuthenticationGuardAction } from '@cccteam/ccc-lib/src/types';
5
+ import { Store } from '@ngxs/store';
6
+ import { of } from 'rxjs';
7
+ import { switchMap, map, catchError } from 'rxjs/operators';
8
+
9
+ const AuthenticationGuard = (route, routerState) => {
10
+ const store = inject(Store);
11
+ const authService = inject(AuthService);
12
+ const baseUrl = inject(BASE_URL);
13
+ const authenticate = () => {
14
+ const url = routerState.url;
15
+ const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);
16
+ const encodedUrl = encodeURIComponent(absoluteUrl);
17
+ window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;
18
+ };
19
+ return store.select(AuthState.isAuthenticated).pipe(switchMap((authenticated) => {
20
+ if (authenticated) {
21
+ return of(authenticated);
22
+ }
23
+ // Handle uninitialized state (ie Browser reload)
24
+ return store.dispatch(AuthenticationGuardAction.CheckUserSession).pipe(switchMap(() => {
25
+ return store.select(AuthState.isAuthenticated);
26
+ }));
27
+ }), map((authenticated) => {
28
+ if (authenticated) {
29
+ return true;
30
+ }
31
+ authenticate();
32
+ return false;
33
+ }), catchError(() => {
34
+ authenticate();
35
+ return of(false);
36
+ }));
37
+ };
38
+
39
+ /**
40
+ * Generated bundle index. Do not edit.
41
+ */
42
+
43
+ export { AuthenticationGuard };
44
+ //# 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 { AuthState } from '@cccteam/ccc-lib/src/auth-state';\nimport { AuthenticationGuardAction, BASE_URL } from '@cccteam/ccc-lib/src/types';\nimport { Store } from '@ngxs/store';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map, switchMap } from 'rxjs/operators';\n\nexport const AuthenticationGuard = (\n route: ActivatedRouteSnapshot,\n routerState: RouterStateSnapshot,\n): Observable<boolean> => {\n const store = inject(Store);\n const authService = inject(AuthService);\n\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 return store.select(AuthState.isAuthenticated).pipe(\n switchMap((authenticated) => {\n if (authenticated) {\n return of(authenticated);\n }\n // Handle uninitialized state (ie Browser reload)\n return store.dispatch(AuthenticationGuardAction.CheckUserSession).pipe(\n switchMap(() => {\n return store.select(AuthState.isAuthenticated);\n }),\n );\n }),\n map((authenticated) => {\n if (authenticated) {\n return true;\n }\n\n authenticate();\n\n return false;\n }),\n catchError(() => {\n authenticate();\n\n return of(false);\n }),\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MASa,mBAAmB,GAAG,CACjC,KAA6B,EAC7B,WAAgC,KACT;AACvB,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAC3B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAEvC,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,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,IAAI,CACjD,SAAS,CAAC,CAAC,aAAa,KAAI;QAC1B,IAAI,aAAa,EAAE;AACjB,YAAA,OAAO,EAAE,CAAC,aAAa,CAAC;;;AAG1B,QAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC,IAAI,CACpE,SAAS,CAAC,MAAK;YACb,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;SAC/C,CAAC,CACH;AACH,KAAC,CAAC,EACF,GAAG,CAAC,CAAC,aAAa,KAAI;QACpB,IAAI,aAAa,EAAE;AACjB,YAAA,OAAO,IAAI;;AAGb,QAAA,YAAY,EAAE;AAEd,QAAA,OAAO,KAAK;AACd,KAAC,CAAC,EACF,UAAU,CAAC,MAAK;AACd,QAAA,YAAY,EAAE;AAEd,QAAA,OAAO,EAAE,CAAC,KAAK,CAAC;KACjB,CAAC,CACH;AACH;;ACpDA;;AAEG;;;;"}
@@ -0,0 +1,24 @@
1
+ import { inject } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { AuthState } from '@cccteam/ccc-lib/src/auth-state';
4
+ import { Store } from '@ngxs/store';
5
+ import { map } from 'rxjs';
6
+
7
+ const AuthorizationGuard = (route) => {
8
+ const store = inject(Store);
9
+ const router = inject(Router);
10
+ return store.select(AuthState.hasPermission).pipe(map((permissionFn) => permissionFn(route.data['scope'])), map((hasPermission) => {
11
+ if (hasPermission) {
12
+ return true;
13
+ }
14
+ router.navigate(['/']);
15
+ return false;
16
+ }));
17
+ };
18
+
19
+ /**
20
+ * Generated bundle index. Do not edit.
21
+ */
22
+
23
+ export { AuthorizationGuard };
24
+ //# 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 { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { AuthState } from '@cccteam/ccc-lib/src/auth-state';\nimport { Store } from '@ngxs/store';\nimport { map, Observable } from 'rxjs';\n\nexport const AuthorizationGuard = (route: ActivatedRouteSnapshot): Observable<boolean> => {\n const store = inject(Store);\n const router = inject(Router);\n return store.select(AuthState.hasPermission).pipe(\n map((permissionFn) => permissionFn(route.data['scope'])),\n map((hasPermission) => {\n if (hasPermission) {\n return true;\n }\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":";;;;;;AAMa,MAAA,kBAAkB,GAAG,CAAC,KAA6B,KAAyB;AACvF,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAC3B,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B,IAAA,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAC/C,GAAG,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EACxD,GAAG,CAAC,CAAC,aAAa,KAAI;QACpB,IAAI,aAAa,EAAE;AACjB,YAAA,OAAO,IAAI;;AAEb,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;AACtB,QAAA,OAAO,KAAK;KACb,CAAC,CACH;AACH;;ACnBA;;AAEG;;;;"}
@@ -0,0 +1,118 @@
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 { AuthState } from '@cccteam/ccc-lib/src/auth-state';
8
+ import { ReadPermission, UpdatePermission } from '@cccteam/ccc-lib/src/types';
9
+ import { Store } from '@ngxs/store';
10
+ import { isEqual } from 'lodash-es';
11
+
12
+ var InputMode;
13
+ (function (InputMode) {
14
+ InputMode["Read"] = "read";
15
+ InputMode["Edit"] = "edit";
16
+ })(InputMode || (InputMode = {}));
17
+ class CccInputFieldComponent {
18
+ store = inject(Store);
19
+ className = input();
20
+ mode = input.required();
21
+ resource = input.required();
22
+ domain = input.required();
23
+ value = input.required();
24
+ name = input.required();
25
+ inputMode = InputMode;
26
+ canEdit = signal(false);
27
+ canEditSelector = false;
28
+ canRead = signal(false);
29
+ canReadSelector = false;
30
+ ngOnInit() {
31
+ this.canEditSelector = this.store.selectSnapshot(AuthState.hasPermission)({
32
+ resource: this.resource(),
33
+ permission: ReadPermission,
34
+ domain: this.domain(),
35
+ });
36
+ this.canReadSelector = this.store.selectSnapshot(AuthState.hasPermission)({
37
+ resource: this.resource(),
38
+ permission: UpdatePermission,
39
+ domain: this.domain(),
40
+ });
41
+ this.canRead = computed(() => {
42
+ const res = this.resource();
43
+ if (!res) {
44
+ return false;
45
+ }
46
+ if (AuthState.requiresPermission(this.resource(), ReadPermission)) {
47
+ return this.canReadSelector;
48
+ }
49
+ return false;
50
+ });
51
+ this.canEdit = computed(() => {
52
+ const res = this.resource();
53
+ if (!res) {
54
+ return false;
55
+ }
56
+ if (AuthState.requiresPermission(this.resource(), UpdatePermission)) {
57
+ return this.canEditSelector;
58
+ }
59
+ return false;
60
+ });
61
+ }
62
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: CccInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
63
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.3", 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: `
64
+ <mat-form-field [class]="className()">
65
+ <mat-label>{{ name() }}</mat-label>
66
+ <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
67
+ </mat-form-field>
68
+ `, 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"] }] });
69
+ }
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: CccInputFieldComponent, decorators: [{
71
+ type: Component,
72
+ args: [{ selector: 'ccc-input-field', imports: [MatFormFieldModule, MatInputModule], template: `
73
+ <mat-form-field [class]="className()">
74
+ <mat-label>{{ name() }}</mat-label>
75
+ <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
76
+ </mat-form-field>
77
+ ` }]
78
+ }] });
79
+
80
+ /**
81
+ * Accepts a FormGroup and compares it to an object to return the dirty form values
82
+ * as a sparse object
83
+ * @param form - FormGroup
84
+ * @param compareData - object to compare form values against
85
+ * @returns Partial<T>
86
+ * @example sparseFormData<UserCreate>(this.userForm, initUser)
87
+ */
88
+ function sparseFormData(form, compareData) {
89
+ const sparseFormData = {};
90
+ for (const [key, control] of Object.entries(form.controls)) {
91
+ const controlValue = control.value;
92
+ const compareValue = compareData[key];
93
+ if (!isEqual(controlValue, compareValue)) {
94
+ sparseFormData[key] = controlValue;
95
+ }
96
+ }
97
+ return sparseFormData;
98
+ }
99
+ /**
100
+ * Accepts a FormArray and removes empty strings
101
+ * @param formArray - FormArray
102
+ * @returns FormArray
103
+ */
104
+ function cleanStringFormArray(formArray) {
105
+ for (let i = formArray.controls.length - 1; i >= 0; i--) {
106
+ if (formArray.at(i).value === '') {
107
+ formArray.removeAt(i);
108
+ }
109
+ }
110
+ return formArray;
111
+ }
112
+
113
+ /**
114
+ * Generated bundle index. Do not edit.
115
+ */
116
+
117
+ export { CccInputFieldComponent, InputMode, cleanStringFormArray, sparseFormData };
118
+ //# 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/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 { AuthState } from '@cccteam/ccc-lib/src/auth-state';\nimport { Domain, ReadPermission, Resource, UpdatePermission } from '@cccteam/ccc-lib/src/types';\nimport { Store } from '@ngxs/store';\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 store = inject(Store);\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.store.selectSnapshot(AuthState.hasPermission)({\n resource: this.resource(),\n permission: ReadPermission,\n domain: this.domain(),\n });\n this.canReadSelector = this.store.selectSnapshot(AuthState.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 (AuthState.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 (AuthState.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":";;;;;;;;;;;IAOY;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,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACrB,SAAS,GAAG,KAAK,EAAE;AACnB,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAa;AAClC,IAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAY;AACrC,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAU;AACjC,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE;AACxB,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAU;IAE/B,SAAS,GAAG,SAAS;AAErB,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,CAAC;IACxC,eAAe,GAAG,KAAK;AAEvB,IAAA,OAAO,GAAoB,MAAM,CAAC,KAAK,CAAC;IACxC,eAAe,GAAG,KAAK;IAEvB,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AACxE,YAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;AACzB,YAAA,UAAU,EAAE,cAAc;AAC1B,YAAA,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;AACtB,SAAA,CAAC;AACF,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;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,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,EACnC,QAAA,EAAA;;;;;AAKT,EAAA,CAAA,EAAA;;;ACjBH;;;;;;;AAOG;AACa,SAAA,cAAc,CAAI,IAAe,EAAE,WAAc,EAAA;IAC/D,MAAM,cAAc,GAAM,EAAO;AAEjC,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC1D,QAAA,MAAM,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;;;;"}
@@ -0,0 +1,51 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, TemplateRef, ViewContainerRef, Directive, Input } from '@angular/core';
3
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
+ import { AuthState } from '@cccteam/ccc-lib/src/auth-state';
5
+ import { Store } from '@ngxs/store';
6
+ import { Subject, combineLatest, map, catchError, of } from 'rxjs';
7
+
8
+ class HasPermissionDirective {
9
+ templateRef = inject((TemplateRef));
10
+ viewContainer = inject(ViewContainerRef);
11
+ store = inject(Store);
12
+ scope = new Subject();
13
+ set cccHasPermission(scope) {
14
+ this.scope.next(scope);
15
+ }
16
+ constructor() {
17
+ combineLatest({
18
+ permissionFn: this.store.select(AuthState.hasPermission),
19
+ scope: this.scope.asObservable(),
20
+ })
21
+ .pipe(takeUntilDestroyed(), map(({ permissionFn, scope }) => (scope !== undefined ? permissionFn(scope) : true)), catchError(() => of(false)))
22
+ .subscribe((result) => {
23
+ if (result) {
24
+ if (!this.viewContainer.get(0)) {
25
+ this.viewContainer.createEmbeddedView(this.templateRef);
26
+ }
27
+ }
28
+ else {
29
+ this.viewContainer.clear();
30
+ }
31
+ });
32
+ }
33
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HasPermissionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
34
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.3", type: HasPermissionDirective, isStandalone: true, selector: "[cccHasPermission]", inputs: { cccHasPermission: "cccHasPermission" }, ngImport: i0 });
35
+ }
36
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: HasPermissionDirective, decorators: [{
37
+ type: Directive,
38
+ args: [{
39
+ selector: '[cccHasPermission]',
40
+ standalone: true,
41
+ }]
42
+ }], ctorParameters: () => [], propDecorators: { cccHasPermission: [{
43
+ type: Input
44
+ }] } });
45
+
46
+ /**
47
+ * Generated bundle index. Do not edit.
48
+ */
49
+
50
+ export { HasPermissionDirective };
51
+ //# 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, inject } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { AuthState } from '@cccteam/ccc-lib/src/auth-state';\nimport { PermissionScope } from '@cccteam/ccc-lib/src/types';\nimport { Store } from '@ngxs/store';\nimport { Subject, catchError, combineLatest, map, of } from 'rxjs';\n\n@Directive({\n selector: '[cccHasPermission]',\n standalone: true,\n})\nexport class HasPermissionDirective {\n private templateRef = inject(TemplateRef<unknown>);\n private viewContainer = inject(ViewContainerRef);\n private store = inject(Store);\n\n private scope = new Subject<PermissionScope>();\n\n @Input()\n set cccHasPermission(scope: PermissionScope) {\n this.scope.next(scope);\n }\n\n constructor() {\n combineLatest({\n permissionFn: this.store.select(AuthState.hasPermission),\n scope: this.scope.asObservable(),\n })\n .pipe(\n takeUntilDestroyed(),\n map(({ permissionFn, scope }) => (scope !== undefined ? permissionFn(scope) : true)),\n catchError(() => of(false)),\n )\n .subscribe((result) => {\n if (result) {\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":";;;;;;;MAWa,sBAAsB,CAAA;AACzB,IAAA,WAAW,GAAG,MAAM,EAAC,WAAoB,EAAC;AAC1C,IAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,IAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAErB,IAAA,KAAK,GAAG,IAAI,OAAO,EAAmB;IAE9C,IACI,gBAAgB,CAAC,KAAsB,EAAA;AACzC,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;;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Injectable, Inject } from '@angular/core';
3
+ import { API_URL } from '@cccteam/ccc-lib/src/types';
4
+ import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
5
+ import { map } from 'rxjs';
6
+ import * as i1 from '@angular/common/http';
7
+
8
+ const routes = {
9
+ login: (rootUrl) => `${rootUrl}/user/login`,
10
+ session: (rootUrl) => `${rootUrl}/user/session`,
11
+ };
12
+ class AuthService {
13
+ http;
14
+ apiUrl;
15
+ constructor(http, apiUrl) {
16
+ this.http = http;
17
+ this.apiUrl = apiUrl;
18
+ }
19
+ /**
20
+ * Logs a user out.
21
+ *
22
+ * @returns Observable with a boolean indicating whether they were logged out.
23
+ */
24
+ logout() {
25
+ return this.http.delete(routes.session(this.apiUrl), errorOptions(false)).pipe(map(() => true));
26
+ }
27
+ /**
28
+ * Checks a user's session with the server.
29
+ *
30
+ * @returns Observable with the user session info
31
+ */
32
+ checkUserSession() {
33
+ return this.http.get(routes.session(this.apiUrl), errorOptions(false));
34
+ }
35
+ loginRoute() {
36
+ return routes.login(this.apiUrl);
37
+ }
38
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: API_URL }], target: i0.ɵɵFactoryTarget.Injectable });
39
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthService, providedIn: 'root' });
40
+ }
41
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthService, decorators: [{
42
+ type: Injectable,
43
+ args: [{
44
+ providedIn: 'root',
45
+ }]
46
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
47
+ type: Inject,
48
+ args: [API_URL]
49
+ }] }] });
50
+
51
+ /**
52
+ * Generated bundle index. Do not edit.
53
+ */
54
+
55
+ export { AuthService };
56
+ //# 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 } from '@angular/core';\nimport { API_URL, SessionInfo } from '@cccteam/ccc-lib/src/types';\nimport { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';\nimport { map, Observable } 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 constructor(\n private http: HttpClient,\n @Inject(API_URL) private apiUrl: string,\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.delete(routes.session(this.apiUrl), errorOptions(false)).pipe(map(() => true));\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 | null> {\n return this.http.get<SessionInfo>(routes.session(this.apiUrl), errorOptions(false));\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';\n"],"names":[],"mappings":";;;;;;;AAMA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,CAAC,OAAe,KAAa,CAAA,EAAG,OAAO,CAAa,WAAA,CAAA;IAC3D,OAAO,EAAE,CAAC,OAAe,KAAa,CAAA,EAAG,OAAO,CAAe,aAAA,CAAA;CAChE;MAKY,WAAW,CAAA;AAEZ,IAAA,IAAA;AACiB,IAAA,MAAA;IAF3B,WACU,CAAA,IAAgB,EACC,MAAc,EAAA;QAD/B,IAAI,CAAA,IAAA,GAAJ,IAAI;QACa,IAAM,CAAA,MAAA,GAAN,MAAM;;AAGjC;;;;AAIG;IACH,MAAM,GAAA;AACJ,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;;AAGjG;;;;AAIG;IACH,gBAAgB,GAAA;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;;IAGrF,UAAU,GAAA;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;;AAzBvB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,4CAGZ,OAAO,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAHN,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;;0BAII,MAAM;2BAAC,OAAO;;;ACjBnB;;AAEG;;;;"}
@@ -0,0 +1,109 @@
1
+ import { __decorate } from 'tslib';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, Injectable } from '@angular/core';
4
+ import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
5
+ import { PERMISSION_REQUIRED, AppAction, AuthenticationGuardAction, LoginAction, ApiInterceptorAction } from '@cccteam/ccc-lib/src/types';
6
+ import { Action, Selector, State } from '@ngxs/store';
7
+ import { patch } from '@ngxs/store/operators';
8
+ import { cloneDeep } from 'lodash-es';
9
+ import { tap } from 'rxjs';
10
+
11
+ var AuthState_1;
12
+ const initState = {
13
+ authenticated: false,
14
+ redirectUrl: '',
15
+ sessionInfo: null,
16
+ };
17
+ let AuthState = class AuthState {
18
+ static { AuthState_1 = this; }
19
+ authService = inject(AuthService);
20
+ static permissionFn;
21
+ constructor() {
22
+ AuthState_1.initializePermissionFn();
23
+ }
24
+ static initializePermissionFn() {
25
+ if (!AuthState_1.permissionFn) {
26
+ AuthState_1.permissionFn = inject(PERMISSION_REQUIRED);
27
+ }
28
+ }
29
+ static hasPermission(state) {
30
+ return (scope) => {
31
+ if (!scope)
32
+ return true;
33
+ const resourcePermissions = state?.sessionInfo?.permissions?.[scope.domain]?.[scope.resource];
34
+ return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);
35
+ };
36
+ }
37
+ static requiresPermission(resource, permission) {
38
+ if (!AuthState_1.permissionFn) {
39
+ throw new Error(`AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`);
40
+ }
41
+ return AuthState_1.permissionFn(resource, permission);
42
+ }
43
+ static isAuthenticated(state) {
44
+ return state?.authenticated;
45
+ }
46
+ static redirectUrl(state) {
47
+ return state?.redirectUrl;
48
+ }
49
+ checkUserSession(ctx) {
50
+ return this.authService.checkUserSession().pipe(tap((result) => ctx.setState(patch({
51
+ authenticated: !!result?.authenticated,
52
+ sessionInfo: result,
53
+ }))));
54
+ }
55
+ logout(ctx) {
56
+ const localStateCopy = cloneDeep(initState);
57
+ localStateCopy.redirectUrl = ctx.getState().redirectUrl;
58
+ return this.authService.logout().pipe(tap(() => {
59
+ ctx.setState(localStateCopy);
60
+ }));
61
+ }
62
+ setRedirectUrl(ctx, action) {
63
+ ctx.setState(patch({
64
+ redirectUrl: action.redirectUrl,
65
+ }));
66
+ return ctx.getState();
67
+ }
68
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
69
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthState });
70
+ };
71
+ __decorate([
72
+ Action([AppAction.CheckUserSession, AuthenticationGuardAction.CheckUserSession])
73
+ ], AuthState.prototype, "checkUserSession", null);
74
+ __decorate([
75
+ Action([LoginAction.Logout])
76
+ ], AuthState.prototype, "logout", null);
77
+ __decorate([
78
+ Action([
79
+ AppAction.SetRedirectUrl,
80
+ LoginAction.SetRedirectUrl,
81
+ AuthenticationGuardAction.SetRedirectUrl,
82
+ ApiInterceptorAction.SetRedirectUrl,
83
+ ])
84
+ ], AuthState.prototype, "setRedirectUrl", null);
85
+ __decorate([
86
+ Selector()
87
+ ], AuthState, "hasPermission", null);
88
+ __decorate([
89
+ Selector()
90
+ ], AuthState, "isAuthenticated", null);
91
+ __decorate([
92
+ Selector()
93
+ ], AuthState, "redirectUrl", null);
94
+ AuthState = AuthState_1 = __decorate([
95
+ State({
96
+ name: 'authState',
97
+ defaults: initState,
98
+ })
99
+ ], AuthState);
100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.3", ngImport: i0, type: AuthState, decorators: [{
101
+ type: Injectable
102
+ }], ctorParameters: () => [], propDecorators: { checkUserSession: [], logout: [], setRedirectUrl: [] } });
103
+
104
+ /**
105
+ * Generated bundle index. Do not edit.
106
+ */
107
+
108
+ export { AuthState, initState };
109
+ //# sourceMappingURL=cccteam-ccc-lib-src-auth-state.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-auth-state.mjs","sources":["../../../projects/ccc-lib/src/auth-state/auth.state.ts","../../../projects/ccc-lib/src/auth-state/cccteam-ccc-lib-src-auth-state.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport {\n ApiInterceptorAction,\n AppAction,\n AuthenticationGuardAction,\n LoginAction,\n Permission,\n PERMISSION_REQUIRED,\n PermissionScope,\n Resource,\n SessionInfo,\n} from '@cccteam/ccc-lib/src/types';\nimport { Action, Selector, State, StateContext } from '@ngxs/store';\nimport { patch } from '@ngxs/store/operators';\nimport { cloneDeep } from 'lodash-es';\nimport { Observable, tap } from 'rxjs';\n\nexport interface AuthStateModel {\n authenticated: boolean;\n redirectUrl: string;\n sessionInfo: SessionInfo | null;\n}\n\nexport const initState: AuthStateModel = {\n authenticated: false,\n redirectUrl: '',\n sessionInfo: null,\n};\n\n@State<AuthStateModel>({\n name: 'authState',\n defaults: initState,\n})\n@Injectable()\nexport class AuthState {\n private authService = inject(AuthService);\n private static permissionFn: (resource: Resource, permission: Permission) => boolean;\n\n constructor() {\n AuthState.initializePermissionFn();\n }\n\n private static initializePermissionFn(): void {\n if (!AuthState.permissionFn) {\n AuthState.permissionFn = inject(PERMISSION_REQUIRED);\n }\n }\n\n @Selector()\n static hasPermission(state: AuthStateModel): (scope?: PermissionScope) => boolean {\n return (scope?: PermissionScope) => {\n if (!scope) return true;\n const resourcePermissions = state?.sessionInfo?.permissions?.[scope.domain]?.[scope.resource];\n return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);\n };\n }\n\n static requiresPermission(resource: Resource, permission: Permission): boolean {\n if (!AuthState.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 AuthState.permissionFn(resource, permission);\n }\n\n @Selector()\n static isAuthenticated(state: AuthStateModel): boolean {\n return state?.authenticated;\n }\n\n @Selector()\n static redirectUrl(state: AuthStateModel): string {\n return state?.redirectUrl;\n }\n\n @Action([AppAction.CheckUserSession, AuthenticationGuardAction.CheckUserSession])\n checkUserSession(ctx: StateContext<AuthStateModel>): Observable<SessionInfo | null> {\n return this.authService.checkUserSession().pipe(\n tap((result) =>\n ctx.setState(\n patch({\n authenticated: !!result?.authenticated,\n sessionInfo: result,\n }),\n ),\n ),\n );\n }\n\n @Action([LoginAction.Logout])\n logout(ctx: StateContext<AuthStateModel>): Observable<boolean> {\n const localStateCopy = cloneDeep(initState);\n localStateCopy.redirectUrl = ctx.getState().redirectUrl;\n return this.authService.logout().pipe(\n tap(() => {\n ctx.setState(localStateCopy);\n }),\n );\n }\n\n @Action([\n AppAction.SetRedirectUrl,\n LoginAction.SetRedirectUrl,\n AuthenticationGuardAction.SetRedirectUrl,\n ApiInterceptorAction.SetRedirectUrl,\n ])\n setRedirectUrl(ctx: StateContext<AuthStateModel>, action: { redirectUrl: string }): AuthStateModel {\n ctx.setState(\n patch({\n redirectUrl: action.redirectUrl,\n }),\n );\n return ctx.getState();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAwBa,MAAA,SAAS,GAAmB;AACvC,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,WAAW,EAAE,IAAI;;AAQN,IAAA,SAAS,GAAf,MAAM,SAAS,CAAA;;AACZ,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACjC,OAAO,YAAY;AAE3B,IAAA,WAAA,GAAA;QACE,WAAS,CAAC,sBAAsB,EAAE;;AAG5B,IAAA,OAAO,sBAAsB,GAAA;AACnC,QAAA,IAAI,CAAC,WAAS,CAAC,YAAY,EAAE;AAC3B,YAAA,WAAS,CAAC,YAAY,GAAG,MAAM,CAAC,mBAAmB,CAAC;;;AAKjD,IAAP,OAAO,aAAa,CAAC,KAAqB,EAAA;QACxC,OAAO,CAAC,KAAuB,KAAI;AACjC,YAAA,IAAI,CAAC,KAAK;AAAE,gBAAA,OAAO,IAAI;AACvB,YAAA,MAAM,mBAAmB,GAAG,KAAK,EAAE,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,M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iFrB;2FAjFY,SAAS,EAAA,UAAA,EAAA,CAAA;kBADrB;wDA4CC,gBAAgB,EAAA,EAAA,EAchB,MAAM,EAAA,EAAA,EAgBN,cAAc,EAAA,EAAA,EAAA,EAAA,CAAA;;AC5GhB;;AAEG;;;;"}
@@ -0,0 +1,137 @@
1
+ import { InjectionToken } from '@angular/core';
2
+
3
+ /* eslint-disable @typescript-eslint/no-namespace */
4
+ // no-namespace rule is disabled because action hygiene prevents import pollution
5
+ var AuthenticationGuardAction;
6
+ (function (AuthenticationGuardAction) {
7
+ class SetRedirectUrl {
8
+ redirectUrl;
9
+ static type = '[AuthenticationGuard] Set Redirect Url And Navigate To Login Page';
10
+ constructor(redirectUrl) {
11
+ this.redirectUrl = redirectUrl;
12
+ }
13
+ }
14
+ AuthenticationGuardAction.SetRedirectUrl = SetRedirectUrl;
15
+ class CheckUserSession {
16
+ static type = '[AuthenticationGuard] Check User Session';
17
+ }
18
+ AuthenticationGuardAction.CheckUserSession = CheckUserSession;
19
+ })(AuthenticationGuardAction || (AuthenticationGuardAction = {}));
20
+ var LoginAction;
21
+ (function (LoginAction) {
22
+ class Logout {
23
+ static type = '[Login] Auto Logout';
24
+ }
25
+ LoginAction.Logout = Logout;
26
+ class SetRedirectUrl {
27
+ redirectUrl;
28
+ static type = '[Login] Set Redirect Url';
29
+ constructor(redirectUrl) {
30
+ this.redirectUrl = redirectUrl;
31
+ }
32
+ }
33
+ LoginAction.SetRedirectUrl = SetRedirectUrl;
34
+ class PublishError {
35
+ message;
36
+ static type = '[Login] Publish Error';
37
+ constructor(message) {
38
+ this.message = message;
39
+ }
40
+ }
41
+ LoginAction.PublishError = PublishError;
42
+ })(LoginAction || (LoginAction = {}));
43
+ var AppAction;
44
+ (function (AppAction) {
45
+ class CheckUserSession {
46
+ static type = '[App] Check User Session';
47
+ }
48
+ AppAction.CheckUserSession = CheckUserSession;
49
+ class SetRedirectUrl {
50
+ redirectUrl;
51
+ static type = '[App] Set Redirect Url';
52
+ constructor(redirectUrl) {
53
+ this.redirectUrl = redirectUrl;
54
+ }
55
+ }
56
+ AppAction.SetRedirectUrl = SetRedirectUrl;
57
+ class SetNavIdentifier {
58
+ identifier;
59
+ static type = '[App] Set Nav Identifier';
60
+ constructor(identifier) {
61
+ this.identifier = identifier;
62
+ }
63
+ }
64
+ AppAction.SetNavIdentifier = SetNavIdentifier;
65
+ })(AppAction || (AppAction = {}));
66
+
67
+ /* eslint-disable @typescript-eslint/no-namespace */
68
+ // no-namespace rule is disabled because action hygiene prevents import pollution
69
+ var ApiInterceptorAction;
70
+ (function (ApiInterceptorAction) {
71
+ class BeginActivity {
72
+ process;
73
+ static type = '[ApiInterceptor] Add Loading Activity';
74
+ constructor(process) {
75
+ this.process = process;
76
+ }
77
+ }
78
+ ApiInterceptorAction.BeginActivity = BeginActivity;
79
+ class EndActivity {
80
+ process;
81
+ static type = '[ApiInterceptor] Remove Loading Activity';
82
+ constructor(process) {
83
+ this.process = process;
84
+ }
85
+ }
86
+ ApiInterceptorAction.EndActivity = EndActivity;
87
+ class PublishError {
88
+ message;
89
+ static type = '[ApiInterceptor] Publish Error';
90
+ constructor(message) {
91
+ this.message = message;
92
+ }
93
+ }
94
+ ApiInterceptorAction.PublishError = PublishError;
95
+ class SetRedirectUrl {
96
+ redirectUrl;
97
+ static type = '[ApiInterceptor] Set Redirect Url';
98
+ constructor(redirectUrl) {
99
+ this.redirectUrl = redirectUrl;
100
+ }
101
+ }
102
+ ApiInterceptorAction.SetRedirectUrl = SetRedirectUrl;
103
+ })(ApiInterceptorAction || (ApiInterceptorAction = {}));
104
+ var HeaderAction;
105
+ (function (HeaderAction) {
106
+ class ToggleSidenav {
107
+ static type = '[Header] Toggle Sidenav';
108
+ }
109
+ HeaderAction.ToggleSidenav = ToggleSidenav;
110
+ class Logout {
111
+ static type = '[Header] User Logout';
112
+ }
113
+ HeaderAction.Logout = Logout;
114
+ })(HeaderAction || (HeaderAction = {}));
115
+
116
+ var AlertLevel;
117
+ (function (AlertLevel) {
118
+ AlertLevel["ERROR"] = "warn";
119
+ AlertLevel["INFO"] = "accent";
120
+ AlertLevel["SUCCESS"] = "success";
121
+ })(AlertLevel || (AlertLevel = {}));
122
+
123
+ const ReadPermission = 'Read';
124
+ const UpdatePermission = 'Update';
125
+
126
+ const BASE_URL = new InjectionToken('BASE_URL');
127
+ const API_URL = new InjectionToken('API_URL');
128
+ const PERMISSION_REQUIRED = new InjectionToken('PERMISSION_REQUIRED');
129
+ const AVAILABLE_PERMISSIONS = new InjectionToken('AVAILABLE_PERMISSIONS');
130
+ const AVAILABLE_DOMAINS = new InjectionToken('AVAILABLE_DOMAINS');
131
+
132
+ /**
133
+ * Generated bundle index. Do not edit.
134
+ */
135
+
136
+ export { API_URL, AVAILABLE_DOMAINS, AVAILABLE_PERMISSIONS, AlertLevel, ApiInterceptorAction, AppAction, AuthenticationGuardAction, BASE_URL, HeaderAction, LoginAction, PERMISSION_REQUIRED, ReadPermission, UpdatePermission };
137
+ //# sourceMappingURL=cccteam-ccc-lib-src-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cccteam-ccc-lib-src-types.mjs","sources":["../../../projects/ccc-lib/src/types/auth.actions.ts","../../../projects/ccc-lib/src/types/core.actions.ts","../../../projects/ccc-lib/src/types/notification-message.ts","../../../projects/ccc-lib/src/types/permissions.ts","../../../projects/ccc-lib/src/types/tokens.ts","../../../projects/ccc-lib/src/types/cccteam-ccc-lib-src-types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\nexport namespace AuthenticationGuardAction {\n export class SetRedirectUrl {\n static readonly type = '[AuthenticationGuard] Set Redirect Url And Navigate To Login Page';\n constructor(public redirectUrl: string) {}\n }\n\n export class CheckUserSession {\n static readonly type = '[AuthenticationGuard] Check User Session';\n }\n}\n\nexport namespace LoginAction {\n export class Logout {\n static readonly type = '[Login] Auto Logout';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[Login] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class PublishError {\n static readonly type = '[Login] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n}\n\nexport namespace AppAction {\n export class CheckUserSession {\n static readonly type = '[App] Check User Session';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[App] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class SetNavIdentifier {\n static readonly type = '[App] Set Nav Identifier';\n constructor(public identifier: string) {}\n }\n}\n","/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\n\nexport namespace ApiInterceptorAction {\n export class BeginActivity {\n static readonly type = '[ApiInterceptor] Add Loading Activity';\n constructor(public process: string) {}\n }\n export class EndActivity {\n static readonly type = '[ApiInterceptor] Remove Loading Activity';\n constructor(public process: string) {}\n }\n export class PublishError {\n static readonly type = '[ApiInterceptor] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n export class SetRedirectUrl {\n static readonly type = '[ApiInterceptor] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n}\n\nexport namespace HeaderAction {\n export class ToggleSidenav {\n static readonly type = '[Header] Toggle Sidenav';\n }\n\n export class Logout {\n static readonly type = '[Header] User Logout';\n }\n}\n","export enum AlertLevel {\n ERROR = 'warn',\n INFO = 'accent',\n SUCCESS = 'success',\n}\n\nexport interface CreateNotificationMessage {\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n\nexport interface NotificationMessage {\n id: number;\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n","type Brand<K, T> = K & { __brand: T };\n\nexport type Permission = Brand<string, 'Permission'>;\nexport type Resource = Brand<string, 'Resource'>;\nexport type Domain = Brand<string, 'Domain'>;\nexport type DomainPermissions = Record<Domain, Record<Resource, Record<Permission, Permissions>>>;\n\nexport interface PermissionScope {\n resource: Resource;\n permission: Permission;\n domain: Domain;\n}\n\nexport const ReadPermission = 'Read' as Permission;\nexport const UpdatePermission = 'Update' as Permission;\n","import { InjectionToken } from '@angular/core';\nimport { Domain, Permission, Resource } from './permissions';\n\nexport const BASE_URL = new InjectionToken<string>('BASE_URL');\nexport const API_URL = new InjectionToken<string>('API_URL');\nexport const PERMISSION_REQUIRED = new InjectionToken<(resource: Resource, permission: Permission) => boolean>(\n 'PERMISSION_REQUIRED',\n);\n\nexport const AVAILABLE_PERMISSIONS = new InjectionToken<{\n Create: Permission;\n Delete: Permission;\n List: Permission;\n Read: Permission;\n Update: Permission;\n}>('AVAILABLE_PERMISSIONS');\nexport const AVAILABLE_DOMAINS = new InjectionToken<Record<string, Domain>[]>('AVAILABLE_DOMAINS');\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;AACA;AAGM,IAAW;AAAjB,CAAA,UAAiB,yBAAyB,EAAA;AACxC,IAAA,MAAa,cAAc,CAAA;AAEN,QAAA,WAAA;AADnB,QAAA,OAAgB,IAAI,GAAG,mEAAmE;AAC1F,QAAA,WAAA,CAAmB,WAAmB,EAAA;YAAnB,IAAW,CAAA,WAAA,GAAX,WAAW;;;AAFnB,IAAA,yBAAA,CAAA,cAAc,iBAG1B;AAED,IAAA,MAAa,gBAAgB,CAAA;AAC3B,QAAA,OAAgB,IAAI,GAAG,0CAA0C;;AADtD,IAAA,yBAAA,CAAA,gBAAgB,mBAE5B;AACH,CAAC,EATgB,yBAAyB,KAAzB,yBAAyB,GASzC,EAAA,CAAA,CAAA;AAEK,IAAW;AAAjB,CAAA,UAAiB,WAAW,EAAA;AAC1B,IAAA,MAAa,MAAM,CAAA;AACjB,QAAA,OAAgB,IAAI,GAAG,qBAAqB;;AADjC,IAAA,WAAA,CAAA,MAAM,SAElB;AAED,IAAA,MAAa,cAAc,CAAA;AAEN,QAAA,WAAA;AADnB,QAAA,OAAgB,IAAI,GAAG,0BAA0B;AACjD,QAAA,WAA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