From 9b99991b2e1267bebd772a80d2001a844c302bf5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 23 Nov 2023 14:01:58 +0000 Subject: [PATCH] Update SDK to account for new creator builder flag --- packages/shared-core/src/sdk/documents/users.ts | 10 +++++++++- packages/types/src/documents/global/user.ts | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/shared-core/src/sdk/documents/users.ts b/packages/shared-core/src/sdk/documents/users.ts index b58994aa46..ccd88bf854 100644 --- a/packages/shared-core/src/sdk/documents/users.ts +++ b/packages/shared-core/src/sdk/documents/users.ts @@ -87,13 +87,21 @@ export function hasAdminPermissions(user?: User | ContextUser): boolean { return !!user.admin?.global } +export function hasCreatorPermissions(user?: User | ContextUser): boolean { + if (!user) { + return false + } + return !!user.builder?.creator +} + export function isCreator(user?: User | ContextUser): boolean { if (!user) { return false } return ( - isGlobalBuilder(user) || + isGlobalBuilder(user!) || hasAdminPermissions(user) || + hasCreatorPermissions(user) || hasAppBuilderPermissions(user) || hasAppCreatorPermissions(user) ) diff --git a/packages/types/src/documents/global/user.ts b/packages/types/src/documents/global/user.ts index 9769661cd5..337855787f 100644 --- a/packages/types/src/documents/global/user.ts +++ b/packages/types/src/documents/global/user.ts @@ -44,6 +44,7 @@ export interface User extends Document { builder?: { global?: boolean apps?: string[] + creator?: boolean } admin?: { global: boolean