AI SDK v5 migration (#14549)
Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { Test, type TestingModule } from '@nestjs/testing';
|
||||
import { AuditContextMock } from 'test/utils/audit-context.mock';
|
||||
|
||||
import { ClickHouseService } from 'src/database/clickHouse/clickHouse.service';
|
||||
import { OBJECT_RECORD_CREATED_EVENT } from 'src/engine/core-modules/audit/utils/events/object-event/object-record-created';
|
||||
import { CUSTOM_DOMAIN_ACTIVATED_EVENT } from 'src/engine/core-modules/audit/utils/events/workspace-event/custom-domain/custom-domain-activated';
|
||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
@@ -135,7 +136,7 @@ describe('AuditService', () => {
|
||||
const context = service.createContext(mockUserIdAndWorkspaceId);
|
||||
|
||||
const result = await context.createObjectEvent(
|
||||
CUSTOM_DOMAIN_ACTIVATED_EVENT,
|
||||
OBJECT_RECORD_CREATED_EVENT,
|
||||
{
|
||||
recordId: 'test-record-id',
|
||||
objectMetadataId: 'test-object-metadata-id',
|
||||
|
||||
+6
-8
@@ -1,10 +1,8 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const baseEventSchema = z
|
||||
.object({
|
||||
timestamp: z.string(),
|
||||
userId: z.string().nullish(),
|
||||
workspaceId: z.string().nullish(),
|
||||
version: z.string(),
|
||||
})
|
||||
.strict();
|
||||
export const baseEventSchema = z.strictObject({
|
||||
timestamp: z.string(),
|
||||
userId: z.string().nullish(),
|
||||
workspaceId: z.string().nullish(),
|
||||
version: z.string(),
|
||||
});
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
export const OBJECT_RECORD_CREATED_EVENT = 'Object Record Created' as const;
|
||||
export const objectRecordCreatedSchema = z.object({
|
||||
event: z.literal(OBJECT_RECORD_CREATED_EVENT),
|
||||
properties: z.object({}).passthrough(),
|
||||
properties: z.looseObject({}),
|
||||
});
|
||||
|
||||
export type ObjectRecordCreatedTrackEvent = z.infer<
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
export const OBJECT_RECORD_DELETED_EVENT = 'Object Record Deleted' as const;
|
||||
export const objectRecordDeletedSchema = z.object({
|
||||
event: z.literal(OBJECT_RECORD_DELETED_EVENT),
|
||||
properties: z.object({}).passthrough(),
|
||||
properties: z.looseObject({}),
|
||||
});
|
||||
|
||||
export type ObjectRecordDeletedTrackEvent = z.infer<
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
export const OBJECT_RECORD_UPDATED_EVENT = 'Object Record Updated' as const;
|
||||
export const objectRecordUpdatedSchema = z.object({
|
||||
event: z.literal(OBJECT_RECORD_UPDATED_EVENT),
|
||||
properties: z.object({}).passthrough(),
|
||||
properties: z.looseObject({}),
|
||||
});
|
||||
|
||||
export type ObjectRecordUpdatedTrackEvent = z.infer<
|
||||
|
||||
+4
-6
@@ -3,12 +3,10 @@ import { z } from 'zod';
|
||||
import { registerEvent } from 'src/engine/core-modules/audit/utils/events/workspace-event/track';
|
||||
|
||||
export const CUSTOM_DOMAIN_ACTIVATED_EVENT = 'Custom Domain Activated' as const;
|
||||
export const customDomainActivatedSchema = z
|
||||
.object({
|
||||
event: z.literal(CUSTOM_DOMAIN_ACTIVATED_EVENT),
|
||||
properties: z.object({}).strict(),
|
||||
})
|
||||
.strict();
|
||||
export const customDomainActivatedSchema = z.strictObject({
|
||||
event: z.literal(CUSTOM_DOMAIN_ACTIVATED_EVENT),
|
||||
properties: z.strictObject({}),
|
||||
});
|
||||
|
||||
export type CustomDomainActivatedTrackEvent = z.infer<
|
||||
typeof customDomainActivatedSchema
|
||||
|
||||
+4
-6
@@ -4,12 +4,10 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
|
||||
export const CUSTOM_DOMAIN_DEACTIVATED_EVENT =
|
||||
'Custom Domain Deactivated' as const;
|
||||
export const customDomainDeactivatedSchema = z
|
||||
.object({
|
||||
event: z.literal(CUSTOM_DOMAIN_DEACTIVATED_EVENT),
|
||||
properties: z.object({}).strict(),
|
||||
})
|
||||
.strict();
|
||||
export const customDomainDeactivatedSchema = z.strictObject({
|
||||
event: z.literal(CUSTOM_DOMAIN_DEACTIVATED_EVENT),
|
||||
properties: z.strictObject({}),
|
||||
});
|
||||
|
||||
export type CustomDomainDeactivatedTrackEvent = z.infer<
|
||||
typeof customDomainDeactivatedSchema
|
||||
|
||||
+9
-13
@@ -3,19 +3,15 @@ import { z } from 'zod';
|
||||
import { registerEvent } from 'src/engine/core-modules/audit/utils/events/workspace-event/track';
|
||||
|
||||
export const MONITORING_EVENT = 'Monitoring' as const;
|
||||
export const monitoringSchema = z
|
||||
.object({
|
||||
event: z.literal(MONITORING_EVENT),
|
||||
properties: z
|
||||
.object({
|
||||
eventName: z.string(),
|
||||
connectedAccountId: z.string().optional(),
|
||||
messageChannelId: z.string().optional(),
|
||||
message: z.string().optional(),
|
||||
})
|
||||
.strict(),
|
||||
})
|
||||
.strict();
|
||||
export const monitoringSchema = z.strictObject({
|
||||
event: z.literal(MONITORING_EVENT),
|
||||
properties: z.strictObject({
|
||||
eventName: z.string(),
|
||||
connectedAccountId: z.string().optional(),
|
||||
messageChannelId: z.string().optional(),
|
||||
message: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type MonitoringTrackEvent = z.infer<typeof monitoringSchema>;
|
||||
|
||||
|
||||
+10
-14
@@ -4,20 +4,16 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
|
||||
export const SERVERLESS_FUNCTION_EXECUTED_EVENT =
|
||||
'Serverless Function Executed' as const;
|
||||
export const serverlessFunctionExecutedSchema = z
|
||||
.object({
|
||||
event: z.literal(SERVERLESS_FUNCTION_EXECUTED_EVENT),
|
||||
properties: z
|
||||
.object({
|
||||
duration: z.number(),
|
||||
status: z.enum(['IDLE', 'SUCCESS', 'ERROR']),
|
||||
errorType: z.string().optional(),
|
||||
functionId: z.string(),
|
||||
functionName: z.string(),
|
||||
})
|
||||
.strict(),
|
||||
})
|
||||
.strict();
|
||||
export const serverlessFunctionExecutedSchema = z.strictObject({
|
||||
event: z.literal(SERVERLESS_FUNCTION_EXECUTED_EVENT),
|
||||
properties: z.strictObject({
|
||||
duration: z.number(),
|
||||
status: z.enum(['IDLE', 'SUCCESS', 'ERROR']),
|
||||
errorType: z.string().optional(),
|
||||
functionId: z.string(),
|
||||
functionName: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type ServerlessFunctionExecutedTrackEvent = z.infer<
|
||||
typeof serverlessFunctionExecutedSchema
|
||||
|
||||
+4
-6
@@ -3,12 +3,10 @@ import { z } from 'zod';
|
||||
import { registerEvent } from 'src/engine/core-modules/audit/utils/events/workspace-event/track';
|
||||
|
||||
export const USER_SIGNUP_EVENT = 'User Signup' as const;
|
||||
export const userSignupSchema = z
|
||||
.object({
|
||||
event: z.literal(USER_SIGNUP_EVENT),
|
||||
properties: z.object({}).strict(),
|
||||
})
|
||||
.strict();
|
||||
export const userSignupSchema = z.strictObject({
|
||||
event: z.literal(USER_SIGNUP_EVENT),
|
||||
properties: z.strictObject({}),
|
||||
});
|
||||
|
||||
export type UserSignupTrackEvent = z.infer<typeof userSignupSchema>;
|
||||
|
||||
|
||||
+10
-14
@@ -3,20 +3,16 @@ import { z } from 'zod';
|
||||
import { registerEvent } from 'src/engine/core-modules/audit/utils/events/workspace-event/track';
|
||||
|
||||
export const WEBHOOK_RESPONSE_EVENT = 'Webhook Response' as const;
|
||||
export const webhookResponseSchema = z
|
||||
.object({
|
||||
event: z.literal(WEBHOOK_RESPONSE_EVENT),
|
||||
properties: z
|
||||
.object({
|
||||
status: z.number().optional(),
|
||||
success: z.boolean(),
|
||||
url: z.string(),
|
||||
webhookId: z.string(),
|
||||
eventName: z.string(),
|
||||
})
|
||||
.strict(),
|
||||
})
|
||||
.strict();
|
||||
export const webhookResponseSchema = z.strictObject({
|
||||
event: z.literal(WEBHOOK_RESPONSE_EVENT),
|
||||
properties: z.strictObject({
|
||||
status: z.number().optional(),
|
||||
success: z.boolean(),
|
||||
url: z.string(),
|
||||
webhookId: z.string(),
|
||||
eventName: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type WebhookResponseTrackEvent = z.infer<typeof webhookResponseSchema>;
|
||||
|
||||
|
||||
+6
-8
@@ -4,14 +4,12 @@ import { registerEvent } from 'src/engine/core-modules/audit/utils/events/worksp
|
||||
|
||||
export const WORKSPACE_ENTITY_CREATED_EVENT =
|
||||
'Workspace Entity Created' as const;
|
||||
export const workspaceEntityCreatedSchema = z
|
||||
.object({
|
||||
event: z.literal(WORKSPACE_ENTITY_CREATED_EVENT),
|
||||
properties: z.object({
|
||||
name: z.string(),
|
||||
}),
|
||||
})
|
||||
.strict();
|
||||
export const workspaceEntityCreatedSchema = z.strictObject({
|
||||
event: z.literal(WORKSPACE_ENTITY_CREATED_EVENT),
|
||||
properties: z.strictObject({
|
||||
name: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type WorkspaceEntityCreatedTrackEvent = z.infer<
|
||||
typeof workspaceEntityCreatedSchema
|
||||
|
||||
Reference in New Issue
Block a user