@uniformdev/mesh-sdk 19.114.0 → 19.114.1-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -32,6 +32,7 @@ interface paths$1 {
32
32
  /** @enum {string} */
33
33
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
34
34
  public?: boolean;
35
+ scopes?: string[];
35
36
  baseLocationUrl?: string;
36
37
  locations: {
37
38
  install?: {
@@ -183,6 +184,7 @@ interface paths$1 {
183
184
  /** @enum {string} */
184
185
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
185
186
  public?: boolean;
187
+ scopes?: string[];
186
188
  baseLocationUrl?: string;
187
189
  locations: {
188
190
  install?: {
@@ -333,6 +335,7 @@ interface paths$1 {
333
335
  badgeIconUrl?: string;
334
336
  /** @enum {string} */
335
337
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
338
+ scopes?: string[];
336
339
  baseLocationUrl?: string;
337
340
  locations: {
338
341
  install?: {
@@ -732,6 +735,7 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
732
735
  badgeIconUrl?: string | undefined;
733
736
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown" | undefined;
734
737
  public?: boolean | undefined;
738
+ scopes?: string[] | undefined;
735
739
  baseLocationUrl?: string | undefined;
736
740
  locations: {
737
741
  install?: {
@@ -876,19 +880,11 @@ declare class IntegrationInstallationClient extends ApiClient {
876
880
  remove(body: ExceptProject<IntegrationInstallationDeleteParameters>): Promise<void>;
877
881
  }
878
882
 
879
- type AssetLibraryLocationMetadata<TIntegrationConfiguration = unknown> = {
880
- /** Settings defined at the integration level (arbitrary type used on settings location) */
881
- settings: TIntegrationConfiguration;
882
- /** The Uniform project ID */
883
- projectId: string;
883
+ type AssetLibraryLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
884
884
  /** The current Uniform integration source ID */
885
885
  sourceId: string;
886
- };
887
- type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = {
888
- /** Settings defined at the integration level (arbitrary type used on settings location) */
889
- settings: TIntegrationConfiguration;
890
- /** The Uniform project ID */
891
- projectId: string;
886
+ }, TIntegrationConfiguration>;
887
+ type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
892
888
  /** The current Uniform integration source ID */
893
889
  sourceId: string;
894
890
  /** The resolved data if this source is connected to a data resource */
@@ -899,7 +895,7 @@ type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = {
899
895
  * Default: 1
900
896
  */
901
897
  maxAssets?: number;
902
- };
898
+ }, TIntegrationConfiguration>;
903
899
  type AssetLibraryLocation = MeshLocationCore<unknown, AssetLibraryLocationMetadata, unknown, 'assetLibrary'> & GetDataResourceLocation;
904
900
  type AssetParameterLocation = MeshLocationCore<AssetParamValue, AssetParameterLocationMetadata, AssetParamValue, 'assetParameter'> & GetDataResourceLocation;
905
901
 
@@ -908,11 +904,7 @@ type DataConnectorInfo = {
908
904
  type: string;
909
905
  displayName: string;
910
906
  };
911
- type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
912
- /** Settings defined at the integration level (arbitrary type used on settings location) */
913
- settings: TIntegrationConfiguration;
914
- /** The Uniform project ID */
915
- projectId: string;
907
+ type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
916
908
  /**
917
909
  * The current data type's data source. NOTE: param and header values are not available in this context.
918
910
  */
@@ -921,13 +913,10 @@ type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
921
913
  dataConnector: DataConnectorInfo;
922
914
  /** The data type's archetype value. */
923
915
  archetype: string;
924
- };
916
+ }, TIntegrationConfiguration>;
925
917
  type DataTypeLocation = MeshLocationCore<DataTypeLocationValue, DataTypeLocationMetadata, DataTypeLocationValue, 'dataType'> & GetDataResourceLocation;
926
918
 
927
- type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = {
928
- /** Settings defined at the integration level (arbitrary type used on settings location) */
929
- settings: TIntegrationConfiguration;
930
- /** The current data resource's data type */
919
+ type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
931
920
  dataType: DataType;
932
921
  /** The data type's archetype value. */
933
922
  archetype: string;
@@ -937,32 +926,21 @@ type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = {
937
926
  dataSource: DataSource;
938
927
  /** The data connector type of the current data resource's data source */
939
928
  dataConnector: DataConnectorInfo;
940
- /** The Uniform project ID */
941
- projectId: string;
942
929
  /** Current dynamic inputs that are configured on the composition (if any). */
943
930
  dynamicInputs: DynamicInputs;
944
- };
931
+ }, TIntegrationConfiguration>;
945
932
  type DataResourceLocation = MeshLocationCore<DataResourceVariables, DataResourceLocationMetadata, DataResourceVariables, 'dataResource'> & GetDataResourceLocation;
946
933
 
947
934
  type DataSourceLocationValue = Pick<DataSource, 'baseUrl' | 'custom' | 'customPublic' | 'headers' | 'parameters' | 'variables'>;
948
- type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = {
949
- /** Settings defined at the integration level (arbitrary type used on settings location) */
950
- settings: TIntegrationConfiguration;
951
- /** The Uniform project ID */
952
- projectId: string;
953
- };
935
+ type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<unknown, TIntegrationConfiguration>;
954
936
  type DataSourceLocation = MeshLocationCore<DataSourceLocationValue, DataSourceLocationMetadata, DataSourceLocationValue, 'dataSource'>;
955
937
 
956
- type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = {
938
+ type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = CommonMetadata<{
957
939
  rootNode: Omit<RootComponentInstance, 'slots' | '_data'>;
958
940
  parameterConfiguration: TParamConfiguration;
959
941
  component: Omit<ComponentInstance, 'slots'>;
960
942
  componentDefinitions: Record<string, ComponentDefinition | undefined>;
961
943
  parameterDefinition: ComponentDefinitionParameter;
962
- /** Settings defined at the integration level (arbitrary type used on settings location) */
963
- settings: TIntegrationConfiguration;
964
- /** The Uniform project ID */
965
- projectId: string;
966
944
  /**
967
945
  * Current dynamic inputs that are configured on the composition (if any).
968
946
  * Use the <ParamTypeDynamicDataProvider> to wire up dynamic data in your parameter.
@@ -984,7 +962,7 @@ type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfig
984
962
  * Note that setValue() always sets the target language automatically.
985
963
  */
986
964
  targetLocale: string | undefined;
987
- };
965
+ }, TIntegrationConfiguration>;
988
966
  type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TParamSetValue = TParamValue, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeLocationMetadata<TParamConfiguration, TIntegrationConfiguration>, TParamSetValue, 'paramType'> & {
989
967
  /**
990
968
  * Opens a dialog on the Uniform platform to edit or select a dynamic token to connect to.
@@ -993,9 +971,7 @@ type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TPa
993
971
  editConnectedData: Awaited<ReturnType<typeof connectToParent>>['parent']['editConnectedData'];
994
972
  };
995
973
 
996
- type SettingsLocationMetadata = {
997
- projectId: string;
998
- };
974
+ type SettingsLocationMetadata = CommonMetadata;
999
975
  type SettingsLocation<TSettingsType> = MeshLocationCore<TSettingsType, SettingsLocationMetadata, TSettingsType, 'settings'>;
1000
976
 
1001
977
  /**
@@ -1126,6 +1102,22 @@ type EditConnectedDataResponse = {
1126
1102
  canceled: true;
1127
1103
  editorCancelledContext: EditConnectedDataResponseCancellationContext;
1128
1104
  };
1105
+ type UniformUser = {
1106
+ /** Permissions the user has as per Team Admin assigned, can be used to do conditional rendering */
1107
+ permissions: MeshLocationUserPermissions[];
1108
+ /** Permissions the user has as per Team Admin created and assigned, can be used to do conditional rendering */
1109
+ roles: {
1110
+ id: string;
1111
+ name: string;
1112
+ }[];
1113
+ /** Name of the user assigned by Team Admin. Unless your Mesh integration was given permissions to expose User Name - it is not available */
1114
+ name?: string;
1115
+ /** Email of the user used to sign in. Unless your Mesh integration was given permissions to expose User Name - it is not available */
1116
+ email?: string;
1117
+ /** Unique ID of the user */
1118
+ id: string;
1119
+ isAdmin: boolean;
1120
+ };
1129
1121
 
1130
1122
  type MeshSDKEventInterface = Awaited<ReturnType<typeof connectToParent>>['parent'] & {
1131
1123
  initialize: () => Promise<MeshContextData>;
@@ -1188,6 +1180,84 @@ interface MeshLocationCore<TValue = unknown, TMetadata = unknown, TSetValue = TV
1188
1180
  returnDialogValue: (value: unknown) => Promise<void>;
1189
1181
  };
1190
1182
  }
1183
+ /** Common metadata for all mesh locations */
1184
+ type CommonMetadata<ExtendedMetadata = unknown, TIntegrationConfiguration = unknown> = {
1185
+ /** The current Uniform user context. Contains name, email and context to check for permissions */
1186
+ user: UniformUser;
1187
+ /** Current Uniform Project ID */
1188
+ projectId: string;
1189
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
1190
+ settings: TIntegrationConfiguration;
1191
+ } & ExtendedMetadata;
1192
+ type MeshLocationUserPermissions =
1193
+ /** Uniform Context:Enrichments:Create */
1194
+ 'ENRICHMENTS_CREATE'
1195
+ /** Uniform Context:Enrichments:Update */
1196
+ | 'ENRICHMENTS_UPDATE'
1197
+ /** Uniform Context:Enrichments:Delete */
1198
+ | 'ENRICHMENTS_DELETE'
1199
+ /** Uniform Context:Intents & Audiences:Create */
1200
+ | 'INTENTS_CREATE'
1201
+ /** Uniform Context:Intents & Audiences:Update */
1202
+ | 'INTENTS_UPDATE'
1203
+ /** Uniform Context:Intents & Audiences:Delete */
1204
+ | 'INTENTS_DELETE'
1205
+ /** Uniform Context:Quirks:Create */
1206
+ | 'QUIRKS_CREATE'
1207
+ /** Uniform Context:Quirks:Update| */
1208
+ | 'QUIRKS_UPDATE'
1209
+ /** Uniform Context:Quirks:Delete */
1210
+ | 'QUIRKS_DELETE'
1211
+ /** Uniform Context:Signals:Create */
1212
+ | 'SIGNALS_CREATE'
1213
+ /** Uniform Context:Signals:Update */
1214
+ | 'SIGNALS_UPDATE'
1215
+ /** Uniform Context:Signals:Delete */
1216
+ | 'SIGNALS_DELETE'
1217
+ /** Uniform Context:Tests:Create */
1218
+ | 'TESTS_CREATE'
1219
+ /** Uniform Context:Tests:Update|Declare winners and close existing tests. */
1220
+ | 'TESTS_UPDATE'
1221
+ /** Uniform Context:Tests:Delete */
1222
+ | 'TESTS_DELETE'
1223
+ /** Uniform Context:Manifest:Read|Read the published manifest */
1224
+ | 'MANIFEST_READ'
1225
+ /** Uniform Context:Manifest:Publish|Publish the manifest */
1226
+ | 'MANIFEST_PUBLISH'
1227
+ /** Uniform Context:Read Drafts|Read all drafts and preview manifest */
1228
+ | 'MANIFEST_READ_DRAFT'
1229
+ /** Uniform Canvas:Project Map:Manage|Create, update, and delete Project Maps and nodes in Project Map trees. */
1230
+ | 'PROJECT_MAP_MANAGE'
1231
+ /** General:Read Project|See the project in the team dashboard. */
1232
+ | 'PROJECT_READ'
1233
+ /** Uniform Canvas:Redirects:Advanced|Grants access to advanced redirect features and options. */
1234
+ | 'REDIRECTS_ADVANCED'
1235
+ /** Uniform Canvas:Redirects:Create */
1236
+ | 'REDIRECTS_CREATE'
1237
+ /** Uniform Canvas:Redirects:Update */
1238
+ | 'REDIRECTS_UPDATE'
1239
+ /** Uniform Canvas:Redirects:Delete */
1240
+ | 'REDIRECTS_DELETE'
1241
+ /** Uniform Canvas:Data Sources:Manage|Create, update, and delete data sources. */
1242
+ | 'DATA_SOURCES_MANAGE'
1243
+ /** Uniform Canvas:Data Types:Manage|Create, update, and delete data types. */
1244
+ | 'DATA_TYPES_MANAGE'
1245
+ /** Uniform Canvas:Compositions:Create */
1246
+ | 'COMPOSITIONS_CREATE'
1247
+ /** Uniform Canvas:Compositions:Update */
1248
+ | 'COMPOSITIONS_WRITE'
1249
+ /** Uniform Canvas:Compositions:Delete */
1250
+ | 'COMPOSITIONS_DELETE'
1251
+ /** Uniform Canvas:Compositions:Read Published */
1252
+ | 'COMPOSITIONS_READ'
1253
+ /** Uniform Canvas:Compositions:Publish */
1254
+ | 'COMPOSITIONS_PUBLISH'
1255
+ /** Uniform Canvas::Read|Includes read access to all canvas assets */
1256
+ | 'COMPOSITIONS_READ_DRAFT'
1257
+ /** Uniform Canvas:Component Library:Manage|Create, update, and delete component library data */
1258
+ | 'COMPOSITIONS_MANAGE_SCHEMA'
1259
+ /** UTM Mapper:Read|Read UTM mapper configuration */
1260
+ | 'UTM_MAPPER_READ';
1191
1261
  /**
1192
1262
  * Known location types that can be passed to a mesh location
1193
1263
  */
@@ -1217,31 +1287,23 @@ type DynamicInput = {
1217
1287
  /** Record of dynamic inputs keyed by the input name */
1218
1288
  type DynamicInputs = Record<string, DynamicInput>;
1219
1289
 
1220
- type AIGenerateLocationMetadata<TIntegrationConfiguration = unknown> = {
1221
- /** Settings defined at the integration level (arbitrary type used on settings location) */
1222
- settings: TIntegrationConfiguration;
1223
- /** The Uniform project ID */
1224
- projectId: string;
1290
+ type AIGenerateLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1225
1291
  prompt: string;
1226
1292
  promptMetadata: Record<string, unknown>;
1227
1293
  /** Useful to differentiate AI Generate UI between text and image */
1228
1294
  promptOutputType: 'text' | 'image';
1229
- };
1230
- type PromptSettingsLocationMetadata<TIntegrationConfiguration = unknown> = {
1231
- settings: TIntegrationConfiguration;
1295
+ }, TIntegrationConfiguration>;
1296
+ type PromptSettingsLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1232
1297
  /** Useful to differentiate metadata settings between text and image generation */
1233
1298
  promptOutputType: 'text' | 'image';
1234
- };
1299
+ }, TIntegrationConfiguration>;
1235
1300
  type AIGenerateLocation<TType> = MeshLocationCore<TType, AIGenerateLocationMetadata, TType, 'aiGenerate'>;
1236
1301
  type AIPromptMetadataLocation = MeshLocationCore<Record<string, unknown>, PromptSettingsLocationMetadata, Record<string, unknown>, 'aiMetadata'>;
1237
1302
 
1238
- type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = {
1239
- /** Settings defined at the integration level (arbitrary type used on settings location) */
1240
- settings: TIntegrationConfiguration;
1303
+ type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1241
1304
  /** The Uniform project ID */
1242
- projectId: string;
1243
1305
  componentDefinition: ComponentDefinition;
1244
- };
1306
+ }, TIntegrationConfiguration>;
1245
1307
  type ParamTypeConfigLocation<TParamValue = unknown, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeConfigLocationMetadata<TIntegrationConfiguration>, TParamValue, 'paramTypeConfig'>;
1246
1308
 
1247
1309
  interface SdkWindow {
@@ -1341,4 +1403,10 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
1341
1403
  autoResizingDisabled?: boolean;
1342
1404
  }): Promise<UniformMeshSDK | undefined>;
1343
1405
 
1344
- export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CloseDialogMessage, type CloseLocationDialogOptions, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshSDKEventInterface, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type ValidationResult, initializeUniformMeshSDK };
1406
+ declare const hasPermissions: (permissions: MeshLocationUserPermissions | MeshLocationUserPermissions[], user: UniformUser) => boolean;
1407
+ /**
1408
+ * Check if user has a role by both name and id
1409
+ */
1410
+ declare const hasRole: (role: string, user: UniformUser) => boolean;
1411
+
1412
+ export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshSDKEventInterface, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, hasPermissions, hasRole, initializeUniformMeshSDK };
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ interface paths$1 {
32
32
  /** @enum {string} */
33
33
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
34
34
  public?: boolean;
35
+ scopes?: string[];
35
36
  baseLocationUrl?: string;
36
37
  locations: {
37
38
  install?: {
@@ -183,6 +184,7 @@ interface paths$1 {
183
184
  /** @enum {string} */
184
185
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
185
186
  public?: boolean;
187
+ scopes?: string[];
186
188
  baseLocationUrl?: string;
187
189
  locations: {
188
190
  install?: {
@@ -333,6 +335,7 @@ interface paths$1 {
333
335
  badgeIconUrl?: string;
334
336
  /** @enum {string} */
335
337
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown";
338
+ scopes?: string[];
336
339
  baseLocationUrl?: string;
337
340
  locations: {
338
341
  install?: {
@@ -732,6 +735,7 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
732
735
  badgeIconUrl?: string | undefined;
733
736
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "uniform" | "ai" | "unknown" | undefined;
734
737
  public?: boolean | undefined;
738
+ scopes?: string[] | undefined;
735
739
  baseLocationUrl?: string | undefined;
736
740
  locations: {
737
741
  install?: {
@@ -876,19 +880,11 @@ declare class IntegrationInstallationClient extends ApiClient {
876
880
  remove(body: ExceptProject<IntegrationInstallationDeleteParameters>): Promise<void>;
877
881
  }
878
882
 
879
- type AssetLibraryLocationMetadata<TIntegrationConfiguration = unknown> = {
880
- /** Settings defined at the integration level (arbitrary type used on settings location) */
881
- settings: TIntegrationConfiguration;
882
- /** The Uniform project ID */
883
- projectId: string;
883
+ type AssetLibraryLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
884
884
  /** The current Uniform integration source ID */
885
885
  sourceId: string;
886
- };
887
- type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = {
888
- /** Settings defined at the integration level (arbitrary type used on settings location) */
889
- settings: TIntegrationConfiguration;
890
- /** The Uniform project ID */
891
- projectId: string;
886
+ }, TIntegrationConfiguration>;
887
+ type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
892
888
  /** The current Uniform integration source ID */
893
889
  sourceId: string;
894
890
  /** The resolved data if this source is connected to a data resource */
@@ -899,7 +895,7 @@ type AssetParameterLocationMetadata<TIntegrationConfiguration = unknown> = {
899
895
  * Default: 1
900
896
  */
901
897
  maxAssets?: number;
902
- };
898
+ }, TIntegrationConfiguration>;
903
899
  type AssetLibraryLocation = MeshLocationCore<unknown, AssetLibraryLocationMetadata, unknown, 'assetLibrary'> & GetDataResourceLocation;
904
900
  type AssetParameterLocation = MeshLocationCore<AssetParamValue, AssetParameterLocationMetadata, AssetParamValue, 'assetParameter'> & GetDataResourceLocation;
905
901
 
@@ -908,11 +904,7 @@ type DataConnectorInfo = {
908
904
  type: string;
909
905
  displayName: string;
910
906
  };
911
- type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
912
- /** Settings defined at the integration level (arbitrary type used on settings location) */
913
- settings: TIntegrationConfiguration;
914
- /** The Uniform project ID */
915
- projectId: string;
907
+ type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
916
908
  /**
917
909
  * The current data type's data source. NOTE: param and header values are not available in this context.
918
910
  */
@@ -921,13 +913,10 @@ type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
921
913
  dataConnector: DataConnectorInfo;
922
914
  /** The data type's archetype value. */
923
915
  archetype: string;
924
- };
916
+ }, TIntegrationConfiguration>;
925
917
  type DataTypeLocation = MeshLocationCore<DataTypeLocationValue, DataTypeLocationMetadata, DataTypeLocationValue, 'dataType'> & GetDataResourceLocation;
926
918
 
927
- type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = {
928
- /** Settings defined at the integration level (arbitrary type used on settings location) */
929
- settings: TIntegrationConfiguration;
930
- /** The current data resource's data type */
919
+ type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
931
920
  dataType: DataType;
932
921
  /** The data type's archetype value. */
933
922
  archetype: string;
@@ -937,32 +926,21 @@ type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = {
937
926
  dataSource: DataSource;
938
927
  /** The data connector type of the current data resource's data source */
939
928
  dataConnector: DataConnectorInfo;
940
- /** The Uniform project ID */
941
- projectId: string;
942
929
  /** Current dynamic inputs that are configured on the composition (if any). */
943
930
  dynamicInputs: DynamicInputs;
944
- };
931
+ }, TIntegrationConfiguration>;
945
932
  type DataResourceLocation = MeshLocationCore<DataResourceVariables, DataResourceLocationMetadata, DataResourceVariables, 'dataResource'> & GetDataResourceLocation;
946
933
 
947
934
  type DataSourceLocationValue = Pick<DataSource, 'baseUrl' | 'custom' | 'customPublic' | 'headers' | 'parameters' | 'variables'>;
948
- type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = {
949
- /** Settings defined at the integration level (arbitrary type used on settings location) */
950
- settings: TIntegrationConfiguration;
951
- /** The Uniform project ID */
952
- projectId: string;
953
- };
935
+ type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<unknown, TIntegrationConfiguration>;
954
936
  type DataSourceLocation = MeshLocationCore<DataSourceLocationValue, DataSourceLocationMetadata, DataSourceLocationValue, 'dataSource'>;
955
937
 
956
- type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = {
938
+ type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = CommonMetadata<{
957
939
  rootNode: Omit<RootComponentInstance, 'slots' | '_data'>;
958
940
  parameterConfiguration: TParamConfiguration;
959
941
  component: Omit<ComponentInstance, 'slots'>;
960
942
  componentDefinitions: Record<string, ComponentDefinition | undefined>;
961
943
  parameterDefinition: ComponentDefinitionParameter;
962
- /** Settings defined at the integration level (arbitrary type used on settings location) */
963
- settings: TIntegrationConfiguration;
964
- /** The Uniform project ID */
965
- projectId: string;
966
944
  /**
967
945
  * Current dynamic inputs that are configured on the composition (if any).
968
946
  * Use the <ParamTypeDynamicDataProvider> to wire up dynamic data in your parameter.
@@ -984,7 +962,7 @@ type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfig
984
962
  * Note that setValue() always sets the target language automatically.
985
963
  */
986
964
  targetLocale: string | undefined;
987
- };
965
+ }, TIntegrationConfiguration>;
988
966
  type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TParamSetValue = TParamValue, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeLocationMetadata<TParamConfiguration, TIntegrationConfiguration>, TParamSetValue, 'paramType'> & {
989
967
  /**
990
968
  * Opens a dialog on the Uniform platform to edit or select a dynamic token to connect to.
@@ -993,9 +971,7 @@ type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TPa
993
971
  editConnectedData: Awaited<ReturnType<typeof connectToParent>>['parent']['editConnectedData'];
994
972
  };
995
973
 
996
- type SettingsLocationMetadata = {
997
- projectId: string;
998
- };
974
+ type SettingsLocationMetadata = CommonMetadata;
999
975
  type SettingsLocation<TSettingsType> = MeshLocationCore<TSettingsType, SettingsLocationMetadata, TSettingsType, 'settings'>;
1000
976
 
1001
977
  /**
@@ -1126,6 +1102,22 @@ type EditConnectedDataResponse = {
1126
1102
  canceled: true;
1127
1103
  editorCancelledContext: EditConnectedDataResponseCancellationContext;
1128
1104
  };
1105
+ type UniformUser = {
1106
+ /** Permissions the user has as per Team Admin assigned, can be used to do conditional rendering */
1107
+ permissions: MeshLocationUserPermissions[];
1108
+ /** Permissions the user has as per Team Admin created and assigned, can be used to do conditional rendering */
1109
+ roles: {
1110
+ id: string;
1111
+ name: string;
1112
+ }[];
1113
+ /** Name of the user assigned by Team Admin. Unless your Mesh integration was given permissions to expose User Name - it is not available */
1114
+ name?: string;
1115
+ /** Email of the user used to sign in. Unless your Mesh integration was given permissions to expose User Name - it is not available */
1116
+ email?: string;
1117
+ /** Unique ID of the user */
1118
+ id: string;
1119
+ isAdmin: boolean;
1120
+ };
1129
1121
 
1130
1122
  type MeshSDKEventInterface = Awaited<ReturnType<typeof connectToParent>>['parent'] & {
1131
1123
  initialize: () => Promise<MeshContextData>;
@@ -1188,6 +1180,84 @@ interface MeshLocationCore<TValue = unknown, TMetadata = unknown, TSetValue = TV
1188
1180
  returnDialogValue: (value: unknown) => Promise<void>;
1189
1181
  };
1190
1182
  }
1183
+ /** Common metadata for all mesh locations */
1184
+ type CommonMetadata<ExtendedMetadata = unknown, TIntegrationConfiguration = unknown> = {
1185
+ /** The current Uniform user context. Contains name, email and context to check for permissions */
1186
+ user: UniformUser;
1187
+ /** Current Uniform Project ID */
1188
+ projectId: string;
1189
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
1190
+ settings: TIntegrationConfiguration;
1191
+ } & ExtendedMetadata;
1192
+ type MeshLocationUserPermissions =
1193
+ /** Uniform Context:Enrichments:Create */
1194
+ 'ENRICHMENTS_CREATE'
1195
+ /** Uniform Context:Enrichments:Update */
1196
+ | 'ENRICHMENTS_UPDATE'
1197
+ /** Uniform Context:Enrichments:Delete */
1198
+ | 'ENRICHMENTS_DELETE'
1199
+ /** Uniform Context:Intents & Audiences:Create */
1200
+ | 'INTENTS_CREATE'
1201
+ /** Uniform Context:Intents & Audiences:Update */
1202
+ | 'INTENTS_UPDATE'
1203
+ /** Uniform Context:Intents & Audiences:Delete */
1204
+ | 'INTENTS_DELETE'
1205
+ /** Uniform Context:Quirks:Create */
1206
+ | 'QUIRKS_CREATE'
1207
+ /** Uniform Context:Quirks:Update| */
1208
+ | 'QUIRKS_UPDATE'
1209
+ /** Uniform Context:Quirks:Delete */
1210
+ | 'QUIRKS_DELETE'
1211
+ /** Uniform Context:Signals:Create */
1212
+ | 'SIGNALS_CREATE'
1213
+ /** Uniform Context:Signals:Update */
1214
+ | 'SIGNALS_UPDATE'
1215
+ /** Uniform Context:Signals:Delete */
1216
+ | 'SIGNALS_DELETE'
1217
+ /** Uniform Context:Tests:Create */
1218
+ | 'TESTS_CREATE'
1219
+ /** Uniform Context:Tests:Update|Declare winners and close existing tests. */
1220
+ | 'TESTS_UPDATE'
1221
+ /** Uniform Context:Tests:Delete */
1222
+ | 'TESTS_DELETE'
1223
+ /** Uniform Context:Manifest:Read|Read the published manifest */
1224
+ | 'MANIFEST_READ'
1225
+ /** Uniform Context:Manifest:Publish|Publish the manifest */
1226
+ | 'MANIFEST_PUBLISH'
1227
+ /** Uniform Context:Read Drafts|Read all drafts and preview manifest */
1228
+ | 'MANIFEST_READ_DRAFT'
1229
+ /** Uniform Canvas:Project Map:Manage|Create, update, and delete Project Maps and nodes in Project Map trees. */
1230
+ | 'PROJECT_MAP_MANAGE'
1231
+ /** General:Read Project|See the project in the team dashboard. */
1232
+ | 'PROJECT_READ'
1233
+ /** Uniform Canvas:Redirects:Advanced|Grants access to advanced redirect features and options. */
1234
+ | 'REDIRECTS_ADVANCED'
1235
+ /** Uniform Canvas:Redirects:Create */
1236
+ | 'REDIRECTS_CREATE'
1237
+ /** Uniform Canvas:Redirects:Update */
1238
+ | 'REDIRECTS_UPDATE'
1239
+ /** Uniform Canvas:Redirects:Delete */
1240
+ | 'REDIRECTS_DELETE'
1241
+ /** Uniform Canvas:Data Sources:Manage|Create, update, and delete data sources. */
1242
+ | 'DATA_SOURCES_MANAGE'
1243
+ /** Uniform Canvas:Data Types:Manage|Create, update, and delete data types. */
1244
+ | 'DATA_TYPES_MANAGE'
1245
+ /** Uniform Canvas:Compositions:Create */
1246
+ | 'COMPOSITIONS_CREATE'
1247
+ /** Uniform Canvas:Compositions:Update */
1248
+ | 'COMPOSITIONS_WRITE'
1249
+ /** Uniform Canvas:Compositions:Delete */
1250
+ | 'COMPOSITIONS_DELETE'
1251
+ /** Uniform Canvas:Compositions:Read Published */
1252
+ | 'COMPOSITIONS_READ'
1253
+ /** Uniform Canvas:Compositions:Publish */
1254
+ | 'COMPOSITIONS_PUBLISH'
1255
+ /** Uniform Canvas::Read|Includes read access to all canvas assets */
1256
+ | 'COMPOSITIONS_READ_DRAFT'
1257
+ /** Uniform Canvas:Component Library:Manage|Create, update, and delete component library data */
1258
+ | 'COMPOSITIONS_MANAGE_SCHEMA'
1259
+ /** UTM Mapper:Read|Read UTM mapper configuration */
1260
+ | 'UTM_MAPPER_READ';
1191
1261
  /**
1192
1262
  * Known location types that can be passed to a mesh location
1193
1263
  */
@@ -1217,31 +1287,23 @@ type DynamicInput = {
1217
1287
  /** Record of dynamic inputs keyed by the input name */
1218
1288
  type DynamicInputs = Record<string, DynamicInput>;
1219
1289
 
1220
- type AIGenerateLocationMetadata<TIntegrationConfiguration = unknown> = {
1221
- /** Settings defined at the integration level (arbitrary type used on settings location) */
1222
- settings: TIntegrationConfiguration;
1223
- /** The Uniform project ID */
1224
- projectId: string;
1290
+ type AIGenerateLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1225
1291
  prompt: string;
1226
1292
  promptMetadata: Record<string, unknown>;
1227
1293
  /** Useful to differentiate AI Generate UI between text and image */
1228
1294
  promptOutputType: 'text' | 'image';
1229
- };
1230
- type PromptSettingsLocationMetadata<TIntegrationConfiguration = unknown> = {
1231
- settings: TIntegrationConfiguration;
1295
+ }, TIntegrationConfiguration>;
1296
+ type PromptSettingsLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1232
1297
  /** Useful to differentiate metadata settings between text and image generation */
1233
1298
  promptOutputType: 'text' | 'image';
1234
- };
1299
+ }, TIntegrationConfiguration>;
1235
1300
  type AIGenerateLocation<TType> = MeshLocationCore<TType, AIGenerateLocationMetadata, TType, 'aiGenerate'>;
1236
1301
  type AIPromptMetadataLocation = MeshLocationCore<Record<string, unknown>, PromptSettingsLocationMetadata, Record<string, unknown>, 'aiMetadata'>;
1237
1302
 
1238
- type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = {
1239
- /** Settings defined at the integration level (arbitrary type used on settings location) */
1240
- settings: TIntegrationConfiguration;
1303
+ type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = CommonMetadata<{
1241
1304
  /** The Uniform project ID */
1242
- projectId: string;
1243
1305
  componentDefinition: ComponentDefinition;
1244
- };
1306
+ }, TIntegrationConfiguration>;
1245
1307
  type ParamTypeConfigLocation<TParamValue = unknown, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeConfigLocationMetadata<TIntegrationConfiguration>, TParamValue, 'paramTypeConfig'>;
1246
1308
 
1247
1309
  interface SdkWindow {
@@ -1341,4 +1403,10 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
1341
1403
  autoResizingDisabled?: boolean;
1342
1404
  }): Promise<UniformMeshSDK | undefined>;
1343
1405
 
1344
- export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CloseDialogMessage, type CloseLocationDialogOptions, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshSDKEventInterface, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type ValidationResult, initializeUniformMeshSDK };
1406
+ declare const hasPermissions: (permissions: MeshLocationUserPermissions | MeshLocationUserPermissions[], user: UniformUser) => boolean;
1407
+ /**
1408
+ * Check if user has a role by both name and id
1409
+ */
1410
+ declare const hasRole: (role: string, user: UniformUser) => boolean;
1411
+
1412
+ export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshSDKEventInterface, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, hasPermissions, hasRole, initializeUniformMeshSDK };
package/dist/index.esm.js CHANGED
@@ -801,8 +801,26 @@ async function initializeUniformMeshSDK({
801
801
  return sdk;
802
802
  }
803
803
  }
804
+
805
+ // src/user.ts
806
+ var hasPermissions = (permissions, user) => {
807
+ if (user.isAdmin)
808
+ return true;
809
+ if (Array.isArray(permissions)) {
810
+ return permissions.every((permission) => user.permissions.includes(permission));
811
+ } else {
812
+ return user.permissions.includes(permissions);
813
+ }
814
+ };
815
+ var hasRole = (role, user) => {
816
+ if (user.isAdmin)
817
+ return true;
818
+ return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
819
+ };
804
820
  export {
805
821
  IntegrationDefinitionClient,
806
822
  IntegrationInstallationClient,
823
+ hasPermissions,
824
+ hasRole,
807
825
  initializeUniformMeshSDK
808
826
  };
package/dist/index.js CHANGED
@@ -45,6 +45,8 @@ var src_exports = {};
45
45
  __export(src_exports, {
46
46
  IntegrationDefinitionClient: () => IntegrationDefinitionClient,
47
47
  IntegrationInstallationClient: () => IntegrationInstallationClient,
48
+ hasPermissions: () => hasPermissions,
49
+ hasRole: () => hasRole,
48
50
  initializeUniformMeshSDK: () => initializeUniformMeshSDK
49
51
  });
50
52
  module.exports = __toCommonJS(src_exports);
@@ -838,9 +840,27 @@ async function initializeUniformMeshSDK({
838
840
  return sdk;
839
841
  }
840
842
  }
843
+
844
+ // src/user.ts
845
+ var hasPermissions = (permissions, user) => {
846
+ if (user.isAdmin)
847
+ return true;
848
+ if (Array.isArray(permissions)) {
849
+ return permissions.every((permission) => user.permissions.includes(permission));
850
+ } else {
851
+ return user.permissions.includes(permissions);
852
+ }
853
+ };
854
+ var hasRole = (role, user) => {
855
+ if (user.isAdmin)
856
+ return true;
857
+ return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
858
+ };
841
859
  // Annotate the CommonJS export names for ESM import in node:
842
860
  0 && (module.exports = {
843
861
  IntegrationDefinitionClient,
844
862
  IntegrationInstallationClient,
863
+ hasPermissions,
864
+ hasRole,
845
865
  initializeUniformMeshSDK
846
866
  });
package/dist/index.mjs CHANGED
@@ -801,8 +801,26 @@ async function initializeUniformMeshSDK({
801
801
  return sdk;
802
802
  }
803
803
  }
804
+
805
+ // src/user.ts
806
+ var hasPermissions = (permissions, user) => {
807
+ if (user.isAdmin)
808
+ return true;
809
+ if (Array.isArray(permissions)) {
810
+ return permissions.every((permission) => user.permissions.includes(permission));
811
+ } else {
812
+ return user.permissions.includes(permissions);
813
+ }
814
+ };
815
+ var hasRole = (role, user) => {
816
+ if (user.isAdmin)
817
+ return true;
818
+ return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
819
+ };
804
820
  export {
805
821
  IntegrationDefinitionClient,
806
822
  IntegrationInstallationClient,
823
+ hasPermissions,
824
+ hasRole,
807
825
  initializeUniformMeshSDK
808
826
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "19.114.0",
3
+ "version": "19.114.1-alpha.7+205e9240f9",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -33,14 +33,14 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@uniformdev/canvas": "19.114.0",
37
- "@uniformdev/context": "19.114.0",
38
- "@uniformdev/project-map": "19.114.0",
36
+ "@uniformdev/canvas": "19.114.1-alpha.7+205e9240f9",
37
+ "@uniformdev/context": "19.114.1-alpha.7+205e9240f9",
38
+ "@uniformdev/project-map": "19.114.1-alpha.7+205e9240f9",
39
39
  "imagesloaded": "^5.0.0",
40
40
  "mitt": "^3.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/imagesloaded": "^4.1.2"
44
44
  },
45
- "gitHead": "c9d4260a191785215cdca52c78f869be809f6e06"
45
+ "gitHead": "205e9240f95b7c75d2cdaefb5588c56b8c1e9368"
46
46
  }