add workspaceId to indirect entities (#19522)
Required for `workspace:export` command --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+2
@@ -186,6 +186,7 @@ describe('ApplicationVariableEntityService', () => {
|
||||
description: 'A secret key',
|
||||
isSecret: true,
|
||||
applicationId: mockApplicationId,
|
||||
workspaceId: mockWorkspaceId,
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -216,6 +217,7 @@ describe('ApplicationVariableEntityService', () => {
|
||||
description: 'Public URL',
|
||||
isSecret: false,
|
||||
applicationId: mockApplicationId,
|
||||
workspaceId: mockWorkspaceId,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
+10
@@ -5,6 +5,7 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import type { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { EntityRelation } from 'src/engine/workspace-manager/workspace-migration/types/entity-relation.interface';
|
||||
|
||||
@Entity({
|
||||
@@ -30,6 +32,14 @@ export class ApplicationVariableEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
@Index()
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne('WorkspaceEntity', { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: EntityRelation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
key: string;
|
||||
|
||||
|
||||
+1
@@ -136,6 +136,7 @@ export class ApplicationVariableEntityService {
|
||||
description: description ?? '',
|
||||
isSecret: isSecretValue,
|
||||
applicationId,
|
||||
workspaceId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ export const fromApplicationVariableEntityToFlatApplicationVariable = (
|
||||
description: entity.description,
|
||||
isSecret: entity.isSecret,
|
||||
applicationId: entity.applicationId,
|
||||
workspaceId: entity.workspaceId,
|
||||
createdAt: entity.createdAt.toISOString(),
|
||||
updatedAt: entity.updatedAt.toISOString(),
|
||||
});
|
||||
|
||||
+3
@@ -137,6 +137,7 @@ export class BillingWebhookSubscriptionService {
|
||||
await this.updateBillingSubscriptionItems(
|
||||
updatedBillingSubscription.id,
|
||||
event,
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const shouldSuspend = this.shouldSuspendWorkspace(data);
|
||||
@@ -224,6 +225,7 @@ export class BillingWebhookSubscriptionService {
|
||||
| Stripe.CustomerSubscriptionUpdatedEvent
|
||||
| Stripe.CustomerSubscriptionCreatedEvent
|
||||
| Stripe.CustomerSubscriptionDeletedEvent,
|
||||
workspaceId: string,
|
||||
) {
|
||||
const deletedSubscriptionItemIds =
|
||||
getDeletedStripeSubscriptionItemIdsFromStripeSubscriptionEvent(event);
|
||||
@@ -239,6 +241,7 @@ export class BillingWebhookSubscriptionService {
|
||||
transformStripeSubscriptionEventToDatabaseSubscriptionItem(
|
||||
subscriptionId,
|
||||
event.data,
|
||||
workspaceId,
|
||||
),
|
||||
{
|
||||
conflictPaths: ['stripeSubscriptionItemId'],
|
||||
|
||||
+2
@@ -8,10 +8,12 @@ export const transformStripeSubscriptionEventToDatabaseSubscriptionItem = (
|
||||
| Stripe.CustomerSubscriptionUpdatedEvent.Data
|
||||
| Stripe.CustomerSubscriptionCreatedEvent.Data
|
||||
| Stripe.CustomerSubscriptionDeletedEvent.Data,
|
||||
workspaceId: string,
|
||||
) => {
|
||||
return data.object.items.data.map((item) => {
|
||||
return {
|
||||
billingSubscriptionId,
|
||||
workspaceId,
|
||||
stripeSubscriptionId: data.object.id,
|
||||
stripeProductId: String(item.price.product),
|
||||
stripePriceId: item.price.id,
|
||||
|
||||
+10
@@ -5,6 +5,7 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
import { BillingProductEntity } from 'src/engine/core-modules/billing/entities/billing-product.entity';
|
||||
import { BillingSubscriptionEntity } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
|
||||
import { BillingSubscriptionItemMetadata } from 'src/engine/core-modules/billing/types/billing-subscription-item-metadata.type';
|
||||
import type { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
@Entity({ name: 'billingSubscriptionItem', schema: 'core' })
|
||||
@Unique(
|
||||
'IDX_BILLING_SUBSCRIPTION_ITEM_BILLING_SUBSCRIPTION_ID_STRIPE_PRODUCT_ID_UNIQUE',
|
||||
@@ -25,6 +27,14 @@ export class BillingSubscriptionItemEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
@Index()
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne('WorkspaceEntity', { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: true, type: 'timestamptz' })
|
||||
deletedAt?: Date;
|
||||
|
||||
|
||||
+1
@@ -348,6 +348,7 @@ export class BillingSubscriptionService {
|
||||
{
|
||||
object: subscription,
|
||||
},
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
const meterBillingSubscriptionItem = findOrThrow(
|
||||
|
||||
+6
@@ -27,6 +27,7 @@ describe('buildEnvVar', () => {
|
||||
description: 'Public URL',
|
||||
isSecret: false,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
@@ -37,6 +38,7 @@ describe('buildEnvVar', () => {
|
||||
description: 'API secret',
|
||||
isSecret: true,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
@@ -47,6 +49,7 @@ describe('buildEnvVar', () => {
|
||||
description: 'Debug flag',
|
||||
isSecret: false,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
@@ -74,6 +77,7 @@ describe('buildEnvVar', () => {
|
||||
description: '',
|
||||
isSecret: false,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
@@ -84,6 +88,7 @@ describe('buildEnvVar', () => {
|
||||
description: '',
|
||||
isSecret: false,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
@@ -106,6 +111,7 @@ describe('buildEnvVar', () => {
|
||||
description: '',
|
||||
isSecret: false,
|
||||
applicationId: 'app-1',
|
||||
workspaceId: '00000000-0000-0000-0000-000000000000',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
|
||||
+9
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
import { OTPStatus } from 'src/engine/core-modules/two-factor-authentication/strategies/otp/otp.constants';
|
||||
import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
|
||||
import type { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
|
||||
@Index(['userWorkspaceId', 'strategy'], { unique: true })
|
||||
@Entity({ name: 'twoFactorAuthenticationMethod', schema: 'core' })
|
||||
@@ -20,6 +21,14 @@ export class TwoFactorAuthenticationMethodEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
@Index()
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne('WorkspaceEntity', { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
userWorkspaceId: string;
|
||||
|
||||
|
||||
+1
@@ -191,6 +191,7 @@ describe('TwoFactorAuthenticationService', () => {
|
||||
);
|
||||
expect(repository.save).toHaveBeenCalledWith({
|
||||
id: undefined,
|
||||
workspaceId: workspace.id,
|
||||
userWorkspace: mockUserWorkspace,
|
||||
secret: encryptedSecret,
|
||||
status: 'PENDING',
|
||||
|
||||
+1
@@ -140,6 +140,7 @@ export class TwoFactorAuthenticationService {
|
||||
|
||||
await this.twoFactorAuthenticationMethodRepository.save({
|
||||
id: existing2FAMethod?.id,
|
||||
workspaceId,
|
||||
userWorkspace: userWorkspace,
|
||||
secret: encryptedSecret,
|
||||
status: context.status,
|
||||
|
||||
Reference in New Issue
Block a user