Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
TuvalSimha committed Nov 7, 2024
1 parent 653cf78 commit 4a52852
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 69 deletions.
40 changes: 20 additions & 20 deletions integration-tests/tests/api/audit-logs/create-record.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { execute } from 'testkit/graphql';
import { initSeed } from 'testkit/seed';

test.concurrent('Create Audit Log Record for Organization', async ({ expect }) => {
const query = graphql(`
const query = graphql(`
query GetAllAuditLogs($selector: OrganizationSelectorInput!) {
organization(selector: $selector) {
organization {
Expand All @@ -30,25 +30,25 @@ test.concurrent('Create Audit Log Record for Organization', async ({ expect }) =
}
`);

const { ownerToken, createOrg } = await initSeed().createOwner();
const { organization } = await createOrg();
const { ownerToken, createOrg } = await initSeed().createOwner();
const { organization } = await createOrg();

const result = await execute({
document: query,
variables: {
selector: {
organizationSlug: organization.id,
},
},
authToken: ownerToken,
}).then(r => r.expectNoGraphQLErrors());
const auditLogs = result.organization?.organization.auditLogs.edges;
const result = await execute({
document: query,
variables: {
selector: {
organizationSlug: organization.id,
},
},
authToken: ownerToken,
}).then(r => r.expectNoGraphQLErrors());

Check failure on line 44 in integration-tests/tests/api/audit-logs/create-record.spec.ts

View workflow job for this annotation

GitHub Actions / test / integration (2)

tests/api/audit-logs/create-record.spec.ts > Create Audit Log Record for Organization

Error: Expected GraphQL response to have no errors, but got 1 errors: Unexpected error. endpoint: http://localhost:8082/graphql query: query GetAllAuditLogs($selector: OrganizationSelectorInput!) { organization(selector: $selector) { organization { id slug auditLogs { edges { node { ... on OrganizationCreatedAuditLog { id eventTime organizationSlug organizationId __typename record { organizationId } } } } } } } } body: { "errors": [ { "message": "Unexpected error.", "locations": [ { "line": 2, "column": 3 } ], "path": [ "organization" ] } ], "data": { "organization": null } } request-id: 7EwS2BrcSGSHsV3xvJ6LjA/0000000760 ❯ Object.expectNoGraphQLErrors testkit/graphql:55:15 ❯ tests/api/audit-logs/create-record.spec.ts:44:18 ❯ tests/api/audit-logs/create-record.spec.ts:36:18
const auditLogs = result.organization?.organization.auditLogs.edges;

expect(auditLogs?.length).toBe(1);
expect(auditLogs?.length).not.toBe(0);
expect(auditLogs?.[0].node.__typename).toBe('OrganizationCreatedAuditLog');
if (auditLogs?.[0].node.__typename === 'OrganizationCreatedAuditLog') {
expect(auditLogs?.[0].node.record.organizationId).toBe(organization.id);
expect(auditLogs?.[0].node.organizationId).toBe(organization.id);
}
expect(auditLogs?.length).toBe(1);
expect(auditLogs?.length).not.toBe(0);
expect(auditLogs?.[0].node.__typename).toBe('OrganizationCreatedAuditLog');
if (auditLogs?.[0].node.__typename === 'OrganizationCreatedAuditLog') {
expect(auditLogs?.[0].node.record.organizationId).toBe(organization.id);
expect(auditLogs?.[0].node.organizationId).toBe(organization.id);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ export class AuditLogManager {

const s3Storage = this.s3Config[0];
const { endpoint, bucket, client } = s3Storage;
const key = `audit-logs/${organizationSlug}/${filter.startDate}-${filter.endDate}.csv`;
const cleanStartDate = formattedStartDate?.toISOString().split('T')[0];
const cleanEndDate = formattedEndDate?.toISOString().split('T')[0];
const key = `audit-logs/${organizationSlug}/${cleanStartDate}-${cleanEndDate}.csv`;
const uploadResult = await client.fetch([endpoint, bucket, key].join('/'), {
method: 'PUT',
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class BillingProvider {
const result = this.billingService.createSubscriptionForOrganization.mutate(input);

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'SUBSCRIPTION_CREATED',
operations: input.reserved.operations,
paymentMethodId: input.paymentMethodId,
Expand Down Expand Up @@ -127,7 +127,7 @@ export class BillingProvider {
}

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'SUBSCRIPTION_CANCELED',
newPlan: 'HOBBY',
previousPlan: 'PRO',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class CdnProvider {
);

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'TARGET_SETTINGS_UPDATED',
targetId: args.targetId,
projectId: args.projectId,
Expand Down Expand Up @@ -339,7 +339,7 @@ export class CdnProvider {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'TARGET_SETTINGS_UPDATED',
targetId: args.targetId,
projectId: args.projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class CollectionProvider {
targetId,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'COLLECTION_CREATED',
collectionId: collection.id,
collectionName: collection.title,
Expand Down Expand Up @@ -158,7 +158,7 @@ export class CollectionProvider {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'COLLECTION_UPDATED',
collectionId: collection.id,
collectionName: collection.title,
Expand Down Expand Up @@ -225,7 +225,7 @@ export class CollectionProvider {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'COLLECTION_DELETED',
collectionId: args.collectionId,
collectionName: collection.title,
Expand Down Expand Up @@ -326,7 +326,7 @@ export class CollectionProvider {
createdByUserId: currentUser.id,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'OPERATION_IN_DOCUMENT_COLLECTION_CREATED',
collectionId: collection.id,
collectionName: collection.title,
Expand Down Expand Up @@ -445,7 +445,7 @@ export class CollectionProvider {

const currentUser = await this.session.getViewer();

this.auditLog.record({
await this.auditLog.record({
eventType: 'OPERATION_IN_DOCUMENT_COLLECTION_UPDATED',
collectionId: collection.id,
collectionName: collection.title,
Expand Down Expand Up @@ -542,7 +542,7 @@ export class CollectionProvider {

const currentUser = await this.session.getViewer();

this.auditLog.record({
await this.auditLog.record({
eventType: 'OPERATION_IN_DOCUMENT_COLLECTION_DELETED',
collectionId: collection.id,
collectionName: collection.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class GitHubIntegrationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_UPDATED_INTEGRATION',
integrationId: input.installationId,
updatedFields: JSON.stringify({
Expand Down Expand Up @@ -112,7 +112,7 @@ export class GitHubIntegrationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_UPDATED_INTEGRATION',
integrationId: input.organizationId,
updatedFields: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class SlackIntegrationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_UPDATED_INTEGRATION',
integrationId: input.organizationId,
updatedFields: JSON.stringify({
Expand Down Expand Up @@ -83,7 +83,7 @@ export class SlackIntegrationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_UPDATED_INTEGRATION',
integrationId: input.organizationId,
updatedFields: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class OIDCIntegrationsProvider {
}

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
createOIDCIntegrationForOrganization: true,
Expand Down Expand Up @@ -254,7 +254,7 @@ export class OIDCIntegrationsProvider {
}

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
updateOIDCIntegration: true,
Expand Down Expand Up @@ -318,7 +318,7 @@ export class OIDCIntegrationsProvider {
await this.storage.deleteOIDCIntegration(args);

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
deleteOIDCIntegration: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class OrganizationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_CREATED',
organizationId: result.organization.id,
organizationSlug: slug,
Expand Down Expand Up @@ -364,7 +364,7 @@ export class OrganizationManager {
this.session.reset();

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_DELETED',
organizationId: organization.id,
metadata: {
Expand Down Expand Up @@ -414,7 +414,7 @@ export class OrganizationManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
newPlan: plan,
Expand Down Expand Up @@ -463,7 +463,7 @@ export class OrganizationManager {
}

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'SUBSCRIPTION_UPDATED',
updatedFields: JSON.stringify({
monthlyRateLimit: {
Expand Down Expand Up @@ -518,7 +518,7 @@ export class OrganizationManager {
reservedSlugs: reservedOrganizationSlugs,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
newSlug: slug,
Expand Down Expand Up @@ -671,7 +671,7 @@ export class OrganizationManager {

const user = await this.session.getViewer();

this.auditLog.record({
await this.auditLog.record({
eventType: 'USER_INVITED',
inviteeEmail: email,
roleId: role.id,
Expand Down Expand Up @@ -746,7 +746,7 @@ export class OrganizationManager {
}),
]);

this.auditLog.record({
await this.auditLog.record({
eventType: 'USER_JOINED',
inviteeEmail: user.email,
metadata: {
Expand Down Expand Up @@ -822,7 +822,7 @@ export class OrganizationManager {
`,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_TRANSFERRED_REQUEST',
newOwnerEmail: member.user.email,
newOwnerId: member.user.id,
Expand Down Expand Up @@ -878,7 +878,7 @@ export class OrganizationManager {
});
const currentUser = await this.session.getViewer();

this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_TRANSFERRED',
newOwnerEmail: currentUser.email,
newOwnerId: currentUser.id,
Expand Down Expand Up @@ -972,7 +972,7 @@ export class OrganizationManager {
this.authManager.resetAccessCache();
this.session.reset();

this.auditLog.record({
await this.auditLog.record({
eventType: 'USER_REMOVED',
removedUserEmail: member.user.email,
removedUserId: member.user.id,
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export class OrganizationManager {
scopes,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'ROLE_CREATED',
roleId: role.id,
roleName: role.name,
Expand Down Expand Up @@ -1196,7 +1196,7 @@ export class OrganizationManager {
roleId: input.roleId,
});

this.auditLog.record({
await this.auditLog.record({
eventType: 'ROLE_DELETED',
roleId: role.id,
roleName: role.name,
Expand Down Expand Up @@ -1325,7 +1325,7 @@ export class OrganizationManager {
};

if (result) {
this.auditLog.record({
await this.auditLog.record({
eventType: 'ROLE_ASSIGNED',
previousMemberRole: member.role ? member.role.name : null,
roleId: newRole.id,
Expand Down Expand Up @@ -1468,7 +1468,7 @@ export class OrganizationManager {
this.authManager.resetAccessCache();
this.session.reset();

this.auditLog.record({
await this.auditLog.record({
eventType: 'ROLE_UPDATED',
roleId: updatedRole.id,
roleName: updatedRole.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export const Organization: Pick<
const auditLogs = await ctx.injector.get(AuditLogManager).getPaginatedAuditLogs(
organization.id,
{
after: arg.pagination?.after!,
first: arg.pagination?.first!,
after: arg.pagination?.after ?? 0,
first: arg.pagination?.first ?? 25,
},
{
endDate: arg.filter?.endDate ? arg.filter.endDate : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class SchemaPolicyProvider {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'ORGANIZATION_SETTINGS_UPDATED',
updatedFields: JSON.stringify({
allowOverrides: allowOverrides,
Expand Down Expand Up @@ -174,7 +174,7 @@ export class SchemaPolicyProvider {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'PROJECT_SETTINGS_UPDATED',
projectId: selector.projectId,
updatedFields: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ProjectManager {
});

const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'PROJECT_CREATED',
projectId: result.ok ? result.project.id : '',
projectType: type,
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ProjectManager {
organizationId: organization,
});
const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'PROJECT_DELETED',
projectId: deletedProject.id,
projectSlug: deletedProject.slug,
Expand Down Expand Up @@ -241,7 +241,7 @@ export class ProjectManager {
},
});
const currentUser = await this.session.getViewer();
this.auditLog.record({
await this.auditLog.record({
eventType: 'PROJECT_SETTINGS_UPDATED',
projectId: result.project.id,
updatedFields: JSON.stringify({
Expand Down
Loading

0 comments on commit 4a52852

Please sign in to comment.