Api keys and webhook migration to core (#13011)
TODO: check Zapier trigger records work as expected --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
+1
@@ -49,6 +49,7 @@ export class StandardFieldFactory {
|
||||
isGatedAndNotEnabled(
|
||||
workspaceEntityMetadataArgs.gate,
|
||||
context.featureFlags,
|
||||
'database',
|
||||
)
|
||||
) {
|
||||
return acc;
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ export class StandardObjectFactory {
|
||||
isGatedAndNotEnabled(
|
||||
workspaceEntityMetadataArgs.gate,
|
||||
context.featureFlags,
|
||||
'database',
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
|
||||
+2
-2
@@ -37,7 +37,6 @@ import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/sta
|
||||
|
||||
// TODO: Maybe we should automate this with the DiscoverService of Nest.JS
|
||||
export const standardObjectMetadataDefinitions = [
|
||||
ApiKeyWorkspaceEntity,
|
||||
AttachmentWorkspaceEntity,
|
||||
BlocklistWorkspaceEntity,
|
||||
CalendarEventWorkspaceEntity,
|
||||
@@ -55,7 +54,6 @@ export const standardObjectMetadataDefinitions = [
|
||||
ViewFilterGroupWorkspaceEntity,
|
||||
ViewSortWorkspaceEntity,
|
||||
ViewWorkspaceEntity,
|
||||
WebhookWorkspaceEntity,
|
||||
WorkflowWorkspaceEntity,
|
||||
WorkflowVersionWorkspaceEntity,
|
||||
WorkflowRunWorkspaceEntity,
|
||||
@@ -73,4 +71,6 @@ export const standardObjectMetadataDefinitions = [
|
||||
PersonWorkspaceEntity,
|
||||
TaskWorkspaceEntity,
|
||||
TaskTargetWorkspaceEntity,
|
||||
ApiKeyWorkspaceEntity,
|
||||
WebhookWorkspaceEntity,
|
||||
];
|
||||
|
||||
+25
-3
@@ -1,11 +1,33 @@
|
||||
import { Gate } from 'src/engine/twenty-orm/interfaces/gate.interface';
|
||||
|
||||
export type GateContext = 'database' | 'graphql';
|
||||
|
||||
export const isGatedAndNotEnabled = (
|
||||
gate: Gate | undefined,
|
||||
workspaceFeatureFlagsMap: Record<string, boolean>,
|
||||
context?: GateContext,
|
||||
): boolean => {
|
||||
const featureFlagValue =
|
||||
gate?.featureFlag && workspaceFeatureFlagsMap[gate.featureFlag];
|
||||
// If no gate, not gated
|
||||
if (!gate?.featureFlag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return gate?.featureFlag !== undefined && !featureFlagValue;
|
||||
// Check if explicitly excluded from the specific context
|
||||
switch (context) {
|
||||
case 'database':
|
||||
if (gate.excludeFromDatabase === false) {
|
||||
return false; // Not gated for database
|
||||
}
|
||||
break;
|
||||
case 'graphql':
|
||||
if (gate.excludeFromGraphQL === false) {
|
||||
return false; // Not gated for GraphQL
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If context-specific exclusion is true or undefined (default behavior), check the flag
|
||||
const featureFlagValue = workspaceFeatureFlagsMap[gate.featureFlag];
|
||||
|
||||
return !featureFlagValue;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user