feat: Add seed people and companies data for demo environment (#2207) (#2307)

* feat: seed companies and people data

* init DataSeedDemoWorkspaceCommand to handle:
- seedCoreSchema()
- seedMetadataSchema()

* feature: Seed workspace with demo data

- delete workspace
- initDemo() with prefillWorkspaceWithDemoObjects()

* added companies-demo.ts with data
* added people-demo.ts with data

* added workspaceId to seedFeatureFlags()

* delete previous CoreSchema before seedCoreSchema

* added workspaceMemberPrefillData

* getDemoWorkspaces() to get DEMO_WORKSPACES from config

* defined DemoSeedUserIds

- created core/demo/ to keep modified seedCoreSchema() there
- DemoSeedUserIds with new set of users and Ids

* generateOpportunities() to seed demo opportunities (limit = 50)

* Code review and fixes

* Fix

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Ruslan
2023-12-03 00:37:45 +07:00
committed by GitHub
parent 31f29582d0
commit fd9467c54d
35 changed files with 5190 additions and 38 deletions

View File

@ -0,0 +1,12 @@
import { Transform } from 'class-transformer';
export const CastToStringArray = () =>
Transform(({ value }: { value: string }) => toStringArray(value));
const toStringArray = (value: any) => {
if (typeof value === 'string') {
return value.split(',').map((item) => item.trim());
}
return undefined;
};

View File

@ -173,4 +173,8 @@ export class EnvironmentService {
getSentryDSN(): string | undefined {
return this.configService.get<string>('SENTRY_DSN');
}
getDemoWorkspaceIds(): string[] {
return this.configService.get<string[]>('DEMO_WORKSPACE_IDS') ?? [];
}
}

View File

@ -13,6 +13,7 @@ import {
} from 'class-validator';
import { assert } from 'src/utils/assert';
import { CastToStringArray } from 'src/integrations/environment/decorators/cast-to-string-array.decorator';
import { IsDuration } from './decorators/is-duration.decorator';
import { StorageType } from './interfaces/storage.interface';
@ -145,6 +146,10 @@ export class EnvironmentVariables {
@IsOptional()
LOG_LEVELS?: LogLevel[];
@CastToStringArray()
@IsOptional()
DEMO_WORKSPACE_IDS?: string[];
@ValidateIf((env) => env.LOGGER_DRIVER === LoggerDriver.Sentry)
@IsString()
SENTRY_DSN?: string;