### Install @graduatecollege/vue-useful-api Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-useful-api/README.md Installs the @graduatecollege/vue-useful-api package using npm. This is the initial step to integrate the library into your Vue 3 project. ```bash npm install @graduatecollege/vue-useful-api ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/graduatecollege/vuelib/blob/main/README.md Installs all project dependencies for all packages within the monorepo. This is typically the first step after cloning the repository. ```bash npm install ``` -------------------------------- ### Install @graduatecollege/vue-auth Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/README.md Installs the @graduatecollege/vue-auth package using npm. This is the primary step to include the authentication utilities in your Vue 3 project. ```bash npm install @graduatecollege/vue-auth ``` -------------------------------- ### Install @graduatecollege/vue-datetime Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-datetime/README.md Installs the @graduatecollege/vue-datetime package using npm. This package provides Vue 3 datetime formatting utilities. ```bash npm install @graduatecollege/vue-datetime ``` -------------------------------- ### Peer Dependencies for @graduatecollege/vue-auth Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/README.md Lists the required peer dependencies for @graduatecollege/vue-auth, including MSAL browser, Pinia, Vue, and Vue Router. Ensure these are installed in your project. ```json { "@azure/msal-browser": "^4.0.0", "pinia": "^3.0.0", "vue": "^3.0.0", "vue-router": "^4.0.0" } ``` -------------------------------- ### Install @graduatecollege/codex Package Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/README.md Installs the @graduatecollege/codex package using npm. This is the primary method to include the library in your project. ```bash npm install @graduatecollege/codex ``` -------------------------------- ### Create MSAL Configuration Helper Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md A utility function to generate a standard MSAL configuration object. It simplifies the setup process by taking common parameters like client ID, authority, and scopes. This function is crucial for initializing MSAL within a Vue application. ```typescript /** * Helper function to create a standard MSAL configuration * @param clientId - Azure AD application client ID * @param authority - Azure AD authority (tenant ID) * @param apiAccessScope - API access scope for authentication * @param allowedHosts - List of allowed hosts for API access * @param additionalScopes - Additional scopes beyond User.Read * @returns Complete MSAL configuration */ export declare function createMsalConfig(clientId: string, authority: string, apiAccessScope: string, allowedHosts: string[], additionalScopes?: string[]): MsalConfig; ``` -------------------------------- ### Publish Package with Git Tag Source: https://github.com/graduatecollege/vuelib/blob/main/README.md Explains the process of publishing packages to GitHub Packages by creating and pushing a new version tag. Tags starting with 'v' trigger automatic publishing. ```bash # Create and push a new version tag git tag v0.1.1 git push origin v0.1.1 ``` -------------------------------- ### MSAL Vue Plugin for Authentication Integration Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md The `msalPlugin` provides a Vue plugin for integrating MSAL authentication into a Vue application. The `install` method sets up the authentication instance and makes it available throughout the application. It requires MSAL instance, configuration, and Vue Router. ```typescript /** * Vue plugin for integrating MSAL authentication */ export declare const msalPlugin: { install: (app: App, apiAccessScope: string, msalInstance: PublicClientApplication, msalConfig: MsalConfig, router: Router) => void; }; ``` -------------------------------- ### Integrate MSAL Authentication with Vue Plugin Source: https://context7.com/graduatecollege/vuelib/llms.txt Provides a Vue plugin to integrate MSAL authentication into a Vue application. It creates a reactive Auth instance and installs it globally. This requires Vue, Vue Router, MSAL browser library, and the vue-auth package. It configures the router, MSAL instance, and then uses the plugin to make authentication available throughout the app. ```typescript import { createApp } from 'vue'; import { createRouter, createWebHistory } from 'vue-router'; import { PublicClientApplication } from '@azure/msal-browser'; import { msalPlugin, createMsalConfig, CustomNavigationClient } from '@graduatecollege/vue-auth'; import App from './App.vue'; const router = createRouter({ history: createWebHistory(), routes: [/* your routes */] }); const msalConfig = createMsalConfig( 'your-client-id', 'your-tenant-id', 'api://your-api/.default', ['api.example.com'] ); const msalInstance = new PublicClientApplication(msalConfig); msalInstance.setNavigationClient(new CustomNavigationClient(router)); const app = createApp(App); app.use(router); app.use(msalPlugin, 'api://your-api/.default', msalInstance, msalConfig, router); app.mount('#app'); ``` -------------------------------- ### @graduatecollege/vue-auth - msalPlugin Source: https://context7.com/graduatecollege/vuelib/llms.txt Vue plugin that integrates MSAL authentication into your Vue application. It creates a reactive Auth instance and installs it as a global property accessible throughout the app. ```APIDOC ## msalPlugin ### Description Vue plugin that integrates MSAL authentication into your Vue application. It creates a reactive Auth instance and installs it as a global property accessible throughout the app. ### Method Vue Plugin ### Endpoint N/A (Plugin installation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { createApp } from 'vue'; import { createRouter, createWebHistory } from 'vue-router'; import { PublicClientApplication } from '@azure/msal-browser'; import { msalPlugin, createMsalConfig, CustomNavigationClient } from '@graduatecollege/vue-auth'; import App from './App.vue'; const router = createRouter({ history: createWebHistory(), routes: [/* your routes */] }); const msalConfig = createMsalConfig( 'your-client-id', 'your-tenant-id', 'api://your-api/.default', ['api.example.com'] ); const msalInstance = new PublicClientApplication(msalConfig); msalInstance.setNavigationClient(new CustomNavigationClient(router)); const app = createApp(App); app.use(router); app.use(msalPlugin, 'api://your-api/.default', msalInstance, msalConfig, router); app.mount('#app'); ``` ### Response #### Success Response (N/A) This is a plugin installation, it does not return a direct response but makes the auth instance available globally. #### Response Example N/A ``` -------------------------------- ### Get User Initials from NetID Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md A utility function to format user initials from a given username or netID. It handles system users by returning 'SYS'. This function is useful for displaying user avatars or identifying users in a concise format. ```typescript /** * Formats user initials from their netID or username. * Returns "SYS" for system users. * * @param updater - Username or netID * @returns Formatted initials (uppercase) */ export declare function getUpdaterInitials(updater: string): string; ``` -------------------------------- ### Build All Packages with npm Source: https://github.com/graduatecollege/vuelib/blob/main/README.md Builds all packages within the monorepo simultaneously from the root directory. This command is essential for development and local testing before publishing. ```bash npm run build ``` -------------------------------- ### Automatic API Execution with apiWatch in Vue.js Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-useful-api/README.md Demonstrates how to use the `apiWatch` composable from @graduatecollege/vue-useful-api to automatically execute API calls based on reactive dependencies. It shows how to set up API calls, define watch sources, and handle success and error callbacks, along with reactive loading and error states. ```typescript import { ref, computed } from 'vue' import { usefulApi, apiWatch } from '@graduatecollege/vue-useful-api' import { useUsersApi } from './users' const userId = ref('123') const includeDetails = ref(true) const users = useUsersApi(); const me = users.getMe(); apiWatch(me.execute, () => { if (auth.isAuthenticated) { return [userId.value, includeDetails.value]; } // Return undefined to skip execution return undefined; }); // The response is reactive const profile = computed(() => { return me.response.value?.userInfo; }); // You can also use event hooks me.onSuccess((user) => { console.log('User loaded:', user) }) // Now whenever userId or includeDetails changes, the API is called automatically userId.value = '456' // Triggers API call with new ID includeDetails.value = false // Triggers API call with new details flag // The error state is also reactive me.error.value // null if no error // And errors have events me.onError((error) => { console.error('Failed to load user:', error) }); // The loading state is also reactive me.isLoading.value // false if finished ``` -------------------------------- ### MsalConfig Interface Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Configuration interface for MSAL. ```APIDOC ## MsalConfig Interface ### Description Configuration interface for MSAL. ### Properties - **`auth`** (object) - Authentication configuration. - **`clientId`** (string) - Azure AD application client ID. - **`authority`** (string) - Azure AD authority (tenant ID). - **`redirectUri`** (string) - The redirect URI. - **`postLogoutRedirectUri`** (string) - The post-logout redirect URI. - **`cache`** (object) - Cache configuration. - **`cacheLocation`** ("localStorage" | "sessionStorage") - The cache location. - **`storeAuthStateInCookie`** (boolean) - Optional: Whether to store auth state in cookies. - **`system`** (object) - Optional: System configuration. - **`loggerOptions`** (object) - Optional: Logger options. - **`loggerCallback`** (function) - Callback function for logging. - **`logLevel`** (LogLevel) - Optional: The log level. - **`loginRequest`** (object) - Login request configuration. - **`scopes`** (string[]) - The scopes for the login request. - **`apiAccessScope`** (string) - The API access scope. - **`allowedHosts`** (string[]) - List of allowed hosts for API access. - **`graphConfig`** (object) - Optional: Microsoft Graph configuration. - **`graphMeEndpoint`** (string) - The endpoint for fetching user profile. ``` -------------------------------- ### createMsalConfig Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Helper function to create a standard MSAL configuration object. ```APIDOC ## createMsalConfig ### Description Helper function to create a standard MSAL configuration. ### Parameters - **`clientId`** (string) - Required - Azure AD application client ID - **`authority`** (string) - Required - Azure AD authority (tenant ID) - **`apiAccessScope`** (string) - Required - API access scope for authentication - **`allowedHosts`** (string[]) - Required - List of allowed hosts for API access - **`additionalScopes`** (string[]) - Optional - Additional scopes beyond User.Read ### Returns - **`MsalConfig`** - Complete MSAL configuration. ``` -------------------------------- ### Term Utility Functions Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/README.md Provides functions for manipulating and retrieving academic term information. Includes parsing term codes, generating term codes, creating term objects, and getting the current term. ```typescript // parseTermCode(code: string, returnDefault?: boolean): Term // generateTermCode(year: number, month: number): string // createTerm(year: number, monthInput: number | Term["name"] | Term["gradMonthName"]): Term // getCurrentTerm(): Term // getCurrentTermCode(): string // monthToTermName(month: number): Term["name"] // monthToGradMonthName(month: number): Term["gradMonthName"] ``` -------------------------------- ### Get Current Term Information Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/API.md Retrieves the Term object or term code corresponding to the current date. The logic determines the current term based on the month: Spring before June, Summer from June to September, and Fall from October onwards. ```typescript /** * Get the Term object for the term that matches the current date. * * Logic: * - Before June: Spring term * - June through September: Summer term * - October and later: Fall term * * @returns Term object for current term */ export declare function getCurrentTerm(): Term; /** * Generate a term code that matches the current date. */ export declare function getCurrentTermCode(): string; ``` -------------------------------- ### Link Local Package with npm Source: https://github.com/graduatecollege/vuelib/blob/main/README.md Demonstrates how to link a local package for development and testing within another project. It involves linking the package globally and then linking it to the consuming project. ```bash # In the package directory cd packages/vue-auth npm link # In the consuming project npm link @graduatecollege/vue-auth ``` -------------------------------- ### Get Current Academic Term and Code Source: https://context7.com/graduatecollege/vuelib/llms.txt Retrieves the current academic term and its corresponding code based on the current date. The `getCurrentTerm` and `getCurrentTermCode` functions from '@graduatecollege/codex' implement specific Graduate College logic for term determination. ```typescript import { getCurrentTerm, getCurrentTermCode } from '@graduatecollege/codex'; // Get current term object const currentTerm = getCurrentTerm(); console.log(currentTerm.name); // e.g., "Spring" console.log(currentTerm.year); // e.g., 2024 console.log(currentTerm.termName); // e.g., "Spring 2024" console.log(currentTerm.academicYear); // e.g., "2023-2024" // Get just the term code const code = getCurrentTermCode(); console.log(code); // e.g., "120241" // Term determination logic: // January - May: Spring (month=1) // June - September: Summer (month=5) // October - December: Fall (month=8) ``` -------------------------------- ### Basic Date Formatting with @graduatecollege/vue-datetime Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-datetime/README.md Demonstrates basic date formatting using the formatDate function from the @graduatecollege/vue-datetime package. It shows how to format dates with or without time, in short or full formats, and how to handle null or invalid date inputs with custom text. ```typescript import { formatDate } from '@graduatecollege/vue-datetime' // Full format (default) formatDate('2024-01-15T10:30:00Z') // "Jan 15, 2024" // With time formatDate('2024-01-15T10:30:00Z', { includeTime: true }) // "Jan 15, 2024 10:30 AM" // Short format formatDate('2024-01-15T10:30:00Z', { shortFormat: true }) // "1/15" (if 2024 is the current year) // Short format with year formatDate('2023-01-15T10:30:00Z', { shortFormat: true }) // "1/15/2023" // Handle null values formatDate(null) // "None" // Custom null text formatDate(null, { nullText: 'N/A' }) // "N/A" // Invalid dates formatDate('invalid-date', { invalidText: 'Unknown' }) // "Unknown" ``` -------------------------------- ### CustomNavigationClient Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Custom navigation client for integrating MSAL with Vue Router, preventing full page reloads. ```APIDOC ## CustomNavigationClient ### Description Custom navigation client for integrating MSAL with Vue Router. This prevents full page reloads on auth redirects and uses Vue Router for navigation. ### Constructor - **`constructor(router: Router)`** Initializes the client with a Vue Router instance. ### Methods - **`navigateInternal(url: string, options: NavigationOptions): Promise`** Navigates to other pages within the same web application using the router. - **`url`** (string) - The URL to navigate to. - **`options`** (NavigationOptions) - Navigation options. ``` -------------------------------- ### getUpdaterInitials Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Formats user initials from their netID or username. ```APIDOC ## getUpdaterInitials ### Description Formats user initials from their netID or username. Returns "SYS" for system users. ### Parameters - **`updater`** (string) - Username or netID ### Returns - **`string`** - Formatted initials (uppercase). ``` -------------------------------- ### Peer Dependencies for @graduatecollege/vue-useful-api Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-useful-api/README.md Specifies the peer dependencies required by the @graduatecollege/vue-useful-api package. It requires Vue version 3.0.0 or higher. ```json { "vue": "^3.0.0" } ``` -------------------------------- ### msalPlugin Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Vue plugin for integrating MSAL authentication. ```APIDOC ## msalPlugin ### Description Vue plugin for integrating MSAL authentication. ### Install Method - **`install(app: App, apiAccessScope: string, msalInstance: PublicClientApplication, msalConfig: MsalConfig, router: Router): void`** Installs the MSAL plugin into the Vue application. ``` -------------------------------- ### AuthStoreInterface Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Interface for the auth store, defining methods required for authentication guard integration. ```APIDOC ## AuthStoreInterface ### Description Interface for the auth store used by the auth guard. Your auth store should implement this interface. ### Properties - **`initPromise: Promise`** A promise that resolves when the auth store is initialized. - **`isAuthenticated: boolean`** A boolean indicating whether the user is authenticated. ### Methods - **`handleRedirect(): Promise`** Handles the authentication redirect. - **`login(redirectStartPage?: string): void`** Initiates the login process. ``` -------------------------------- ### @graduatecollege/vue-auth - Auth Class Source: https://context7.com/graduatecollege/vuelib/llms.txt Reactive authentication state manager that handles login, logout, token acquisition, and account management. Use `Auth.create()` to instantiate a reactive instance with automatic event listeners. ```APIDOC ## Auth Class ### Description Reactive authentication state manager that handles login, logout, token acquisition, and account management. Use `Auth.create()` to instantiate a reactive instance with automatic event listeners. ### Method Class Instance ### Endpoint N/A (Class usage) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { PublicClientApplication } from '@azure/msal-browser'; import { Auth, createMsalConfig } from '@graduatecollege/vue-auth'; import { inject } from 'vue'; // In a component or composable: const auth = inject('auth'); // Check authentication state console.log(auth.ready); // true when initialized console.log(auth.inProgress); // true during login/logout console.log(auth.account.value); // Current AccountInfo or null console.log(auth.accounts); // All available accounts // Trigger login redirect auth.loginRedirect('/dashboard'); // Logout await auth.logout(); // Load tokens for API calls const apiToken = await auth.loadApiToken(); console.log(apiToken.accessToken); // Bearer token for API const graphToken = await auth.loadGraphToken(); console.log(graphToken.accessToken); // Bearer token for Microsoft Graph // Initialize on app startup await auth.initialize(); ``` ### Response #### Success Response (Auth Instance Properties/Methods) - **ready** (boolean) - Indicates if the authentication instance is ready. - **inProgress** (boolean) - Indicates if an authentication operation (login/logout) is in progress. - **account** (Ref) - A reactive reference to the currently active account. - **accounts** (AccountInfo[]) - An array of all available accounts. - **loginRedirect(redirectPath?: string)** - Initiates a redirect flow for login. - **logout()** - Initiates the logout flow. - **loadApiToken()** - Acquires and returns an access token for the configured API scope. - **loadGraphToken()** - Acquires and returns an access token for the Microsoft Graph API. - **initialize()** - Initializes the authentication instance, loading existing tokens and accounts. #### Response Example ```json // Example of auth.account.value structure: { "homeAccountId": "...", "localAccountId": "...", "name": "User Name", "username": "user@example.com", "tenantId": "..." } // Example of token response structure: { "accessToken": "eyJ...", "expiresOn": "2023-10-27T10:00:00.000Z", "scopes": ["api://your-api/.default"] } ``` ``` -------------------------------- ### Term Creation and Manipulation Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/API.md Functions for creating, generating, and retrieving information about academic terms. ```APIDOC ## POST /api/terms/create ### Description Creates a Term object from a given year and month input. The month input can be a number, term name, or graduation month name. ### Method POST ### Endpoint /api/terms/create ### Parameters #### Query Parameters - **year** (number) - Required - Four digit year - **monthInput** (number | string) - Required - Month number (1, 5, 8), term name ("Spring", "Summer", "Fall"), or graduation month ("May", "Aug", "Dec") ### Request Example ```json { "year": 2024, "monthInput": 1 } ``` ### Response #### Success Response (200) - **Term object** - Complete Term object #### Response Example ```json { "year": 2024, "month": 1, "name": "Spring", "gradMonthName": "May", "code": "120241", "academicYear": "2023-2024", "termName": "Spring 2024", "shortTermName": "Spring" } ``` ## POST /api/terms/generateCode ### Description Generates a term code string in the format "1YYYYX" from a given year and month. ### Method POST ### Endpoint /api/terms/generateCode ### Parameters #### Query Parameters - **year** (number) - Required - Four digit year - **month** (number) - Required - Month number (1 for Spring, 5 for Summer, 8 for Fall) ### Request Example ```json { "year": 2024, "month": 1 } ``` ### Response #### Success Response (200) - **termCode** (string) - Term code string in format "1YYYYX" #### Response Example ```json { "termCode": "120241" } ``` ## GET /api/terms/current ### Description Retrieves the Term object for the term that matches the current date. ### Method GET ### Endpoint /api/terms/current ### Response #### Success Response (200) - **Term object** - Term object for the current term #### Response Example ```json { "year": 2024, "month": 1, "name": "Spring", "gradMonthName": "May", "code": "120241", "academicYear": "2023-2024", "termName": "Spring 2024", "shortTermName": "Spring" } ``` ## GET /api/terms/currentCode ### Description Generates a term code string that matches the current date. ### Method GET ### Endpoint /api/terms/currentCode ### Response #### Success Response (200) - **termCode** (string) - Term code string for the current term #### Response Example ```json { "termCode": "120241" } ``` ## POST /api/terms/monthToGradMonthName ### Description Converts a month number to its corresponding graduation month name. ### Method POST ### Endpoint /api/terms/monthToGradMonthName ### Parameters #### Query Parameters - **month** (number) - Required - Month number (1 for Spring, 5 for Summer, 8 for Fall) ### Request Example ```json { "month": 1 } ``` ### Response #### Success Response (200) - **gradMonthName** (string) - Graduation month name ("May", "Aug", or "Dec") #### Response Example ```json { "gradMonthName": "May" } ``` ## POST /api/terms/monthToTermName ### Description Converts a month number to its corresponding term name. ### Method POST ### Endpoint /api/terms/monthToTermName ### Parameters #### Query Parameters - **month** (number) - Required - Month number (1 for Spring, 5 for Summer, 8 for Fall) ### Request Example ```json { "month": 1 } ``` ### Response #### Success Response (200) - **termName** (string) - Term name ("Spring", "Summer", or "Fall") #### Response Example ```json { "termName": "Spring" } ``` ## POST /api/terms/parseCode ### Description Parses a term code string into a Term object. The term code format is "1YYYYX". ### Method POST ### Endpoint /api/terms/parseCode ### Parameters #### Query Parameters - **code** (string) - Required - Term code to parse (e.g., "120241" for Spring 2024) - **returnDefault** (boolean) - Optional - If true, returns the current term if parsing fails ### Request Example ```json { "code": "120241", "returnDefault": false } ``` ### Response #### Success Response (200) - **Term object** - Parsed Term object or "Unknown" term if parsing fails #### Response Example ```json { "year": 2024, "month": 1, "name": "Spring", "gradMonthName": "May", "code": "120241", "academicYear": "2023-2024", "termName": "Spring 2024", "shortTermName": "Spring" } ``` ``` -------------------------------- ### Create MSAL Configuration for Vue Auth Source: https://context7.com/graduatecollege/vuelib/llms.txt Generates a complete MSAL configuration object for Azure AD/Entra authentication. This includes auth settings, cache options, logger configuration, and login request scopes. It requires Azure AD client ID, tenant ID, API access scope, allowed hosts, and optional additional scopes. ```typescript import { createMsalConfig } from '@graduatecollege/vue-auth'; const msalConfig = createMsalConfig( 'your-client-id-uuid', // Azure AD app client ID 'your-tenant-id-uuid', // Azure AD tenant ID 'api://your-api-id/.default', // API access scope ['api.example.com', 'localhost'], // Allowed hosts ['Mail.Read', 'Calendars.Read'] // Additional scopes (optional) ); // Result structure: // { // auth: { // clientId: 'your-client-id-uuid', // authority: 'https://login.microsoftonline.com/your-tenant-id-uuid', // redirectUri: '/', // postLogoutRedirectUri: '/' // }, // cache: { cacheLocation: 'localStorage' }, // system: { loggerOptions: { ... } }, // loginRequest: { scopes: ['User.Read', 'Mail.Read', 'Calendars.Read'] }, // apiAccessScope: 'api://your-api-id/.default', // allowedHosts: ['api.example.com', 'localhost'], // graphConfig: { graphMeEndpoint: 'https://graph.microsoft.com/v1.0/me' } // } ``` -------------------------------- ### Check Authentication Status and Initiate Login Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md A function that checks if a user is authenticated and initiates the login process if they are not. It takes a function to retrieve the auth store and an optional redirect path. This is a common pattern for protecting routes in Vue applications. ```typescript /** * Checks if the user is authenticated and initiates login if not. * * @param getAuthStore - Function that returns the auth store * @param redirectStartPage - Optional redirect path after login * @returns Promise - True if authenticated, false otherwise */ export declare function isAuthenticated(getAuthStore: () => AuthStoreInterface, redirectStartPage?: string): Promise; ``` -------------------------------- ### @graduatecollege/vue-auth - createMsalConfig Source: https://context7.com/graduatecollege/vuelib/llms.txt Creates a complete MSAL configuration object for Azure AD/Entra authentication. This helper function generates all necessary configuration including auth settings, cache options, logger configuration, and login request scopes. ```APIDOC ## createMsalConfig ### Description Creates a complete MSAL configuration object for Azure AD/Entra authentication. This helper function generates all necessary configuration including auth settings, cache options, logger configuration, and login request scopes. ### Method Utility Function ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { createMsalConfig } from '@graduatecollege/vue-auth'; const msalConfig = createMsalConfig( 'your-client-id-uuid', // Azure AD app client ID 'your-tenant-id-uuid', // Azure AD tenant ID 'api://your-api-id/.default', // API access scope ['api.example.com', 'localhost'], // Allowed hosts ['Mail.Read', 'Calendars.Read'] // Additional scopes (optional) ); ``` ### Response #### Success Response (Object) - **auth** (object) - Authentication settings including clientId, authority, redirectUri, postLogoutRedirectUri. - **cache** (object) - Cache configuration, typically `{ cacheLocation: 'localStorage' }`. - **system** (object) - System configuration, including logger options. - **loginRequest** (object) - Scopes for the initial login request. - **apiAccessScope** (string) - The default API access scope. - **allowedHosts** (array) - A list of allowed hosts for the application. - **graphConfig** (object) - Configuration for Microsoft Graph API access, including the graphMeEndpoint. #### Response Example ```json { "auth": { "clientId": "your-client-id-uuid", "authority": "https://login.microsoftonline.com/your-tenant-id-uuid", "redirectUri": "/", "postLogoutRedirectUri": "/" }, "cache": {"cacheLocation": "localStorage"}, "system": {"loggerOptions": {...}}, "loginRequest": {"scopes": ["User.Read", "Mail.Read", "Calendars.Read"]}, "apiAccessScope": "api://your-api-id/.default", "allowedHosts": ["api.example.com", "localhost"], "graphConfig": {"graphMeEndpoint": "https://graph.microsoft.com/v1.0/me"} } ``` ``` -------------------------------- ### MsalConfig Interface for MSAL Configuration Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Defines the structure for MSAL configuration within the vue-auth library. This interface specifies all necessary parameters for initializing MSAL, including client ID, authority, redirect URIs, cache settings, and API scopes. ```typescript /** * Configuration interface for MSAL */ export declare interface MsalConfig { auth: { clientId: string; authority: string; redirectUri: string; postLogoutRedirectUri: string; }; cache: { cacheLocation: "localStorage" | "sessionStorage"; storeAuthStateInCookie?: boolean; }; system?: { loggerOptions?: { loggerCallback: (level: LogLevel, message: string, containsPii: boolean) => void; logLevel?: LogLevel; }; }; loginRequest: { scopes: string[]; }; apiAccessScope: string; allowedHosts: string[]; graphConfig?: { graphMeEndpoint: string; }; } ``` -------------------------------- ### Apply Useful API to a Class - TypeScript Source: https://context7.com/graduatecollege/vuelib/llms.txt Wraps all methods of an API class with usefulApi, making the entire API reactive. This is ideal for wrapping service classes or API client instances. Each method then returns a factory function that can be used to execute the API call and access its response, error, and loading states. ```typescript import { applyUsefulApi, UsefulApiMethod } from '@graduatecollege/vue-useful-api'; // Define your API class class UsersApi { async getUser(id: string): Promise { const res = await fetch(`/api/users/${id}`); return res.json(); } async updateUser(id: string, data: Partial): Promise { const res = await fetch(`/api/users/${id}`, { method: 'PATCH', body: JSON.stringify(data) }); return res.json(); } async deleteUser(id: string): Promise { await fetch(`/api/users/${id}`, { method: 'DELETE' }); } } // Wrap the entire class const usersApi = applyUsefulApi(new UsersApi()); // Each method returns a factory function const getUser = usersApi.getUser(); const updateUser = usersApi.updateUser(); // Use in components await getUser.execute('user-123'); console.log(getUser.response.value); // User object await updateUser.execute('user-123', { name: 'Jane' }); if (updateUser.error.value) { console.error('Update failed'); } // Type helper for store definitions type GetUserMethod = UsefulApiMethod; ``` -------------------------------- ### Program Code Parsing Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/API.md Functions for splitting and validating program codes. ```APIDOC ## POST /api/programs/splitCode ### Description Splits a program code string into its component parts: campus, college, major, and degree. ### Method POST ### Endpoint /api/programs/splitCode ### Parameters #### Query Parameters - **programCode** (string) - Required - The program code to split (e.g., "1ULA0501MS") ### Request Example ```json { "programCode": "1ULA0501MS" } ``` ### Response #### Success Response (200) - **ProgramCodeParts object** - Object containing the parsed components #### Response Example ```json { "programCampus": "1U", "programCollege": "LA", "programMajor": "0501", "programDegree": "MS" } ``` ``` -------------------------------- ### Create Term Object Source: https://github.com/graduatecollege/vuelib/blob/main/packages/codex/API.md Creates a Term object from a given year and month input. The month input can be a number, term name, or graduation month name. It handles validation and returns a complete Term object or throws an error for invalid input. ```typescript /** * Create a Term object from year and month/name. * * @param year - Four digit year * @param monthInput - Month number (1, 5, 8), term name ("Spring", "Summer", "Fall"), or graduation month ("May", "Aug", "Dec") * @returns Complete Term object * @throws Error if monthInput is invalid */ export declare function createTerm(year: number, monthInput: number | Term["name"] | Term["gradMonthName"]): Term; ``` -------------------------------- ### Manage Authentication State with Vue Auth Class Source: https://context7.com/graduatecollege/vuelib/llms.txt A reactive authentication state manager for handling login, logout, token acquisition, and account management within Vue applications. Use `Auth.create()` to instantiate a reactive instance with automatic event listeners. It provides methods for login redirects, logout, and loading API or Microsoft Graph tokens. Initialization is handled via `auth.initialize()`. ```typescript import { PublicClientApplication } from '@azure/msal-browser'; import { Auth, createMsalConfig } from '@graduatecollege/vue-auth'; import { inject } from 'vue'; // In a component or composable: const auth = inject('auth'); // Check authentication state console.log(auth.ready); // true when initialized console.log(auth.inProgress); // true during login/logout console.log(auth.account.value); // Current AccountInfo or null console.log(auth.accounts); // All available accounts // Trigger login redirect auth.loginRedirect('/dashboard'); // Logout await auth.logout(); // Load tokens for API calls const apiToken = await auth.loadApiToken(); console.log(apiToken.accessToken); // Bearer token for API const graphToken = await auth.loadGraphToken(); console.log(graphToken.accessToken); // Bearer token for Microsoft Graph // Initialize on app startup await auth.initialize(); ``` -------------------------------- ### Generate Deterministic Color and Initials from NetID Source: https://context7.com/graduatecollege/vuelib/llms.txt Generates a deterministic hex color and user initials from a given netID. `netIdToColor` provides a consistent color for avatars, while `getUpdaterInitials` extracts uppercase initials, with a special case for 'system' users. These utilities are useful for consistent UI representation. ```typescript import { netIdToColor, getUpdaterInitials } from '@graduatecollege/vue-auth'; // Generate consistent color for user avatar const color = netIdToColor('jsmith2'); console.log(color); // "#a1b2c3" (deterministic based on netID) // Get initials for display const initials = getUpdaterInitials('jsmith2'); console.log(initials); // "JS" (uppercase initials) const systemInitials = getUpdaterInitials('system'); console.log(systemInitials); // "SYS" (special case for system users) // Use in a Vue component template: //
// {{ getUpdaterInitials(user.netId) }} //
``` -------------------------------- ### Format Date with Options (TypeScript) Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-datetime/API.md Formats a given date according to specified options. It supports various date inputs (string, Date, null/undefined) and offers customization for including time, using short formats, year awareness, and custom text for null or invalid dates. ```typescript import { ComputedRef } from 'vue'; import { MaybeRefOrGetter } from 'vue'; /** * Options for date formatting */ export declare interface DateFormatOptions { /** * Include time in the output * @default false */ includeTime?: boolean; /** * Use short format (M/D instead of full month name) * @default false */ shortFormat?: boolean; /** * Omit year if it's the current year (only applies to short format) * @default true */ yearAware?: boolean; /** * Text to display for null/undefined values * @default "None" */ nullText?: string; /** * Text to display for invalid dates * @default "Invalid Date" */ invalidText?: string; } /** * Formats a date with the given options. * * @param date - Date to format (string, Date, or null/undefined) * @param options - Formatting options * @returns Formatted date string * * @example * ````typescript * formatDate('2024-01-15T10:30:00Z') // "Jan 15, 2024" * formatDate('2024-01-15T10:30:00Z', { includeTime: true }) // "Jan 15, 2024 10:30 AM" * formatDate('2024-01-15T10:30:00Z', { shortFormat: true }) // "1/15" (if current year) * formatDate('2023-01-15T10:30:00Z', { shortFormat: true }) // "1/15/2023" * formatDate(null) // "None" * formatDate('invalid', { invalidText: 'N/A' }) // "N/A" * ```` */ export declare function formatDate(date: string | Date | undefined | null, options?: DateFormatOptions): string; ``` -------------------------------- ### Custom Navigation Client for Vue Router Integration Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-auth/API.md Extends MSAL's NavigationClient to integrate seamlessly with Vue Router. This class prevents full page reloads during authentication redirects by leveraging Vue Router's client-side navigation capabilities. It requires a Vue Router instance for operation. ```typescript /** * Custom navigation client for integrating MSAL with Vue Router. * This prevents full page reloads on auth redirects and uses Vue Router for navigation. */ export declare class CustomNavigationClient extends NavigationClient { private router; constructor(router: Router); /** * Navigates to other pages within the same web application * You can use the router to take advantage of client-side routing * @param url - The URL to navigate to * @param options - Navigation options */ navigateInternal(url: string, options: NavigationOptions): Promise; } ``` -------------------------------- ### Date Formatting Functions Source: https://github.com/graduatecollege/vuelib/blob/main/packages/vue-datetime/API.md This section details the standalone functions for formatting dates with different options. ```APIDOC ## formatDate ### Description Formats a date with the given options. It can handle string, Date, null, or undefined inputs. ### Method N/A (Function) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **date** (string | Date | undefined | null) - Required - The date value to format. - **options** (DateFormatOptions) - Optional - An object containing formatting options. - **includeTime** (boolean) - Optional - If true, includes the time in the output. Defaults to false. - **shortFormat** (boolean) - Optional - If true, uses a short date format (M/D instead of full month name). Defaults to false. - **yearAware** (boolean) - Optional - If true and `shortFormat` is true, omits the year if it's the current year. Defaults to true. - **nullText** (string) - Optional - Text to display for null or undefined values. Defaults to "None". - **invalidText** (string) - Optional - Text to display for invalid date values. Defaults to "Invalid Date". ### Request Example ```typescript formatDate('2024-01-15T10:30:00Z') // "Jan 15, 2024" formatDate('2024-01-15T10:30:00Z', { includeTime: true }) // "Jan 15, 2024 10:30 AM" formatDate('2024-01-15T10:30:00Z', { shortFormat: true }) // "1/15" (if current year) formatDate('2023-01-15T10:30:00Z', { shortFormat: true }) // "1/15/2023" formatDate(null) // "None" formatDate('invalid', { invalidText: 'N/A' }) // "N/A" ``` ### Response #### Success Response (string) - **Formatted Date** (string) - The date formatted according to the provided options. #### Response Example ```json "Jan 15, 2024" ``` ## fullDateFormat ### Description Formats a date in a full format (e.g., "Jan 15, 2024"). ### Method N/A (Function) ### Endpoint N/A ### Parameters - **date** (string | Date | undefined | null) - Required - The date value to format. ### Request Example ```typescript fullDateFormat('2024-01-15T10:30:00Z') // "Jan 15, 2024" ``` ### Response #### Success Response (string) - **Formatted Date** (string) - The date formatted in full. #### Response Example ```json "Jan 15, 2024" ``` ## fullDateTimeFormat ### Description Formats a date with time in a full format (e.g., "Jan 15, 2024 10:30 AM"). ### Method N/A (Function) ### Endpoint N/A ### Parameters - **date** (string | Date | undefined | null) - Required - The date value to format. ### Request Example ```typescript fullDateTimeFormat('2024-01-15T10:30:00Z') // "Jan 15, 2024 10:30 AM" ``` ### Response #### Success Response (string) - **Formatted Date and Time** (string) - The date and time formatted in full. #### Response Example ```json "Jan 15, 2024 10:30 AM" ``` ## shortDateFormat ### Description Formats a date in a short format (e.g., "1/15" or "1/15/2024"). The year is omitted if it's the current year. ### Method N/A (Function) ### Endpoint N/A ### Parameters - **date** (string | Date | undefined | null) - Required - The date value to format. ### Request Example ```typescript shortDateFormat('2024-01-15T10:30:00Z') // "1/15" shortDateFormat('2023-01-15T10:30:00Z') // "1/15/2023" ``` ### Response #### Success Response (string) - **Formatted Date** (string) - The date formatted in short format. #### Response Example ```json "1/15" ``` ## shortDateTimeFormat ### Description Formats a date with time in a short format (e.g., "1/15 10:30 AM" or "1/15/2024 10:30 AM"). The year is omitted if it's the current year. ### Method N/A (Function) ### Endpoint N/A ### Parameters - **date** (string | Date | undefined | null) - Required - The date value to format. ### Request Example ```typescript shortDateTimeFormat('2024-01-15T10:30:00Z') // "1/15 10:30 AM" shortDateTimeFormat('2023-01-15T10:30:00Z') // "1/15/2023 10:30 AM" ``` ### Response #### Success Response (string) - **Formatted Date and Time** (string) - The date and time formatted in short format. #### Response Example ```json "1/15 10:30 AM" ``` ```