@cccteam/ccc-lib 0.0.13 → 0.0.15

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 (226) hide show
  1. package/eslint.config.js +32 -0
  2. package/ng-package.json +11 -0
  3. package/package.json +7 -68
  4. package/src/auth-authentication-guard/authentication.guard.ts +40 -0
  5. package/src/auth-authentication-guard/ng-package.json +6 -0
  6. package/src/auth-authorization-guard/authorization.guard.ts +17 -0
  7. package/src/auth-authorization-guard/ng-package.json +6 -0
  8. package/src/auth-forms/ccc-field/ccc-field.component.html +1 -0
  9. package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
  10. package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +22 -0
  11. package/src/auth-forms/ccc-field/ccc-field.component.ts +74 -0
  12. package/src/auth-forms/form-helpers.ts +39 -0
  13. package/src/auth-forms/{public-api.d.ts → index.ts} +1 -0
  14. package/src/auth-forms/ng-package.json +6 -0
  15. package/src/auth-has-permission/has-permission.directive.ts +34 -0
  16. package/src/auth-has-permission/ng-package.json +6 -0
  17. package/src/auth-service/auth.service.ts +92 -0
  18. package/src/auth-service/ng-package.json +6 -0
  19. package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +23 -0
  20. package/src/ccc-camel-case-to-title/index.ts +1 -0
  21. package/src/ccc-camel-case-to-title/ng-package.json +6 -0
  22. package/src/ccc-grid/ccc-grid.component.ts +155 -0
  23. package/src/ccc-grid/index.ts +3 -0
  24. package/src/ccc-grid/ng-package.json +6 -0
  25. package/src/ccc-grid/table-button/table-button.component.html +16 -0
  26. package/src/ccc-grid/table-button/table-button.component.scss +5 -0
  27. package/src/ccc-grid/table-button/table-button.component.spec.ts +22 -0
  28. package/src/ccc-grid/table-button/table-button.component.ts +49 -0
  29. package/src/ccc-resource/can-deactivate.guard.ts +41 -0
  30. package/src/ccc-resource/compound-resource/compound-resource.component.html +57 -0
  31. package/src/ccc-resource/compound-resource/compound-resource.component.scss +86 -0
  32. package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +22 -0
  33. package/src/ccc-resource/compound-resource/compound-resource.component.ts +158 -0
  34. package/src/ccc-resource/concat-fns.ts +162 -0
  35. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +12 -0
  36. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.scss +0 -0
  37. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.spec.ts +23 -0
  38. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +17 -0
  39. package/src/ccc-resource/form-state.service.ts +24 -0
  40. package/src/ccc-resource/format-fns.ts +49 -0
  41. package/src/ccc-resource/gui-constants.ts +88 -0
  42. package/src/ccc-resource/index.ts +23 -0
  43. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +8 -0
  44. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.scss +0 -0
  45. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.spec.ts +22 -0
  46. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +12 -0
  47. package/src/ccc-resource/ng-package.json +6 -0
  48. package/src/ccc-resource/operation-types.ts +19 -0
  49. package/src/ccc-resource/padding-element/padding-element.component.html +1 -0
  50. package/src/ccc-resource/padding-element/padding-element.component.scss +3 -0
  51. package/src/ccc-resource/padding-element/padding-element.component.spec.ts +22 -0
  52. package/src/ccc-resource/padding-element/padding-element.component.ts +20 -0
  53. package/src/ccc-resource/resource-array-view/resource-array-view.component.html +81 -0
  54. package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +21 -0
  55. package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +22 -0
  56. package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +143 -0
  57. package/src/ccc-resource/resource-base/resource-base.component.spec.ts +22 -0
  58. package/src/ccc-resource/resource-base/resource-base.component.ts +11 -0
  59. package/src/ccc-resource/resource-cache.service.ts +232 -0
  60. package/src/ccc-resource/resource-create/resource-create.component.html +31 -0
  61. package/src/ccc-resource/resource-create/resource-create.component.scss +130 -0
  62. package/src/ccc-resource/resource-create/resource-create.component.spec.ts +22 -0
  63. package/src/ccc-resource/resource-create/resource-create.component.ts +303 -0
  64. package/src/ccc-resource/resource-field/base-field.directive.ts +102 -0
  65. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +16 -0
  66. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.scss +0 -0
  67. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.spec.ts +22 -0
  68. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +15 -0
  69. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +13 -0
  70. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.scss +0 -0
  71. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.spec.ts +23 -0
  72. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +50 -0
  73. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +22 -0
  74. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.scss +0 -0
  75. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.spec.ts +22 -0
  76. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +14 -0
  77. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +71 -0
  78. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +9 -0
  79. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +22 -0
  80. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +207 -0
  81. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +38 -0
  82. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +3 -0
  83. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +22 -0
  84. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +87 -0
  85. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +23 -0
  86. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +6 -0
  87. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +22 -0
  88. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +14 -0
  89. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +29 -0
  90. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +6 -0
  91. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +22 -0
  92. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +23 -0
  93. package/src/ccc-resource/resource-field/resource-field.component.html +112 -0
  94. package/src/ccc-resource/resource-field/resource-field.component.scss +7 -0
  95. package/src/ccc-resource/resource-field/resource-field.component.spec.ts +22 -0
  96. package/src/ccc-resource/resource-field/resource-field.component.ts +214 -0
  97. package/src/ccc-resource/resource-layout/resource-layout.component.html +73 -0
  98. package/src/ccc-resource/resource-layout/resource-layout.component.scss +26 -0
  99. package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +22 -0
  100. package/src/ccc-resource/resource-layout/resource-layout.component.ts +176 -0
  101. package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +22 -0
  102. package/src/ccc-resource/resource-list/resource-list.component.html +27 -0
  103. package/src/ccc-resource/resource-list/resource-list.component.scss +67 -0
  104. package/src/ccc-resource/resource-list/resource-list.component.ts +376 -0
  105. package/src/ccc-resource/resource-list-create/resource-list-create.component.html +71 -0
  106. package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +9 -0
  107. package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +22 -0
  108. package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +103 -0
  109. package/src/ccc-resource/resource-resolver/resource-resolver.component.html +1 -0
  110. package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
  111. package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +22 -0
  112. package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +69 -0
  113. package/src/ccc-resource/resource-store.service.ts +93 -0
  114. package/src/ccc-resource/resource-view/resource-view.component.html +133 -0
  115. package/src/ccc-resource/resource-view/resource-view.component.scss +150 -0
  116. package/src/ccc-resource/resource-view/resource-view.component.spec.ts +22 -0
  117. package/src/ccc-resource/resource-view/resource-view.component.ts +354 -0
  118. package/src/ccc-resource/resources-helpers.ts +262 -0
  119. package/src/ccc-resource/utils/validator-utils.ts +6 -0
  120. package/{fesm2022/cccteam-ccc-lib.mjs → src/index.ts} +32 -11
  121. package/src/internal-types/index.ts +1 -0
  122. package/src/internal-types/ng-package.json +6 -0
  123. package/src/types/auth.actions.ts +46 -0
  124. package/src/types/configs.ts +952 -0
  125. package/src/types/constants.ts +1 -0
  126. package/src/types/core.actions.ts +33 -0
  127. package/src/types/{public-api.d.ts → index.ts} +3 -0
  128. package/src/types/ng-package.json +6 -0
  129. package/src/types/notification-message.ts +20 -0
  130. package/src/types/{permissions.d.ts → permissions.ts} +9 -9
  131. package/src/types/{session-info.d.ts → session-info.ts} +4 -3
  132. package/src/types/tokens.ts +20 -0
  133. package/src/ui-alert/alert.component.html +13 -0
  134. package/src/ui-alert/alert.component.scss +48 -0
  135. package/src/ui-alert/alert.component.spec.ts +22 -0
  136. package/src/ui-alert/alert.component.ts +35 -0
  137. package/src/ui-alert/ng-package.json +6 -0
  138. package/src/ui-core-service/index.ts +1 -0
  139. package/src/ui-core-service/ng-package.json +6 -0
  140. package/src/ui-core-service/ui-core.service.ts +34 -0
  141. package/src/ui-interceptor/api.interceptor.spec.ts +16 -0
  142. package/src/ui-interceptor/api.interceptor.ts +45 -0
  143. package/src/ui-interceptor/ng-package.json +6 -0
  144. package/src/ui-notification-service/ng-package.json +6 -0
  145. package/src/ui-notification-service/notification.service.ts +59 -0
  146. package/src/ui-sidenav/ng-package.json +6 -0
  147. package/src/ui-sidenav/sidenav.component.html +60 -0
  148. package/src/ui-sidenav/sidenav.component.scss +99 -0
  149. package/src/ui-sidenav/sidenav.component.spec.ts +22 -0
  150. package/src/ui-sidenav/sidenav.component.ts +64 -0
  151. package/src/util-request-options/ng-package.json +6 -0
  152. package/src/util-request-options/request-options.ts +17 -0
  153. package/tsconfig.lib.json +13 -0
  154. package/tsconfig.lib.prod.json +11 -0
  155. package/tsconfig.spec.json +15 -0
  156. package/cccteam-ccc-lib-0.0.13.tgz +0 -0
  157. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +0 -44
  158. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +0 -1
  159. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +0 -24
  160. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +0 -1
  161. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +0 -118
  162. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +0 -1
  163. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +0 -51
  164. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +0 -1
  165. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +0 -56
  166. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +0 -1
  167. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs +0 -109
  168. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs.map +0 -1
  169. package/fesm2022/cccteam-ccc-lib-src-types.mjs +0 -137
  170. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +0 -1
  171. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +0 -48
  172. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +0 -1
  173. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs +0 -100
  174. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs.map +0 -1
  175. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +0 -48
  176. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +0 -1
  177. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +0 -57
  178. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +0 -1
  179. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +0 -70
  180. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +0 -1
  181. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +0 -19
  182. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +0 -1
  183. package/fesm2022/cccteam-ccc-lib.mjs.map +0 -1
  184. package/index.d.ts +0 -5
  185. package/public-api.d.ts +0 -13
  186. package/src/auth-authentication-guard/authentication.guard.d.ts +0 -3
  187. package/src/auth-authentication-guard/index.d.ts +0 -5
  188. package/src/auth-authorization-guard/authorization.guard.d.ts +0 -3
  189. package/src/auth-authorization-guard/index.d.ts +0 -5
  190. package/src/auth-forms/ccc-field/ccc-field.component.d.ts +0 -25
  191. package/src/auth-forms/form-helpers.d.ts +0 -16
  192. package/src/auth-forms/index.d.ts +0 -5
  193. package/src/auth-has-permission/has-permission.directive.d.ts +0 -12
  194. package/src/auth-has-permission/index.d.ts +0 -5
  195. package/src/auth-service/auth.service.d.ts +0 -24
  196. package/src/auth-service/index.d.ts +0 -5
  197. package/src/auth-state/auth.state.d.ts +0 -27
  198. package/src/auth-state/index.d.ts +0 -5
  199. package/src/auth-state/public-api.d.ts +0 -1
  200. package/src/types/auth.actions.d.ts +0 -41
  201. package/src/types/core.actions.d.ts +0 -31
  202. package/src/types/index.d.ts +0 -5
  203. package/src/types/notification-message.d.ts +0 -18
  204. package/src/types/tokens.d.ts +0 -13
  205. package/src/ui-alert/alert.component.d.ts +0 -13
  206. package/src/ui-alert/index.d.ts +0 -5
  207. package/src/ui-core-state/core.state.d.ts +0 -28
  208. package/src/ui-core-state/index.d.ts +0 -5
  209. package/src/ui-core-state/public-api.d.ts +0 -1
  210. package/src/ui-interceptor/api.interceptor.d.ts +0 -12
  211. package/src/ui-interceptor/index.d.ts +0 -5
  212. package/src/ui-notification-service/index.d.ts +0 -5
  213. package/src/ui-notification-service/notification.service.d.ts +0 -30
  214. package/src/ui-sidenav/index.d.ts +0 -5
  215. package/src/ui-sidenav/sidenav.component.d.ts +0 -31
  216. package/src/util-request-options/index.d.ts +0 -5
  217. package/src/util-request-options/request-options.d.ts +0 -8
  218. /package/src/auth-authentication-guard/{public-api.d.ts → index.ts} +0 -0
  219. /package/src/auth-authorization-guard/{public-api.d.ts → index.ts} +0 -0
  220. /package/src/auth-has-permission/{public-api.d.ts → index.ts} +0 -0
  221. /package/src/auth-service/{public-api.d.ts → index.ts} +0 -0
  222. /package/src/ui-alert/{public-api.d.ts → index.ts} +0 -0
  223. /package/src/ui-interceptor/{public-api.d.ts → index.ts} +0 -0
  224. /package/src/ui-notification-service/{public-api.d.ts → index.ts} +0 -0
  225. /package/src/ui-sidenav/{public-api.d.ts → index.ts} +0 -0
  226. /package/src/util-request-options/{public-api.d.ts → index.ts} +0 -0
