fix: removed unefficient AI generated call pattern using one-use object types created for 2-3 variable passing.
Some checks failed
build / build (push) Failing after 13s
Some checks failed
build / build (push) Failing after 13s
This commit is contained in:
@@ -6,11 +6,6 @@ type GraphResult<T = GraphObject> = {
|
||||
value?: T[];
|
||||
};
|
||||
|
||||
type AppQueryOptions = {
|
||||
displayName?: string;
|
||||
appId?: string;
|
||||
};
|
||||
|
||||
type RequiredResourceAccessItem = {
|
||||
type?: string;
|
||||
id?: string;
|
||||
@@ -38,11 +33,6 @@ type ServicePrincipal = {
|
||||
appRoles?: GraphPermission[];
|
||||
};
|
||||
|
||||
type ResourcePermissionsOptions = {
|
||||
appId?: string;
|
||||
displayName?: string;
|
||||
};
|
||||
|
||||
export async function getApp(client: any, displayName: string): Promise<GraphObject | null> {
|
||||
const result = await client
|
||||
.api("/applications")
|
||||
@@ -68,8 +58,11 @@ export async function deleteApp(client: any, appObjectId: string): Promise<void>
|
||||
await client.api(`/applications/${appObjectId}`).delete();
|
||||
}
|
||||
|
||||
export async function listApps(client: any, options: AppQueryOptions = {}): Promise<GraphObject[]> {
|
||||
const { displayName, appId } = options;
|
||||
export async function listApps(
|
||||
client: any,
|
||||
displayName?: string,
|
||||
appId?: string,
|
||||
): Promise<GraphObject[]> {
|
||||
let request = client.api("/applications");
|
||||
const filters: string[] = [];
|
||||
|
||||
@@ -219,8 +212,11 @@ export async function listAppGrants(client: any, appId: string): Promise<GraphOb
|
||||
return Array.isArray(grantsResult?.value) ? grantsResult.value : [];
|
||||
}
|
||||
|
||||
export async function listResourcePermissions(client: any, options: ResourcePermissionsOptions = {}): Promise<Array<Record<string, unknown>>> {
|
||||
const { appId, displayName } = options;
|
||||
export async function listResourcePermissions(
|
||||
client: any,
|
||||
appId?: string,
|
||||
displayName?: string,
|
||||
): Promise<Array<Record<string, unknown>>> {
|
||||
if (!appId && !displayName) {
|
||||
throw new Error("appId or displayName is required");
|
||||
}
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { Client } from "@microsoft/microsoft-graph-client";
|
||||
import { acquireResourceTokenFromLogin } from "../azure/index.ts";
|
||||
|
||||
type GraphClientOptions = {
|
||||
tenantId?: string;
|
||||
clientId?: string;
|
||||
};
|
||||
import { acquireResourceToken } from "../azure/index.ts";
|
||||
|
||||
type GraphApiToken = {
|
||||
accessToken: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export async function getGraphClient({ tenantId, clientId }: GraphClientOptions): Promise<{ graphApiToken: GraphApiToken; client: any }> {
|
||||
const graphApiToken = await acquireResourceTokenFromLogin({
|
||||
tenantId,
|
||||
clientId,
|
||||
resource: "graph",
|
||||
}) as GraphApiToken;
|
||||
export async function getGraphClient(
|
||||
tenantId: string,
|
||||
clientId: string,
|
||||
): Promise<{ graphApiToken: GraphApiToken; client: any }> {
|
||||
const graphApiToken = await acquireResourceToken(tenantId, clientId, "graph") as GraphApiToken;
|
||||
|
||||
const client = Client.init({
|
||||
authProvider: (done) => {
|
||||
|
||||
Reference in New Issue
Block a user