jackson/npm/src/directory-sync/types.ts

228 lines
5.4 KiB
TypeScript
Raw Normal View History

Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
import directorySync from '.';
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
import { DirectoryConfig } from './scim/DirectoryConfig';
import { DirectoryGroups } from './scim/DirectoryGroups';
import { DirectoryUsers } from './scim/DirectoryUsers';
import { Users } from './scim/Users';
import { Groups } from './scim/Groups';
import { WebhookEventsLogger } from './scim/WebhookEventsLogger';
import { ApiError } from '../typings';
import { RequestHandler } from './request';
import { EventProcessor } from './batch-events/queue';
import { CronLock as Lock } from '../cron/lock';
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
export type IDirectorySyncController = Awaited<ReturnType<typeof directorySync>>;
export type IDirectoryConfig = InstanceType<typeof DirectoryConfig>;
export type IDirectoryGroups = InstanceType<typeof DirectoryGroups>;
export type IDirectoryUsers = InstanceType<typeof DirectoryUsers>;
export type IUsers = InstanceType<typeof Users>;
export type IGroups = InstanceType<typeof Groups>;
export type IWebhookEventsLogger = InstanceType<typeof WebhookEventsLogger>;
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
export type IRequestHandler = InstanceType<typeof RequestHandler>;
export type IEventProcessor = InstanceType<typeof EventProcessor>;
export type CronLock = InstanceType<typeof Lock>;
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
export type DirectorySyncEventType =
| 'user.created'
| 'user.updated'
| 'user.deleted'
| 'group.created'
| 'group.updated'
| 'group.deleted'
| 'group.user_added'
| 'group.user_removed';
export enum DirectorySyncProviders {
'azure-scim-v2' = 'Azure SCIM v2.0',
'onelogin-scim-v2' = 'OneLogin SCIM v2.0',
'okta-scim-v2' = 'Okta SCIM v2.0',
'jumpcloud-scim-v2' = 'JumpCloud v2.0',
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
'generic-scim-v2' = 'Generic SCIM v2.0',
'google' = 'Google',
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
}
export type DirectoryType = keyof typeof DirectorySyncProviders;
export type Directory = {
id: string;
name: string;
tenant: string;
product: string;
type: DirectoryType;
log_webhook_events: boolean;
scim: {
path: string;
endpoint?: string;
secret: string;
};
webhook: {
endpoint: string;
secret: string;
};
deactivated?: boolean;
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
google_domain?: string;
google_access_token?: string;
google_refresh_token?: string;
google_authorization_url?: string;
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
};
export type DirectorySyncGroupMember = { value: string; email?: string };
export type DirectorySyncResponse = {
status: number;
data?: any;
};
export interface Events {
handle(event: DirectorySyncEvent): Promise<void>;
}
export interface DirectorySyncRequest {
method: string; //'POST' | 'PUT' | 'DELETE' | 'GET' | 'PATCH';
body: any | undefined;
directoryId: Directory['id'];
resourceType: string; //'users' | 'groups';
resourceId: string | undefined;
apiSecret: string | null;
query: {
count?: number;
startIndex?: number;
filter?: string;
};
}
export type DirectorySyncEventData = User | Group | UserWithGroup;
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
export interface DirectorySyncEvent {
directory_id: Directory['id'];
event: DirectorySyncEventType;
data: DirectorySyncEventData;
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
tenant: string;
product: string;
}
export interface WebhookEventLog {
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
id: string;
webhook_endpoint: string;
created_at: Date;
status_code?: number;
delivered?: boolean;
payload: DirectorySyncEvent | DirectorySyncEvent[];
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
}
export type User = {
id: string;
email: string;
first_name: string;
last_name: string;
active: boolean;
roles?: string[];
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
raw?: any;
};
export type Group = {
id: string;
name: string;
raw?: any;
};
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
export type GroupMember = {
id: string;
raw?: any;
};
export type UserWithGroup = User & { group: Group };
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
export type PaginationParams = {
pageOffset?: number;
pageLimit?: number;
2023-03-16 21:42:36 +00:00
pageToken?: string;
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
hasNextPage?: boolean;
Add Playwright test for `/api/v1/` and `/api/scim/` endpoints (#816) * Update config * add the test cases for /api/v1/connections * Fix the strategyChecker, add metadataUrl to the condition * add the test cases for /api/v1/connections * update /api/v1/connections * Update the SSO connections tests * Rename the test file * update the tests * should be able to check if a connection exists * add the tests for directory sync APIs * rstructure the tests folder * add tests wip * Fix the API tests * Fix the sso connections tests * Refactor the connections list * restructure the /api/v1/connections APIs * restructure the /api/v1/directory-sync tests * add the tests for /api/scim/v2.0/ * update the tests * wip * fixes the api testing * allow adding multiple directory connections for the same tenant and product * update the tests * update the unit tests * improved the integration tests * cleanup the api tests * add tests for SCIM APIs * fix the globalSetup * update the tests for SCIM endpoints * add the remaining tests * fix the bug with fetching resource by invalid ID * cleanup * fix the tests * update the tenant name * typescript types cleanup * directory sync API updates * standardize the /api/v1/directory-sync * update the directories.test.ts * remove unused methods * filter the users and groups by directoryId * improve the SCIM request handling * fix the e2e tests * fix the e2e tests * attempt to fix the api tests * fix the api testing * move the files to helpers * add pagination for directory groups * API - delete a directory by id * delete the directory after the tests * remove the members array from the group info
2023-01-17 10:07:14 +00:00
};
export type UserPatchOperation = {
op: 'replace' | 'add';
path?: string;
value:
| boolean
| {
active: boolean;
}
| {
'name.givenName': string;
}
| {
'name.familyName': string;
}
| {
'emails[type eq "work"].value': string;
}
| {
[key: string]: string | boolean;
};
};
export type GroupPatchOperation = {
op: 'add' | 'remove' | 'replace';
path?: 'members' | 'displayName';
value:
| string
| {
value: string;
display?: string;
}[];
};
export type GroupMembership = {
id: string;
group_id: string;
user_id: string;
};
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
export type Response<T> = { data: T; error: null; pageToken?: string } | { data: null; error: ApiError };
Google Directory API Integration (#1158) * Add Google Group API * Restructure the Group interface * Rename the methods * wip * temp change * Revert the changes * Fix the groups from Google * wip fetch users * Skip directory check * Convert to SCIM schema * Updates to users sync * Fix the unit test * Rename folder and merge the files * add raw to the user payload * Fix the unit tests * Optimize the Group sync create ops * Reorder import * Remove unused imports * Add type safety to SCIM Schema * Fix the users and groups update * try fixing unit tests * Fix the file extension * Delete groups that are not in the directory anymore * Fix the group update * Compare and find the delete users * Add and update group members * cleanup the test * Fix the test (temp) * dont throw error * Add secondary index if the directory type is `google` * Rename the file * wip * Export functions inline * Hide the SCIM endpoint and token for non-scim provider * Update the `dsync` option key to allow multiple providers * Restructure the folders * Update folder structure * Cleanup * Revert the callback changes * Fix the type * Fix the type * Fix existing unit tests * add callback * Fix the internal callback * Fix the method call * merge the type files * add console.info for testing * Fix the Google OAuth client usage * Reactor the update method * Handle no users or group cases * Refactor the sync method * Fix the pagination * Cleanup * Finish the pagination * Fix the unit tests * Fix the lint errors * Fix the build issues * Pass directory id to the method * Pass directoryId while fetching * apply changes to the UI * display the Google auth URL * Fix the type * add unit tests * add unit test for syncing users * add unit tests * Pass operation to SCIM payload * unit tests wip 1 * updated * Test the events deleted * Test group.user_added events * Finish the tests * Revert and cleanup * update map.js * Revert * update the e2e test * Cleanup * Revert * label tweak * Remove unused import * Protect the cron job using apiKey --------- Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
2023-06-15 13:31:38 +00:00
export type EventCallback = (event: DirectorySyncEvent) => Promise<void>;
export interface IDirectoryProvider {
/**
* Fields to exclude from the user payload while comparing the user to find if it is updated
*/
userFieldsToExcludeWhenCompare?: string[];
/**
* Fields to exclude from the group payload while comparing the group to find if it is updated
*/
groupFieldsToExcludeWhenCompare?: string[];
/**
* Get all directories for the provider
*/
getDirectories(): Promise<Directory[]>;
/**
* Get all users for a directory
* @param directory
* @param options
*/
getUsers(
directory: Directory,
options: PaginationParams | null
): Promise<{ data: User[]; metadata: PaginationParams | null }>;
/**
* Get all groups for a directory
* @param directory
* @param options
*/
getGroups(
directory: Directory,
options: PaginationParams | null
): Promise<{ data: Group[]; metadata: PaginationParams | null }>;
/**
* Get all members of a group
* @param directory
* @param group
*/
getGroupMembers(directory: Directory, group: Group): Promise<GroupMember[]>;
}