@fhss-web-team/frontend-utils 4.1.2 → 21.0.1

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 (29) hide show
  1. package/fesm2022/fhss-web-team-frontend-utils.mjs +179 -317
  2. package/fesm2022/fhss-web-team-frontend-utils.mjs.map +1 -1
  3. package/package.json +5 -5
  4. package/{lib/signals/fetch-signal/fetch-signal.types.d.ts → types/fhss-web-team-frontend-utils.d.ts} +372 -35
  5. package/index.d.ts +0 -5
  6. package/lib/components/byu-footer/byu-footer.component.d.ts +0 -6
  7. package/lib/components/byu-header/byu-header-link/byu-header-link.d.ts +0 -30
  8. package/lib/components/byu-header/byu-header.component.d.ts +0 -54
  9. package/lib/components/combo-box/combo-box.component.d.ts +0 -24
  10. package/lib/components/confirmation/confirmation.dialog.d.ts +0 -27
  11. package/lib/components/fhss-table/fhss-table.component.d.ts +0 -37
  12. package/lib/components/fhss-table/fhss-table.types.d.ts +0 -46
  13. package/lib/config/lib.config.d.ts +0 -5
  14. package/lib/config/utils.config.d.ts +0 -3
  15. package/lib/directives/scroll-anchor.directive.d.ts +0 -12
  16. package/lib/guards/auth/auth.guard.d.ts +0 -5
  17. package/lib/guards/permission/permission.guard.d.ts +0 -25
  18. package/lib/pages/auth-error/auth-error.page.d.ts +0 -7
  19. package/lib/pages/forbidden/forbidden.page.d.ts +0 -7
  20. package/lib/pages/not-found/not-found.page.d.ts +0 -7
  21. package/lib/pages/server-error/server-error.page.d.ts +0 -7
  22. package/lib/pages/system/system.page.d.ts +0 -11
  23. package/lib/services/auth/auth.service.d.ts +0 -67
  24. package/lib/services/scroll-registry/scroll-registry.service.d.ts +0 -12
  25. package/lib/signals/debounced/debounced.d.ts +0 -2
  26. package/lib/signals/fetch-signal/fetch-signal.d.ts +0 -4
  27. package/lib/signals/trpcResource/trpcResource.d.ts +0 -9
  28. package/lib/signals/trpcResource/trpcResource.types.d.ts +0 -72
  29. package/public-api.d.ts +0 -41
