Update seed default values (#2681)

* Update seed default values

* Update seed default values

* Update seed default values

* remove allowImpersonation in workspaceMembers

* remove USD from currencyCode defaultValue

* fix tests
This commit is contained in:
Weiko 2023-11-23 23:30:53 +01:00 committed by GitHub
parent a0478a0a83
commit 5038c36df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 97 additions and 93 deletions

View File

@ -16,7 +16,7 @@ describe('AuthResolver', () => {
providers: [
AuthResolver,
{
provide: getRepositoryToken(Workspace),
provide: getRepositoryToken(Workspace, 'core'),
useValue: {},
},
{

View File

@ -34,11 +34,11 @@ describe('AuthService', () => {
useValue: {},
},
{
provide: getRepositoryToken(Workspace),
provide: getRepositoryToken(Workspace, 'core'),
useValue: {},
},
{
provide: getRepositoryToken(User),
provide: getRepositoryToken(User, 'core'),
useValue: {},
},
],

View File

@ -24,11 +24,11 @@ describe('TokenService', () => {
useValue: {},
},
{
provide: getRepositoryToken(User),
provide: getRepositoryToken(User, 'core'),
useValue: {},
},
{
provide: getRepositoryToken(RefreshToken),
provide: getRepositoryToken(RefreshToken, 'core'),
useValue: {},
},
],

View File

@ -15,7 +15,7 @@ describe('UserService', () => {
providers: [
UserService,
{
provide: getRepositoryToken(User),
provide: getRepositoryToken(User, 'core'),
useValue: {},
},
{

View File

@ -14,7 +14,7 @@ describe('WorkspaceService', () => {
providers: [
WorkspaceService,
{
provide: getRepositoryToken(Workspace),
provide: getRepositoryToken(Workspace, 'core'),
useValue: {},
},
{

View File

@ -124,7 +124,7 @@ export const seedActivityFieldMetadata = async (
icon: 'IconNotes',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
// Scalar fields
@ -144,7 +144,7 @@ export const seedActivityFieldMetadata = async (
icon: 'IconList',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedActivityFieldMetadataIds.Type,
@ -162,7 +162,7 @@ export const seedActivityFieldMetadata = async (
icon: 'IconCheckbox',
isNullable: false,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: 'Note' },
},
{
id: SeedActivityFieldMetadataIds.ReminderAt,

View File

@ -113,7 +113,7 @@ export const seedApiKeyFieldMetadata = async (
icon: 'IconLink',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedApiKeyFieldMetadataIds.ExpiresAt,

View File

@ -147,7 +147,7 @@ export const seedCompanyFieldMetadata = async (
icon: 'IconLink',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedCompanyFieldMetadataIds.Address,
@ -165,7 +165,7 @@ export const seedCompanyFieldMetadata = async (
icon: 'IconMap',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedCompanyFieldMetadataIds.Employees,

View File

@ -155,11 +155,11 @@ export const seedOpportunityFieldMetadata = async (
targetColumnMap: {
value: 'probability',
},
description: 'Opportunity amount',
description: 'Opportunity probability',
icon: 'IconProgressCheck',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '0' },
},
// Relationships
{

View File

@ -204,7 +204,7 @@ export const seedPersonFieldMetadata = async (
icon: 'IconBriefcase',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.Phone,
@ -222,7 +222,7 @@ export const seedPersonFieldMetadata = async (
icon: 'IconPhone',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.City,
@ -240,7 +240,7 @@ export const seedPersonFieldMetadata = async (
icon: 'IconMap',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.AvatarUrl,
@ -258,7 +258,7 @@ export const seedPersonFieldMetadata = async (
icon: 'IconFileUpload',
isNullable: true,
isSystem: true,
defaultValue: undefined,
defaultValue: { value: '' },
},
// Relationships

View File

@ -106,7 +106,7 @@ export const seedViewFieldFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -116,7 +116,7 @@ export const seedViewFieldFieldMetadata = async (
icon: 'IconTag',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
defaultValue: undefined,
},
{
id: SeedViewFieldFieldMetadataIds.View,

View File

@ -106,7 +106,7 @@ export const seedViewFilterFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -116,7 +116,7 @@ export const seedViewFilterFieldMetadata = async (
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
defaultValue: undefined,
},
{
id: SeedViewFilterFieldMetadataIds.View,
@ -124,7 +124,7 @@ export const seedViewFilterFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'viewId',
label: 'View Id',
targetColumnMap: {},

View File

@ -104,7 +104,7 @@ export const seedViewSortFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -114,7 +114,7 @@ export const seedViewSortFieldMetadata = async (
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
defaultValue: undefined,
},
{
id: SeedViewSortFieldMetadataIds.View,
@ -122,7 +122,7 @@ export const seedViewSortFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'viewId',
label: 'View Id',
targetColumnMap: {},

View File

@ -124,7 +124,7 @@ export const seedViewFieldMetadata = async (
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'objectMetadataId',
label: 'Object Metadata Id',
targetColumnMap: {
@ -134,7 +134,7 @@ export const seedViewFieldMetadata = async (
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
defaultValue: undefined,
},
{
id: SeedViewFieldMetadataIds.Type,
@ -152,7 +152,7 @@ export const seedViewFieldMetadata = async (
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
defaultValue: { value: 'table' },
},
{
id: SeedViewFieldMetadataIds.ViewFields,

View File

@ -15,7 +15,6 @@ export enum SeedWorkspaceMemberFieldMetadataIds {
AvatarUrl = '20202020-7ba6-40d5-934b-17146183a212',
Locale = '20202020-10f6-4df9-8d6f-a760b65bd800',
ColorScheme = '20202020-83f2-4c5f-96b0-0c51ecc160e3',
AllowImpersonation = '20202020-bb19-44a1-8156-8866f87a5f42',
UserId = '20202020-f2c1-4ca1-9ca5-7b9d5cc87eb0',
AuthoredActivities = '20202020-37a0-4db4-9c9f-fd3e3f4e47fc',
AssignedActivities = '20202020-ac05-44b9-9526-764dd5ce14e2',
@ -178,7 +177,7 @@ export const seedWorkspaceMemberFieldMetadata = async (
icon: 'IconColorSwatch',
isNullable: true,
isSystem: false,
defaultValue: undefined,
defaultValue: { value: 'Light' },
},
{
id: SeedWorkspaceMemberFieldMetadataIds.Locale,
@ -196,7 +195,7 @@ export const seedWorkspaceMemberFieldMetadata = async (
icon: 'IconLanguage',
isNullable: false,
isSystem: false,
defaultValue: { value: 'fr' },
defaultValue: { value: 'en' },
},
// Relationships

View File

@ -23,7 +23,6 @@ export const seedWorkspaceMember = async (
'nameLastName',
'locale',
'colorScheme',
'allowImpersonation',
'userId',
])
.orIgnore()
@ -34,7 +33,6 @@ export const seedWorkspaceMember = async (
nameLastName: 'Apple',
locale: 'en',
colorScheme: 'Light',
allowImpersonation: true,
userId: SeedUserIds.Tim,
},
{
@ -43,7 +41,6 @@ export const seedWorkspaceMember = async (
nameLastName: 'Ive',
locale: 'en',
colorScheme: 'Light',
allowImpersonation: true,
userId: SeedUserIds.Jony,
},
{
@ -52,7 +49,6 @@ export const seedWorkspaceMember = async (
nameLastName: 'Shiler',
locale: 'en',
colorScheme: 'Light',
allowImpersonation: true,
userId: SeedUserIds.Phil,
},
])

View File

@ -56,7 +56,7 @@ describe('convertFieldMetadataToColumnActions', () => {
{
action: 'CREATE',
columnName: 'moneyAmountMicros',
columnType: 'integer',
columnType: 'numeric',
defaultValue: 100 * 1_000_000,
},
{

View File

@ -22,11 +22,13 @@ export const addCompanyTable: WorkspaceMigrationTableAction[] = [
columnName: 'domainName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'address',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'employees',

View File

@ -20,15 +20,14 @@ export const addViewTable: WorkspaceMigrationTableAction[] = [
},
{
columnName: 'objectMetadataId',
columnType: 'varchar',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
defaultValue: "'table'",
},
],
},

View File

@ -14,9 +14,8 @@ export const addViewFieldTable: WorkspaceMigrationTableAction[] = [
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'varchar',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'position',

View File

@ -14,9 +14,8 @@ export const addViewFilterTable: WorkspaceMigrationTableAction[] = [
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'varchar',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'operand',

View File

@ -14,9 +14,8 @@ export const addViewSortTable: WorkspaceMigrationTableAction[] = [
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'varchar',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'direction',

View File

@ -16,16 +16,19 @@ export const addActivityTable: WorkspaceMigrationTableAction[] = [
columnName: 'title',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'body',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'Note'",
},
{
columnName: 'reminderAt',

View File

@ -26,6 +26,7 @@ export const addOpportunityTable: WorkspaceMigrationTableAction[] = [
columnName: 'probability',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'0'",
},
{
columnName: 'closeDate',

View File

@ -33,17 +33,13 @@ export const addWorkspaceMemberTable: WorkspaceMigrationTableAction[] = [
columnName: 'colorScheme',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'Light'",
},
{
columnName: 'locale',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'fr'",
},
{
columnName: 'allowImpersonation',
columnType: 'boolean',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'en'",
},
{
columnName: 'userId',

View File

@ -24,6 +24,7 @@ const activityMetadata = {
description: 'Activity title',
icon: 'IconNotes',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -37,6 +38,7 @@ const activityMetadata = {
description: 'Activity body',
icon: 'IconList',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -50,6 +52,7 @@ const activityMetadata = {
description: 'Activity type',
icon: 'IconCheckbox',
isNullable: false,
defaultValue: { value: 'Note' },
},
{
isCustom: false,
@ -148,7 +151,6 @@ const activityMetadata = {
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
isCustom: false,

View File

@ -23,6 +23,7 @@ const apiKeyMetadata = {
description: 'ApiKey name',
icon: 'IconLink',
isNullable: false,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -25,6 +25,18 @@ const commentMetadata = {
isNullable: false,
defaultValue: { value: '' },
},
{
isCustom: false,
isActive: true,
type: FieldMetadataType.UUID,
name: 'authorId',
label: 'Author',
targetColumnMap: {},
description: 'Comment author',
icon: 'IconCircleUser',
isNullable: true,
isSystem: true,
},
// Relations
{
isCustom: false,
@ -37,18 +49,6 @@ const commentMetadata = {
icon: 'IconCircleUser',
isNullable: true,
},
{
isCustom: false,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'authorId',
label: 'Author',
targetColumnMap: {},
description: 'Comment author',
icon: 'IconCircleUser',
isNullable: true,
isSystem: true,
},
{
isCustom: false,
isActive: true,

View File

@ -38,6 +38,7 @@ const companyMetadata = {
'The company website URL. We use this url to fetch the company icon',
icon: 'IconLink',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -51,6 +52,7 @@ const companyMetadata = {
description: 'The company address',
icon: 'IconMap',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -47,9 +47,10 @@ const opportunityMetadata = {
targetColumnMap: {
value: 'probability',
},
description: 'Opportunity amount',
description: 'Opportunity probability',
icon: 'IconProgressCheck',
isNullable: true,
defaultValue: { value: '0' },
},
// Relations
{

View File

@ -78,6 +78,7 @@ const personMetadata = {
description: 'Contacts job title',
icon: 'IconBriefcase',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -91,6 +92,7 @@ const personMetadata = {
description: 'Contacts phone number',
icon: 'IconPhone',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -104,6 +106,7 @@ const personMetadata = {
description: 'Contacts city',
icon: 'IconMap',
isNullable: true,
defaultValue: { value: '' },
},
{
isCustom: false,
@ -118,6 +121,7 @@ const personMetadata = {
icon: 'IconFileUpload',
isNullable: true,
isSystem: true,
defaultValue: { value: '' },
},
// Relations
{

View File

@ -14,7 +14,7 @@ const viewFieldMetadata = {
{
isCustom: false,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -23,7 +23,6 @@ const viewFieldMetadata = {
description: 'View Field target field',
icon: 'IconTag',
isNullable: false,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -14,7 +14,7 @@ const viewFilterMetadata = {
{
isCustom: false,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -23,7 +23,6 @@ const viewFilterMetadata = {
description: 'View Filter target field',
icon: null,
isNullable: false,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -14,7 +14,7 @@ const viewSortMetadata = {
{
isCustom: false,
isActive: true,
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
@ -23,7 +23,6 @@ const viewSortMetadata = {
description: 'View Sort target field',
icon: null,
isNullable: false,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -24,7 +24,7 @@ const viewMetadata = {
defaultValue: { value: '' },
},
{
type: FieldMetadataType.TEXT,
type: FieldMetadataType.UUID,
name: 'objectMetadataId',
label: 'Object Metadata Id',
targetColumnMap: {
@ -33,7 +33,6 @@ const viewMetadata = {
description: 'View target object',
icon: null,
isNullable: false,
defaultValue: { value: '' },
},
{
type: FieldMetadataType.TEXT,

View File

@ -38,6 +38,7 @@ const workspaceMemberMetadata = {
description: 'Preferred color scheme',
icon: 'IconColorSwatch',
isNullable: false,
defaultValue: { value: 'Light' },
},
{
isCustom: false,
@ -51,7 +52,7 @@ const workspaceMemberMetadata = {
description: 'Preferred language',
icon: 'IconLanguage',
isNullable: false,
defaultValue: { value: 'fr' },
defaultValue: { value: 'en' },
},
{
isCustom: false,
@ -66,6 +67,7 @@ const workspaceMemberMetadata = {
icon: 'IconFileUpload',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
isCustom: false,

View File

@ -81,23 +81,21 @@ export class WorkspaceManagerService {
workspaceId: string,
): Promise<ObjectMetadataEntity[]> {
const createdObjectMetadata = await this.objectMetadataService.createMany(
Object.values(standardObjectsMetadata).map(
(objectMetadata: ObjectMetadataEntity) => ({
...objectMetadata,
dataSourceId,
workspaceId,
isCustom: false,
isActive: true,
fields: [...basicFieldsMetadata, ...objectMetadata.fields].map(
(field) => ({
...field,
workspaceId,
isCustom: false,
isActive: true,
}),
),
}),
),
Object.values(standardObjectsMetadata).map((objectMetadata: any) => ({
...objectMetadata,
dataSourceId,
workspaceId,
isCustom: false,
isActive: true,
fields: [...basicFieldsMetadata, ...objectMetadata.fields].map(
(field) => ({
...field,
workspaceId,
isCustom: false,
isActive: true,
}),
),
})),
);
await this.relationMetadataService.createMany(

View File

@ -3,6 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
import { ObjectMetadataService } from 'src/metadata/object-metadata/object-metadata.service';
import { WorkspaceSchemaStorageService } from 'src/workspace/workspace-schema-storage/workspace-schema-storage.service';
import { ScalarsExplorerService } from 'src/workspace/services/scalars-explorer.service';
import { WorkspaceFactory } from './workspace.factory';
@ -24,6 +25,10 @@ describe('WorkspaceFactory', () => {
provide: ObjectMetadataService,
useValue: {},
},
{
provide: ScalarsExplorerService,
useValue: {},
},
{
provide: WorkspaceGraphQLSchemaFactory,
useValue: {},