@backstage/plugin-catalog-backend-module-msgraph 0.10.4-next.0 → 0.10.5-next.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage/plugin-catalog-backend-module-msgraph
2
2
 
3
+ ## 0.10.5-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-plugin-api@1.10.0-next.0
9
+ - @backstage/plugin-catalog-node@2.2.4-next.0
10
+
11
+ ## 0.10.4
12
+
13
+ ### Patch Changes
14
+
15
+ - 06bf22e: Configuring `userGroupMember.path` together with `user.filter` is now rejected with a configuration error, as the two options are mutually exclusive. This matches the existing validation for `userGroupMember.filter` and `userGroupMember.search`.
16
+ - Updated dependencies
17
+ - @backstage/backend-plugin-api@1.9.3
18
+ - @backstage/plugin-catalog-node@2.2.3
19
+
3
20
  ## 0.10.4-next.0
4
21
 
5
22
  ### Patch Changes
@@ -133,6 +133,11 @@ function readProviderConfig(id, config) {
133
133
  `userGroupMemberSearch cannot be specified when userFilter is defined.`
134
134
  );
135
135
  }
136
+ if (userFilter && userGroupMemberPath) {
137
+ throw new Error(
138
+ `userGroupMemberPath cannot be specified when userFilter is defined.`
139
+ );
140
+ }
136
141
  if (clientId && !clientSecret) {
137
142
  throw new Error(`clientSecret must be provided when clientId is defined.`);
138
143
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/microsoftGraph/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SchedulerServiceTaskScheduleDefinition,\n readSchedulerServiceTaskScheduleDefinitionFromConfig,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\n\nconst DEFAULT_PROVIDER_ID = 'default';\nconst DEFAULT_TARGET = 'https://graph.microsoft.com/v1.0';\n\n/**\n * The configuration parameters for a single Microsoft Graph provider.\n *\n * @public\n */\nexport type MicrosoftGraphProviderConfig = {\n /**\n * Identifier of the provider which will be used i.e. at the location key for ingested entities.\n */\n id: string;\n\n /**\n * The prefix of the target that this matches on, e.g.\n * \"https://graph.microsoft.com/v1.0\", with no trailing slash.\n */\n target: string;\n /**\n * The auth authority used.\n *\n * E.g. \"https://login.microsoftonline.com\"\n */\n authority?: string;\n /**\n * The tenant whose org data we are interested in.\n */\n tenantId: string;\n /**\n * The OAuth client ID to use for authenticating requests.\n * If specified, ClientSecret must also be specified\n */\n clientId?: string;\n /**\n * The OAuth client secret to use for authenticating requests.\n * If specified, ClientId must also be specified\n */\n clientSecret?: string;\n /**\n * The filter to apply to extract users. Disabled users\n * (`accountEnabled === false`) are always filtered out client-side\n * regardless of this setting.\n *\n * E.g. \"userType eq 'member'\"\n */\n userFilter?: string;\n /**\n * The fields to be fetched on query.\n *\n * E.g. [\"id\", \"displayName\", \"description\"]\n */\n userSelect?: string[];\n /**\n * The \"expand\" argument to apply to users.\n *\n * E.g. \"manager\".\n */\n userExpand?: string;\n\n /**\n * The path to the users endpoint. Defaults to \"/users\".\n *\n * E.g. \"/users\"\n */\n userPath?: string;\n /**\n * The filter to apply to extract users by groups memberships.\n *\n * E.g. \"displayName eq 'Backstage Users'\"\n */\n userGroupMemberFilter?: string;\n /**\n * The search criteria to apply to extract users by groups memberships.\n *\n * E.g. \"\\\"displayName:-team\\\"\" would only match groups which contain '-team'\n */\n userGroupMemberSearch?: string;\n\n /**\n * The path to the groups endpoint. Defaults to \"/groups\".\n *\n * E.g. \"/groups\"\n */\n userGroupMemberPath?: string;\n\n /**\n * The \"expand\" argument to apply to groups.\n *\n * E.g. \"member\".\n */\n groupExpand?: string;\n /**\n * The filter to apply to extract groups.\n *\n * E.g. \"securityEnabled eq false and mailEnabled eq true\"\n */\n groupFilter?: string;\n /**\n * The search criteria to apply to extract groups.\n *\n * E.g. \"\\\"displayName:-team\\\"\" would only match groups which contain '-team'\n */\n groupSearch?: string;\n\n /**\n * The fields to be fetched on query.\n *\n * E.g. [\"id\", \"displayName\", \"description\"]\n */\n groupSelect?: string[];\n\n /**\n * The path to the groups endpoint. Defaults to \"/groups\".\n *\n * E.g. \"/groups\"\n */\n groupPath?: string;\n\n /**\n * Whether to ingest groups that are members of the found/filtered/searched groups.\n * Default value is `false`.\n */\n groupIncludeSubGroups?: boolean;\n\n /**\n * By default, the Microsoft Graph API only provides the basic feature set\n * for querying. Certain features are limited to advanced query capabilities\n * (see https://docs.microsoft.com/en-us/graph/aad-advanced-queries)\n * and need to be enabled.\n *\n * Some features like `$expand` are not available for advanced queries, though.\n */\n queryMode?: 'basic' | 'advanced';\n\n /**\n * Set to false to not load user photos.\n * This can be useful for huge organizations.\n */\n loadUserPhotos?: boolean;\n\n /**\n * Schedule configuration for refresh tasks.\n */\n schedule?: SchedulerServiceTaskScheduleDefinition;\n};\n\n/**\n * Parses configuration.\n *\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n * @deprecated Replaced by not exported `readProviderConfigs` and kept for backwards compatibility only.\n */\nexport function readMicrosoftGraphConfig(\n config: Config,\n): MicrosoftGraphProviderConfig[] {\n const providers: MicrosoftGraphProviderConfig[] = [];\n const providerConfigs = config.getOptionalConfigArray('providers') ?? [];\n\n for (const providerConfig of providerConfigs) {\n const target = trimEnd(\n providerConfig.getOptionalString('target') ?? DEFAULT_TARGET,\n '/',\n );\n const authority = providerConfig.getOptionalString('authority');\n\n const tenantId = providerConfig.getString('tenantId');\n const clientId = providerConfig.getOptionalString('clientId');\n const clientSecret = providerConfig.getOptionalString('clientSecret');\n\n const userExpand = providerConfig.getOptionalString('userExpand');\n const userFilter = providerConfig.getOptionalString('userFilter');\n const userSelect = providerConfig.getOptionalStringArray('userSelect');\n const userGroupMemberFilter = providerConfig.getOptionalString(\n 'userGroupMemberFilter',\n );\n const userGroupMemberSearch = providerConfig.getOptionalString(\n 'userGroupMemberSearch',\n );\n const groupExpand = providerConfig.getOptionalString('groupExpand');\n const groupFilter = providerConfig.getOptionalString('groupFilter');\n const groupSearch = providerConfig.getOptionalString('groupSearch');\n\n if (userFilter && userGroupMemberFilter) {\n throw new Error(\n `userFilter and userGroupMemberFilter are mutually exclusive, only one can be specified.`,\n );\n }\n if (userFilter && userGroupMemberSearch) {\n throw new Error(\n `userGroupMemberSearch cannot be specified when userFilter is defined.`,\n );\n }\n\n const groupSelect = providerConfig.getOptionalStringArray('groupSelect');\n const queryMode = providerConfig.getOptionalString('queryMode');\n if (\n queryMode !== undefined &&\n queryMode !== 'basic' &&\n queryMode !== 'advanced'\n ) {\n throw new Error(`queryMode must be one of: basic, advanced`);\n }\n\n if (clientId && !clientSecret) {\n throw new Error(\n `clientSecret must be provided when clientId is defined.`,\n );\n }\n\n if (clientSecret && !clientId) {\n throw new Error(\n `clientId must be provided when clientSecret is defined.`,\n );\n }\n\n providers.push({\n id: target,\n target,\n authority,\n tenantId,\n clientId,\n clientSecret,\n userExpand,\n userFilter,\n userSelect,\n userGroupMemberFilter,\n userGroupMemberSearch,\n groupExpand,\n groupFilter,\n groupSearch,\n groupSelect,\n queryMode,\n });\n }\n\n return providers;\n}\n\n/**\n * Parses all configured providers.\n *\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n */\nexport function readProviderConfigs(\n config: Config,\n): MicrosoftGraphProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.microsoftGraphOrg',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('clientId')) {\n // simple/single config variant\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n const providerConfig = providersConfig.getConfig(id);\n\n return readProviderConfig(id, providerConfig);\n });\n}\n\n/**\n * Parses a single configured provider by id.\n *\n * @param id - the id of the provider to parse\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n */\nexport function readProviderConfig(\n id: string,\n config: Config,\n): MicrosoftGraphProviderConfig {\n const target = trimEnd(\n config.getOptionalString('target') ?? DEFAULT_TARGET,\n '/',\n );\n const authority = config.getOptionalString('authority');\n\n const tenantId = config.getString('tenantId');\n const clientId = config.getOptionalString('clientId');\n const clientSecret = config.getOptionalString('clientSecret');\n\n const userExpand = config.getOptionalString('user.expand');\n const userFilter = config.getOptionalString('user.filter');\n const userSelect = config.getOptionalStringArray('user.select');\n const userPath = config.getOptionalString('user.path') ?? 'users';\n const loadUserPhotos = config.getOptionalBoolean('user.loadPhotos');\n\n const groupExpand = config.getOptionalString('group.expand');\n const groupFilter = config.getOptionalString('group.filter');\n const groupSearch = config.getOptionalString('group.search');\n const groupSelect = config.getOptionalStringArray('group.select');\n const groupPath = config.getOptionalString('group.path') ?? 'groups';\n const groupIncludeSubGroups = config.getOptionalBoolean(\n 'group.includeSubGroups',\n );\n\n const queryMode = config.getOptionalString('queryMode');\n if (\n queryMode !== undefined &&\n queryMode !== 'basic' &&\n queryMode !== 'advanced'\n ) {\n throw new Error(`queryMode must be one of: basic, advanced`);\n }\n\n const userGroupMemberFilter = config.getOptionalString(\n 'userGroupMember.filter',\n );\n const userGroupMemberSearch = config.getOptionalString(\n 'userGroupMember.search',\n );\n const userGroupMemberPath = config.getOptionalString('userGroupMember.path');\n\n if (userFilter && userGroupMemberFilter) {\n throw new Error(\n `userFilter and userGroupMemberFilter are mutually exclusive, only one can be specified.`,\n );\n }\n if (userFilter && userGroupMemberSearch) {\n throw new Error(\n `userGroupMemberSearch cannot be specified when userFilter is defined.`,\n );\n }\n\n if (clientId && !clientSecret) {\n throw new Error(`clientSecret must be provided when clientId is defined.`);\n }\n\n if (clientSecret && !clientId) {\n throw new Error(`clientId must be provided when clientSecret is defined.`);\n }\n\n const schedule = config.has('schedule')\n ? readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config.getConfig('schedule'),\n )\n : undefined;\n\n return {\n id,\n target,\n authority,\n clientId,\n clientSecret,\n tenantId,\n userExpand,\n userFilter,\n userSelect,\n userPath,\n loadUserPhotos,\n groupExpand,\n groupFilter,\n groupSearch,\n groupSelect,\n groupPath,\n groupIncludeSubGroups,\n queryMode,\n userGroupMemberFilter,\n userGroupMemberSearch,\n userGroupMemberPath,\n schedule,\n };\n}\n"],"names":["trimEnd","readSchedulerServiceTaskScheduleDefinitionFromConfig"],"mappings":";;;;;AAuBA,MAAM,mBAAA,GAAsB,SAAA;AAC5B,MAAM,cAAA,GAAiB,kCAAA;AA0JhB,SAAS,yBACd,MAAA,EACgC;AAChC,EAAA,MAAM,YAA4C,EAAC;AACnD,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,sBAAA,CAAuB,WAAW,KAAK,EAAC;AAEvE,EAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC5C,IAAA,MAAM,MAAA,GAASA,cAAA;AAAA,MACb,cAAA,CAAe,iBAAA,CAAkB,QAAQ,CAAA,IAAK,cAAA;AAAA,MAC9C;AAAA,KACF;AACA,IAAA,MAAM,SAAA,GAAY,cAAA,CAAe,iBAAA,CAAkB,WAAW,CAAA;AAE9D,IAAA,MAAM,QAAA,GAAW,cAAA,CAAe,SAAA,CAAU,UAAU,CAAA;AACpD,IAAA,MAAM,QAAA,GAAW,cAAA,CAAe,iBAAA,CAAkB,UAAU,CAAA;AAC5D,IAAA,MAAM,YAAA,GAAe,cAAA,CAAe,iBAAA,CAAkB,cAAc,CAAA;AAEpE,IAAA,MAAM,UAAA,GAAa,cAAA,CAAe,iBAAA,CAAkB,YAAY,CAAA;AAChE,IAAA,MAAM,UAAA,GAAa,cAAA,CAAe,iBAAA,CAAkB,YAAY,CAAA;AAChE,IAAA,MAA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CAAO,iBAAA,CAAkB,sBAAsB,CAAA;AAE3E,EAAA,IAAI,cAAc,qBAAA,EAAuB;AACvC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,uFAAA;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,cAAc,qBAAA,EAAuB;AACvC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,qEAAA;AAAA,KACF;AAAA,EACF;AAEA,EAAA,IAAI,QAAA,IAAY,CAAC,YAAA,EAAc;AAC7B,IAAA,MAAM,IAAI,MAAM,CAAA,uDAAA,CAAyD,CAAA;AAAA,EAC3E;AAEA,EAAA,IAAI,YAAA,IAAgB,CAAC,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAI,MAAM,CAAA,uDAAA,CAAyD,CAAA;AAAA,EAC3E;AAEA,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,GAAA,CAAI,UAAU,CAAA,GAClCC,qEAAA;AAAA,IACE,MAAA,CAAO,UAAU,UAAU;AAAA,GAC7B,GACA,MAAA;AAEJ,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,qBAAA;AAAA,IACA,SAAA;AAAA,IACA,qBAAA;AAAA,IACA,qBAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/microsoftGraph/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SchedulerServiceTaskScheduleDefinition,\n readSchedulerServiceTaskScheduleDefinitionFromConfig,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\n\nconst DEFAULT_PROVIDER_ID = 'default';\nconst DEFAULT_TARGET = 'https://graph.microsoft.com/v1.0';\n\n/**\n * The configuration parameters for a single Microsoft Graph provider.\n *\n * @public\n */\nexport type MicrosoftGraphProviderConfig = {\n /**\n * Identifier of the provider which will be used i.e. at the location key for ingested entities.\n */\n id: string;\n\n /**\n * The prefix of the target that this matches on, e.g.\n * \"https://graph.microsoft.com/v1.0\", with no trailing slash.\n */\n target: string;\n /**\n * The auth authority used.\n *\n * E.g. \"https://login.microsoftonline.com\"\n */\n authority?: string;\n /**\n * The tenant whose org data we are interested in.\n */\n tenantId: string;\n /**\n * The OAuth client ID to use for authenticating requests.\n * If specified, ClientSecret must also be specified\n */\n clientId?: string;\n /**\n * The OAuth client secret to use for authenticating requests.\n * If specified, ClientId must also be specified\n */\n clientSecret?: string;\n /**\n * The filter to apply to extract users. Disabled users\n * (`accountEnabled === false`) are always filtered out client-side\n * regardless of this setting.\n *\n * E.g. \"userType eq 'member'\"\n */\n userFilter?: string;\n /**\n * The fields to be fetched on query.\n *\n * E.g. [\"id\", \"displayName\", \"description\"]\n */\n userSelect?: string[];\n /**\n * The \"expand\" argument to apply to users.\n *\n * E.g. \"manager\".\n */\n userExpand?: string;\n\n /**\n * The path to the users endpoint. Defaults to \"/users\".\n *\n * E.g. \"/users\"\n */\n userPath?: string;\n /**\n * The filter to apply to extract users by groups memberships.\n *\n * E.g. \"displayName eq 'Backstage Users'\"\n */\n userGroupMemberFilter?: string;\n /**\n * The search criteria to apply to extract users by groups memberships.\n *\n * E.g. \"\\\"displayName:-team\\\"\" would only match groups which contain '-team'\n */\n userGroupMemberSearch?: string;\n\n /**\n * The path to the groups endpoint. Defaults to \"/groups\".\n *\n * E.g. \"/groups\"\n */\n userGroupMemberPath?: string;\n\n /**\n * The \"expand\" argument to apply to groups.\n *\n * E.g. \"member\".\n */\n groupExpand?: string;\n /**\n * The filter to apply to extract groups.\n *\n * E.g. \"securityEnabled eq false and mailEnabled eq true\"\n */\n groupFilter?: string;\n /**\n * The search criteria to apply to extract groups.\n *\n * E.g. \"\\\"displayName:-team\\\"\" would only match groups which contain '-team'\n */\n groupSearch?: string;\n\n /**\n * The fields to be fetched on query.\n *\n * E.g. [\"id\", \"displayName\", \"description\"]\n */\n groupSelect?: string[];\n\n /**\n * The path to the groups endpoint. Defaults to \"/groups\".\n *\n * E.g. \"/groups\"\n */\n groupPath?: string;\n\n /**\n * Whether to ingest groups that are members of the found/filtered/searched groups.\n * Default value is `false`.\n */\n groupIncludeSubGroups?: boolean;\n\n /**\n * By default, the Microsoft Graph API only provides the basic feature set\n * for querying. Certain features are limited to advanced query capabilities\n * (see https://docs.microsoft.com/en-us/graph/aad-advanced-queries)\n * and need to be enabled.\n *\n * Some features like `$expand` are not available for advanced queries, though.\n */\n queryMode?: 'basic' | 'advanced';\n\n /**\n * Set to false to not load user photos.\n * This can be useful for huge organizations.\n */\n loadUserPhotos?: boolean;\n\n /**\n * Schedule configuration for refresh tasks.\n */\n schedule?: SchedulerServiceTaskScheduleDefinition;\n};\n\n/**\n * Parses configuration.\n *\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n * @deprecated Replaced by not exported `readProviderConfigs` and kept for backwards compatibility only.\n */\nexport function readMicrosoftGraphConfig(\n config: Config,\n): MicrosoftGraphProviderConfig[] {\n const providers: MicrosoftGraphProviderConfig[] = [];\n const providerConfigs = config.getOptionalConfigArray('providers') ?? [];\n\n for (const providerConfig of providerConfigs) {\n const target = trimEnd(\n providerConfig.getOptionalString('target') ?? DEFAULT_TARGET,\n '/',\n );\n const authority = providerConfig.getOptionalString('authority');\n\n const tenantId = providerConfig.getString('tenantId');\n const clientId = providerConfig.getOptionalString('clientId');\n const clientSecret = providerConfig.getOptionalString('clientSecret');\n\n const userExpand = providerConfig.getOptionalString('userExpand');\n const userFilter = providerConfig.getOptionalString('userFilter');\n const userSelect = providerConfig.getOptionalStringArray('userSelect');\n const userGroupMemberFilter = providerConfig.getOptionalString(\n 'userGroupMemberFilter',\n );\n const userGroupMemberSearch = providerConfig.getOptionalString(\n 'userGroupMemberSearch',\n );\n const groupExpand = providerConfig.getOptionalString('groupExpand');\n const groupFilter = providerConfig.getOptionalString('groupFilter');\n const groupSearch = providerConfig.getOptionalString('groupSearch');\n\n if (userFilter && userGroupMemberFilter) {\n throw new Error(\n `userFilter and userGroupMemberFilter are mutually exclusive, only one can be specified.`,\n );\n }\n if (userFilter && userGroupMemberSearch) {\n throw new Error(\n `userGroupMemberSearch cannot be specified when userFilter is defined.`,\n );\n }\n\n const groupSelect = providerConfig.getOptionalStringArray('groupSelect');\n const queryMode = providerConfig.getOptionalString('queryMode');\n if (\n queryMode !== undefined &&\n queryMode !== 'basic' &&\n queryMode !== 'advanced'\n ) {\n throw new Error(`queryMode must be one of: basic, advanced`);\n }\n\n if (clientId && !clientSecret) {\n throw new Error(\n `clientSecret must be provided when clientId is defined.`,\n );\n }\n\n if (clientSecret && !clientId) {\n throw new Error(\n `clientId must be provided when clientSecret is defined.`,\n );\n }\n\n providers.push({\n id: target,\n target,\n authority,\n tenantId,\n clientId,\n clientSecret,\n userExpand,\n userFilter,\n userSelect,\n userGroupMemberFilter,\n userGroupMemberSearch,\n groupExpand,\n groupFilter,\n groupSearch,\n groupSelect,\n queryMode,\n });\n }\n\n return providers;\n}\n\n/**\n * Parses all configured providers.\n *\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n */\nexport function readProviderConfigs(\n config: Config,\n): MicrosoftGraphProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.microsoftGraphOrg',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('clientId')) {\n // simple/single config variant\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n const providerConfig = providersConfig.getConfig(id);\n\n return readProviderConfig(id, providerConfig);\n });\n}\n\n/**\n * Parses a single configured provider by id.\n *\n * @param id - the id of the provider to parse\n * @param config - The root of the msgraph config hierarchy\n *\n * @public\n */\nexport function readProviderConfig(\n id: string,\n config: Config,\n): MicrosoftGraphProviderConfig {\n const target = trimEnd(\n config.getOptionalString('target') ?? DEFAULT_TARGET,\n '/',\n );\n const authority = config.getOptionalString('authority');\n\n const tenantId = config.getString('tenantId');\n const clientId = config.getOptionalString('clientId');\n const clientSecret = config.getOptionalString('clientSecret');\n\n const userExpand = config.getOptionalString('user.expand');\n const userFilter = config.getOptionalString('user.filter');\n const userSelect = config.getOptionalStringArray('user.select');\n const userPath = config.getOptionalString('user.path') ?? 'users';\n const loadUserPhotos = config.getOptionalBoolean('user.loadPhotos');\n\n const groupExpand = config.getOptionalString('group.expand');\n const groupFilter = config.getOptionalString('group.filter');\n const groupSearch = config.getOptionalString('group.search');\n const groupSelect = config.getOptionalStringArray('group.select');\n const groupPath = config.getOptionalString('group.path') ?? 'groups';\n const groupIncludeSubGroups = config.getOptionalBoolean(\n 'group.includeSubGroups',\n );\n\n const queryMode = config.getOptionalString('queryMode');\n if (\n queryMode !== undefined &&\n queryMode !== 'basic' &&\n queryMode !== 'advanced'\n ) {\n throw new Error(`queryMode must be one of: basic, advanced`);\n }\n\n const userGroupMemberFilter = config.getOptionalString(\n 'userGroupMember.filter',\n );\n const userGroupMemberSearch = config.getOptionalString(\n 'userGroupMember.search',\n );\n const userGroupMemberPath = config.getOptionalString('userGroupMember.path');\n\n if (userFilter && userGroupMemberFilter) {\n throw new Error(\n `userFilter and userGroupMemberFilter are mutually exclusive, only one can be specified.`,\n );\n }\n if (userFilter && userGroupMemberSearch) {\n throw new Error(\n `userGroupMemberSearch cannot be specified when userFilter is defined.`,\n );\n }\n if (userFilter && userGroupMemberPath) {\n throw new Error(\n `userGroupMemberPath cannot be specified when userFilter is defined.`,\n );\n }\n\n if (clientId && !clientSecret) {\n throw new Error(`clientSecret must be provided when clientId is defined.`);\n }\n\n if (clientSecret && !clientId) {\n throw new Error(`clientId must be provided when clientSecret is defined.`);\n }\n\n const schedule = config.has('schedule')\n ? readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config.getConfig('schedule'),\n )\n : undefined;\n\n return {\n id,\n target,\n authority,\n clientId,\n clientSecret,\n tenantId,\n userExpand,\n userFilter,\n userSelect,\n userPath,\n loadUserPhotos,\n groupExpand,\n groupFilter,\n groupSearch,\n groupSelect,\n groupPath,\n groupIncludeSubGroups,\n queryMode,\n userGroupMemberFilter,\n userGroupMemberSearch,\n userGroupMemberPath,\n schedule,\n };\n}\n"],"names":["trimEnd","readSchedulerServiceTaskScheduleDefinitionFromConfig"],"mappings":";;;;;AAuBA,MAAM,mBAAA,GAAsB,SAAA;AAC5B,MAAM,cAAA,GAAiB,kCAAA;AA0JhB,SAAS,yBACd,MAAA,EACgC;AAChC,EAAA,MAAM,YAA4C,EAAC;AACnD,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,sBAAA,CAAuB,WAAW,KAAK,EAAC;AAEvE,EAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC5C,IAAA,MAAM,MAAA,GAASA,cAAA;AAAA,MACb,cAAA,CAAe,iBAAA,CAAkB,QAAQ,CAAA,IAAK,cAAA;AAAA,MAC9C;AAAA,KACF;AACA,IAAA,MAAM,SAAA,GAAY,cAAA,CAAe,iBAAA,CAAkB,WAAW,CAAA;AAE9D,IAAA,MAAM,QAAA,GAAW,cAAA,CAAe,SAAA,CAAU,UAAU,CAAA;AACpD,IAAA,MAAM,QAAA,GAAW,cAAA,CAAe,iBAAA,CAAkB,UAAU,CAA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AAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,qBAAA;AAAA,IACA,SAAA;AAAA,IACA,qBAAA;AAAA,IACA,qBAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-msgraph",
3
- "version": "0.10.4-next.0",
3
+ "version": "0.10.5-next.0",
4
4
  "description": "A Backstage catalog backend module that helps integrate towards Microsoft Graph",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -66,21 +66,21 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@azure/identity": "^4.0.0",
69
- "@backstage/backend-plugin-api": "1.9.3-next.0",
69
+ "@backstage/backend-plugin-api": "1.10.0-next.0",
70
70
  "@backstage/catalog-model": "1.9.0",
71
71
  "@backstage/config": "1.3.8",
72
72
  "@backstage/plugin-catalog-common": "1.1.10",
73
- "@backstage/plugin-catalog-node": "2.2.3-next.0",
73
+ "@backstage/plugin-catalog-node": "2.2.4-next.0",
74
74
  "@microsoft/microsoft-graph-types": "^2.6.0",
75
75
  "lodash": "^4.17.21",
76
76
  "p-limit": "^3.0.2",
77
77
  "qs": "^6.15.2"
78
78
  },
79
79
  "devDependencies": {
80
- "@backstage/backend-test-utils": "1.11.5-next.0",
81
- "@backstage/cli": "0.36.4-next.0",
80
+ "@backstage/backend-test-utils": "1.11.6-next.0",
81
+ "@backstage/cli": "0.36.4",
82
82
  "@types/lodash": "^4.14.151",
83
- "msw": "^1.0.0"
83
+ "msw": "^2.0.0"
84
84
  },
85
85
  "configSchema": "config.schema.json"
86
86
  }