@@ -1,46 +0,0 @@
1
- import { Resolver } from '@trpc/client';
2
- import { ResolverDef } from '../../signals/trpcResource/trpcResource.types';
3
- import { trpcResource } from '../../signals/trpcResource/trpcResource';
4
- export type FhssTableConfig<TDef extends ResolverDef> = {
5
- procedure: Resolver<TDef>;
6
- columns: {
7
- [K in keyof TDef['output']['data'][number]]: {
8
- hide?: boolean;
9
- header?: string;
10
- allowSort?: boolean;
11
- individualFilter?: boolean;
12
- };
13
- };
14
- showSearch?: boolean;
15
- sorting: {
16
- defaultSortBy: Extract<keyof TDef['output']['data'][number], string>;
17
- defaultSortDirection?: 'asc' | 'desc';
18
- };
19
- pagination: {
20
- pageSize: number;
21
- hideControls?: boolean;
22
- };
23
- disableAlternatingColors?: boolean;
24
- interaction?: {
25
- type: 'click';
26
- onClick: (obj: TDef['output']['data'][number]) => void;
27
- } | {
28
- type: 'select';
29
- multi?: boolean;
30
- };
31
- };
32
- export declare const makeTableConfig: <TDef extends ResolverDef>(config: FhssTableConfig<TDef>) => FhssTableConfig<TDef>;
33
- export type AnyResolver = {
34
- input: any;
35
- output: {
36
- totalCount: number;
37
- data: any[];
38
- };
39
- transformer: any;
40
- errorShape: {
41
- code: any;
42
- message: string;
43
- data: any;
44
- };
45
- };
46
- export type AnyResource = ReturnType<typeof trpcResource<AnyResolver>>;
@@ -1,5 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- export declare const FHSS_CONFIG: InjectionToken<FhssConfig>;
3
- export interface FhssConfig {
4
- rolePermissionMap: Record<string, string[]>;
5
- }
@@ -1,3 +0,0 @@
1
- import { Provider } from "@angular/core";
2
- import { FhssConfig } from "./lib.config";
3
- export declare const provideFhss: (config: FhssConfig) => Provider;
@@ -1,12 +0,0 @@
1
- import { ElementRef } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- export declare class ScrollAnchorDirective {
4
- private element;
5
- private readonly registery;
6
- scrollAnchor: import("@angular/core").InputSignal<string>;
7
- constructor(element: ElementRef<HTMLElement>);
8
- ngOnInit(): void;
9
- ngOnDestroy(): void;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<ScrollAnchorDirective, never>;
11
- static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollAnchorDirective, "[scrollAnchor]", never, { "scrollAnchor": { "alias": "scrollAnchor"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
12
- }
@@ -1,5 +0,0 @@
1
- import { CanActivateFn } from '@angular/router';
2
- /**
3
- * This guard checks if the client is authenticated, redirecting to login if not.
4
- */
5
- export declare const authGuard: CanActivateFn;
@@ -1,25 +0,0 @@
1
- import { CanActivateFn } from '@angular/router';
2
- /**
3
- * A permission-based route guard.
4
- *
5
- * This guard checks if the current user has the required permissions to access a route.
6
- * If the user is not authenticated, they are redirected to the login page.
7
- * If the user lacks the necessary permissions, they are redirected to the `/forbidden` page.
8
- *
9
- * Pass the Permission type to get intellisense on requiredPermissions
10
- * @param requiredPermissions - An array of permission strings that the user must have.
11
- * @param haveAll - If `true`, the user must have all required permissions. If `false` or omitted, the user must have at least one of the required permissions.
12
- * @returns A `CanActivateFn` function to be used as a route guard.
13
- *
14
- * @example
15
- * ```typescript
16
- * const routes: Routes = [
17
- * {
18
- * path: 'admin',
19
- * component: AdminPage,
20
- * canActivate: [permissionGuard<Permission>(['manage-users', 'see-data'], true)],
21
- * },
22
- * ];
23
- * ```
24
- */
25
- export declare const permissionGuard: <Permission extends string>(requiredPermissions: Permission[], haveAll?: boolean) => CanActivateFn;
@@ -1,7 +0,0 @@
1
- import { SystemConfig } from "../system/system.page";
2
- import * as i0 from "@angular/core";
3
- export declare class AuthErrorPage {
4
- protected readonly config: SystemConfig;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthErrorPage, never>;
6
- static ɵcmp: i0.ɵɵComponentDeclaration<AuthErrorPage, "fhss-auth-error", never, {}, {}, never, never, true, never>;
7
- }
@@ -1,7 +0,0 @@
1
- import { SystemConfig } from '../system/system.page';
2
- import * as i0 from "@angular/core";
3
- export declare class ForbiddenPage {
4
- protected readonly config: SystemConfig;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<ForbiddenPage, never>;
6
- static ɵcmp: i0.ɵɵComponentDeclaration<ForbiddenPage, "fhss-forbidden", never, {}, {}, never, never, true, never>;
7
- }
@@ -1,7 +0,0 @@
1
- import { SystemConfig } from '../system/system.page';
2
- import * as i0 from "@angular/core";
3
- export declare class NotFoundPage {
4
- protected readonly config: SystemConfig;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<NotFoundPage, never>;
6
- static ɵcmp: i0.ɵɵComponentDeclaration<NotFoundPage, "fhss-not-found", never, {}, {}, never, never, true, never>;
7
- }
@@ -1,7 +0,0 @@
1
- import { SystemConfig } from '../system/system.page';
2
- import * as i0 from "@angular/core";
3
- export declare class ServerErrorPage {
4
- protected readonly config: SystemConfig;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<ServerErrorPage, never>;
6
- static ɵcmp: i0.ɵɵComponentDeclaration<ServerErrorPage, "fhss-server-error", never, {}, {}, never, never, true, never>;
7
- }
@@ -1,11 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export type SystemConfig = {
3
- title?: string;
4
- message?: string;
5
- image?: string;
6
- };
7
- export declare class SystemPage {
8
- readonly config: import("@angular/core").InputSignal<SystemConfig>;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<SystemPage, never>;
10
- static ɵcmp: i0.ɵɵComponentDeclaration<SystemPage, "fhss-system", never, { "config": { "alias": "config"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
11
- }
@@ -1,67 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- type AuthUser = {
3
- id: string;
4
- preferredFirstName: string;
5
- preferredLastName: string;
6
- roles: string[];
7
- permissions: string[];
8
- };
9
- export declare class AuthService {
10
- private readonly FhssConfig;
11
- private readonly readyPromise;
12
- constructor();
13
- /**
14
- * Returns a promise that resolves when the authentication service is ready.
15
- */
16
- ready(): Promise<AuthUser | null>;
17
- /**
18
- * Updates the authentication state by retrieving the current user's information.
19
- *
20
- * @returns A promise containing the current user's authentication details.
21
- */
22
- update(): Promise<AuthUser | null>;
23
- readonly authenticated: import("@angular/core").WritableSignal<boolean>;
24
- readonly userId: import("@angular/core").WritableSignal<string | undefined>;
25
- readonly preferredFirstName: import("@angular/core").WritableSignal<string | undefined>;
26
- readonly preferredLastName: import("@angular/core").WritableSignal<string | undefined>;
27
- readonly roles: import("@angular/core").WritableSignal<string[]>;
28
- readonly permissions: import("@angular/core").WritableSignal<string[]>;
29
- /**
30
- * Contains all of the user's permissions, meaning those explicitly given, as well as
31
- * those provided by the user's roles.
32
- *
33
- * The result is a `Set` containing all unique permissions granted to the user.
34
- */
35
- readonly effectivePermissions: import("@angular/core").Signal<Set<string>>;
36
- /**
37
- * Computes the user's preferred full name by concatenating the preferred first name
38
- * and, if available, the preferred last name separated by a space.
39
- * If the preferred first name is not set, an empty string is used.
40
- * If the preferred last name is not set, only the first name is returned.
41
- *
42
- * @returns The computed preferred full name as a string.
43
- */
44
- readonly preferredName: import("@angular/core").Signal<string>;
45
- private resetAuthState;
46
- private setUser;
47
- /**
48
- * Redirects the user to the login page.
49
- *
50
- * @param nextUri - (Optional) The URI to redirect to after login.
51
- */
52
- login(nextUri?: string): void;
53
- /**
54
- * Logs the user out by resetting the authentication state and redirecting to the logout page.
55
- */
56
- logout(): void;
57
- /**
58
- * Retrieves information about the currently authenticated user.
59
- *
60
- * @returns A promise that resolves to a `WhoAmI` object
61
- * representing the current user, or `null` if not authenticated or on error.
62
- */
63
- private whoAmI;
64
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
65
- static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
66
- }
67
- export {};
@@ -1,12 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class ScrollRegistryService {
3
- private anchors;
4
- private pending;
5
- register(key: string, el: HTMLElement): void;
6
- unregister(key: string): void;
7
- scrollTo(key: string, opts?: ScrollIntoViewOptions & {
8
- delay?: number;
9
- }): void;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<ScrollRegistryService, never>;
11
- static ɵprov: i0.ɵɵInjectableDeclaration<ScrollRegistryService>;
12
- }
@@ -1,2 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- export declare const debounced: <T>(inputSignal: Signal<T>, wait?: number) => import("@angular/core").WritableSignal<T>;
@@ -1,4 +0,0 @@
1
- import { FetchSignalFactory, Json } from './fetch-signal.types';
2
- declare const fetchSignal: FetchSignalFactory;
3
- export { fetchSignal };
4
- export type { Json };
@@ -1,9 +0,0 @@
1
- import { Resolver } from "@trpc/client";
2
- import { ResolverDef, TrpcResource, TrpcResourceOptions } from "./trpcResource.types";
3
- declare function trpcResource<TDef extends ResolverDef>(procedure: Resolver<TDef>, input: () => TDef['input'] | undefined, options?: TrpcResourceOptions<TDef['output']>): TrpcResource<TDef>;
4
- declare function debugTrpcResource<TDef extends ResolverDef>(_trpcResource: TrpcResource<TDef>): {
5
- value: TDef["output"] | undefined;
6
- error: TDef["errorShape"] | undefined;
7
- isLoading: boolean;
8
- };
9
- export { debugTrpcResource, trpcResource };
@@ -1,72 +0,0 @@
1
- import { Injector, ValueEqualityFn, WritableSignal } from "@angular/core";
2
- export type ResolverDef = {
3
- input: any;
4
- output: any;
5
- transformer: boolean;
6
- errorShape: any;
7
- };
8
- export type TrpcResourceOptions<TOutput> = {
9
- /**
10
- * Whether or not the request should be fetched reactively when the request updates.
11
- */
12
- autoRefresh?: boolean;
13
- /**
14
- * Optional computation that will be used in a `linkedSignal` definition of the `trpcResource` value.
15
- */
16
- valueComputation?: () => NoInfer<TOutput>;
17
- /**
18
- * Value that the `trpcResource` will take when in the Idle or Error states.
19
- *
20
- * If not set, the `trpcResource` will use `undefined` as its default value.
21
- */
22
- defaultValue?: NoInfer<TOutput> | undefined;
23
- /**
24
- * Value that the `trpcResource` will take when first initialized.
25
- *
26
- * If not set, the `trpcResource` will use `defaultValue` as its initial value.
27
- */
28
- initialValue?: NoInfer<TOutput> | undefined;
29
- /**
30
- * The `Injector` in which to create the `trpcResource`.
31
- *
32
- * If this is not provided, the current
33
- * [injection context](https://angular.dev/guide/di/dependency-injection-context)
34
- * will be used instead (via `inject`).
35
- */
36
- injector?: Injector | undefined;
37
- /**
38
- * A comparison function which defines equality for the response value.
39
- */
40
- equal?: ValueEqualityFn<NoInfer<TOutput | undefined>> | undefined;
41
- };
42
- type Expand<T> = T extends infer O ? {
43
- [K in keyof O]: O[K];
44
- } : never;
45
- type _TrpcResource<TDef extends ResolverDef> = {
46
- /**
47
- * Signal of the tRPC procedure output, when available.
48
- * This value will persist while the `trpcResource` is loading.
49
- */
50
- value: WritableSignal<TDef["output"] | undefined>;
51
- /**
52
- * Signal of the tRPC procedure error, when available.
53
- */
54
- error: WritableSignal<TDef['errorShape'] | undefined>;
55
- /**
56
- * Whether this `trpcResource` is loading a new value (or reloading the existing one).
57
- */
58
- isLoading: WritableSignal<boolean>;
59
- /**
60
- * Instructs the `trpcResource` to call the procedure with the current reactive dependencies.
61
- * @param abortSignal Optional abort signal to abort the procedure call.
62
- * @param keepLoadingThroughAbort Whether the `trpcResource` should maintain a loading state after an abort.
63
- * This is useful when another refresh is the cause of an abort so the resource appears to keep loading.
64
- * @returns true if there was no error during the call
65
- */
66
- refresh: (abortSignal?: AbortSignal, keepLoadingThroughAbort?: boolean) => Promise<boolean>;
67
- };
68
- /**
69
- * Represents the reactive result of an tRPC request.
70
- */
71
- export type TrpcResource<TDef extends ResolverDef> = Expand<_TrpcResource<TDef>>;
72
- export {};
package/public-api.d.ts DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * Components
3
- */
4
- export * from './lib/components/byu-footer/byu-footer.component';
5
- export { ByuHeaderComponent } from './lib/components/byu-header/byu-header.component';
6
- export type { HeaderConfig } from './lib/components/byu-header/byu-header.component';
7
- export * from './lib/components/fhss-table/fhss-table.component';
8
- export * from './lib/components/confirmation/confirmation.dialog';
9
- export * from './lib/components/combo-box/combo-box.component';
10
- /**
11
- * Config
12
- */
13
- export * from './lib/config/lib.config';
14
- export * from './lib/config/utils.config';
15
- /**
16
- * Directives
17
- */
18
- export * from './lib/directives/scroll-anchor.directive';
19
- /**
20
- * Guards
21
- */
22
- export * from './lib/guards/auth/auth.guard';
23
- export * from './lib/guards/permission/permission.guard';
24
- /**
25
- * Pages
26
- */
27
- export * from './lib/pages/auth-error/auth-error.page';
28
- export * from './lib/pages/forbidden/forbidden.page';
29
- export * from './lib/pages/not-found/not-found.page';
30
- export * from './lib/pages/server-error/server-error.page';
31
- /**
32
- * Services
33
- */
34
- export * from './lib/services/auth/auth.service';
35
- export * from './lib/services/scroll-registry/scroll-registry.service';
36
- /**
37
- * Signals
38
- */
39
- export * from './lib/signals/trpcResource/trpcResource';
40
- export * from './lib/signals/fetch-signal/fetch-signal';
41
- export * from './lib/signals/debounced/debounced';