Skip to content

Commit

Permalink
some and some
Browse files Browse the repository at this point in the history
  • Loading branch information
TuvalSimha committed Oct 19, 2024
1 parent 8cffdcb commit 51f5a77
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type AuditLogMapper = AuditLogModel;
export type SchemaPolicySettingsUpdatedAuditLogMapper = AuditLogModel;
export type SchemaCheckedAuditLogMapper = AuditLogModel;
export type SchemaPublishAuditLogMapper = AuditLogModel;
export type SchemaDeletedAuditLogMapper = AuditLogModel;
export type ServiceDeletedAuditLogMapper = AuditLogModel;
// Organization
export type OrganizationSettingsUpdatedAuditLogMapper = AuditLogModel;
export type OrganizationTransferredAuditLogMapper = AuditLogModel;
Expand Down Expand Up @@ -46,3 +46,7 @@ export type TargetDeletedAuditLogMapper = AuditLogModel;
export type SubscriptionCreatedAuditLogMapper = AuditLogModel;
export type SubscriptionUpdatedAuditLogMapper = AuditLogModel;
export type SubscriptionCanceledAuditLogMapper = AuditLogModel;
// App Deployment
export type AppDeploymentCreatedAuditLogMapper = AuditLogModel;
export type AppDeploymentUpdatedAuditLogMapper = AuditLogModel;
export type AppDeploymentPublishedAuditLogMapper = AuditLogModel;
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export const typeDefs = gql`
updatedFields: JSON!
}
type appDeploymentPublishedAuditLog implements AuditLog {
type AppDeploymentPublishedAuditLog implements AuditLog {
id: ID!
eventTime: DateTime!
record: AuditLogIdRecord!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ const appDeploymentPublishedAuditLogSchema = z.object({
deploymentVersion: z.string(),
});

const serviceDeletedAuditLogSchema = z.object({
serviceName: z.string(),
targetId: z.string(),
projectId: z.string(),
});

export const auditLogSchema = z.discriminatedUnion('eventType', [
z.object({
eventType: z.literal('USER_INVITED'),
Expand Down Expand Up @@ -288,6 +294,10 @@ export const auditLogSchema = z.discriminatedUnion('eventType', [
eventType: z.literal('SCHEMA_DELETED'),
schemaDeletedAuditLogSchema,
}),
z.object({
eventType: z.literal('SERVICE_DELETED'),
serviceDeletedAuditLogSchema,
}),
z.object({
eventType: z.literal('ROLE_CREATED'),
roleCreatedAuditLogSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { resolveRecordAuditLog } from '../helpers';
import type { AppDeploymentCreatedAuditLogResolvers } from './../../../__generated__/types.next';

/*
* Note: This object type is generated because "AppDeploymentCreatedAuditLogMapper" is declared. This is to ensure runtime safety.
*
* When a mapper is used, it is possible to hit runtime errors in some scenarios:
* - given a field name, the schema type's field type does not match mapper's field type
* - or a schema type's field does not exist in the mapper's fields
*
* If you want to skip this file generation, remove the mapper or update the pattern in the `resolverGeneration.object` config.
*/
export const AppDeploymentCreatedAuditLog: AppDeploymentCreatedAuditLogResolvers = {
__isTypeOf: e => e.event_action === 'APP_DEPLOYMENT_CREATED',
eventTime: e => new Date(e.event_time).toISOString(),
deploymentId: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentId,
deploymentName: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentName,
deploymentVersion: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentVersion,
record: (e, _, { injector }) => resolveRecordAuditLog(e, injector),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { resolveRecordAuditLog } from '../helpers';
import type { AppDeploymentPublishedAuditLogResolvers } from './../../../__generated__/types.next';

/*
* Note: This object type is generated because "AppDeploymentPublishedAuditLogMapper" is declared. This is to ensure runtime safety.
*
* When a mapper is used, it is possible to hit runtime errors in some scenarios:
* - given a field name, the schema type's field type does not match mapper's field type
* - or a schema type's field does not exist in the mapper's fields
*
* If you want to skip this file generation, remove the mapper or update the pattern in the `resolverGeneration.object` config.
*/
export const AppDeploymentPublishedAuditLog: AppDeploymentPublishedAuditLogResolvers = {
__isTypeOf: e => e.event_action === 'APP_DEPLOYMENT_PUBLISHED',
eventTime: e => new Date(e.event_time).toISOString(),
deploymentId: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentId,
deploymentVersion: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentVersion,
record: (e, _, { injector }) => resolveRecordAuditLog(e, injector),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { resolveRecordAuditLog } from '../helpers';
import type { AppDeploymentUpdatedAuditLogResolvers } from './../../../__generated__/types.next';

/*
* Note: This object type is generated because "AppDeploymentUpdatedAuditLogMapper" is declared. This is to ensure runtime safety.
*
* When a mapper is used, it is possible to hit runtime errors in some scenarios:
* - given a field name, the schema type's field type does not match mapper's field type
* - or a schema type's field does not exist in the mapper's fields
*
* If you want to skip this file generation, remove the mapper or update the pattern in the `resolverGeneration.object` config.
*/
export const AppDeploymentUpdatedAuditLog: AppDeploymentUpdatedAuditLogResolvers = {
__isTypeOf: e => e.event_action === 'APP_DEPLOYMENT_UPDATED',
eventTime: e => new Date(e.event_time).toISOString(),
deploymentId: e => e.metadata.appDeploymentCreatedAuditLogSchema.deploymentId,
updatedFields: e => e.metadata.appDeploymentUpdatedAuditLogSchema.updatedFields,
record: (e, _, { injector }) => resolveRecordAuditLog(e, injector),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { resolveRecordAuditLog } from '../helpers';
import type { ServiceDeletedAuditLogResolvers } from './../../../__generated__/types.next';

/*
* Note: This object type is generated because "ServiceDeletedAuditLogMapper" is declared. This is to ensure runtime safety.
*
* When a mapper is used, it is possible to hit runtime errors in some scenarios:
* - given a field name, the schema type's field type does not match mapper's field type
* - or a schema type's field does not exist in the mapper's fields
*
* If you want to skip this file generation, remove the mapper or update the pattern in the `resolverGeneration.object` config.
*/
export const ServiceDeletedAuditLog: ServiceDeletedAuditLogResolvers = {
__isTypeOf: e => e.event_action === 'SERVICE_DELETED',
eventTime: e => new Date(e.event_time).toISOString(),
projectId: e => e.metadata.serviceDeletedAuditLogSchema.projectId,
serviceName: e => e.metadata.serviceDeletedAuditLogSchema.serviceName,
targetId: e => e.metadata.serviceDeletedAuditLogSchema.targetId,
record: (e, _, { injector }) => resolveRecordAuditLog(e, injector),
};

0 comments on commit 51f5a77

Please sign in to comment.