Skip to content

Commit

Permalink
fix: sync multiple issues
Browse files Browse the repository at this point in the history
  • Loading branch information
magrinj committed May 13, 2024
1 parent 55e4769 commit 9db2e03
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 120 deletions.
16 changes: 7 additions & 9 deletions packages/twenty-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import { ConfigModule } from '@nestjs/config';
import { ServeStaticModule } from '@nestjs/serve-static';
import { GraphQLModule } from '@nestjs/graphql';
import { DevtoolsModule } from '@nestjs/devtools-integration';

import { existsSync } from 'fs';
import { join } from 'path';
Expand All @@ -20,7 +19,6 @@ import { CoreGraphQLApiModule } from 'src/engine/api/graphql/core-graphql-api.mo
import { MetadataGraphQLApiModule } from 'src/engine/api/graphql/metadata-graphql-api.module';
import { GraphQLConfigModule } from 'src/engine/api/graphql/graphql-config/graphql-config.module';
import { GraphQLConfigService } from 'src/engine/api/graphql/graphql-config/graphql-config.service';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module';
import { GraphQLHydrateRequestFromTokenMiddleware } from 'src/engine/middlewares/graphql-hydrate-request-from-token.middleware';

Expand All @@ -30,13 +28,13 @@ import { IntegrationsModule } from './engine/integrations/integrations.module';
@Module({
imports: [
// Nest.js devtools, use devtools.nestjs.com to debug
DevtoolsModule.registerAsync({
useFactory: (environmentService: EnvironmentService) => ({
http: environmentService.get('DEBUG_MODE'),
port: environmentService.get('DEBUG_PORT'),
}),
inject: [EnvironmentService],
}),
// DevtoolsModule.registerAsync({
// useFactory: (environmentService: EnvironmentService) => ({
// http: environmentService.get('DEBUG_MODE'),
// port: environmentService.get('DEBUG_PORT'),
// }),
// inject: [EnvironmentService],
// }),
ConfigModule.forRoot({
isGlobal: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ export function WorkspaceDynamicRelation<TClass extends object>(
args: WorkspaceBaseDynamicRelationOptions<TClass>,
): PropertyDecorator {
return (target, propertyKey) => {
const isSystem = TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
target,
propertyKey.toString(),
);
const isSystem =
TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
target,
propertyKey.toString(),
) ?? false;
const gate = TypedReflect.getMetadata(
'workspace:gate-metadata-args',
target,
Expand All @@ -39,8 +40,9 @@ export function WorkspaceDynamicRelation<TClass extends object>(
inverseSideTarget: args.inverseSideTarget,
inverseSideFieldKey: args.inverseSideFieldKey as string | undefined,
onDelete: args.onDelete,
isSystem: isSystem,
isSystem,
isNullable: true,
isPrimary: false,
gate,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ export interface WorkspaceFieldOptions<
description?: string | ((objectMetadata: ObjectMetadataEntity) => string);
icon?: string;
defaultValue?: FieldMetadataDefaultValue<T>;
joinColumn?: string;
options?: FieldMetadataOptions<T>;
}

export function WorkspaceField<T extends FieldMetadataType>(
options: WorkspaceFieldOptions<T>,
): PropertyDecorator {
return (object, propertyKey) => {
const isPrimary = TypedReflect.getMetadata(
'workspace:is-primary-field-metadata-args',
object,
propertyKey.toString(),
);
const isNullable = TypedReflect.getMetadata(
'workspace:is-nullable-metadata-args',
object,
propertyKey.toString(),
);
const isSystem = TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
object,
propertyKey.toString(),
);
const isPrimary =
TypedReflect.getMetadata(
'workspace:is-primary-field-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const isNullable =
TypedReflect.getMetadata(
'workspace:is-nullable-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const isSystem =
TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const gate = TypedReflect.getMetadata(
'workspace:gate-metadata-args',
object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ export function WorkspaceEntity(
'workspace:is-audit-logged-metadata-args',
target,
) ?? true;
const isSystem = TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
target,
);
const isSystem =
TypedReflect.getMetadata('workspace:is-system-metadata-args', target) ??
false;
const gate = TypedReflect.getMetadata(
'workspace:gate-metadata-args',
target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,24 @@ export function WorkspaceRelation<TClass extends object>(
| WorkspaceOtherRelationOptions<TClass>,
): PropertyDecorator {
return (object, propertyKey) => {
const isPrimary = TypedReflect.getMetadata(
'workspace:is-primary-field-metadata-args',
object,
propertyKey.toString(),
);
const isNullable = TypedReflect.getMetadata(
'workspace:is-nullable-metadata-args',
object,
propertyKey.toString(),
);
const isSystem = TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
object,
propertyKey.toString(),
);
const isPrimary =
TypedReflect.getMetadata(
'workspace:is-primary-field-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const isNullable =
TypedReflect.getMetadata(
'workspace:is-nullable-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const isSystem =
TypedReflect.getMetadata(
'workspace:is-system-metadata-args',
object,
propertyKey.toString(),
) ?? false;
const gate = TypedReflect.getMetadata(
'workspace:gate-metadata-args',
object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface WorkspaceDynamicRelationMetadataArgs {
* Class to which relation is applied.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly target: Function | string;
readonly target: Function;

/**
* Factory function
Expand Down Expand Up @@ -77,17 +77,17 @@ export interface WorkspaceDynamicRelationMetadataArgs {
/**
* Is primary field.
*/
readonly isPrimary?: boolean;
readonly isPrimary: boolean;

/**
* Is system field.
*/
readonly isSystem?: boolean;
readonly isSystem: boolean;

/**
* Is nullable field.
*/
readonly isNullable?: boolean;
readonly isNullable: boolean;

/**
* Field gate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface WorkspaceEntityMetadataArgs {
* String target is a table defined in a json schema.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly target: Function | string;
readonly target: Function;

/**
* Entity name.
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface WorkspaceEntityMetadataArgs {
/**
* Is system object.
*/
readonly isSystem?: boolean;
readonly isSystem: boolean;

/**
* Entity gate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface WorkspaceExtendedEntityMetadataArgs {
* String target is a table defined in a json schema.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly target: Function | string;
readonly target: Function;

/**
* Entity gate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface WorkspaceFieldMetadataArgs {
* Class to which field is applied.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly target: Function | string;
readonly target: Function;

/**
* Field name.
Expand Down Expand Up @@ -57,17 +57,17 @@ export interface WorkspaceFieldMetadataArgs {
/**
* Is primary field.
*/
readonly isPrimary?: boolean;
readonly isPrimary: boolean;

/**
* Is system field.
*/
readonly isSystem?: boolean;
readonly isSystem: boolean;

/**
* Is nullable field.
*/
readonly isNullable?: boolean;
readonly isNullable: boolean;

/**
* Field gate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface WorkspaceRelationMetadataArgs {
* Class to which relation is applied.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
readonly target: Function | string;
readonly target: Function;

/**
* Relation name.
Expand Down Expand Up @@ -70,17 +70,17 @@ export interface WorkspaceRelationMetadataArgs {
/**
* Is primary field.
*/
readonly isPrimary?: boolean;
readonly isPrimary: boolean;

/**
* Is system field.
*/
readonly isSystem?: boolean;
readonly isSystem: boolean;

/**
* Is nullable field.
*/
readonly isNullable?: boolean;
readonly isNullable: boolean;

/**
* Field gate.
Expand Down

0 comments on commit 9db2e03

Please sign in to comment.