Phone country code unique (#9035)

fix #8775
This commit is contained in:
Guillim
2024-12-19 16:42:18 +01:00
committed by GitHub
parent 3f58a41d2f
commit 360c34fd18
47 changed files with 878 additions and 132 deletions

View File

@ -1,5 +1,3 @@
import { Logger } from '@nestjs/common';
import chalk from 'chalk';
import { Option } from 'nest-commander';
import { Repository } from 'typeorm';
@ -20,11 +18,8 @@ export type ActiveWorkspacesCommandOptions = BaseCommandOptions & {
export abstract class ActiveWorkspacesCommandRunner extends BaseCommandRunner {
private workspaceIds: string[] = [];
protected readonly logger: Logger;
constructor(protected readonly workspaceRepository: Repository<Workspace>) {
super();
this.logger = new Logger(this.constructor.name);
}
@Option({

View File

@ -3,6 +3,7 @@ import { Logger } from '@nestjs/common';
import chalk from 'chalk';
import { CommandRunner, Option } from 'nest-commander';
import { CommandLogger } from './logger';
export type BaseCommandOptions = {
workspaceId?: string;
dryRun?: boolean;
@ -10,11 +11,13 @@ export type BaseCommandOptions = {
};
export abstract class BaseCommandRunner extends CommandRunner {
protected readonly logger: Logger;
protected logger: CommandLogger | Logger;
constructor() {
super();
this.logger = new Logger(this.constructor.name);
this.logger = new CommandLogger({
verbose: false,
constructorName: this.constructor.name,
});
}
@Option({
@ -27,10 +30,11 @@ export abstract class BaseCommandRunner extends CommandRunner {
}
@Option({
flags: '--verbose',
flags: '-v, --verbose',
description: 'Verbose output',
required: false,
})
parseVerbose() {
parseVerbose(): boolean {
return true;
}
@ -38,6 +42,13 @@ export abstract class BaseCommandRunner extends CommandRunner {
passedParams: string[],
options: BaseCommandOptions,
): Promise<void> {
if (options.verbose) {
this.logger = new CommandLogger({
verbose: true,
constructorName: this.constructor.name,
});
}
try {
await this.executeBaseCommand(passedParams, options);
} catch (error) {

View File

@ -52,8 +52,8 @@ import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/worksp
UpgradeTo0_32CommandModule,
UpgradeTo0_33CommandModule,
UpgradeTo0_34CommandModule,
FeatureFlagModule,
UpgradeTo0_40CommandModule,
FeatureFlagModule,
],
providers: [
DataSeedWorkspaceCommand,

View File

@ -0,0 +1,46 @@
import { Logger } from '@nestjs/common';
interface CommandLoggerOptions {
verbose?: boolean;
constructorName: string;
}
export class CommandLogger {
private logger: Logger;
private verbose: boolean;
constructor(options: CommandLoggerOptions) {
this.logger = new Logger(options.constructorName);
this.verbose = options.verbose ?? true;
}
log(message: string, context?: string) {
if (this.verbose) {
this.logger.log(message, context);
}
}
error(message: string, stack?: string, context?: string) {
if (this.verbose) {
this.logger.error(message, stack, context);
}
}
warn(message: string, context?: string) {
if (this.verbose) {
this.logger.warn(message, context);
}
}
debug(message: string, context?: string) {
if (this.verbose) {
this.logger.debug(message, context);
}
}
verboseLog(message: string, context?: string) {
if (this.verbose) {
this.logger.verbose(message, context);
}
}
}

View File

@ -0,0 +1,144 @@
import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk';
import { Command } from 'nest-commander';
import { Repository } from 'typeorm';
import { v4 } from 'uuid';
import {
ActiveWorkspacesCommandOptions,
ActiveWorkspacesCommandRunner,
} from 'src/database/commands/active-workspaces.command';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import {
FieldMetadataEntity,
FieldMetadataType,
} from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service';
import { generateMigrationName } from 'src/engine/metadata-modules/workspace-migration/utils/generate-migration-name.util';
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
WorkspaceMigrationTableActionType,
} from 'src/engine/metadata-modules/workspace-migration/workspace-migration.entity';
import { WorkspaceMigrationFactory } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.factory';
import { WorkspaceMigrationService } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.service';
import { computeObjectTargetTable } from 'src/engine/utils/compute-object-target-table.util';
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service';
import { isDefined } from 'src/utils/is-defined';
@Command({
name: 'upgrade-0.40:phone-calling-code-create-column',
description: 'Create the callingCode column',
})
export class PhoneCallingCodeCreateColumnCommand extends ActiveWorkspacesCommandRunner {
constructor(
@InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>,
@InjectRepository(FieldMetadataEntity, 'metadata')
private readonly fieldMetadataRepository: Repository<FieldMetadataEntity>,
@InjectRepository(ObjectMetadataEntity, 'metadata')
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
private readonly workspaceMigrationService: WorkspaceMigrationService,
private readonly workspaceMigrationFactory: WorkspaceMigrationFactory,
private readonly workspaceMigrationRunnerService: WorkspaceMigrationRunnerService,
private readonly workspaceMetadataVersionService: WorkspaceMetadataVersionService,
) {
super(workspaceRepository);
}
async executeActiveWorkspacesCommand(
_passedParam: string[],
options: ActiveWorkspacesCommandOptions,
workspaceIds: string[],
): Promise<void> {
this.logger.log(
'Running command to add calling code and change country code with default one',
);
this.logger.log(`Part 1 - Workspace`);
let workspaceIterator = 1;
for (const workspaceId of workspaceIds) {
this.logger.log(
`Running command for workspace ${workspaceId} ${workspaceIterator}/${workspaceIds.length}`,
);
this.logger.log(
`P1 Step 1 - let's find all the fieldsMetadata that have the PHONES type, and extract the objectMetadataId`,
);
try {
const phonesFieldMetadata = await this.fieldMetadataRepository.find({
where: {
workspaceId,
type: FieldMetadataType.PHONES,
},
relations: ['object'],
});
for (const phoneFieldMetadata of phonesFieldMetadata) {
if (
isDefined(phoneFieldMetadata?.name && phoneFieldMetadata.object)
) {
this.logger.log(
`P1 Step 1 - Let's find the "nameSingular" of this objectMetadata: ${phoneFieldMetadata.object.nameSingular || 'not found'}`,
);
if (!phoneFieldMetadata.object?.nameSingular) continue;
this.logger.log(
`P1 Step 1 - Create migration for field ${phoneFieldMetadata.name}`,
);
if (options.dryRun === true) {
continue;
}
await this.workspaceMigrationService.createCustomMigration(
generateMigrationName(
`create-${phoneFieldMetadata.object.nameSingular}PrimaryPhoneCallingCode-for-field-${phoneFieldMetadata.name}`,
),
workspaceId,
[
{
name: computeObjectTargetTable(phoneFieldMetadata.object),
action: WorkspaceMigrationTableActionType.ALTER,
columns: this.workspaceMigrationFactory.createColumnActions(
WorkspaceMigrationColumnActionType.CREATE,
{
id: v4(),
type: FieldMetadataType.TEXT,
name: `${phoneFieldMetadata.name}PrimaryPhoneCallingCode`,
label: `${phoneFieldMetadata.name}PrimaryPhoneCallingCode`,
objectMetadataId: phoneFieldMetadata.object.id,
workspaceId: workspaceId,
isNullable: true,
defaultValue: "''",
} satisfies Partial<FieldMetadataEntity>,
),
} satisfies WorkspaceMigrationTableAction,
],
);
}
}
this.logger.log(
`P1 Step 1 - RUN migration to create callingCodes for ${workspaceId.slice(0, 5)}`,
);
await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
workspaceId,
);
await this.workspaceMetadataVersionService.incrementMetadataVersion(
workspaceId,
);
} catch (error) {
console.log(`Error in workspace ${workspaceId} : ${error}`);
}
workspaceIterator++;
}
this.logger.log(chalk.green(`Command completed!`));
}
}

View File

@ -0,0 +1,302 @@
import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk';
import { getCountries, getCountryCallingCode } from 'libphonenumber-js';
import { Command } from 'nest-commander';
import { Repository } from 'typeorm';
import { v4 } from 'uuid';
import {
ActiveWorkspacesCommandOptions,
ActiveWorkspacesCommandRunner,
} from 'src/database/commands/active-workspaces.command';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import {
FieldMetadataEntity,
FieldMetadataType,
} from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/workspace-metadata-version/services/workspace-metadata-version.service';
import { generateMigrationName } from 'src/engine/metadata-modules/workspace-migration/utils/generate-migration-name.util';
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
WorkspaceMigrationTableActionType,
} from 'src/engine/metadata-modules/workspace-migration/workspace-migration.entity';
import { WorkspaceMigrationFactory } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.factory';
import { WorkspaceMigrationService } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.service';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
import { computeObjectTargetTable } from 'src/engine/utils/compute-object-target-table.util';
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service';
import { isDefined } from 'src/utils/is-defined';
const callingCodeToCountryCode = (callingCode: string): string => {
if (!callingCode) {
return '';
}
let callingCodeSanitized = callingCode;
if (callingCode.startsWith('+')) {
callingCodeSanitized = callingCode.slice(1);
}
return (
getCountries().find(
(countryCode) =>
getCountryCallingCode(countryCode) === callingCodeSanitized,
) || ''
);
};
const isCallingCode = (callingCode: string): boolean => {
return callingCodeToCountryCode(callingCode) !== '';
};
@Command({
name: 'upgrade-0.40:phone-calling-code-migrate-data',
description: 'Add calling code and change country code with default one',
})
export class PhoneCallingCodeMigrateDataCommand extends ActiveWorkspacesCommandRunner {
constructor(
@InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>,
@InjectRepository(FieldMetadataEntity, 'metadata')
private readonly fieldMetadataRepository: Repository<FieldMetadataEntity>,
@InjectRepository(ObjectMetadataEntity, 'metadata')
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
private readonly workspaceMigrationService: WorkspaceMigrationService,
private readonly workspaceMigrationFactory: WorkspaceMigrationFactory,
private readonly workspaceMigrationRunnerService: WorkspaceMigrationRunnerService,
private readonly workspaceMetadataVersionService: WorkspaceMetadataVersionService,
) {
super(workspaceRepository);
}
async executeActiveWorkspacesCommand(
_passedParam: string[],
options: ActiveWorkspacesCommandOptions,
workspaceIds: string[],
): Promise<void> {
this.logger.log(
'Running command to add calling code and change country code with default one',
);
this.logger.log(`Part 1 - Workspace`);
let workspaceIterator = 1;
for (const workspaceId of workspaceIds) {
this.logger.log(
`Running command for workspace ${workspaceId} ${workspaceIterator}/${workspaceIds.length}`,
);
this.logger.log(
`P1 Step 1 - let's find all the fieldsMetadata that have the PHONES type, and extract the objectMetadataId`,
);
try {
const phonesFieldMetadata = await this.fieldMetadataRepository.find({
where: {
workspaceId,
type: FieldMetadataType.PHONES,
},
relations: ['object'],
});
for (const phoneFieldMetadata of phonesFieldMetadata) {
if (
isDefined(phoneFieldMetadata?.name) &&
isDefined(phoneFieldMetadata.object)
) {
this.logger.log(
`P1 Step 1 - Let's find the "nameSingular" of this objectMetadata: ${phoneFieldMetadata.object.nameSingular || 'not found'}`,
);
if (!phoneFieldMetadata.object?.nameSingular) continue;
this.logger.log(
`P1 Step 1 - Create migration for field ${phoneFieldMetadata.name}`,
);
if (options.dryRun === false) {
await this.workspaceMigrationService.createCustomMigration(
generateMigrationName(
`create-${phoneFieldMetadata.object.nameSingular}PrimaryPhoneCallingCode-for-field-${phoneFieldMetadata.name}`,
),
workspaceId,
[
{
name: computeObjectTargetTable(phoneFieldMetadata.object),
action: WorkspaceMigrationTableActionType.ALTER,
columns: this.workspaceMigrationFactory.createColumnActions(
WorkspaceMigrationColumnActionType.CREATE,
{
id: v4(),
type: FieldMetadataType.TEXT,
name: `${phoneFieldMetadata.name}PrimaryPhoneCallingCode`,
label: `${phoneFieldMetadata.name}PrimaryPhoneCallingCode`,
objectMetadataId: phoneFieldMetadata.object.id,
workspaceId: workspaceId,
isNullable: true,
defaultValue: "''",
},
),
} satisfies WorkspaceMigrationTableAction,
],
);
}
}
}
this.logger.log(
`P1 Step 1 - RUN migration to create callingCodes for ${workspaceId.slice(0, 5)}`,
);
await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
workspaceId,
);
await this.workspaceMetadataVersionService.incrementMetadataVersion(
workspaceId,
);
this.logger.log(
`P1 Step 2 - Migrations for callingCode must be first. Now can use twentyORMGlobalManager to update countryCode`,
);
this.logger.log(
`P1 Step 3 (same time) - update CountryCode to letters: +33 => FR || +1 => US (if mulitple, first one)`,
);
this.logger.log(
`P1 Step 4 (same time) - update all additioanl phones to add a country code following the same logic`,
);
for (const phoneFieldMetadata of phonesFieldMetadata) {
this.logger.log(`P1 Step 2 - for ${phoneFieldMetadata.name}`);
if (
isDefined(phoneFieldMetadata) &&
isDefined(phoneFieldMetadata.name)
) {
const [objectMetadata] = await this.objectMetadataRepository.find({
where: {
id: phoneFieldMetadata?.objectMetadataId,
},
});
const repository =
await this.twentyORMGlobalManager.getRepositoryForWorkspace(
workspaceId,
objectMetadata.nameSingular,
);
const records = await repository.find();
for (const record of records) {
if (
record?.[phoneFieldMetadata.name]?.primaryPhoneCountryCode &&
isCallingCode(
record[phoneFieldMetadata.name].primaryPhoneCountryCode,
)
) {
let additionalPhones = null;
if (record[phoneFieldMetadata.name].additionalPhones) {
additionalPhones = record[
phoneFieldMetadata.name
].additionalPhones.map((phone) => {
return {
...phone,
countryCode: callingCodeToCountryCode(phone.callingCode),
};
});
}
if (options.dryRun === false) {
await repository.update(record.id, {
[`${phoneFieldMetadata.name}PrimaryPhoneCallingCode`]:
record[phoneFieldMetadata.name].primaryPhoneCountryCode,
[`${phoneFieldMetadata.name}PrimaryPhoneCountryCode`]:
callingCodeToCountryCode(
record[phoneFieldMetadata.name].primaryPhoneCountryCode,
),
[`${phoneFieldMetadata.name}AdditionalPhones`]:
additionalPhones,
});
}
}
}
}
}
} catch (error) {
console.log(`Error in workspace ${workspaceId} : ${error}`);
}
workspaceIterator++;
}
this.logger.log(`
Part 2 - FieldMetadata`);
workspaceIterator = 1;
for (const workspaceId of workspaceIds) {
this.logger.log(
`Running command for workspace ${workspaceId} ${workspaceIterator}/${workspaceIds.length}`,
);
this.logger.log(
`P2 Step 1 - let's find all the fieldsMetadata that have the PHONES type, and extract the objectMetadataId`,
);
try {
const phonesFieldMetadata = await this.fieldMetadataRepository.find({
where: {
workspaceId,
type: FieldMetadataType.PHONES,
},
});
for (const phoneFieldMetadata of phonesFieldMetadata) {
if (
!isDefined(phoneFieldMetadata) ||
!isDefined(phoneFieldMetadata.defaultValue)
)
continue;
let defaultValue = phoneFieldMetadata.defaultValue;
// some cases look like it's an array. let's flatten it (not sure the case is supposed to happen but I saw it in my local db)
if (Array.isArray(defaultValue) && isDefined(defaultValue[0]))
defaultValue = phoneFieldMetadata.defaultValue[0];
if (!isDefined(defaultValue)) continue;
if (typeof defaultValue !== 'object') continue;
if (!('primaryPhoneCountryCode' in defaultValue)) continue;
if (!defaultValue.primaryPhoneCountryCode) continue;
const primaryPhoneCountryCode = defaultValue.primaryPhoneCountryCode;
const countryCode = callingCodeToCountryCode(
primaryPhoneCountryCode.replace(/["']/g, ''),
);
if (options.dryRun === false) {
await this.fieldMetadataRepository.update(phoneFieldMetadata.id, {
defaultValue: {
...defaultValue,
primaryPhoneCountryCode: countryCode
? `'${countryCode}'`
: "''",
primaryPhoneCallingCode: isCallingCode(
primaryPhoneCountryCode.replace(/["']/g, ''),
)
? primaryPhoneCountryCode
: "''",
},
});
}
}
} catch (error) {
console.log(`Error in workspace ${workspaceId} : ${error}`);
}
workspaceIterator++;
}
this.logger.log(chalk.green(`Command completed!`));
}
}

View File

@ -5,6 +5,8 @@ import { Repository } from 'typeorm';
import { ActiveWorkspacesCommandRunner } from 'src/database/commands/active-workspaces.command';
import { BaseCommandOptions } from 'src/database/commands/base.command';
import { PhoneCallingCodeCreateColumnCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-create-column.command';
import { PhoneCallingCodeMigrateDataCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-migrate-data.command';
import { RecordPositionBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-record-position-backfill.command';
import { ViewGroupNoValueBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-view-group-no-value-backfill.command';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@ -18,9 +20,11 @@ export class UpgradeTo0_40Command extends ActiveWorkspacesCommandRunner {
constructor(
@InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>,
private readonly recordPositionBackfillCommand: RecordPositionBackfillCommand,
private readonly viewGroupNoValueBackfillCommand: ViewGroupNoValueBackfillCommand,
private readonly syncWorkspaceMetadataCommand: SyncWorkspaceMetadataCommand,
private readonly phoneCallingCodeMigrateDataCommand: PhoneCallingCodeMigrateDataCommand,
private readonly phoneCallingCodeCreateColumnCommand: PhoneCallingCodeCreateColumnCommand,
private readonly recordPositionBackfillCommand: RecordPositionBackfillCommand,
) {
super(workspaceRepository);
}
@ -30,6 +34,22 @@ export class UpgradeTo0_40Command extends ActiveWorkspacesCommandRunner {
options: BaseCommandOptions,
workspaceIds: string[],
): Promise<void> {
this.logger.log(
'Running command to upgrade to 0.40: must start with phone calling code otherwise SyncMetadata will fail',
);
await this.phoneCallingCodeCreateColumnCommand.executeActiveWorkspacesCommand(
passedParam,
options,
workspaceIds,
);
await this.phoneCallingCodeMigrateDataCommand.executeActiveWorkspacesCommand(
passedParam,
options,
workspaceIds,
);
await this.recordPositionBackfillCommand.executeActiveWorkspacesCommand(
passedParam,
options,

View File

@ -1,6 +1,8 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PhoneCallingCodeCreateColumnCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-create-column.command';
import { PhoneCallingCodeMigrateDataCommand } from 'src/database/commands/upgrade-version/0-40/0-40-phone-calling-code-migrate-data.command';
import { RecordPositionBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-record-position-backfill.command';
import { UpgradeTo0_40Command } from 'src/database/commands/upgrade-version/0-40/0-40-upgrade-version.command';
import { ViewGroupNoValueBackfillCommand } from 'src/database/commands/upgrade-version/0-40/0-40-view-group-no-value-backfill.command';
@ -8,18 +10,35 @@ import { RecordPositionBackfillModule } from 'src/engine/api/graphql/workspace-q
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { FieldMetadataModule } from 'src/engine/metadata-modules/field-metadata/field-metadata.module';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { SearchModule } from 'src/engine/metadata-modules/search/search.module';
import { WorkspaceMetadataVersionModule } from 'src/engine/metadata-modules/workspace-metadata-version/workspace-metadata-version.module';
import { WorkspaceMigrationFactory } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.factory';
import { WorkspaceMigrationModule } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.module';
import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.module';
import { WorkspaceSyncMetadataCommandsModule } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module';
@Module({
imports: [
TypeOrmModule.forFeature([Workspace], 'core'),
TypeOrmModule.forFeature(
[ObjectMetadataEntity, FieldMetadataEntity],
'metadata',
),
TypeOrmModule.forFeature([FieldMetadataEntity], 'metadata'),
WorkspaceSyncMetadataCommandsModule,
SearchModule,
WorkspaceMigrationRunnerModule,
WorkspaceMetadataVersionModule,
WorkspaceMigrationModule,
RecordPositionBackfillModule,
FieldMetadataModule,
],
providers: [
UpgradeTo0_40Command,
PhoneCallingCodeMigrateDataCommand,
PhoneCallingCodeCreateColumnCommand,
WorkspaceMigrationFactory,
RecordPositionBackfillCommand,
ViewGroupNoValueBackfillCommand,
],

View File

@ -106,13 +106,12 @@ export const getDevSeedPeopleCustomFields = (
isActive: true,
isNullable: false,
isUnique: false,
defaultValue: [
{
primaryPhoneNumber: '',
primaryPhoneCountryCode: '',
additionalPhones: {},
},
],
defaultValue: {
primaryPhoneNumber: "''",
primaryPhoneCountryCode: "'FR'",
primaryPhoneCallingCode: "'+33'",
additionalPhones: null,
},
objectMetadataId,
},
{

View File

@ -35,12 +35,14 @@ export const seedPeople = async (
'nameFirstName',
'nameLastName',
'phonesPrimaryPhoneCountryCode',
'phonesPrimaryPhoneCallingCode',
'phonesPrimaryPhoneNumber',
'city',
'companyId',
'emailsPrimaryEmail',
'position',
'whatsappPrimaryPhoneCountryCode',
'whatsappPrimaryPhoneCallingCode',
'whatsappPrimaryPhoneNumber',
'createdBySource',
'createdByWorkspaceMemberId',
@ -52,13 +54,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.CHRISTOPH,
nameFirstName: 'Christoph',
nameLastName: 'Callisto',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '789012345',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '789012345',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.LINKEDIN,
emailsPrimaryEmail: 'christoph.calisto@linkedin.com',
position: 1,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '789012345',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -68,13 +72,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.SYLVIE,
nameFirstName: 'Sylvie',
nameLastName: 'Palmer',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '780123456',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '780123456',
city: 'Los Angeles',
companyId: DEV_SEED_COMPANY_IDS.LINKEDIN,
emailsPrimaryEmail: 'sylvie.palmer@linkedin.com',
position: 2,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '780123456',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -84,13 +90,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.CHRISTOPHER_G,
nameFirstName: 'Christopher',
nameLastName: 'Gonzalez',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '789012345',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '789012345',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.QONTO,
emailsPrimaryEmail: 'christopher.gonzalez@qonto.com',
position: 3,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '789012345',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -100,13 +108,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.ASHLEY,
nameFirstName: 'Ashley',
nameLastName: 'Parker',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '780123456',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '780123456',
city: 'Los Angeles',
companyId: DEV_SEED_COMPANY_IDS.QONTO,
emailsPrimaryEmail: 'ashley.parker@qonto.com',
position: 4,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '780123456',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -116,13 +126,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.NICHOLAS,
nameFirstName: 'Nicholas',
nameLastName: 'Wright',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '781234567',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '781234567',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.MICROSOFT,
emailsPrimaryEmail: 'nicholas.wright@microsoft.com',
position: 5,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '781234567',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -132,13 +144,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.ISABELLA,
nameFirstName: 'Isabella',
nameLastName: 'Scott',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '782345678',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '782345678',
city: 'New York',
companyId: DEV_SEED_COMPANY_IDS.MICROSOFT,
emailsPrimaryEmail: 'isabella.scott@microsoft.com',
position: 6,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '782345678',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -148,13 +162,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.MATTHEW,
nameFirstName: 'Matthew',
nameLastName: 'Green',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '783456789',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '783456789',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.MICROSOFT,
emailsPrimaryEmail: 'matthew.green@microsoft.com',
position: 7,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '783456789',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -164,13 +180,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.ELIZABETH,
nameFirstName: 'Elizabeth',
nameLastName: 'Baker',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '784567890',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '784567890',
city: 'New York',
companyId: DEV_SEED_COMPANY_IDS.AIRBNB,
emailsPrimaryEmail: 'elizabeth.baker@airbnb.com',
position: 8,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '784567890',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -180,13 +198,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.CHRISTOPHER_N,
nameFirstName: 'Christopher',
nameLastName: 'Nelson',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '785678901',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '785678901',
city: 'San Francisco',
companyId: DEV_SEED_COMPANY_IDS.AIRBNB,
emailsPrimaryEmail: 'christopher.nelson@airbnb.com',
position: 9,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '785678901',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -196,13 +216,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.AVERY,
nameFirstName: 'Avery',
nameLastName: 'Carter',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '786789012',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '786789012',
city: 'New York',
companyId: DEV_SEED_COMPANY_IDS.AIRBNB,
emailsPrimaryEmail: 'avery.carter@airbnb.com',
position: 10,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '786789012',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -212,13 +234,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.ETHAN,
nameFirstName: 'Ethan',
nameLastName: 'Mitchell',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '787890123',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '787890123',
city: 'Los Angeles',
companyId: DEV_SEED_COMPANY_IDS.GOOGLE,
emailsPrimaryEmail: 'ethan.mitchell@google.com',
position: 11,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '787890123',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -228,13 +252,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.MADISON,
nameFirstName: 'Madison',
nameLastName: 'Perez',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '788901234',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '788901234',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.GOOGLE,
emailsPrimaryEmail: 'madison.perez@google.com',
position: 12,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '788901234',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -244,13 +270,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.BERTRAND,
nameFirstName: 'Bertrand',
nameLastName: 'Voulzy',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '788901234',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '788901234',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.GOOGLE,
emailsPrimaryEmail: 'bertrand.voulzy@google.com',
position: 13,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '788901234',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -260,13 +288,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.LOUIS,
nameFirstName: 'Louis',
nameLastName: 'Duss',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '789012345',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '789012345',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.GOOGLE,
emailsPrimaryEmail: 'louis.duss@google.com',
position: 14,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '789012345',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: DEV_SEED_WORKSPACE_MEMBER_IDS.TIM,
@ -276,13 +306,15 @@ export const seedPeople = async (
id: DEV_SEED_PERSON_IDS.LORIE,
nameFirstName: 'Lorie',
nameLastName: 'Vladim',
phonePrimaryPhoneCountryCode: '+33',
phonePrimaryPhoneNumber: '788901235',
phonesPrimaryPhoneCountryCode: 'FR',
phonesPrimaryPhoneCallingCode: '+33',
phonesPrimaryPhoneNumber: '788901235',
city: 'Seattle',
companyId: DEV_SEED_COMPANY_IDS.GOOGLE,
emailsPrimaryEmail: 'lorie.vladim@google.com',
position: 15,
whatsappPrimaryPhoneCountryCode: '+33',
whatsappPrimaryPhoneCountryCode: 'FR',
whatsappPrimaryPhoneCallingCode: '+33',
whatsappPrimaryPhoneNumber: '788901235',
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,