Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "teams-sync",
"version": "1.0.0",
"description": "",
"main": "app.ts",
"module": "es2015",
"main": "app.ts",
"type":"module",
"scripts": {
"test": "jest --coverage --reporters=jest-junit",
"dev": "nodemon",
Expand All @@ -19,7 +19,7 @@
"@octokit/types": "^13.4.0",
"@types/express": "^4.17.17",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.4.8",
"@types/node": "22.1.0 ",
"@types/swagger-ui-express": "^4.1.3",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
Expand All @@ -31,17 +31,18 @@
},
"dependencies": {
"@octokit/auth-app": "6.1.1",
"@octokit/plugin-throttling": "^9.3.2",
"applicationinsights": "^3.2.1",
"axios": "^1.4.0",
"axios-retry": "^4.0.0",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"js-yaml": "^4.1.0",
"nocache": "^4.0.0",
"octokit": "3.2.1",
"octokit": "4.0.2",
"openapi-backend": "^5.9.1",
"redis": "^4.7.0",
"swagger-ui-express": "5.0.0"
"swagger-ui-express": "5.0.1"
},
"nodemonConfig": {
"watch": [
Expand Down
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import fs from "fs";
import path from "node:path";
import swaggerUi from "swagger-ui-express";
import { routes } from "./routes";
import { SetupLogging } from "./logging";
import { routes } from "./routes.ts";
import { SetupLogging } from "./logging.ts";

Check warning on line 8 in src/app.ts

View check run for this annotation

Codecov / codecov/patch

src/app.ts#L7-L8

Added lines #L7 - L8 were not covered by tests
import nocache from "nocache";
import { createClient } from 'redis';
import { Config } from "./config";
import { Config } from "./config.ts";

Check warning on line 11 in src/app.ts

View check run for this annotation

Codecov / codecov/patch

src/app.ts#L11

Added line #L11 was not covered by tests

import {Request} from "openapi-backend";

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/getCurrentRateLimit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { Limits } from "../types/sync-models";
import { GetClient } from "../services/gitHub";
import { Limits } from "../types/sync-models.ts";
import { GetClient } from "../services/gitHub.ts";

Check warning on line 4 in src/handlers/getCurrentRateLimit.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/getCurrentRateLimit.ts#L4

Added line #L4 was not covered by tests

export async function getCurrentRateLimitHandler(
c: Context,
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/getInstalledOrgs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { OrgModel } from "../types/sync-models";
import { GetClient } from "../services/gitHub";
import { OrgModel } from "../types/sync-models.ts";
import { GetClient } from "../services/gitHub.ts";

Check warning on line 4 in src/handlers/getInstalledOrgs.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/getInstalledOrgs.ts#L4

Added line #L4 was not covered by tests

export async function getInstalledOrgsHandler(
c: Context,
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/getSourceTeam.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { SearchAllAsync } from "../services/ldapClient";
import { Log } from "../logging";
import { SearchAllAsync } from "../services/ldapClient.ts";
import { Log } from "../logging.ts";

Check warning on line 4 in src/handlers/getSourceTeam.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/getSourceTeam.ts#L3-L4

Added lines #L3 - L4 were not covered by tests

export async function getSourceTeamHandler(
c: Context,
Expand Down
10 changes: 5 additions & 5 deletions src/handlers/syncAll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { GetClient } from "../services/gitHub";
import { SyncOrg } from "../services/githubSync";
import { GitHubClient } from "../services/gitHubTypes";
import { GetClient } from "../services/gitHub.ts";
import { SyncOrg } from "../services/githubSync.ts";

Check warning on line 4 in src/handlers/syncAll.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncAll.ts#L3-L4

Added lines #L3 - L4 were not covered by tests
import { GitHubClient } from "../services/gitHubTypes.ts";
import axios from 'axios';
import { Log } from "../logging";
import { GetInvitationsClient } from "../services/githubInvitations";
import { Log } from "../logging.ts";
import { GetInvitationsClient } from "../services/githubInvitations.ts";

Check warning on line 8 in src/handlers/syncAll.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncAll.ts#L7-L8

Added lines #L7 - L8 were not covered by tests

async function syncOrgLocal(installationId: number, client: GitHubClient) {
const orgClient = await client.GetOrgClient(installationId);
Expand Down
10 changes: 5 additions & 5 deletions src/handlers/syncOrg.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { GetClient } from "../services/gitHub";
import { SyncOrg } from "../services/githubSync";
import { AsyncReturnType } from "../utility";
import { GetClient } from "../services/gitHub.ts";
import { SyncOrg } from "../services/githubSync.ts";

Check warning on line 4 in src/handlers/syncOrg.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncOrg.ts#L3-L4

Added lines #L3 - L4 were not covered by tests
import { AsyncReturnType } from "../utility.ts";
import axios from 'axios';
import { Log } from "../logging";
import { GetInvitationsClient } from "../services/githubInvitations";
import { Log } from "../logging.ts";
import { GetInvitationsClient } from "../services/githubInvitations.ts";

Check warning on line 8 in src/handlers/syncOrg.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncOrg.ts#L7-L8

Added lines #L7 - L8 were not covered by tests

async function forwardToProxy(installationId: number) {
Log(`Forwarding request to '${process.env.GITHUB_PROXY}'`);
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/syncSpecificTeamHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Context } from "openapi-backend";
import type { Request, Response } from "express";
import { GetClient } from "../services/gitHub";
import { SyncTeam } from "../services/githubSync";
import { GetClient } from "../services/gitHub.ts";
import { SyncTeam } from "../services/githubSync.ts";

Check warning on line 4 in src/handlers/syncSpecificTeamHandler.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncSpecificTeamHandler.ts#L3-L4

Added lines #L3 - L4 were not covered by tests
import axios from 'axios';
import { Log } from "../logging";
import { GetInvitationsClient } from "../services/githubInvitations";
import { Log } from "../logging.ts";
import { GetInvitationsClient } from "../services/githubInvitations.ts";

Check warning on line 7 in src/handlers/syncSpecificTeamHandler.ts

View check run for this annotation

Codecov / codecov/patch

src/handlers/syncSpecificTeamHandler.ts#L6-L7

Added lines #L6 - L7 were not covered by tests

async function forwardToProxy(installationId: number) {
Log(`Forwarding request to '${process.env.GITHUB_PROXY}'`);
Expand Down
12 changes: 6 additions & 6 deletions src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getCurrentRateLimitHandler } from "./handlers/getCurrentRateLimit";
import { getInstalledOrgsHandler } from "./handlers/getInstalledOrgs";
import { getSourceTeamHandler } from "./handlers/getSourceTeam";
import { syncAllHandler } from "./handlers/syncAll";
import { syncOrgHandler } from "./handlers/syncOrg";
import { syncSpecificTeamHandler } from "./handlers/syncSpecificTeamHandler";
import { getCurrentRateLimitHandler } from "./handlers/getCurrentRateLimit.ts";
import { getInstalledOrgsHandler } from "./handlers/getInstalledOrgs.ts";
import { getSourceTeamHandler } from "./handlers/getSourceTeam.ts";
import { syncAllHandler } from "./handlers/syncAll.ts";
import { syncOrgHandler } from "./handlers/syncOrg.ts";
import { syncSpecificTeamHandler } from "./handlers/syncSpecificTeamHandler.ts";

Check warning on line 6 in src/routes.ts

View check run for this annotation

Codecov / codecov/patch

src/routes.ts#L1-L6

Added lines #L1 - L6 were not covered by tests

function notImplementedHandler(c: any, req: any, res: any) {
return res
Expand Down
16 changes: 8 additions & 8 deletions src/services/gitHub.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Octokit } from "octokit";
import { createAppAuth } from "@octokit/auth-app";
import { Config } from "../config";
import { AddMemberResponse, CopilotAddResponse, GitHubClient, GitHubId, GitHubTeamId, InstalledClient, Org, OrgConfigResponse, OrgInvite, OrgRoles, RemoveMemberResponse, Response } from "./gitHubTypes";
import { AppConfig } from "./appConfig";
import { Config } from "../config.ts";

Check warning on line 3 in src/services/gitHub.ts

View check run for this annotation

Codecov / codecov/patch

src/services/gitHub.ts#L3

Added line #L3 was not covered by tests
import { AddMemberResponse, CopilotAddResponse, GitHubClient, GitHubId, GitHubTeamId, InstalledClient, Org, OrgConfigResponse, OrgInvite, OrgRoles, RemoveMemberResponse, Response } from "./gitHubTypes.ts";
import { AppConfig } from "./appConfig.ts";
import yaml from "js-yaml";
import { throttling } from "@octokit/plugin-throttling";
import { AsyncReturnType } from "../utility";
import { Log, LogError, LoggerToUse } from "../logging";
import { GitHubClientCache } from "./gitHubCache";
import { redisClient } from "../app";
import { GitHubTeamName, OrgConfig, OrgConfigurationOptions } from "./orgConfig";
import { AsyncReturnType } from "../utility.ts";
import { Log, LogError, LoggerToUse } from "../logging.ts";
import { GitHubClientCache } from "./gitHubCache.ts";
import { redisClient } from "../app.ts";
import { GitHubTeamName, OrgConfig, OrgConfigurationOptions } from "./orgConfig.ts";

Check warning on line 12 in src/services/gitHub.ts

View check run for this annotation

Codecov / codecov/patch

src/services/gitHub.ts#L9-L12

Added lines #L9 - L12 were not covered by tests

const config = Config();

Expand Down
6 changes: 3 additions & 3 deletions src/services/gitHubCache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CacheClient } from "../app";
import { ILogger } from "../logging";
import { AddMemberResponse, CopilotAddResponse, GitHubTeamId, InstalledClient, OrgConfigResponse, OrgInvite, OrgRoles, RemoveMemberResponse, Response } from "./gitHubTypes";
import { CacheClient } from "../app.ts";
import { ILogger } from "../logging.ts";
import { AddMemberResponse, CopilotAddResponse, GitHubTeamId, InstalledClient, OrgConfigResponse, OrgInvite, OrgRoles, RemoveMemberResponse, Response } from "./gitHubTypes.ts";

export class GitHubClientCache implements InstalledClient {
client: InstalledClient;
Expand Down
4 changes: 2 additions & 2 deletions src/services/gitHubTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppConfig } from "./appConfig"
import { GitHubTeamName, OrgConfig } from "./orgConfig"
import { AppConfig } from "./appConfig.ts"
import { GitHubTeamName, OrgConfig } from "./orgConfig.ts"

export interface Org {
id: number,
Expand Down
2 changes: 1 addition & 1 deletion src/services/githubInvitations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenericSucceededResponse, InstalledClient, OrgInvite,Response } from "./gitHubTypes";
import { GenericSucceededResponse, InstalledClient, OrgInvite,Response } from "./gitHubTypes.ts";

export interface IGitHubInvitations {
ListInvites():Response<OrgInvite[]>
Expand Down
12 changes: 6 additions & 6 deletions src/services/githubSync.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// REMEMBER TO REPLACE '_' with '-' for GitHub Names! 🤦‍♂️

import e from "express";
import { Log, LogError } from "../logging";
import { AppConfig } from "./appConfig";
import { CopilotAddResponse, FailedResponse, GitHubId, InstalledClient, OrgInvite } from "./gitHubTypes";
import { IGitHubInvitations } from "./githubInvitations";
import { SearchAllAsync } from "./ldapClient";
import { OrgConfig } from "./orgConfig";
import { Log, LogError } from "../logging.ts";

Check warning on line 4 in src/services/githubSync.ts

View check run for this annotation

Codecov / codecov/patch

src/services/githubSync.ts#L4

Added line #L4 was not covered by tests
import { AppConfig } from "./appConfig.ts";
import { CopilotAddResponse, FailedResponse, GitHubId, InstalledClient, OrgInvite } from "./gitHubTypes.ts";
import { IGitHubInvitations } from "./githubInvitations.ts";
import { SearchAllAsync } from "./ldapClient.ts";

Check warning on line 8 in src/services/githubSync.ts

View check run for this annotation

Codecov / codecov/patch

src/services/githubSync.ts#L8

Added line #L8 was not covered by tests
import { OrgConfig } from "./orgConfig.ts";

function teamDescription(shortLink: string, sourceTeam: string) {
return `🤖 Managed by GTTSB: ${shortLink} | Source Team: ${sourceTeam}`
Expand Down
6 changes: 3 additions & 3 deletions src/services/ldapClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Config } from "../config";
import { Config } from "../config.ts";

Check warning on line 1 in src/services/ldapClient.ts

View check run for this annotation

Codecov / codecov/patch

src/services/ldapClient.ts#L1

Added line #L1 was not covered by tests
import axios, { AxiosError } from "axios";
import axiosRetry from "axios-retry";
import { Log, LoggerToUse } from "../logging";
import { redisClient } from "../app";
import { Log, LoggerToUse } from "../logging.ts";
import { redisClient } from "../app.ts";

Check warning on line 5 in src/services/ldapClient.ts

View check run for this annotation

Codecov / codecov/patch

src/services/ldapClient.ts#L4-L5

Added lines #L4 - L5 were not covered by tests

const config = Config()
export interface Entry {
Expand Down
2 changes: 1 addition & 1 deletion tests/orgConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {describe, expect, test} from '@jest/globals';
import { ManagedGitHubTeam, OrgConfig, OrgConfigurationOptions } from '../src/services/orgConfig';
import { ManagedGitHubTeam, OrgConfig, OrgConfigurationOptions } from '../src/services/orgConfig.ts';

describe('OrgConfigClass', () => {
test('Sets proper defaults', () => {
Expand Down
9 changes: 6 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"compilerOptions": {
"target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"module": "commonjs", /* Specify what module code is generated. */
"module": "node16", /* Specify what module code is generated. */
"outDir": "./out", /* Specify an output folder for all emitted files. */
"sourceMap": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"allowImportingTsExtensions": true,
"emitDeclarationOnly": true,
"declaration": true
}
}
Loading