@@ -0,0 +1,64 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, computed, inject, Input, Signal } from '@angular/core';
3
+ import { MatButtonModule } from '@angular/material/button';
4
+ import { MatExpansionModule } from '@angular/material/expansion';
5
+ import { MatIconModule } from '@angular/material/icon';
6
+ import { MatSidenavModule } from '@angular/material/sidenav';
7
+ import { RouterModule } from '@angular/router';
8
+
9
+ import { HasPermissionDirective } from '@cccteam/ccc-lib/src/auth-has-permission';
10
+ import { PermissionScope } from '@cccteam/ccc-lib/src/types';
11
+ import { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';
12
+
13
+ export interface NavItem {
14
+ type: 'link' | 'header' | 'expandable';
15
+ routerLink?: string[];
16
+ label: string;
17
+ icon?: string;
18
+ permission?: PermissionScope;
19
+ children?: NavItem[];
20
+ isExpanded?: boolean;
21
+ attentionCount?: Signal<number>;
22
+ }
23
+
24
+ export type NavGroups = Record<string, NavItem[]>;
25
+
26
+ @Component({
27
+ selector: 'ccc-sidenav',
28
+ templateUrl: './sidenav.component.html',
29
+ styleUrls: ['./sidenav.component.scss'],
30
+ imports: [
31
+ MatIconModule,
32
+ RouterModule,
33
+ CommonModule,
34
+ MatExpansionModule,
35
+ MatButtonModule,
36
+ MatSidenavModule,
37
+ HasPermissionDirective,
38
+ ],
39
+ })
40
+ export class SidenavComponent {
41
+ ui = inject(UiCoreService);
42
+
43
+ @Input() navGroups?: NavGroups;
44
+ currentNav = computed(() => {
45
+ return this.updateNavItems(this.ui.currentSidenavIdentifier());
46
+ });
47
+
48
+ /**
49
+ * Updates the currentNav based on the identifier
50
+ * @param identifier
51
+ * @returns NavItem[]
52
+ * @memberof SidenavComponent
53
+ */
54
+ updateNavItems(identifier: string): NavItem[] {
55
+ if (!this.navGroups) {
56
+ return [];
57
+ }
58
+ if (!this.navGroups[identifier]) {
59
+ // pick the first one if the identifier is not found so we don't break the UI
60
+ identifier = Object.keys(this.navGroups)[0];
61
+ }
62
+ return this.navGroups[identifier];
63
+ }
64
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "./index.ts"
5
+ }
6
+ }
@@ -0,0 +1,17 @@
1
+ import { HttpContext, HttpContextToken } from '@angular/common/http';
2
+
3
+ export interface CustomHttpRequestOptions {
4
+ suppressGlobalError: boolean;
5
+ }
6
+
7
+ export const CUSTOM_HTTP_REQUEST_OPTIONS = new HttpContextToken<CustomHttpRequestOptions>(() => ({
8
+ suppressGlobalError: false,
9
+ }));
10
+
11
+ export function errorOptions(suppressGlobalError: boolean | undefined): { context: HttpContext } {
12
+ return {
13
+ context: new HttpContext().set(CUSTOM_HTTP_REQUEST_OPTIONS, {
14
+ suppressGlobalError: suppressGlobalError ?? false,
15
+ }),
16
+ };
17
+ }
@@ -0,0 +1,13 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "inlineSources": true,
10
+ "types": []
11
+ },
12
+ "exclude": ["**/*.spec.ts"]
13
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "types": [
8
+ "jasmine"
9
+ ]
10
+ },
11
+ "include": [
12
+ "**/*.spec.ts",
13
+ "**/*.d.ts"
14
+ ]
15
+ }
Binary file
@@ -1,44 +0,0 @@
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
@@ -1 +0,0 @@
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;;;;"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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;;;;"}
@@ -1,118 +0,0 @@
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
@@ -1 +0,0 @@
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,M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AAA;;;;;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;;;;"}
@@ -1,51 +0,0 @@
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
@@ -1 +0,0 @@
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;;AAGxB,IAAA,WAAA,GAAA;AACE,QAAA,aAAa,CAAC;YACZ,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC;AACxD,YAAA,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;SACjC;AACE,aAAA,IAAI,CACH,kBAAkB,EAAE,EACpB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,EACpF,UAAU,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;AAE5B,aAAA,SAAS,CAAC,CAAC,MAAM,KAAI;YACpB,IAAI,MAAM,EAAE;gBACV,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;;uGA9BK,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;;;AClBH;;AAEG;;;;"}
@@ -1,56 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { 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
@@ -1 +0,0 @@
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;;;;"}
@@ -1,109 +0,0 @@
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
@@ -1 +0,0 @@
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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