-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen setup fix some some some some more ? ?? SOME? ?? ? fix some? SOME ??? more some some test fix some code review! ? fix some clean! fix codegen path ??? ? ?? ? ? added scope ti auditlogmanager scheme publish & check & delete members role CLEAN MORE target project prettier fix resolver schema published lint fix code review! ? ? prettier migration fix! clean fix filters
- Loading branch information
1 parent
498f621
commit dab6855
Showing
45 changed files
with
2,052 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/migrations/src/clickhouse-actions/011-audit-logs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Action } from '../clickhouse'; | ||
|
||
export const action: Action = async exec => { | ||
await exec(` | ||
CREATE TABLE IF NOT EXISTS "audit_log" | ||
( | ||
"id" UUID DEFAULT generateUUIDv4() CODEC(ZSTD(1)), | ||
"event_time" DateTime CODEC(ZSTD(1)), | ||
"user_id" String CODEC(ZSTD(1)), | ||
"user_email" String CODEC(ZSTD(1)), | ||
"organization_id" String CODEC(ZSTD(1)), | ||
"event_action" String CODEC(ZSTD(1)), | ||
"metadata" String CODEC(ZSTD(1)) | ||
) | ||
ENGINE = ReplacingMergeTree | ||
ORDER BY ("event_time", "user_id") | ||
TTL event_time + INTERVAL 1 YEAR | ||
SETTINGS index_granularity = 8192 | ||
`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createModule } from 'graphql-modules'; | ||
import { ClickHouse } from '../operations/providers/clickhouse-client'; | ||
import { AuditLogManager } from './providers/audit-logs-manager'; | ||
import { resolvers } from './resolvers.generated'; | ||
import { typeDefs } from './module.graphql'; | ||
|
||
export const auditLogsModule = createModule({ | ||
id: 'audit-logs', | ||
dirname: __dirname, | ||
typeDefs, | ||
resolvers, | ||
providers: [AuditLogManager, ClickHouse], | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/services/api/src/modules/audit-logs/module.graphql.mappers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { AuditLogModel } from './providers/audit-logs-manager'; | ||
|
||
export type AuditLogMapper = AuditLogModel; |
238 changes: 238 additions & 0 deletions
238
packages/services/api/src/modules/audit-logs/module.graphql.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
import { gql } from 'graphql-modules'; | ||
|
||
export const typeDefs = gql` | ||
scalar DateTime | ||
scalar Date | ||
interface AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
} | ||
type AuditLogUserRecord { | ||
userId: ID! | ||
userEmail: String! | ||
user: User # this one is nullable because it can be deleted! | ||
} | ||
type AuditLogConnection { | ||
nodes: [AuditLog]! | ||
total: Int! | ||
} | ||
type AuditLogFileExport { | ||
id: ID! | ||
url: String! | ||
validUntil: DateTime! | ||
createdAt: DateTime! | ||
} | ||
type ExportResultEdge { | ||
node: AuditLogFileExport! | ||
cursor: String! | ||
} | ||
type ExportResultConnection { | ||
edges: [ExportResultEdge!]! | ||
pageInfo: PageInfo! | ||
} | ||
input AuditLogFilter { | ||
date: Date | ||
userId: String | ||
organizationId: String | ||
eventType: String | ||
} | ||
extend type Query { | ||
auditLogs(filter: AuditLogFilter, limit: Int, offset: Int): AuditLogConnection! | ||
auditLogExports(limit: Int, offset: Int, filter: AuditLogFilter): ExportResultConnection! | ||
} | ||
extend type Mutation { | ||
exportAuditLogsToFile(filter: AuditLogFilter!): AuditLogFileExport! | ||
} | ||
type ModifyAuditLogError implements Error { | ||
message: String! | ||
} | ||
type UserInvitedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
inviteeId: String! | ||
inviteeEmail: String! | ||
} | ||
type UserJoinedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
inviteeId: String! | ||
inviteeEmail: String! | ||
} | ||
type UserRemovedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
removedUserId: String! | ||
removedUserEmail: String! | ||
} | ||
type OrganizationSettingsUpdatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
updatedFields: JSON! | ||
} | ||
type OrganizationTransferredAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
newOwnerId: String! | ||
newOwnerEmail: String! | ||
} | ||
type ProjectCreatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
projectName: String! | ||
} | ||
type ProjectSettingsUpdatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
updatedFields: JSON! | ||
} | ||
type ProjectDeletedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
projectName: String! | ||
} | ||
type TargetCreatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
targetName: String! | ||
} | ||
type TargetSettingsUpdatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
updatedFields: JSON! | ||
} | ||
type TargetDeletedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
targetName: String! | ||
} | ||
type SchemaPolicySettingsUpdatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
updatedFields: JSON! | ||
} | ||
type SchemaCheckedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
schemaSdl: String! | ||
} | ||
type SchemaPublishAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
schemaName: String! | ||
} | ||
type SchemaDeletedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
projectId: String! | ||
targetId: String! | ||
schemaName: String! | ||
} | ||
type RoleCreatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
roleId: String! | ||
roleName: String! | ||
} | ||
type RoleAssignedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
roleId: String! | ||
roleName: String! | ||
userIdAssigned: String! | ||
userEmailAssigned: String! | ||
} | ||
type RoleDeletedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
roleId: String! | ||
roleName: String! | ||
} | ||
type RoleUpdatedAuditLog implements AuditLog { | ||
id: ID! | ||
eventTime: DateTime! | ||
user: AuditLogUserRecord! | ||
organizationId: String! | ||
roleId: String! | ||
roleName: String! | ||
updatedFields: JSON! | ||
} | ||
`; |
Oops, something went wrong.