@eventcatalog/connectors 0.0.1 → 0.2.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/LICENSE +28 -0
- package/README.md +73 -14
- package/dist/index.d.mts +23 -6
- package/dist/index.d.ts +23 -6
- package/dist/index.js +341 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +339 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2026 boyney123
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Note: Source code within `packages/core/eventcatalog/src/enterprise/` is
|
|
26
|
+
licensed under the EventCatalog Commercial License and is NOT covered by the
|
|
27
|
+
MIT License above. See `packages/core/eventcatalog/src/enterprise/LICENSE`
|
|
28
|
+
for the full terms.
|
package/README.md
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Connectors for syncing external systems into EventCatalog.
|
|
4
4
|
|
|
5
|
+
## GitHub
|
|
6
|
+
|
|
5
7
|
```js
|
|
6
8
|
// eventcatalog.config.js
|
|
7
|
-
import { githubDirectory } from
|
|
9
|
+
import { githubDirectory } from "@eventcatalog/connectors";
|
|
8
10
|
|
|
9
11
|
export default {
|
|
10
12
|
directory: {
|
|
11
13
|
sources: [
|
|
12
14
|
githubDirectory({
|
|
13
|
-
org:
|
|
14
|
-
teams:
|
|
15
|
+
org: "acme",
|
|
16
|
+
teams: ["platform", "architecture"],
|
|
15
17
|
users: true,
|
|
16
18
|
token: process.env.GITHUB_TOKEN,
|
|
17
19
|
}),
|
|
@@ -20,25 +22,82 @@ export default {
|
|
|
20
22
|
};
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
## Microsoft Entra ID
|
|
26
|
+
|
|
27
|
+
Sync selected Microsoft Entra ID groups into EventCatalog teams, and sync their
|
|
28
|
+
direct user members into EventCatalog users.
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// eventcatalog.config.js
|
|
32
|
+
import { microsoftEntraDirectory } from "@eventcatalog/connectors";
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
directory: {
|
|
36
|
+
sources: [
|
|
37
|
+
microsoftEntraDirectory({
|
|
38
|
+
tenantId: process.env.AZURE_TENANT_ID,
|
|
39
|
+
clientId: process.env.AZURE_CLIENT_ID,
|
|
40
|
+
clientSecret: process.env.AZURE_CLIENT_SECRET,
|
|
41
|
+
groups: [
|
|
42
|
+
{
|
|
43
|
+
id: "00000000-0000-0000-0000-000000000000",
|
|
44
|
+
alias: "platform",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: "Architecture Guild",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The connector uses Microsoft Graph with the OAuth client credentials flow.
|
|
57
|
+
Create an app registration in Microsoft Entra ID, add read-only Microsoft Graph
|
|
58
|
+
application permissions for reading groups, users, and group members, grant
|
|
59
|
+
admin consent, then create a client secret for the build environment.
|
|
60
|
+
|
|
61
|
+
Groups can be configured by stable `id` or exact `displayName`. Group IDs are
|
|
62
|
+
recommended. If a `displayName` lookup finds no groups or multiple groups, the
|
|
63
|
+
connector fails and asks you to use the group ID.
|
|
64
|
+
|
|
65
|
+
Selected groups become EventCatalog teams. Team IDs use `alias` when provided,
|
|
66
|
+
otherwise they are slugified from the Entra group display name. Only direct user
|
|
67
|
+
members are synced. Disabled users are excluded by default; set
|
|
68
|
+
`includeDisabledUsers: true` to include them.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
microsoftEntraDirectory({
|
|
72
|
+
tenantId: process.env.AZURE_TENANT_ID,
|
|
73
|
+
clientId: process.env.AZURE_CLIENT_ID,
|
|
74
|
+
clientSecret: process.env.AZURE_CLIENT_SECRET,
|
|
75
|
+
groups: [{ id: "00000000-0000-0000-0000-000000000000" }],
|
|
76
|
+
includeDisabledUsers: true,
|
|
77
|
+
graphBaseUrl: "https://graph.microsoft.com/v1.0",
|
|
78
|
+
tokenUrl: "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token",
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
23
82
|
External directory sources require EventCatalog Scale when loaded by EventCatalog.
|
|
24
83
|
|
|
25
84
|
Custom directory sources can use the same contract:
|
|
26
85
|
|
|
27
86
|
```js
|
|
28
|
-
import { defineDirectorySource } from
|
|
87
|
+
import { defineDirectorySource } from "@eventcatalog/connectors";
|
|
29
88
|
|
|
30
89
|
export const companyDirectory = defineDirectorySource({
|
|
31
|
-
type:
|
|
32
|
-
name:
|
|
90
|
+
type: "directory",
|
|
91
|
+
name: "company-directory",
|
|
33
92
|
|
|
34
93
|
async loadTeams() {
|
|
35
94
|
return [
|
|
36
95
|
{
|
|
37
|
-
id:
|
|
38
|
-
name:
|
|
39
|
-
members: [
|
|
96
|
+
id: "platform",
|
|
97
|
+
name: "Platform",
|
|
98
|
+
members: ["alice"],
|
|
40
99
|
source: {
|
|
41
|
-
provider:
|
|
100
|
+
provider: "company-directory",
|
|
42
101
|
},
|
|
43
102
|
},
|
|
44
103
|
];
|
|
@@ -47,11 +106,11 @@ export const companyDirectory = defineDirectorySource({
|
|
|
47
106
|
async loadUsers() {
|
|
48
107
|
return [
|
|
49
108
|
{
|
|
50
|
-
id:
|
|
51
|
-
name:
|
|
52
|
-
avatarUrl:
|
|
109
|
+
id: "alice",
|
|
110
|
+
name: "Alice",
|
|
111
|
+
avatarUrl: "https://example.com/alice.png",
|
|
53
112
|
source: {
|
|
54
|
-
provider:
|
|
113
|
+
provider: "company-directory",
|
|
55
114
|
},
|
|
56
115
|
},
|
|
57
116
|
];
|
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ type DirectoryEntrySource = {
|
|
|
22
22
|
type DirectoryUser = {
|
|
23
23
|
id: string;
|
|
24
24
|
name: string;
|
|
25
|
-
avatarUrl
|
|
25
|
+
avatarUrl?: string;
|
|
26
26
|
role?: string;
|
|
27
27
|
email?: string;
|
|
28
28
|
markdown?: string;
|
|
@@ -53,11 +53,9 @@ type DirectoryTeam = {
|
|
|
53
53
|
* `.eventcatalog/store/directory.json` file for SDK/editor reads.
|
|
54
54
|
*/
|
|
55
55
|
type DirectorySource = {
|
|
56
|
-
type:
|
|
56
|
+
type: "directory";
|
|
57
57
|
/** Stable source identifier, usually `<provider>:<account-or-org>`. */
|
|
58
58
|
name: string;
|
|
59
|
-
/** Optional stable cache key for this source configuration. */
|
|
60
|
-
cacheKey?: string;
|
|
61
59
|
/** Load users from the external directory. */
|
|
62
60
|
loadUsers?: () => Promise<DirectoryUser[]>;
|
|
63
61
|
/** Load teams from the external directory. */
|
|
@@ -71,10 +69,29 @@ declare const defineDirectorySource: <TSource extends DirectorySource>(source: T
|
|
|
71
69
|
type GitHubDirectoryOptions = {
|
|
72
70
|
org: string;
|
|
73
71
|
token?: string;
|
|
74
|
-
teams
|
|
72
|
+
teams: string[];
|
|
75
73
|
users?: boolean;
|
|
76
74
|
baseUrl?: string;
|
|
77
75
|
};
|
|
78
76
|
declare const githubDirectory: (options: GitHubDirectoryOptions) => DirectorySource;
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
type MicrosoftEntraGroupInput = string | {
|
|
79
|
+
id: string;
|
|
80
|
+
alias?: string;
|
|
81
|
+
} | {
|
|
82
|
+
displayName: string;
|
|
83
|
+
alias?: string;
|
|
84
|
+
};
|
|
85
|
+
type MicrosoftEntraDirectoryOptions = {
|
|
86
|
+
tenantId: string;
|
|
87
|
+
clientId: string;
|
|
88
|
+
clientSecret: string;
|
|
89
|
+
groups: MicrosoftEntraGroupInput[];
|
|
90
|
+
users?: boolean;
|
|
91
|
+
includeDisabledUsers?: boolean;
|
|
92
|
+
graphBaseUrl?: string;
|
|
93
|
+
tokenUrl?: string;
|
|
94
|
+
};
|
|
95
|
+
declare const microsoftEntraDirectory: (options: MicrosoftEntraDirectoryOptions) => DirectorySource;
|
|
96
|
+
|
|
97
|
+
export { type DirectoryEntrySource, type DirectorySource, type DirectoryTeam, type DirectoryUser, defineDirectorySource, githubDirectory, microsoftEntraDirectory };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ type DirectoryEntrySource = {
|
|
|
22
22
|
type DirectoryUser = {
|
|
23
23
|
id: string;
|
|
24
24
|
name: string;
|
|
25
|
-
avatarUrl
|
|
25
|
+
avatarUrl?: string;
|
|
26
26
|
role?: string;
|
|
27
27
|
email?: string;
|
|
28
28
|
markdown?: string;
|
|
@@ -53,11 +53,9 @@ type DirectoryTeam = {
|
|
|
53
53
|
* `.eventcatalog/store/directory.json` file for SDK/editor reads.
|
|
54
54
|
*/
|
|
55
55
|
type DirectorySource = {
|
|
56
|
-
type:
|
|
56
|
+
type: "directory";
|
|
57
57
|
/** Stable source identifier, usually `<provider>:<account-or-org>`. */
|
|
58
58
|
name: string;
|
|
59
|
-
/** Optional stable cache key for this source configuration. */
|
|
60
|
-
cacheKey?: string;
|
|
61
59
|
/** Load users from the external directory. */
|
|
62
60
|
loadUsers?: () => Promise<DirectoryUser[]>;
|
|
63
61
|
/** Load teams from the external directory. */
|
|
@@ -71,10 +69,29 @@ declare const defineDirectorySource: <TSource extends DirectorySource>(source: T
|
|
|
71
69
|
type GitHubDirectoryOptions = {
|
|
72
70
|
org: string;
|
|
73
71
|
token?: string;
|
|
74
|
-
teams
|
|
72
|
+
teams: string[];
|
|
75
73
|
users?: boolean;
|
|
76
74
|
baseUrl?: string;
|
|
77
75
|
};
|
|
78
76
|
declare const githubDirectory: (options: GitHubDirectoryOptions) => DirectorySource;
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
type MicrosoftEntraGroupInput = string | {
|
|
79
|
+
id: string;
|
|
80
|
+
alias?: string;
|
|
81
|
+
} | {
|
|
82
|
+
displayName: string;
|
|
83
|
+
alias?: string;
|
|
84
|
+
};
|
|
85
|
+
type MicrosoftEntraDirectoryOptions = {
|
|
86
|
+
tenantId: string;
|
|
87
|
+
clientId: string;
|
|
88
|
+
clientSecret: string;
|
|
89
|
+
groups: MicrosoftEntraGroupInput[];
|
|
90
|
+
users?: boolean;
|
|
91
|
+
includeDisabledUsers?: boolean;
|
|
92
|
+
graphBaseUrl?: string;
|
|
93
|
+
tokenUrl?: string;
|
|
94
|
+
};
|
|
95
|
+
declare const microsoftEntraDirectory: (options: MicrosoftEntraDirectoryOptions) => DirectorySource;
|
|
96
|
+
|
|
97
|
+
export { type DirectoryEntrySource, type DirectorySource, type DirectoryTeam, type DirectoryUser, defineDirectorySource, githubDirectory, microsoftEntraDirectory };
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
defineDirectorySource: () => defineDirectorySource,
|
|
24
|
-
githubDirectory: () => githubDirectory
|
|
24
|
+
githubDirectory: () => githubDirectory,
|
|
25
|
+
microsoftEntraDirectory: () => microsoftEntraDirectory
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(src_exports);
|
|
27
28
|
|
|
@@ -31,6 +32,11 @@ var defineDirectorySource = (source) => source;
|
|
|
31
32
|
// src/github-directory.ts
|
|
32
33
|
var GITHUB_API_VERSION = "2022-11-28";
|
|
33
34
|
var githubDirectory = (options) => {
|
|
35
|
+
if (!Array.isArray(options.teams) || options.teams.length === 0) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
'GitHub directory connector requires at least one team slug. Set teams: ["platform"].'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
34
40
|
let cachedData;
|
|
35
41
|
const load = () => {
|
|
36
42
|
cachedData = cachedData ?? loadGitHubDirectory(options);
|
|
@@ -39,7 +45,6 @@ var githubDirectory = (options) => {
|
|
|
39
45
|
return defineDirectorySource({
|
|
40
46
|
type: "directory",
|
|
41
47
|
name: `github:${options.org}`,
|
|
42
|
-
cacheKey: createGitHubDirectoryCacheKey(options),
|
|
43
48
|
loadTeams: async () => {
|
|
44
49
|
const data = await load();
|
|
45
50
|
return data.teams;
|
|
@@ -50,12 +55,6 @@ var githubDirectory = (options) => {
|
|
|
50
55
|
}
|
|
51
56
|
});
|
|
52
57
|
};
|
|
53
|
-
var createGitHubDirectoryCacheKey = (options) => {
|
|
54
|
-
const teams = options.teams === true || options.teams === void 0 ? "all" : [...options.teams].sort().join(",");
|
|
55
|
-
const users = options.users !== false ? "true" : "false";
|
|
56
|
-
const baseUrl = options.baseUrl ?? "https://api.github.com";
|
|
57
|
-
return `github:${baseUrl}:${options.org}:teams=${teams}:users=${users}`;
|
|
58
|
-
};
|
|
59
58
|
var loadGitHubDirectory = async (options) => {
|
|
60
59
|
const teams = await loadGitHubTeams(options);
|
|
61
60
|
const shouldLoadUsers = options.users !== false;
|
|
@@ -80,9 +79,11 @@ var loadGitHubDirectory = async (options) => {
|
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
81
|
var loadGitHubTeams = async (options) => {
|
|
83
|
-
const teams =
|
|
84
|
-
const
|
|
85
|
-
|
|
82
|
+
const teams = [];
|
|
83
|
+
for (const teamSlug of options.teams) {
|
|
84
|
+
teams.push(await loadGitHubTeam(options, teamSlug));
|
|
85
|
+
}
|
|
86
|
+
return teams.map((team) => ({
|
|
86
87
|
id: team.slug,
|
|
87
88
|
name: team.name,
|
|
88
89
|
summary: team.description ?? void 0,
|
|
@@ -94,6 +95,16 @@ var loadGitHubTeams = async (options) => {
|
|
|
94
95
|
}
|
|
95
96
|
}));
|
|
96
97
|
};
|
|
98
|
+
var loadGitHubTeam = async (options, teamSlug) => {
|
|
99
|
+
const response = await githubRequest(
|
|
100
|
+
options,
|
|
101
|
+
buildGitHubUrl(
|
|
102
|
+
options,
|
|
103
|
+
`/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}`
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
return response.data;
|
|
107
|
+
};
|
|
97
108
|
var loadGitHubTeamMembers = async (options, teamSlug) => {
|
|
98
109
|
const members = await paginate(
|
|
99
110
|
options,
|
|
@@ -154,7 +165,9 @@ var githubRequest = async (options, url) => {
|
|
|
154
165
|
});
|
|
155
166
|
if (!response.ok) {
|
|
156
167
|
const message = await response.text();
|
|
157
|
-
throw new Error(
|
|
168
|
+
throw new Error(
|
|
169
|
+
`GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`
|
|
170
|
+
);
|
|
158
171
|
}
|
|
159
172
|
return {
|
|
160
173
|
data: await response.json(),
|
|
@@ -175,9 +188,324 @@ var getNextPageUrl = (linkHeader) => {
|
|
|
175
188
|
const match = nextLink?.match(/<([^>]+)>/);
|
|
176
189
|
return match?.[1];
|
|
177
190
|
};
|
|
191
|
+
|
|
192
|
+
// src/microsoft-entra-directory.ts
|
|
193
|
+
var DEFAULT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
|
|
194
|
+
var GRAPH_RETRY_ATTEMPTS = 3;
|
|
195
|
+
var GRAPH_SELECT_GROUP = "id,displayName,description,mail";
|
|
196
|
+
var GRAPH_SELECT_USER = "id,displayName,userPrincipalName,mail,jobTitle,accountEnabled";
|
|
197
|
+
var microsoftEntraDirectory = (options) => {
|
|
198
|
+
validateOptions(options);
|
|
199
|
+
let cachedData;
|
|
200
|
+
const load = () => {
|
|
201
|
+
cachedData = cachedData ?? loadMicrosoftEntraDirectory(options);
|
|
202
|
+
return cachedData;
|
|
203
|
+
};
|
|
204
|
+
return defineDirectorySource({
|
|
205
|
+
type: "directory",
|
|
206
|
+
name: `microsoft-entra:${options.tenantId}`,
|
|
207
|
+
loadTeams: async () => {
|
|
208
|
+
const data = await load();
|
|
209
|
+
return data.teams;
|
|
210
|
+
},
|
|
211
|
+
loadUsers: async () => {
|
|
212
|
+
const data = await load();
|
|
213
|
+
return data.users;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
var validateOptions = (options) => {
|
|
218
|
+
if (!options.tenantId) {
|
|
219
|
+
throw new Error("Microsoft Entra directory connector requires tenantId.");
|
|
220
|
+
}
|
|
221
|
+
if (!options.clientId) {
|
|
222
|
+
throw new Error("Microsoft Entra directory connector requires clientId.");
|
|
223
|
+
}
|
|
224
|
+
if (!options.clientSecret) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
"Microsoft Entra directory connector requires clientSecret."
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
if (!Array.isArray(options.groups) || options.groups.length === 0) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
'Microsoft Entra directory connector requires at least one group. Set groups: [{ id: "00000000-0000-0000-0000-000000000000" }].'
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var loadMicrosoftEntraDirectory = async (options) => {
|
|
236
|
+
const token = await getAccessToken(options);
|
|
237
|
+
const resolvedGroups = await loadMicrosoftEntraGroups(options, token);
|
|
238
|
+
const teams = mapMicrosoftEntraTeams(resolvedGroups);
|
|
239
|
+
const shouldLoadUsers = options.users !== false;
|
|
240
|
+
if (!shouldLoadUsers) {
|
|
241
|
+
return { teams, users: [] };
|
|
242
|
+
}
|
|
243
|
+
const usersById = /* @__PURE__ */ new Map();
|
|
244
|
+
const teamsWithMembers = [];
|
|
245
|
+
for (const team of teams) {
|
|
246
|
+
const members = await loadMicrosoftEntraGroupMembers(
|
|
247
|
+
options,
|
|
248
|
+
token,
|
|
249
|
+
String(team.source?.id ?? team.id)
|
|
250
|
+
);
|
|
251
|
+
for (const member of members) {
|
|
252
|
+
usersById.set(member.id, member);
|
|
253
|
+
}
|
|
254
|
+
teamsWithMembers.push({
|
|
255
|
+
...team,
|
|
256
|
+
members: members.map((member) => member.id)
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
teams: teamsWithMembers,
|
|
261
|
+
users: Array.from(usersById.values())
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
var loadMicrosoftEntraGroups = async (options, token) => {
|
|
265
|
+
const resolvedGroups = [];
|
|
266
|
+
for (const groupInput of options.groups) {
|
|
267
|
+
resolvedGroups.push(
|
|
268
|
+
await resolveMicrosoftEntraGroup(options, token, groupInput)
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
assertUniqueTeamIds(resolvedGroups);
|
|
272
|
+
return resolvedGroups;
|
|
273
|
+
};
|
|
274
|
+
var resolveMicrosoftEntraGroup = async (options, token, groupInput) => {
|
|
275
|
+
if (typeof groupInput === "string") {
|
|
276
|
+
return {
|
|
277
|
+
group: await loadMicrosoftEntraGroupById(options, token, groupInput)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if ("id" in groupInput) {
|
|
281
|
+
return {
|
|
282
|
+
group: await loadMicrosoftEntraGroupById(options, token, groupInput.id),
|
|
283
|
+
alias: groupInput.alias
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
group: await loadMicrosoftEntraGroupByDisplayName(
|
|
288
|
+
options,
|
|
289
|
+
token,
|
|
290
|
+
groupInput.displayName
|
|
291
|
+
),
|
|
292
|
+
alias: groupInput.alias
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
var loadMicrosoftEntraGroupById = async (options, token, groupId) => {
|
|
296
|
+
return microsoftGraphRequest(
|
|
297
|
+
options,
|
|
298
|
+
token,
|
|
299
|
+
buildMicrosoftGraphUrl(options, `/groups/${encodeURIComponent(groupId)}`, {
|
|
300
|
+
$select: GRAPH_SELECT_GROUP
|
|
301
|
+
})
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
var loadMicrosoftEntraGroupByDisplayName = async (options, token, displayName) => {
|
|
305
|
+
const groups = await paginate2(
|
|
306
|
+
options,
|
|
307
|
+
token,
|
|
308
|
+
buildMicrosoftGraphUrl(options, "/groups", {
|
|
309
|
+
$filter: `displayName eq '${escapeODataString(displayName)}'`,
|
|
310
|
+
$select: GRAPH_SELECT_GROUP
|
|
311
|
+
})
|
|
312
|
+
);
|
|
313
|
+
if (groups.length === 0) {
|
|
314
|
+
throw new Error(
|
|
315
|
+
`Microsoft Entra directory connector could not find a group with displayName "${displayName}". Use the group id instead.`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
if (groups.length > 1) {
|
|
319
|
+
throw new Error(
|
|
320
|
+
`Microsoft Entra directory connector found ${groups.length} groups with displayName "${displayName}". Use the group id instead.`
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
return groups[0];
|
|
324
|
+
};
|
|
325
|
+
var mapMicrosoftEntraTeams = (groups) => {
|
|
326
|
+
return groups.map(({ group, alias }) => {
|
|
327
|
+
const displayName = group.displayName ?? group.id;
|
|
328
|
+
return {
|
|
329
|
+
id: alias ?? slugify(displayName),
|
|
330
|
+
name: displayName,
|
|
331
|
+
summary: group.description ?? void 0,
|
|
332
|
+
email: group.mail ?? void 0,
|
|
333
|
+
markdown: createMicrosoftEntraSyncedMarkdown("team"),
|
|
334
|
+
source: {
|
|
335
|
+
provider: "microsoft-entra",
|
|
336
|
+
id: group.id
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
var loadMicrosoftEntraGroupMembers = async (options, token, groupId) => {
|
|
342
|
+
const users = await paginate2(
|
|
343
|
+
options,
|
|
344
|
+
token,
|
|
345
|
+
buildMicrosoftGraphUrl(
|
|
346
|
+
options,
|
|
347
|
+
`/groups/${encodeURIComponent(groupId)}/members/microsoft.graph.user`,
|
|
348
|
+
{
|
|
349
|
+
$select: GRAPH_SELECT_USER
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
);
|
|
353
|
+
return users.filter(
|
|
354
|
+
(user) => options.includeDisabledUsers || user.accountEnabled !== false
|
|
355
|
+
).map(mapMicrosoftEntraUser);
|
|
356
|
+
};
|
|
357
|
+
var mapMicrosoftEntraUser = (user) => {
|
|
358
|
+
const userPrincipalName = user.userPrincipalName ?? void 0;
|
|
359
|
+
const email = user.mail ?? userPrincipalName;
|
|
360
|
+
const id = getMicrosoftEntraUserId(user);
|
|
361
|
+
const name = user.displayName ?? userPrincipalName ?? user.id;
|
|
362
|
+
return {
|
|
363
|
+
id,
|
|
364
|
+
name,
|
|
365
|
+
email,
|
|
366
|
+
role: user.jobTitle ?? void 0,
|
|
367
|
+
markdown: createMicrosoftEntraSyncedMarkdown("user"),
|
|
368
|
+
source: {
|
|
369
|
+
provider: "microsoft-entra",
|
|
370
|
+
id: user.id
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
var getMicrosoftEntraUserId = (user) => {
|
|
375
|
+
if (user.mail) return user.mail.toLowerCase();
|
|
376
|
+
if (user.userPrincipalName)
|
|
377
|
+
return normalizeMicrosoftEntraUserPrincipalName(user.userPrincipalName);
|
|
378
|
+
return user.id;
|
|
379
|
+
};
|
|
380
|
+
var normalizeMicrosoftEntraUserPrincipalName = (userPrincipalName) => {
|
|
381
|
+
const guestUserMatch = userPrincipalName.match(/^(.+)#EXT#@.+$/i);
|
|
382
|
+
if (!guestUserMatch) return userPrincipalName.toLowerCase();
|
|
383
|
+
const externalUserName = guestUserMatch[1];
|
|
384
|
+
const lastUnderscoreIndex = externalUserName.lastIndexOf("_");
|
|
385
|
+
if (lastUnderscoreIndex === -1) return externalUserName.toLowerCase();
|
|
386
|
+
return `${externalUserName.slice(0, lastUnderscoreIndex)}@${externalUserName.slice(lastUnderscoreIndex + 1)}`.toLowerCase();
|
|
387
|
+
};
|
|
388
|
+
var createMicrosoftEntraSyncedMarkdown = (type) => {
|
|
389
|
+
if (type === "team") {
|
|
390
|
+
return [
|
|
391
|
+
":::note",
|
|
392
|
+
"This team is synced from Microsoft Entra ID and is read-only in EventCatalog.",
|
|
393
|
+
"",
|
|
394
|
+
"Manage the team and its members in Microsoft Entra ID.",
|
|
395
|
+
":::"
|
|
396
|
+
].join("\n");
|
|
397
|
+
}
|
|
398
|
+
return [
|
|
399
|
+
":::note",
|
|
400
|
+
"This user is synced from Microsoft Entra ID and is read-only in EventCatalog.",
|
|
401
|
+
"",
|
|
402
|
+
"Manage profile details and team membership in Microsoft Entra ID.",
|
|
403
|
+
":::"
|
|
404
|
+
].join("\n");
|
|
405
|
+
};
|
|
406
|
+
var getAccessToken = async (options) => {
|
|
407
|
+
const tokenUrl = options.tokenUrl ?? `https://login.microsoftonline.com/${encodeURIComponent(options.tenantId)}/oauth2/v2.0/token`;
|
|
408
|
+
const body = new URLSearchParams({
|
|
409
|
+
client_id: options.clientId,
|
|
410
|
+
client_secret: options.clientSecret,
|
|
411
|
+
grant_type: "client_credentials",
|
|
412
|
+
scope: getMicrosoftGraphScope(options)
|
|
413
|
+
});
|
|
414
|
+
const response = await fetch(tokenUrl, {
|
|
415
|
+
method: "POST",
|
|
416
|
+
headers: {
|
|
417
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
418
|
+
"user-agent": "@eventcatalog/connectors"
|
|
419
|
+
},
|
|
420
|
+
body
|
|
421
|
+
});
|
|
422
|
+
if (!response.ok) {
|
|
423
|
+
const message = await response.text();
|
|
424
|
+
throw new Error(
|
|
425
|
+
`Microsoft Entra directory connector failed to get an access token (${response.status} ${response.statusText}): ${message}`
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
const data = await response.json();
|
|
429
|
+
if (!data.access_token) {
|
|
430
|
+
throw new Error(
|
|
431
|
+
"Microsoft Entra directory connector failed to get an access token: response did not include access_token."
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
return data.access_token;
|
|
435
|
+
};
|
|
436
|
+
var getMicrosoftGraphScope = (options) => {
|
|
437
|
+
const graphBaseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;
|
|
438
|
+
return `${new URL(graphBaseUrl).origin}/.default`;
|
|
439
|
+
};
|
|
440
|
+
var microsoftGraphRequest = async (options, token, url, attempt = 0) => {
|
|
441
|
+
const response = await fetch(url, {
|
|
442
|
+
headers: {
|
|
443
|
+
accept: "application/json",
|
|
444
|
+
authorization: `Bearer ${token}`,
|
|
445
|
+
ConsistencyLevel: "eventual",
|
|
446
|
+
"user-agent": "@eventcatalog/connectors"
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
if (response.status === 429 && attempt < GRAPH_RETRY_ATTEMPTS) {
|
|
450
|
+
await waitForRetry(response.headers.get("retry-after"));
|
|
451
|
+
return microsoftGraphRequest(options, token, url, attempt + 1);
|
|
452
|
+
}
|
|
453
|
+
if (!response.ok) {
|
|
454
|
+
const message = await response.text();
|
|
455
|
+
throw new Error(
|
|
456
|
+
`Microsoft Entra directory connector failed (${response.status} ${response.statusText}): ${message}`
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
return await response.json();
|
|
460
|
+
};
|
|
461
|
+
var paginate2 = async (options, token, url) => {
|
|
462
|
+
const results = [];
|
|
463
|
+
let nextUrl = url;
|
|
464
|
+
while (nextUrl) {
|
|
465
|
+
const response = await microsoftGraphRequest(options, token, nextUrl);
|
|
466
|
+
results.push(...response.value ?? []);
|
|
467
|
+
nextUrl = response["@odata.nextLink"];
|
|
468
|
+
}
|
|
469
|
+
return results;
|
|
470
|
+
};
|
|
471
|
+
var buildMicrosoftGraphUrl = (options, pathname, query) => {
|
|
472
|
+
const baseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;
|
|
473
|
+
const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
474
|
+
const normalizedPathname = pathname.replace(/^\//u, "");
|
|
475
|
+
const url = new URL(normalizedPathname, normalizedBaseUrl);
|
|
476
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
477
|
+
url.searchParams.set(key, value);
|
|
478
|
+
}
|
|
479
|
+
return url.toString();
|
|
480
|
+
};
|
|
481
|
+
var assertUniqueTeamIds = (groups) => {
|
|
482
|
+
const teamIds = /* @__PURE__ */ new Map();
|
|
483
|
+
for (const { group, alias } of groups) {
|
|
484
|
+
const displayName = group.displayName ?? group.id;
|
|
485
|
+
const teamId = alias ?? slugify(displayName);
|
|
486
|
+
const existingGroupId = teamIds.get(teamId);
|
|
487
|
+
if (existingGroupId) {
|
|
488
|
+
throw new Error(
|
|
489
|
+
`Microsoft Entra directory connector resolved duplicate team id "${teamId}" from groups "${existingGroupId}" and "${group.id}". Set alias for one of the groups.`
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
teamIds.set(teamId, group.id);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
var slugify = (value) => {
|
|
496
|
+
const slug = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
497
|
+
return slug || value;
|
|
498
|
+
};
|
|
499
|
+
var escapeODataString = (value) => value.replace(/'/g, "''");
|
|
500
|
+
var waitForRetry = async (retryAfter) => {
|
|
501
|
+
const retryAfterSeconds = retryAfter ? Number(retryAfter) : 1;
|
|
502
|
+
const delayMs = Number.isFinite(retryAfterSeconds) ? Math.max(retryAfterSeconds, 0) * 1e3 : 1e3;
|
|
503
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
504
|
+
};
|
|
178
505
|
// Annotate the CommonJS export names for ESM import in node:
|
|
179
506
|
0 && (module.exports = {
|
|
180
507
|
defineDirectorySource,
|
|
181
|
-
githubDirectory
|
|
508
|
+
githubDirectory,
|
|
509
|
+
microsoftEntraDirectory
|
|
182
510
|
});
|
|
183
511
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/github-directory.ts"],"sourcesContent":["export { githubDirectory } from './github-directory';\nexport { defineDirectorySource } from './types';\nexport type { DirectoryEntrySource, DirectorySource, DirectoryTeam, DirectoryUser } from './types';\n","/**\n * Describes where a generated directory entry came from.\n *\n * EventCatalog uses the provider to show source badges and to treat generated\n * resources as externally managed.\n */\nexport type DirectoryEntrySource = {\n /** Provider identifier, for example `github`, `okta`, or `ldap`. */\n provider: string;\n /** Optional provider-specific identifier for the external resource. */\n id?: string;\n /** Optional URL back to the resource in the external provider. */\n url?: string;\n [key: string]: unknown;\n};\n\n/**\n * User returned by a directory source.\n *\n * Directory users are synced as read-only EventCatalog users and can be\n * referenced by teams through their `id`.\n */\nexport type DirectoryUser = {\n id: string;\n name: string;\n avatarUrl: string;\n role?: string;\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Team returned by a directory source.\n *\n * Directory teams are synced as read-only EventCatalog teams.\n */\nexport type DirectoryTeam = {\n id: string;\n name: string;\n summary?: string;\n /** User IDs for members of this team. */\n members?: string[];\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Loads users and/or teams from an external directory provider.\n *\n * EventCatalog calls these loaders during content sync, writes the returned\n * entries into Astro collections, and mirrors them into the generated\n * `.eventcatalog/store/directory.json` file for SDK/editor reads.\n */\nexport type DirectorySource = {\n type: 'directory';\n /** Stable source identifier, usually `<provider>:<account-or-org>`. */\n name: string;\n /** Optional stable cache key for this source configuration. */\n cacheKey?: string;\n /** Load users from the external directory. */\n loadUsers?: () => Promise<DirectoryUser[]>;\n /** Load teams from the external directory. */\n loadTeams?: () => Promise<DirectoryTeam[]>;\n};\n\n/**\n * Defines a custom directory source with type inference for connector authors.\n */\nexport const defineDirectorySource = <TSource extends DirectorySource>(source: TSource) => source;\n","import { defineDirectorySource, type DirectorySource, type DirectoryTeam, type DirectoryUser } from './types';\n\ntype GitHubDirectoryOptions = {\n org: string;\n token?: string;\n teams?: true | string[];\n users?: boolean;\n baseUrl?: string;\n};\n\ntype GitHubTeam = {\n id: number;\n name: string;\n slug: string;\n description: string | null;\n html_url: string;\n};\n\ntype GitHubUser = {\n id: number;\n login: string;\n avatar_url: string;\n html_url: string;\n};\n\ntype GitHubDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\nconst GITHUB_API_VERSION = '2022-11-28';\n\nexport const githubDirectory = (options: GitHubDirectoryOptions): DirectorySource => {\n let cachedData: Promise<GitHubDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadGitHubDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: 'directory',\n name: `github:${options.org}`,\n cacheKey: createGitHubDirectoryCacheKey(options),\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst createGitHubDirectoryCacheKey = (options: GitHubDirectoryOptions) => {\n const teams = options.teams === true || options.teams === undefined ? 'all' : [...options.teams].sort().join(',');\n const users = options.users !== false ? 'true' : 'false';\n const baseUrl = options.baseUrl ?? 'https://api.github.com';\n\n return `github:${baseUrl}:${options.org}:teams=${teams}:users=${users}`;\n};\n\nconst loadGitHubDirectory = async (options: GitHubDirectoryOptions): Promise<GitHubDirectoryData> => {\n const teams = await loadGitHubTeams(options);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadGitHubTeamMembers(options, team.id);\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadGitHubTeams = async (options: GitHubDirectoryOptions): Promise<DirectoryTeam[]> => {\n const teams = await paginate<GitHubTeam>(options, `/orgs/${encodeURIComponent(options.org)}/teams`);\n const configuredTeams = options.teams === undefined || options.teams === true ? undefined : new Set(options.teams);\n\n return teams\n .filter((team) => !configuredTeams || configuredTeams.has(team.slug))\n .map((team) => ({\n id: team.slug,\n name: team.name,\n summary: team.description ?? undefined,\n markdown: createGitHubSyncedMarkdown('team', team.html_url),\n source: {\n provider: 'github',\n id: String(team.id),\n url: team.html_url,\n },\n }));\n};\n\nconst loadGitHubTeamMembers = async (options: GitHubDirectoryOptions, teamSlug: string): Promise<DirectoryUser[]> => {\n const members = await paginate<GitHubUser>(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}/members`\n );\n\n return members.map((member) => ({\n id: member.login,\n name: member.login,\n avatarUrl: member.avatar_url,\n markdown: createGitHubSyncedMarkdown('user', member.html_url),\n source: {\n provider: 'github',\n id: String(member.id),\n url: member.html_url,\n },\n }));\n};\n\nconst createGitHubSyncedMarkdown = (type: 'team' | 'user', url: string) => {\n if (type === 'team') {\n return [\n ':::note',\n 'This team is synced from GitHub and is read-only in EventCatalog.',\n '',\n 'Manage the team and its members in GitHub.',\n '',\n `[View team on GitHub](${url})`,\n ':::',\n ].join('\\n');\n }\n\n return [\n ':::note',\n 'This user is synced from GitHub and is read-only in EventCatalog.',\n '',\n 'Manage profile details and team membership in GitHub.',\n '',\n `[View user on GitHub](${url})`,\n ':::',\n ].join('\\n');\n};\n\nconst paginate = async <T>(options: GitHubDirectoryOptions, pathname: string): Promise<T[]> => {\n const results: T[] = [];\n let url: string | undefined = buildGitHubUrl(options, pathname);\n\n while (url) {\n const response = await githubRequest<T[]>(options, url);\n results.push(...response.data);\n url = getNextPageUrl(response.headers.get('link'));\n }\n\n return results;\n};\n\nconst githubRequest = async <T>(\n options: GitHubDirectoryOptions,\n url: string\n): Promise<{ data: T; headers: Headers }> => {\n const response = await fetch(url, {\n headers: {\n accept: 'application/vnd.github+json',\n 'x-github-api-version': GITHUB_API_VERSION,\n 'user-agent': '@eventcatalog/connectors',\n ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(`GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`);\n }\n\n return {\n data: (await response.json()) as T,\n headers: response.headers,\n };\n};\n\nconst buildGitHubUrl = (options: GitHubDirectoryOptions, pathname: string) => {\n const baseUrl = options.baseUrl ?? 'https://api.github.com';\n const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, '');\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n url.searchParams.set('per_page', '100');\n return url.toString();\n};\n\nconst getNextPageUrl = (linkHeader: string | null) => {\n if (!linkHeader) return undefined;\n\n const nextLink = linkHeader.split(',').find((link) => link.includes('rel=\"next\"'));\n const match = nextLink?.match(/<([^>]+)>/);\n\n return match?.[1];\n};\n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,WAAW;AACnC,QAAM,oBAAoB,QAAQ,SAAS,GAAG,IAAI,UAAU,GAAG,OAAO;AACtE,QAAM,qBAAqB,SAAS,QAAQ,QAAQ,EAAE;AACtD,QAAM,MAAM,IAAI,IAAI,oBAAoB,iBAAiB;AACzD,MAAI,aAAa,IAAI,YAAY,KAAK;AACtC,SAAO,IAAI,SAAS;AACtB;AAEA,IAAM,iBAAiB,CAAC,eAA8B;AACpD,MAAI,CAAC,WAAY,QAAO;AAExB,QAAM,WAAW,WAAW,MAAM,GAAG,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,YAAY,CAAC;AACjF,QAAM,QAAQ,UAAU,MAAM,WAAW;AAEzC,SAAO,QAAQ,CAAC;AAClB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/github-directory.ts","../src/microsoft-entra-directory.ts"],"sourcesContent":["export { githubDirectory } from \"./github-directory\";\nexport { microsoftEntraDirectory } from \"./microsoft-entra-directory\";\nexport { defineDirectorySource } from \"./types\";\nexport type {\n DirectoryEntrySource,\n DirectorySource,\n DirectoryTeam,\n DirectoryUser,\n} from \"./types\";\n","/**\n * Describes where a generated directory entry came from.\n *\n * EventCatalog uses the provider to show source badges and to treat generated\n * resources as externally managed.\n */\nexport type DirectoryEntrySource = {\n /** Provider identifier, for example `github`, `okta`, or `ldap`. */\n provider: string;\n /** Optional provider-specific identifier for the external resource. */\n id?: string;\n /** Optional URL back to the resource in the external provider. */\n url?: string;\n [key: string]: unknown;\n};\n\n/**\n * User returned by a directory source.\n *\n * Directory users are synced as read-only EventCatalog users and can be\n * referenced by teams through their `id`.\n */\nexport type DirectoryUser = {\n id: string;\n name: string;\n avatarUrl?: string;\n role?: string;\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Team returned by a directory source.\n *\n * Directory teams are synced as read-only EventCatalog teams.\n */\nexport type DirectoryTeam = {\n id: string;\n name: string;\n summary?: string;\n /** User IDs for members of this team. */\n members?: string[];\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Loads users and/or teams from an external directory provider.\n *\n * EventCatalog calls these loaders during content sync, writes the returned\n * entries into Astro collections, and mirrors them into the generated\n * `.eventcatalog/store/directory.json` file for SDK/editor reads.\n */\nexport type DirectorySource = {\n type: \"directory\";\n /** Stable source identifier, usually `<provider>:<account-or-org>`. */\n name: string;\n /** Load users from the external directory. */\n loadUsers?: () => Promise<DirectoryUser[]>;\n /** Load teams from the external directory. */\n loadTeams?: () => Promise<DirectoryTeam[]>;\n};\n\n/**\n * Defines a custom directory source with type inference for connector authors.\n */\nexport const defineDirectorySource = <TSource extends DirectorySource>(\n source: TSource,\n) => source;\n","import {\n defineDirectorySource,\n type DirectorySource,\n type DirectoryTeam,\n type DirectoryUser,\n} from \"./types\";\n\ntype GitHubDirectoryOptions = {\n org: string;\n token?: string;\n teams: string[];\n users?: boolean;\n baseUrl?: string;\n};\n\ntype GitHubTeam = {\n id: number;\n name: string;\n slug: string;\n description: string | null;\n html_url: string;\n};\n\ntype GitHubUser = {\n id: number;\n login: string;\n avatar_url: string;\n html_url: string;\n};\n\ntype GitHubDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\nconst GITHUB_API_VERSION = \"2022-11-28\";\n\nexport const githubDirectory = (\n options: GitHubDirectoryOptions,\n): DirectorySource => {\n if (!Array.isArray(options.teams) || options.teams.length === 0) {\n throw new Error(\n 'GitHub directory connector requires at least one team slug. Set teams: [\"platform\"].',\n );\n }\n\n let cachedData: Promise<GitHubDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadGitHubDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: \"directory\",\n name: `github:${options.org}`,\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst loadGitHubDirectory = async (\n options: GitHubDirectoryOptions,\n): Promise<GitHubDirectoryData> => {\n const teams = await loadGitHubTeams(options);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadGitHubTeamMembers(options, team.id);\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadGitHubTeams = async (\n options: GitHubDirectoryOptions,\n): Promise<DirectoryTeam[]> => {\n const teams: GitHubTeam[] = [];\n\n for (const teamSlug of options.teams) {\n teams.push(await loadGitHubTeam(options, teamSlug));\n }\n\n return teams.map((team) => ({\n id: team.slug,\n name: team.name,\n summary: team.description ?? undefined,\n markdown: createGitHubSyncedMarkdown(\"team\", team.html_url),\n source: {\n provider: \"github\",\n id: String(team.id),\n url: team.html_url,\n },\n }));\n};\n\nconst loadGitHubTeam = async (\n options: GitHubDirectoryOptions,\n teamSlug: string,\n) => {\n const response = await githubRequest<GitHubTeam>(\n options,\n buildGitHubUrl(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}`,\n ),\n );\n\n return response.data;\n};\n\nconst loadGitHubTeamMembers = async (\n options: GitHubDirectoryOptions,\n teamSlug: string,\n): Promise<DirectoryUser[]> => {\n const members = await paginate<GitHubUser>(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}/members`,\n );\n\n return members.map((member) => ({\n id: member.login,\n name: member.login,\n avatarUrl: member.avatar_url,\n markdown: createGitHubSyncedMarkdown(\"user\", member.html_url),\n source: {\n provider: \"github\",\n id: String(member.id),\n url: member.html_url,\n },\n }));\n};\n\nconst createGitHubSyncedMarkdown = (type: \"team\" | \"user\", url: string) => {\n if (type === \"team\") {\n return [\n \":::note\",\n \"This team is synced from GitHub and is read-only in EventCatalog.\",\n \"\",\n \"Manage the team and its members in GitHub.\",\n \"\",\n `[View team on GitHub](${url})`,\n \":::\",\n ].join(\"\\n\");\n }\n\n return [\n \":::note\",\n \"This user is synced from GitHub and is read-only in EventCatalog.\",\n \"\",\n \"Manage profile details and team membership in GitHub.\",\n \"\",\n `[View user on GitHub](${url})`,\n \":::\",\n ].join(\"\\n\");\n};\n\nconst paginate = async <T>(\n options: GitHubDirectoryOptions,\n pathname: string,\n): Promise<T[]> => {\n const results: T[] = [];\n let url: string | undefined = buildGitHubUrl(options, pathname);\n\n while (url) {\n const response = await githubRequest<T[]>(options, url);\n results.push(...response.data);\n url = getNextPageUrl(response.headers.get(\"link\"));\n }\n\n return results;\n};\n\nconst githubRequest = async <T>(\n options: GitHubDirectoryOptions,\n url: string,\n): Promise<{ data: T; headers: Headers }> => {\n const response = await fetch(url, {\n headers: {\n accept: \"application/vnd.github+json\",\n \"x-github-api-version\": GITHUB_API_VERSION,\n \"user-agent\": \"@eventcatalog/connectors\",\n ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n return {\n data: (await response.json()) as T,\n headers: response.headers,\n };\n};\n\nconst buildGitHubUrl = (options: GitHubDirectoryOptions, pathname: string) => {\n const baseUrl = options.baseUrl ?? \"https://api.github.com\";\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, \"\");\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n url.searchParams.set(\"per_page\", \"100\");\n return url.toString();\n};\n\nconst getNextPageUrl = (linkHeader: string | null) => {\n if (!linkHeader) return undefined;\n\n const nextLink = linkHeader\n .split(\",\")\n .find((link) => link.includes('rel=\"next\"'));\n const match = nextLink?.match(/<([^>]+)>/);\n\n return match?.[1];\n};\n","import {\n defineDirectorySource,\n type DirectorySource,\n type DirectoryTeam,\n type DirectoryUser,\n} from \"./types\";\n\ntype MicrosoftEntraGroupInput =\n | string\n | {\n id: string;\n alias?: string;\n }\n | {\n displayName: string;\n alias?: string;\n };\n\ntype MicrosoftEntraDirectoryOptions = {\n tenantId: string;\n clientId: string;\n clientSecret: string;\n groups: MicrosoftEntraGroupInput[];\n users?: boolean;\n includeDisabledUsers?: boolean;\n graphBaseUrl?: string;\n tokenUrl?: string;\n};\n\ntype MicrosoftEntraGroup = {\n id: string;\n displayName?: string | null;\n description?: string | null;\n mail?: string | null;\n};\n\ntype MicrosoftEntraUser = {\n id: string;\n displayName?: string | null;\n userPrincipalName?: string | null;\n mail?: string | null;\n jobTitle?: string | null;\n accountEnabled?: boolean | null;\n};\n\ntype MicrosoftEntraDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\ntype MicrosoftGraphCollection<T> = {\n value?: T[];\n \"@odata.nextLink\"?: string;\n};\n\ntype ResolvedGroupInput = {\n group: MicrosoftEntraGroup;\n alias?: string;\n};\n\nconst DEFAULT_GRAPH_BASE_URL = \"https://graph.microsoft.com/v1.0\";\nconst GRAPH_RETRY_ATTEMPTS = 3;\nconst GRAPH_SELECT_GROUP = \"id,displayName,description,mail\";\nconst GRAPH_SELECT_USER =\n \"id,displayName,userPrincipalName,mail,jobTitle,accountEnabled\";\n\nexport const microsoftEntraDirectory = (\n options: MicrosoftEntraDirectoryOptions,\n): DirectorySource => {\n validateOptions(options);\n\n let cachedData: Promise<MicrosoftEntraDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadMicrosoftEntraDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: \"directory\",\n name: `microsoft-entra:${options.tenantId}`,\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst validateOptions = (options: MicrosoftEntraDirectoryOptions) => {\n if (!options.tenantId) {\n throw new Error(\"Microsoft Entra directory connector requires tenantId.\");\n }\n if (!options.clientId) {\n throw new Error(\"Microsoft Entra directory connector requires clientId.\");\n }\n if (!options.clientSecret) {\n throw new Error(\n \"Microsoft Entra directory connector requires clientSecret.\",\n );\n }\n if (!Array.isArray(options.groups) || options.groups.length === 0) {\n throw new Error(\n 'Microsoft Entra directory connector requires at least one group. Set groups: [{ id: \"00000000-0000-0000-0000-000000000000\" }].',\n );\n }\n};\n\nconst loadMicrosoftEntraDirectory = async (\n options: MicrosoftEntraDirectoryOptions,\n): Promise<MicrosoftEntraDirectoryData> => {\n const token = await getAccessToken(options);\n const resolvedGroups = await loadMicrosoftEntraGroups(options, token);\n const teams = mapMicrosoftEntraTeams(resolvedGroups);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadMicrosoftEntraGroupMembers(\n options,\n token,\n String(team.source?.id ?? team.id),\n );\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadMicrosoftEntraGroups = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n): Promise<ResolvedGroupInput[]> => {\n const resolvedGroups: ResolvedGroupInput[] = [];\n\n for (const groupInput of options.groups) {\n resolvedGroups.push(\n await resolveMicrosoftEntraGroup(options, token, groupInput),\n );\n }\n\n assertUniqueTeamIds(resolvedGroups);\n\n return resolvedGroups;\n};\n\nconst resolveMicrosoftEntraGroup = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupInput: MicrosoftEntraGroupInput,\n): Promise<ResolvedGroupInput> => {\n if (typeof groupInput === \"string\") {\n return {\n group: await loadMicrosoftEntraGroupById(options, token, groupInput),\n };\n }\n\n if (\"id\" in groupInput) {\n return {\n group: await loadMicrosoftEntraGroupById(options, token, groupInput.id),\n alias: groupInput.alias,\n };\n }\n\n return {\n group: await loadMicrosoftEntraGroupByDisplayName(\n options,\n token,\n groupInput.displayName,\n ),\n alias: groupInput.alias,\n };\n};\n\nconst loadMicrosoftEntraGroupById = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupId: string,\n) => {\n return microsoftGraphRequest<MicrosoftEntraGroup>(\n options,\n token,\n buildMicrosoftGraphUrl(options, `/groups/${encodeURIComponent(groupId)}`, {\n $select: GRAPH_SELECT_GROUP,\n }),\n );\n};\n\nconst loadMicrosoftEntraGroupByDisplayName = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n displayName: string,\n) => {\n const groups = await paginate<MicrosoftEntraGroup>(\n options,\n token,\n buildMicrosoftGraphUrl(options, \"/groups\", {\n $filter: `displayName eq '${escapeODataString(displayName)}'`,\n $select: GRAPH_SELECT_GROUP,\n }),\n );\n\n if (groups.length === 0) {\n throw new Error(\n `Microsoft Entra directory connector could not find a group with displayName \"${displayName}\". Use the group id instead.`,\n );\n }\n\n if (groups.length > 1) {\n throw new Error(\n `Microsoft Entra directory connector found ${groups.length} groups with displayName \"${displayName}\". Use the group id instead.`,\n );\n }\n\n return groups[0];\n};\n\nconst mapMicrosoftEntraTeams = (groups: ResolvedGroupInput[]) => {\n return groups.map(({ group, alias }) => {\n const displayName = group.displayName ?? group.id;\n\n return {\n id: alias ?? slugify(displayName),\n name: displayName,\n summary: group.description ?? undefined,\n email: group.mail ?? undefined,\n markdown: createMicrosoftEntraSyncedMarkdown(\"team\"),\n source: {\n provider: \"microsoft-entra\",\n id: group.id,\n },\n };\n });\n};\n\nconst loadMicrosoftEntraGroupMembers = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupId: string,\n): Promise<DirectoryUser[]> => {\n const users = await paginate<MicrosoftEntraUser>(\n options,\n token,\n buildMicrosoftGraphUrl(\n options,\n `/groups/${encodeURIComponent(groupId)}/members/microsoft.graph.user`,\n {\n $select: GRAPH_SELECT_USER,\n },\n ),\n );\n\n return users\n .filter(\n (user) => options.includeDisabledUsers || user.accountEnabled !== false,\n )\n .map(mapMicrosoftEntraUser);\n};\n\nconst mapMicrosoftEntraUser = (user: MicrosoftEntraUser): DirectoryUser => {\n const userPrincipalName = user.userPrincipalName ?? undefined;\n const email = user.mail ?? userPrincipalName;\n const id = getMicrosoftEntraUserId(user);\n const name = user.displayName ?? userPrincipalName ?? user.id;\n\n return {\n id,\n name,\n email,\n role: user.jobTitle ?? undefined,\n markdown: createMicrosoftEntraSyncedMarkdown(\"user\"),\n source: {\n provider: \"microsoft-entra\",\n id: user.id,\n },\n };\n};\n\nconst getMicrosoftEntraUserId = (user: MicrosoftEntraUser) => {\n if (user.mail) return user.mail.toLowerCase();\n if (user.userPrincipalName)\n return normalizeMicrosoftEntraUserPrincipalName(user.userPrincipalName);\n return user.id;\n};\n\nconst normalizeMicrosoftEntraUserPrincipalName = (\n userPrincipalName: string,\n) => {\n const guestUserMatch = userPrincipalName.match(/^(.+)#EXT#@.+$/i);\n\n if (!guestUserMatch) return userPrincipalName.toLowerCase();\n\n const externalUserName = guestUserMatch[1];\n const lastUnderscoreIndex = externalUserName.lastIndexOf(\"_\");\n\n if (lastUnderscoreIndex === -1) return externalUserName.toLowerCase();\n\n return `${externalUserName.slice(0, lastUnderscoreIndex)}@${externalUserName.slice(lastUnderscoreIndex + 1)}`.toLowerCase();\n};\n\nconst createMicrosoftEntraSyncedMarkdown = (type: \"team\" | \"user\") => {\n if (type === \"team\") {\n return [\n \":::note\",\n \"This team is synced from Microsoft Entra ID and is read-only in EventCatalog.\",\n \"\",\n \"Manage the team and its members in Microsoft Entra ID.\",\n \":::\",\n ].join(\"\\n\");\n }\n\n return [\n \":::note\",\n \"This user is synced from Microsoft Entra ID and is read-only in EventCatalog.\",\n \"\",\n \"Manage profile details and team membership in Microsoft Entra ID.\",\n \":::\",\n ].join(\"\\n\");\n};\n\nconst getAccessToken = async (options: MicrosoftEntraDirectoryOptions) => {\n const tokenUrl =\n options.tokenUrl ??\n `https://login.microsoftonline.com/${encodeURIComponent(options.tenantId)}/oauth2/v2.0/token`;\n const body = new URLSearchParams({\n client_id: options.clientId,\n client_secret: options.clientSecret,\n grant_type: \"client_credentials\",\n scope: getMicrosoftGraphScope(options),\n });\n\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\",\n \"user-agent\": \"@eventcatalog/connectors\",\n },\n body,\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `Microsoft Entra directory connector failed to get an access token (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n const data = (await response.json()) as { access_token?: string };\n if (!data.access_token) {\n throw new Error(\n \"Microsoft Entra directory connector failed to get an access token: response did not include access_token.\",\n );\n }\n\n return data.access_token;\n};\n\nconst getMicrosoftGraphScope = (options: MicrosoftEntraDirectoryOptions) => {\n const graphBaseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;\n return `${new URL(graphBaseUrl).origin}/.default`;\n};\n\nconst microsoftGraphRequest = async <T>(\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n url: string,\n attempt = 0,\n): Promise<T> => {\n const response = await fetch(url, {\n headers: {\n accept: \"application/json\",\n authorization: `Bearer ${token}`,\n ConsistencyLevel: \"eventual\",\n \"user-agent\": \"@eventcatalog/connectors\",\n },\n });\n\n if (response.status === 429 && attempt < GRAPH_RETRY_ATTEMPTS) {\n await waitForRetry(response.headers.get(\"retry-after\"));\n return microsoftGraphRequest(options, token, url, attempt + 1);\n }\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `Microsoft Entra directory connector failed (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n return (await response.json()) as T;\n};\n\nconst paginate = async <T>(\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n url: string,\n): Promise<T[]> => {\n const results: T[] = [];\n let nextUrl: string | undefined = url;\n\n while (nextUrl) {\n const response: MicrosoftGraphCollection<T> = await microsoftGraphRequest<\n MicrosoftGraphCollection<T>\n >(options, token, nextUrl);\n results.push(...(response.value ?? []));\n nextUrl = response[\"@odata.nextLink\"];\n }\n\n return results;\n};\n\nconst buildMicrosoftGraphUrl = (\n options: MicrosoftEntraDirectoryOptions,\n pathname: string,\n query?: Record<string, string>,\n) => {\n const baseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, \"\");\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n\n for (const [key, value] of Object.entries(query ?? {})) {\n url.searchParams.set(key, value);\n }\n\n return url.toString();\n};\n\nconst assertUniqueTeamIds = (groups: ResolvedGroupInput[]) => {\n const teamIds = new Map<string, string>();\n\n for (const { group, alias } of groups) {\n const displayName = group.displayName ?? group.id;\n const teamId = alias ?? slugify(displayName);\n const existingGroupId = teamIds.get(teamId);\n\n if (existingGroupId) {\n throw new Error(\n `Microsoft Entra directory connector resolved duplicate team id \"${teamId}\" from groups \"${existingGroupId}\" and \"${group.id}\". Set alias for one of the groups.`,\n );\n }\n\n teamIds.set(teamId, group.id);\n }\n};\n\nconst slugify = (value: string) => {\n const slug = value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\n return slug || value;\n};\n\nconst escapeODataString = (value: string) => value.replace(/'/g, \"''\");\n\nconst waitForRetry = async (retryAfter: string | null) => {\n const retryAfterSeconds = retryAfter ? Number(retryAfter) : 1;\n const delayMs = Number.isFinite(retryAfterSeconds)\n ? Math.max(retryAfterSeconds, 0) * 1000\n : 1000;\n\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;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,mEAAmE,MAAM,kBAAkB,eAAe,UAAU,MAAM,EAAE;AAAA,MAC9H;AAAA,IACF;AAEA,YAAQ,IAAI,QAAQ,MAAM,EAAE;AAAA,EAC9B;AACF;AAEA,IAAM,UAAU,CAAC,UAAkB;AACjC,QAAM,OAAO,MACV,KAAK,EACL,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AAEzB,SAAO,QAAQ;AACjB;AAEA,IAAM,oBAAoB,CAAC,UAAkB,MAAM,QAAQ,MAAM,IAAI;AAErE,IAAM,eAAe,OAAO,eAA8B;AACxD,QAAM,oBAAoB,aAAa,OAAO,UAAU,IAAI;AAC5D,QAAM,UAAU,OAAO,SAAS,iBAAiB,IAC7C,KAAK,IAAI,mBAAmB,CAAC,IAAI,MACjC;AAEJ,QAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,OAAO,CAAC;AAC7D;","names":["paginate"]}
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,11 @@ var defineDirectorySource = (source) => source;
|
|
|
4
4
|
// src/github-directory.ts
|
|
5
5
|
var GITHUB_API_VERSION = "2022-11-28";
|
|
6
6
|
var githubDirectory = (options) => {
|
|
7
|
+
if (!Array.isArray(options.teams) || options.teams.length === 0) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
'GitHub directory connector requires at least one team slug. Set teams: ["platform"].'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
7
12
|
let cachedData;
|
|
8
13
|
const load = () => {
|
|
9
14
|
cachedData = cachedData ?? loadGitHubDirectory(options);
|
|
@@ -12,7 +17,6 @@ var githubDirectory = (options) => {
|
|
|
12
17
|
return defineDirectorySource({
|
|
13
18
|
type: "directory",
|
|
14
19
|
name: `github:${options.org}`,
|
|
15
|
-
cacheKey: createGitHubDirectoryCacheKey(options),
|
|
16
20
|
loadTeams: async () => {
|
|
17
21
|
const data = await load();
|
|
18
22
|
return data.teams;
|
|
@@ -23,12 +27,6 @@ var githubDirectory = (options) => {
|
|
|
23
27
|
}
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
|
-
var createGitHubDirectoryCacheKey = (options) => {
|
|
27
|
-
const teams = options.teams === true || options.teams === void 0 ? "all" : [...options.teams].sort().join(",");
|
|
28
|
-
const users = options.users !== false ? "true" : "false";
|
|
29
|
-
const baseUrl = options.baseUrl ?? "https://api.github.com";
|
|
30
|
-
return `github:${baseUrl}:${options.org}:teams=${teams}:users=${users}`;
|
|
31
|
-
};
|
|
32
30
|
var loadGitHubDirectory = async (options) => {
|
|
33
31
|
const teams = await loadGitHubTeams(options);
|
|
34
32
|
const shouldLoadUsers = options.users !== false;
|
|
@@ -53,9 +51,11 @@ var loadGitHubDirectory = async (options) => {
|
|
|
53
51
|
};
|
|
54
52
|
};
|
|
55
53
|
var loadGitHubTeams = async (options) => {
|
|
56
|
-
const teams =
|
|
57
|
-
const
|
|
58
|
-
|
|
54
|
+
const teams = [];
|
|
55
|
+
for (const teamSlug of options.teams) {
|
|
56
|
+
teams.push(await loadGitHubTeam(options, teamSlug));
|
|
57
|
+
}
|
|
58
|
+
return teams.map((team) => ({
|
|
59
59
|
id: team.slug,
|
|
60
60
|
name: team.name,
|
|
61
61
|
summary: team.description ?? void 0,
|
|
@@ -67,6 +67,16 @@ var loadGitHubTeams = async (options) => {
|
|
|
67
67
|
}
|
|
68
68
|
}));
|
|
69
69
|
};
|
|
70
|
+
var loadGitHubTeam = async (options, teamSlug) => {
|
|
71
|
+
const response = await githubRequest(
|
|
72
|
+
options,
|
|
73
|
+
buildGitHubUrl(
|
|
74
|
+
options,
|
|
75
|
+
`/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}`
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
return response.data;
|
|
79
|
+
};
|
|
70
80
|
var loadGitHubTeamMembers = async (options, teamSlug) => {
|
|
71
81
|
const members = await paginate(
|
|
72
82
|
options,
|
|
@@ -127,7 +137,9 @@ var githubRequest = async (options, url) => {
|
|
|
127
137
|
});
|
|
128
138
|
if (!response.ok) {
|
|
129
139
|
const message = await response.text();
|
|
130
|
-
throw new Error(
|
|
140
|
+
throw new Error(
|
|
141
|
+
`GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`
|
|
142
|
+
);
|
|
131
143
|
}
|
|
132
144
|
return {
|
|
133
145
|
data: await response.json(),
|
|
@@ -148,8 +160,323 @@ var getNextPageUrl = (linkHeader) => {
|
|
|
148
160
|
const match = nextLink?.match(/<([^>]+)>/);
|
|
149
161
|
return match?.[1];
|
|
150
162
|
};
|
|
163
|
+
|
|
164
|
+
// src/microsoft-entra-directory.ts
|
|
165
|
+
var DEFAULT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
|
|
166
|
+
var GRAPH_RETRY_ATTEMPTS = 3;
|
|
167
|
+
var GRAPH_SELECT_GROUP = "id,displayName,description,mail";
|
|
168
|
+
var GRAPH_SELECT_USER = "id,displayName,userPrincipalName,mail,jobTitle,accountEnabled";
|
|
169
|
+
var microsoftEntraDirectory = (options) => {
|
|
170
|
+
validateOptions(options);
|
|
171
|
+
let cachedData;
|
|
172
|
+
const load = () => {
|
|
173
|
+
cachedData = cachedData ?? loadMicrosoftEntraDirectory(options);
|
|
174
|
+
return cachedData;
|
|
175
|
+
};
|
|
176
|
+
return defineDirectorySource({
|
|
177
|
+
type: "directory",
|
|
178
|
+
name: `microsoft-entra:${options.tenantId}`,
|
|
179
|
+
loadTeams: async () => {
|
|
180
|
+
const data = await load();
|
|
181
|
+
return data.teams;
|
|
182
|
+
},
|
|
183
|
+
loadUsers: async () => {
|
|
184
|
+
const data = await load();
|
|
185
|
+
return data.users;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
var validateOptions = (options) => {
|
|
190
|
+
if (!options.tenantId) {
|
|
191
|
+
throw new Error("Microsoft Entra directory connector requires tenantId.");
|
|
192
|
+
}
|
|
193
|
+
if (!options.clientId) {
|
|
194
|
+
throw new Error("Microsoft Entra directory connector requires clientId.");
|
|
195
|
+
}
|
|
196
|
+
if (!options.clientSecret) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"Microsoft Entra directory connector requires clientSecret."
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (!Array.isArray(options.groups) || options.groups.length === 0) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
'Microsoft Entra directory connector requires at least one group. Set groups: [{ id: "00000000-0000-0000-0000-000000000000" }].'
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var loadMicrosoftEntraDirectory = async (options) => {
|
|
208
|
+
const token = await getAccessToken(options);
|
|
209
|
+
const resolvedGroups = await loadMicrosoftEntraGroups(options, token);
|
|
210
|
+
const teams = mapMicrosoftEntraTeams(resolvedGroups);
|
|
211
|
+
const shouldLoadUsers = options.users !== false;
|
|
212
|
+
if (!shouldLoadUsers) {
|
|
213
|
+
return { teams, users: [] };
|
|
214
|
+
}
|
|
215
|
+
const usersById = /* @__PURE__ */ new Map();
|
|
216
|
+
const teamsWithMembers = [];
|
|
217
|
+
for (const team of teams) {
|
|
218
|
+
const members = await loadMicrosoftEntraGroupMembers(
|
|
219
|
+
options,
|
|
220
|
+
token,
|
|
221
|
+
String(team.source?.id ?? team.id)
|
|
222
|
+
);
|
|
223
|
+
for (const member of members) {
|
|
224
|
+
usersById.set(member.id, member);
|
|
225
|
+
}
|
|
226
|
+
teamsWithMembers.push({
|
|
227
|
+
...team,
|
|
228
|
+
members: members.map((member) => member.id)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
teams: teamsWithMembers,
|
|
233
|
+
users: Array.from(usersById.values())
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
var loadMicrosoftEntraGroups = async (options, token) => {
|
|
237
|
+
const resolvedGroups = [];
|
|
238
|
+
for (const groupInput of options.groups) {
|
|
239
|
+
resolvedGroups.push(
|
|
240
|
+
await resolveMicrosoftEntraGroup(options, token, groupInput)
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
assertUniqueTeamIds(resolvedGroups);
|
|
244
|
+
return resolvedGroups;
|
|
245
|
+
};
|
|
246
|
+
var resolveMicrosoftEntraGroup = async (options, token, groupInput) => {
|
|
247
|
+
if (typeof groupInput === "string") {
|
|
248
|
+
return {
|
|
249
|
+
group: await loadMicrosoftEntraGroupById(options, token, groupInput)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
if ("id" in groupInput) {
|
|
253
|
+
return {
|
|
254
|
+
group: await loadMicrosoftEntraGroupById(options, token, groupInput.id),
|
|
255
|
+
alias: groupInput.alias
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
group: await loadMicrosoftEntraGroupByDisplayName(
|
|
260
|
+
options,
|
|
261
|
+
token,
|
|
262
|
+
groupInput.displayName
|
|
263
|
+
),
|
|
264
|
+
alias: groupInput.alias
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
var loadMicrosoftEntraGroupById = async (options, token, groupId) => {
|
|
268
|
+
return microsoftGraphRequest(
|
|
269
|
+
options,
|
|
270
|
+
token,
|
|
271
|
+
buildMicrosoftGraphUrl(options, `/groups/${encodeURIComponent(groupId)}`, {
|
|
272
|
+
$select: GRAPH_SELECT_GROUP
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
var loadMicrosoftEntraGroupByDisplayName = async (options, token, displayName) => {
|
|
277
|
+
const groups = await paginate2(
|
|
278
|
+
options,
|
|
279
|
+
token,
|
|
280
|
+
buildMicrosoftGraphUrl(options, "/groups", {
|
|
281
|
+
$filter: `displayName eq '${escapeODataString(displayName)}'`,
|
|
282
|
+
$select: GRAPH_SELECT_GROUP
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
if (groups.length === 0) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
`Microsoft Entra directory connector could not find a group with displayName "${displayName}". Use the group id instead.`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (groups.length > 1) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
`Microsoft Entra directory connector found ${groups.length} groups with displayName "${displayName}". Use the group id instead.`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
return groups[0];
|
|
296
|
+
};
|
|
297
|
+
var mapMicrosoftEntraTeams = (groups) => {
|
|
298
|
+
return groups.map(({ group, alias }) => {
|
|
299
|
+
const displayName = group.displayName ?? group.id;
|
|
300
|
+
return {
|
|
301
|
+
id: alias ?? slugify(displayName),
|
|
302
|
+
name: displayName,
|
|
303
|
+
summary: group.description ?? void 0,
|
|
304
|
+
email: group.mail ?? void 0,
|
|
305
|
+
markdown: createMicrosoftEntraSyncedMarkdown("team"),
|
|
306
|
+
source: {
|
|
307
|
+
provider: "microsoft-entra",
|
|
308
|
+
id: group.id
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var loadMicrosoftEntraGroupMembers = async (options, token, groupId) => {
|
|
314
|
+
const users = await paginate2(
|
|
315
|
+
options,
|
|
316
|
+
token,
|
|
317
|
+
buildMicrosoftGraphUrl(
|
|
318
|
+
options,
|
|
319
|
+
`/groups/${encodeURIComponent(groupId)}/members/microsoft.graph.user`,
|
|
320
|
+
{
|
|
321
|
+
$select: GRAPH_SELECT_USER
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
);
|
|
325
|
+
return users.filter(
|
|
326
|
+
(user) => options.includeDisabledUsers || user.accountEnabled !== false
|
|
327
|
+
).map(mapMicrosoftEntraUser);
|
|
328
|
+
};
|
|
329
|
+
var mapMicrosoftEntraUser = (user) => {
|
|
330
|
+
const userPrincipalName = user.userPrincipalName ?? void 0;
|
|
331
|
+
const email = user.mail ?? userPrincipalName;
|
|
332
|
+
const id = getMicrosoftEntraUserId(user);
|
|
333
|
+
const name = user.displayName ?? userPrincipalName ?? user.id;
|
|
334
|
+
return {
|
|
335
|
+
id,
|
|
336
|
+
name,
|
|
337
|
+
email,
|
|
338
|
+
role: user.jobTitle ?? void 0,
|
|
339
|
+
markdown: createMicrosoftEntraSyncedMarkdown("user"),
|
|
340
|
+
source: {
|
|
341
|
+
provider: "microsoft-entra",
|
|
342
|
+
id: user.id
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
var getMicrosoftEntraUserId = (user) => {
|
|
347
|
+
if (user.mail) return user.mail.toLowerCase();
|
|
348
|
+
if (user.userPrincipalName)
|
|
349
|
+
return normalizeMicrosoftEntraUserPrincipalName(user.userPrincipalName);
|
|
350
|
+
return user.id;
|
|
351
|
+
};
|
|
352
|
+
var normalizeMicrosoftEntraUserPrincipalName = (userPrincipalName) => {
|
|
353
|
+
const guestUserMatch = userPrincipalName.match(/^(.+)#EXT#@.+$/i);
|
|
354
|
+
if (!guestUserMatch) return userPrincipalName.toLowerCase();
|
|
355
|
+
const externalUserName = guestUserMatch[1];
|
|
356
|
+
const lastUnderscoreIndex = externalUserName.lastIndexOf("_");
|
|
357
|
+
if (lastUnderscoreIndex === -1) return externalUserName.toLowerCase();
|
|
358
|
+
return `${externalUserName.slice(0, lastUnderscoreIndex)}@${externalUserName.slice(lastUnderscoreIndex + 1)}`.toLowerCase();
|
|
359
|
+
};
|
|
360
|
+
var createMicrosoftEntraSyncedMarkdown = (type) => {
|
|
361
|
+
if (type === "team") {
|
|
362
|
+
return [
|
|
363
|
+
":::note",
|
|
364
|
+
"This team is synced from Microsoft Entra ID and is read-only in EventCatalog.",
|
|
365
|
+
"",
|
|
366
|
+
"Manage the team and its members in Microsoft Entra ID.",
|
|
367
|
+
":::"
|
|
368
|
+
].join("\n");
|
|
369
|
+
}
|
|
370
|
+
return [
|
|
371
|
+
":::note",
|
|
372
|
+
"This user is synced from Microsoft Entra ID and is read-only in EventCatalog.",
|
|
373
|
+
"",
|
|
374
|
+
"Manage profile details and team membership in Microsoft Entra ID.",
|
|
375
|
+
":::"
|
|
376
|
+
].join("\n");
|
|
377
|
+
};
|
|
378
|
+
var getAccessToken = async (options) => {
|
|
379
|
+
const tokenUrl = options.tokenUrl ?? `https://login.microsoftonline.com/${encodeURIComponent(options.tenantId)}/oauth2/v2.0/token`;
|
|
380
|
+
const body = new URLSearchParams({
|
|
381
|
+
client_id: options.clientId,
|
|
382
|
+
client_secret: options.clientSecret,
|
|
383
|
+
grant_type: "client_credentials",
|
|
384
|
+
scope: getMicrosoftGraphScope(options)
|
|
385
|
+
});
|
|
386
|
+
const response = await fetch(tokenUrl, {
|
|
387
|
+
method: "POST",
|
|
388
|
+
headers: {
|
|
389
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
390
|
+
"user-agent": "@eventcatalog/connectors"
|
|
391
|
+
},
|
|
392
|
+
body
|
|
393
|
+
});
|
|
394
|
+
if (!response.ok) {
|
|
395
|
+
const message = await response.text();
|
|
396
|
+
throw new Error(
|
|
397
|
+
`Microsoft Entra directory connector failed to get an access token (${response.status} ${response.statusText}): ${message}`
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
const data = await response.json();
|
|
401
|
+
if (!data.access_token) {
|
|
402
|
+
throw new Error(
|
|
403
|
+
"Microsoft Entra directory connector failed to get an access token: response did not include access_token."
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
return data.access_token;
|
|
407
|
+
};
|
|
408
|
+
var getMicrosoftGraphScope = (options) => {
|
|
409
|
+
const graphBaseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;
|
|
410
|
+
return `${new URL(graphBaseUrl).origin}/.default`;
|
|
411
|
+
};
|
|
412
|
+
var microsoftGraphRequest = async (options, token, url, attempt = 0) => {
|
|
413
|
+
const response = await fetch(url, {
|
|
414
|
+
headers: {
|
|
415
|
+
accept: "application/json",
|
|
416
|
+
authorization: `Bearer ${token}`,
|
|
417
|
+
ConsistencyLevel: "eventual",
|
|
418
|
+
"user-agent": "@eventcatalog/connectors"
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
if (response.status === 429 && attempt < GRAPH_RETRY_ATTEMPTS) {
|
|
422
|
+
await waitForRetry(response.headers.get("retry-after"));
|
|
423
|
+
return microsoftGraphRequest(options, token, url, attempt + 1);
|
|
424
|
+
}
|
|
425
|
+
if (!response.ok) {
|
|
426
|
+
const message = await response.text();
|
|
427
|
+
throw new Error(
|
|
428
|
+
`Microsoft Entra directory connector failed (${response.status} ${response.statusText}): ${message}`
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
return await response.json();
|
|
432
|
+
};
|
|
433
|
+
var paginate2 = async (options, token, url) => {
|
|
434
|
+
const results = [];
|
|
435
|
+
let nextUrl = url;
|
|
436
|
+
while (nextUrl) {
|
|
437
|
+
const response = await microsoftGraphRequest(options, token, nextUrl);
|
|
438
|
+
results.push(...response.value ?? []);
|
|
439
|
+
nextUrl = response["@odata.nextLink"];
|
|
440
|
+
}
|
|
441
|
+
return results;
|
|
442
|
+
};
|
|
443
|
+
var buildMicrosoftGraphUrl = (options, pathname, query) => {
|
|
444
|
+
const baseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;
|
|
445
|
+
const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
446
|
+
const normalizedPathname = pathname.replace(/^\//u, "");
|
|
447
|
+
const url = new URL(normalizedPathname, normalizedBaseUrl);
|
|
448
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
449
|
+
url.searchParams.set(key, value);
|
|
450
|
+
}
|
|
451
|
+
return url.toString();
|
|
452
|
+
};
|
|
453
|
+
var assertUniqueTeamIds = (groups) => {
|
|
454
|
+
const teamIds = /* @__PURE__ */ new Map();
|
|
455
|
+
for (const { group, alias } of groups) {
|
|
456
|
+
const displayName = group.displayName ?? group.id;
|
|
457
|
+
const teamId = alias ?? slugify(displayName);
|
|
458
|
+
const existingGroupId = teamIds.get(teamId);
|
|
459
|
+
if (existingGroupId) {
|
|
460
|
+
throw new Error(
|
|
461
|
+
`Microsoft Entra directory connector resolved duplicate team id "${teamId}" from groups "${existingGroupId}" and "${group.id}". Set alias for one of the groups.`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
teamIds.set(teamId, group.id);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
var slugify = (value) => {
|
|
468
|
+
const slug = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
469
|
+
return slug || value;
|
|
470
|
+
};
|
|
471
|
+
var escapeODataString = (value) => value.replace(/'/g, "''");
|
|
472
|
+
var waitForRetry = async (retryAfter) => {
|
|
473
|
+
const retryAfterSeconds = retryAfter ? Number(retryAfter) : 1;
|
|
474
|
+
const delayMs = Number.isFinite(retryAfterSeconds) ? Math.max(retryAfterSeconds, 0) * 1e3 : 1e3;
|
|
475
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
476
|
+
};
|
|
151
477
|
export {
|
|
152
478
|
defineDirectorySource,
|
|
153
|
-
githubDirectory
|
|
479
|
+
githubDirectory,
|
|
480
|
+
microsoftEntraDirectory
|
|
154
481
|
};
|
|
155
482
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/github-directory.ts"],"sourcesContent":["/**\n * Describes where a generated directory entry came from.\n *\n * EventCatalog uses the provider to show source badges and to treat generated\n * resources as externally managed.\n */\nexport type DirectoryEntrySource = {\n /** Provider identifier, for example `github`, `okta`, or `ldap`. */\n provider: string;\n /** Optional provider-specific identifier for the external resource. */\n id?: string;\n /** Optional URL back to the resource in the external provider. */\n url?: string;\n [key: string]: unknown;\n};\n\n/**\n * User returned by a directory source.\n *\n * Directory users are synced as read-only EventCatalog users and can be\n * referenced by teams through their `id`.\n */\nexport type DirectoryUser = {\n id: string;\n name: string;\n avatarUrl: string;\n role?: string;\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Team returned by a directory source.\n *\n * Directory teams are synced as read-only EventCatalog teams.\n */\nexport type DirectoryTeam = {\n id: string;\n name: string;\n summary?: string;\n /** User IDs for members of this team. */\n members?: string[];\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Loads users and/or teams from an external directory provider.\n *\n * EventCatalog calls these loaders during content sync, writes the returned\n * entries into Astro collections, and mirrors them into the generated\n * `.eventcatalog/store/directory.json` file for SDK/editor reads.\n */\nexport type DirectorySource = {\n type: 'directory';\n /** Stable source identifier, usually `<provider>:<account-or-org>`. */\n name: string;\n /** Optional stable cache key for this source configuration. */\n cacheKey?: string;\n /** Load users from the external directory. */\n loadUsers?: () => Promise<DirectoryUser[]>;\n /** Load teams from the external directory. */\n loadTeams?: () => Promise<DirectoryTeam[]>;\n};\n\n/**\n * Defines a custom directory source with type inference for connector authors.\n */\nexport const defineDirectorySource = <TSource extends DirectorySource>(source: TSource) => source;\n","import { defineDirectorySource, type DirectorySource, type DirectoryTeam, type DirectoryUser } from './types';\n\ntype GitHubDirectoryOptions = {\n org: string;\n token?: string;\n teams?: true | string[];\n users?: boolean;\n baseUrl?: string;\n};\n\ntype GitHubTeam = {\n id: number;\n name: string;\n slug: string;\n description: string | null;\n html_url: string;\n};\n\ntype GitHubUser = {\n id: number;\n login: string;\n avatar_url: string;\n html_url: string;\n};\n\ntype GitHubDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\nconst GITHUB_API_VERSION = '2022-11-28';\n\nexport const githubDirectory = (options: GitHubDirectoryOptions): DirectorySource => {\n let cachedData: Promise<GitHubDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadGitHubDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: 'directory',\n name: `github:${options.org}`,\n cacheKey: createGitHubDirectoryCacheKey(options),\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst createGitHubDirectoryCacheKey = (options: GitHubDirectoryOptions) => {\n const teams = options.teams === true || options.teams === undefined ? 'all' : [...options.teams].sort().join(',');\n const users = options.users !== false ? 'true' : 'false';\n const baseUrl = options.baseUrl ?? 'https://api.github.com';\n\n return `github:${baseUrl}:${options.org}:teams=${teams}:users=${users}`;\n};\n\nconst loadGitHubDirectory = async (options: GitHubDirectoryOptions): Promise<GitHubDirectoryData> => {\n const teams = await loadGitHubTeams(options);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadGitHubTeamMembers(options, team.id);\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadGitHubTeams = async (options: GitHubDirectoryOptions): Promise<DirectoryTeam[]> => {\n const teams = await paginate<GitHubTeam>(options, `/orgs/${encodeURIComponent(options.org)}/teams`);\n const configuredTeams = options.teams === undefined || options.teams === true ? undefined : new Set(options.teams);\n\n return teams\n .filter((team) => !configuredTeams || configuredTeams.has(team.slug))\n .map((team) => ({\n id: team.slug,\n name: team.name,\n summary: team.description ?? undefined,\n markdown: createGitHubSyncedMarkdown('team', team.html_url),\n source: {\n provider: 'github',\n id: String(team.id),\n url: team.html_url,\n },\n }));\n};\n\nconst loadGitHubTeamMembers = async (options: GitHubDirectoryOptions, teamSlug: string): Promise<DirectoryUser[]> => {\n const members = await paginate<GitHubUser>(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}/members`\n );\n\n return members.map((member) => ({\n id: member.login,\n name: member.login,\n avatarUrl: member.avatar_url,\n markdown: createGitHubSyncedMarkdown('user', member.html_url),\n source: {\n provider: 'github',\n id: String(member.id),\n url: member.html_url,\n },\n }));\n};\n\nconst createGitHubSyncedMarkdown = (type: 'team' | 'user', url: string) => {\n if (type === 'team') {\n return [\n ':::note',\n 'This team is synced from GitHub and is read-only in EventCatalog.',\n '',\n 'Manage the team and its members in GitHub.',\n '',\n `[View team on GitHub](${url})`,\n ':::',\n ].join('\\n');\n }\n\n return [\n ':::note',\n 'This user is synced from GitHub and is read-only in EventCatalog.',\n '',\n 'Manage profile details and team membership in GitHub.',\n '',\n `[View user on GitHub](${url})`,\n ':::',\n ].join('\\n');\n};\n\nconst paginate = async <T>(options: GitHubDirectoryOptions, pathname: string): Promise<T[]> => {\n const results: T[] = [];\n let url: string | undefined = buildGitHubUrl(options, pathname);\n\n while (url) {\n const response = await githubRequest<T[]>(options, url);\n results.push(...response.data);\n url = getNextPageUrl(response.headers.get('link'));\n }\n\n return results;\n};\n\nconst githubRequest = async <T>(\n options: GitHubDirectoryOptions,\n url: string\n): Promise<{ data: T; headers: Headers }> => {\n const response = await fetch(url, {\n headers: {\n accept: 'application/vnd.github+json',\n 'x-github-api-version': GITHUB_API_VERSION,\n 'user-agent': '@eventcatalog/connectors',\n ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(`GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`);\n }\n\n return {\n data: (await response.json()) as T,\n headers: response.headers,\n };\n};\n\nconst buildGitHubUrl = (options: GitHubDirectoryOptions, pathname: string) => {\n const baseUrl = options.baseUrl ?? 'https://api.github.com';\n const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, '');\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n url.searchParams.set('per_page', '100');\n return url.toString();\n};\n\nconst getNextPageUrl = (linkHeader: string | null) => {\n if (!linkHeader) return undefined;\n\n const nextLink = linkHeader.split(',').find((link) => link.includes('rel=\"next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AACnC,QAAM,oBAAoB,QAAQ,SAAS,GAAG,IAAI,UAAU,GAAG,OAAO;AACtE,QAAM,qBAAqB,SAAS,QAAQ,QAAQ,EAAE;AACtD,QAAM,MAAM,IAAI,IAAI,oBAAoB,iBAAiB;AACzD,MAAI,aAAa,IAAI,YAAY,KAAK;AACtC,SAAO,IAAI,SAAS;AACtB;AAEA,IAAM,iBAAiB,CAAC,eAA8B;AACpD,MAAI,CAAC,WAAY,QAAO;AAExB,QAAM,WAAW,WAAW,MAAM,GAAG,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,YAAY,CAAC;AACjF,QAAM,QAAQ,UAAU,MAAM,WAAW;AAEzC,SAAO,QAAQ,CAAC;AAClB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/github-directory.ts","../src/microsoft-entra-directory.ts"],"sourcesContent":["/**\n * Describes where a generated directory entry came from.\n *\n * EventCatalog uses the provider to show source badges and to treat generated\n * resources as externally managed.\n */\nexport type DirectoryEntrySource = {\n /** Provider identifier, for example `github`, `okta`, or `ldap`. */\n provider: string;\n /** Optional provider-specific identifier for the external resource. */\n id?: string;\n /** Optional URL back to the resource in the external provider. */\n url?: string;\n [key: string]: unknown;\n};\n\n/**\n * User returned by a directory source.\n *\n * Directory users are synced as read-only EventCatalog users and can be\n * referenced by teams through their `id`.\n */\nexport type DirectoryUser = {\n id: string;\n name: string;\n avatarUrl?: string;\n role?: string;\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Team returned by a directory source.\n *\n * Directory teams are synced as read-only EventCatalog teams.\n */\nexport type DirectoryTeam = {\n id: string;\n name: string;\n summary?: string;\n /** User IDs for members of this team. */\n members?: string[];\n email?: string;\n markdown?: string;\n source?: DirectoryEntrySource;\n [key: string]: unknown;\n};\n\n/**\n * Loads users and/or teams from an external directory provider.\n *\n * EventCatalog calls these loaders during content sync, writes the returned\n * entries into Astro collections, and mirrors them into the generated\n * `.eventcatalog/store/directory.json` file for SDK/editor reads.\n */\nexport type DirectorySource = {\n type: \"directory\";\n /** Stable source identifier, usually `<provider>:<account-or-org>`. */\n name: string;\n /** Load users from the external directory. */\n loadUsers?: () => Promise<DirectoryUser[]>;\n /** Load teams from the external directory. */\n loadTeams?: () => Promise<DirectoryTeam[]>;\n};\n\n/**\n * Defines a custom directory source with type inference for connector authors.\n */\nexport const defineDirectorySource = <TSource extends DirectorySource>(\n source: TSource,\n) => source;\n","import {\n defineDirectorySource,\n type DirectorySource,\n type DirectoryTeam,\n type DirectoryUser,\n} from \"./types\";\n\ntype GitHubDirectoryOptions = {\n org: string;\n token?: string;\n teams: string[];\n users?: boolean;\n baseUrl?: string;\n};\n\ntype GitHubTeam = {\n id: number;\n name: string;\n slug: string;\n description: string | null;\n html_url: string;\n};\n\ntype GitHubUser = {\n id: number;\n login: string;\n avatar_url: string;\n html_url: string;\n};\n\ntype GitHubDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\nconst GITHUB_API_VERSION = \"2022-11-28\";\n\nexport const githubDirectory = (\n options: GitHubDirectoryOptions,\n): DirectorySource => {\n if (!Array.isArray(options.teams) || options.teams.length === 0) {\n throw new Error(\n 'GitHub directory connector requires at least one team slug. Set teams: [\"platform\"].',\n );\n }\n\n let cachedData: Promise<GitHubDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadGitHubDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: \"directory\",\n name: `github:${options.org}`,\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst loadGitHubDirectory = async (\n options: GitHubDirectoryOptions,\n): Promise<GitHubDirectoryData> => {\n const teams = await loadGitHubTeams(options);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadGitHubTeamMembers(options, team.id);\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadGitHubTeams = async (\n options: GitHubDirectoryOptions,\n): Promise<DirectoryTeam[]> => {\n const teams: GitHubTeam[] = [];\n\n for (const teamSlug of options.teams) {\n teams.push(await loadGitHubTeam(options, teamSlug));\n }\n\n return teams.map((team) => ({\n id: team.slug,\n name: team.name,\n summary: team.description ?? undefined,\n markdown: createGitHubSyncedMarkdown(\"team\", team.html_url),\n source: {\n provider: \"github\",\n id: String(team.id),\n url: team.html_url,\n },\n }));\n};\n\nconst loadGitHubTeam = async (\n options: GitHubDirectoryOptions,\n teamSlug: string,\n) => {\n const response = await githubRequest<GitHubTeam>(\n options,\n buildGitHubUrl(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}`,\n ),\n );\n\n return response.data;\n};\n\nconst loadGitHubTeamMembers = async (\n options: GitHubDirectoryOptions,\n teamSlug: string,\n): Promise<DirectoryUser[]> => {\n const members = await paginate<GitHubUser>(\n options,\n `/orgs/${encodeURIComponent(options.org)}/teams/${encodeURIComponent(teamSlug)}/members`,\n );\n\n return members.map((member) => ({\n id: member.login,\n name: member.login,\n avatarUrl: member.avatar_url,\n markdown: createGitHubSyncedMarkdown(\"user\", member.html_url),\n source: {\n provider: \"github\",\n id: String(member.id),\n url: member.html_url,\n },\n }));\n};\n\nconst createGitHubSyncedMarkdown = (type: \"team\" | \"user\", url: string) => {\n if (type === \"team\") {\n return [\n \":::note\",\n \"This team is synced from GitHub and is read-only in EventCatalog.\",\n \"\",\n \"Manage the team and its members in GitHub.\",\n \"\",\n `[View team on GitHub](${url})`,\n \":::\",\n ].join(\"\\n\");\n }\n\n return [\n \":::note\",\n \"This user is synced from GitHub and is read-only in EventCatalog.\",\n \"\",\n \"Manage profile details and team membership in GitHub.\",\n \"\",\n `[View user on GitHub](${url})`,\n \":::\",\n ].join(\"\\n\");\n};\n\nconst paginate = async <T>(\n options: GitHubDirectoryOptions,\n pathname: string,\n): Promise<T[]> => {\n const results: T[] = [];\n let url: string | undefined = buildGitHubUrl(options, pathname);\n\n while (url) {\n const response = await githubRequest<T[]>(options, url);\n results.push(...response.data);\n url = getNextPageUrl(response.headers.get(\"link\"));\n }\n\n return results;\n};\n\nconst githubRequest = async <T>(\n options: GitHubDirectoryOptions,\n url: string,\n): Promise<{ data: T; headers: Headers }> => {\n const response = await fetch(url, {\n headers: {\n accept: \"application/vnd.github+json\",\n \"x-github-api-version\": GITHUB_API_VERSION,\n \"user-agent\": \"@eventcatalog/connectors\",\n ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `GitHub directory connector failed (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n return {\n data: (await response.json()) as T,\n headers: response.headers,\n };\n};\n\nconst buildGitHubUrl = (options: GitHubDirectoryOptions, pathname: string) => {\n const baseUrl = options.baseUrl ?? \"https://api.github.com\";\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, \"\");\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n url.searchParams.set(\"per_page\", \"100\");\n return url.toString();\n};\n\nconst getNextPageUrl = (linkHeader: string | null) => {\n if (!linkHeader) return undefined;\n\n const nextLink = linkHeader\n .split(\",\")\n .find((link) => link.includes('rel=\"next\"'));\n const match = nextLink?.match(/<([^>]+)>/);\n\n return match?.[1];\n};\n","import {\n defineDirectorySource,\n type DirectorySource,\n type DirectoryTeam,\n type DirectoryUser,\n} from \"./types\";\n\ntype MicrosoftEntraGroupInput =\n | string\n | {\n id: string;\n alias?: string;\n }\n | {\n displayName: string;\n alias?: string;\n };\n\ntype MicrosoftEntraDirectoryOptions = {\n tenantId: string;\n clientId: string;\n clientSecret: string;\n groups: MicrosoftEntraGroupInput[];\n users?: boolean;\n includeDisabledUsers?: boolean;\n graphBaseUrl?: string;\n tokenUrl?: string;\n};\n\ntype MicrosoftEntraGroup = {\n id: string;\n displayName?: string | null;\n description?: string | null;\n mail?: string | null;\n};\n\ntype MicrosoftEntraUser = {\n id: string;\n displayName?: string | null;\n userPrincipalName?: string | null;\n mail?: string | null;\n jobTitle?: string | null;\n accountEnabled?: boolean | null;\n};\n\ntype MicrosoftEntraDirectoryData = {\n teams: DirectoryTeam[];\n users: DirectoryUser[];\n};\n\ntype MicrosoftGraphCollection<T> = {\n value?: T[];\n \"@odata.nextLink\"?: string;\n};\n\ntype ResolvedGroupInput = {\n group: MicrosoftEntraGroup;\n alias?: string;\n};\n\nconst DEFAULT_GRAPH_BASE_URL = \"https://graph.microsoft.com/v1.0\";\nconst GRAPH_RETRY_ATTEMPTS = 3;\nconst GRAPH_SELECT_GROUP = \"id,displayName,description,mail\";\nconst GRAPH_SELECT_USER =\n \"id,displayName,userPrincipalName,mail,jobTitle,accountEnabled\";\n\nexport const microsoftEntraDirectory = (\n options: MicrosoftEntraDirectoryOptions,\n): DirectorySource => {\n validateOptions(options);\n\n let cachedData: Promise<MicrosoftEntraDirectoryData> | undefined;\n\n const load = () => {\n cachedData = cachedData ?? loadMicrosoftEntraDirectory(options);\n return cachedData;\n };\n\n return defineDirectorySource({\n type: \"directory\",\n name: `microsoft-entra:${options.tenantId}`,\n loadTeams: async () => {\n const data = await load();\n return data.teams;\n },\n loadUsers: async () => {\n const data = await load();\n return data.users;\n },\n });\n};\n\nconst validateOptions = (options: MicrosoftEntraDirectoryOptions) => {\n if (!options.tenantId) {\n throw new Error(\"Microsoft Entra directory connector requires tenantId.\");\n }\n if (!options.clientId) {\n throw new Error(\"Microsoft Entra directory connector requires clientId.\");\n }\n if (!options.clientSecret) {\n throw new Error(\n \"Microsoft Entra directory connector requires clientSecret.\",\n );\n }\n if (!Array.isArray(options.groups) || options.groups.length === 0) {\n throw new Error(\n 'Microsoft Entra directory connector requires at least one group. Set groups: [{ id: \"00000000-0000-0000-0000-000000000000\" }].',\n );\n }\n};\n\nconst loadMicrosoftEntraDirectory = async (\n options: MicrosoftEntraDirectoryOptions,\n): Promise<MicrosoftEntraDirectoryData> => {\n const token = await getAccessToken(options);\n const resolvedGroups = await loadMicrosoftEntraGroups(options, token);\n const teams = mapMicrosoftEntraTeams(resolvedGroups);\n const shouldLoadUsers = options.users !== false;\n\n if (!shouldLoadUsers) {\n return { teams, users: [] };\n }\n\n const usersById = new Map<string, DirectoryUser>();\n const teamsWithMembers: DirectoryTeam[] = [];\n\n for (const team of teams) {\n const members = await loadMicrosoftEntraGroupMembers(\n options,\n token,\n String(team.source?.id ?? team.id),\n );\n\n for (const member of members) {\n usersById.set(member.id, member);\n }\n\n teamsWithMembers.push({\n ...team,\n members: members.map((member) => member.id),\n });\n }\n\n return {\n teams: teamsWithMembers,\n users: Array.from(usersById.values()),\n };\n};\n\nconst loadMicrosoftEntraGroups = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n): Promise<ResolvedGroupInput[]> => {\n const resolvedGroups: ResolvedGroupInput[] = [];\n\n for (const groupInput of options.groups) {\n resolvedGroups.push(\n await resolveMicrosoftEntraGroup(options, token, groupInput),\n );\n }\n\n assertUniqueTeamIds(resolvedGroups);\n\n return resolvedGroups;\n};\n\nconst resolveMicrosoftEntraGroup = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupInput: MicrosoftEntraGroupInput,\n): Promise<ResolvedGroupInput> => {\n if (typeof groupInput === \"string\") {\n return {\n group: await loadMicrosoftEntraGroupById(options, token, groupInput),\n };\n }\n\n if (\"id\" in groupInput) {\n return {\n group: await loadMicrosoftEntraGroupById(options, token, groupInput.id),\n alias: groupInput.alias,\n };\n }\n\n return {\n group: await loadMicrosoftEntraGroupByDisplayName(\n options,\n token,\n groupInput.displayName,\n ),\n alias: groupInput.alias,\n };\n};\n\nconst loadMicrosoftEntraGroupById = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupId: string,\n) => {\n return microsoftGraphRequest<MicrosoftEntraGroup>(\n options,\n token,\n buildMicrosoftGraphUrl(options, `/groups/${encodeURIComponent(groupId)}`, {\n $select: GRAPH_SELECT_GROUP,\n }),\n );\n};\n\nconst loadMicrosoftEntraGroupByDisplayName = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n displayName: string,\n) => {\n const groups = await paginate<MicrosoftEntraGroup>(\n options,\n token,\n buildMicrosoftGraphUrl(options, \"/groups\", {\n $filter: `displayName eq '${escapeODataString(displayName)}'`,\n $select: GRAPH_SELECT_GROUP,\n }),\n );\n\n if (groups.length === 0) {\n throw new Error(\n `Microsoft Entra directory connector could not find a group with displayName \"${displayName}\". Use the group id instead.`,\n );\n }\n\n if (groups.length > 1) {\n throw new Error(\n `Microsoft Entra directory connector found ${groups.length} groups with displayName \"${displayName}\". Use the group id instead.`,\n );\n }\n\n return groups[0];\n};\n\nconst mapMicrosoftEntraTeams = (groups: ResolvedGroupInput[]) => {\n return groups.map(({ group, alias }) => {\n const displayName = group.displayName ?? group.id;\n\n return {\n id: alias ?? slugify(displayName),\n name: displayName,\n summary: group.description ?? undefined,\n email: group.mail ?? undefined,\n markdown: createMicrosoftEntraSyncedMarkdown(\"team\"),\n source: {\n provider: \"microsoft-entra\",\n id: group.id,\n },\n };\n });\n};\n\nconst loadMicrosoftEntraGroupMembers = async (\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n groupId: string,\n): Promise<DirectoryUser[]> => {\n const users = await paginate<MicrosoftEntraUser>(\n options,\n token,\n buildMicrosoftGraphUrl(\n options,\n `/groups/${encodeURIComponent(groupId)}/members/microsoft.graph.user`,\n {\n $select: GRAPH_SELECT_USER,\n },\n ),\n );\n\n return users\n .filter(\n (user) => options.includeDisabledUsers || user.accountEnabled !== false,\n )\n .map(mapMicrosoftEntraUser);\n};\n\nconst mapMicrosoftEntraUser = (user: MicrosoftEntraUser): DirectoryUser => {\n const userPrincipalName = user.userPrincipalName ?? undefined;\n const email = user.mail ?? userPrincipalName;\n const id = getMicrosoftEntraUserId(user);\n const name = user.displayName ?? userPrincipalName ?? user.id;\n\n return {\n id,\n name,\n email,\n role: user.jobTitle ?? undefined,\n markdown: createMicrosoftEntraSyncedMarkdown(\"user\"),\n source: {\n provider: \"microsoft-entra\",\n id: user.id,\n },\n };\n};\n\nconst getMicrosoftEntraUserId = (user: MicrosoftEntraUser) => {\n if (user.mail) return user.mail.toLowerCase();\n if (user.userPrincipalName)\n return normalizeMicrosoftEntraUserPrincipalName(user.userPrincipalName);\n return user.id;\n};\n\nconst normalizeMicrosoftEntraUserPrincipalName = (\n userPrincipalName: string,\n) => {\n const guestUserMatch = userPrincipalName.match(/^(.+)#EXT#@.+$/i);\n\n if (!guestUserMatch) return userPrincipalName.toLowerCase();\n\n const externalUserName = guestUserMatch[1];\n const lastUnderscoreIndex = externalUserName.lastIndexOf(\"_\");\n\n if (lastUnderscoreIndex === -1) return externalUserName.toLowerCase();\n\n return `${externalUserName.slice(0, lastUnderscoreIndex)}@${externalUserName.slice(lastUnderscoreIndex + 1)}`.toLowerCase();\n};\n\nconst createMicrosoftEntraSyncedMarkdown = (type: \"team\" | \"user\") => {\n if (type === \"team\") {\n return [\n \":::note\",\n \"This team is synced from Microsoft Entra ID and is read-only in EventCatalog.\",\n \"\",\n \"Manage the team and its members in Microsoft Entra ID.\",\n \":::\",\n ].join(\"\\n\");\n }\n\n return [\n \":::note\",\n \"This user is synced from Microsoft Entra ID and is read-only in EventCatalog.\",\n \"\",\n \"Manage profile details and team membership in Microsoft Entra ID.\",\n \":::\",\n ].join(\"\\n\");\n};\n\nconst getAccessToken = async (options: MicrosoftEntraDirectoryOptions) => {\n const tokenUrl =\n options.tokenUrl ??\n `https://login.microsoftonline.com/${encodeURIComponent(options.tenantId)}/oauth2/v2.0/token`;\n const body = new URLSearchParams({\n client_id: options.clientId,\n client_secret: options.clientSecret,\n grant_type: \"client_credentials\",\n scope: getMicrosoftGraphScope(options),\n });\n\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\",\n \"user-agent\": \"@eventcatalog/connectors\",\n },\n body,\n });\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `Microsoft Entra directory connector failed to get an access token (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n const data = (await response.json()) as { access_token?: string };\n if (!data.access_token) {\n throw new Error(\n \"Microsoft Entra directory connector failed to get an access token: response did not include access_token.\",\n );\n }\n\n return data.access_token;\n};\n\nconst getMicrosoftGraphScope = (options: MicrosoftEntraDirectoryOptions) => {\n const graphBaseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;\n return `${new URL(graphBaseUrl).origin}/.default`;\n};\n\nconst microsoftGraphRequest = async <T>(\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n url: string,\n attempt = 0,\n): Promise<T> => {\n const response = await fetch(url, {\n headers: {\n accept: \"application/json\",\n authorization: `Bearer ${token}`,\n ConsistencyLevel: \"eventual\",\n \"user-agent\": \"@eventcatalog/connectors\",\n },\n });\n\n if (response.status === 429 && attempt < GRAPH_RETRY_ATTEMPTS) {\n await waitForRetry(response.headers.get(\"retry-after\"));\n return microsoftGraphRequest(options, token, url, attempt + 1);\n }\n\n if (!response.ok) {\n const message = await response.text();\n throw new Error(\n `Microsoft Entra directory connector failed (${response.status} ${response.statusText}): ${message}`,\n );\n }\n\n return (await response.json()) as T;\n};\n\nconst paginate = async <T>(\n options: MicrosoftEntraDirectoryOptions,\n token: string,\n url: string,\n): Promise<T[]> => {\n const results: T[] = [];\n let nextUrl: string | undefined = url;\n\n while (nextUrl) {\n const response: MicrosoftGraphCollection<T> = await microsoftGraphRequest<\n MicrosoftGraphCollection<T>\n >(options, token, nextUrl);\n results.push(...(response.value ?? []));\n nextUrl = response[\"@odata.nextLink\"];\n }\n\n return results;\n};\n\nconst buildMicrosoftGraphUrl = (\n options: MicrosoftEntraDirectoryOptions,\n pathname: string,\n query?: Record<string, string>,\n) => {\n const baseUrl = options.graphBaseUrl ?? DEFAULT_GRAPH_BASE_URL;\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n const normalizedPathname = pathname.replace(/^\\//u, \"\");\n const url = new URL(normalizedPathname, normalizedBaseUrl);\n\n for (const [key, value] of Object.entries(query ?? {})) {\n url.searchParams.set(key, value);\n }\n\n return url.toString();\n};\n\nconst assertUniqueTeamIds = (groups: ResolvedGroupInput[]) => {\n const teamIds = new Map<string, string>();\n\n for (const { group, alias } of groups) {\n const displayName = group.displayName ?? group.id;\n const teamId = alias ?? slugify(displayName);\n const existingGroupId = teamIds.get(teamId);\n\n if (existingGroupId) {\n throw new Error(\n `Microsoft Entra directory connector resolved duplicate team id \"${teamId}\" from groups \"${existingGroupId}\" and \"${group.id}\". Set alias for one of the groups.`,\n );\n }\n\n teamIds.set(teamId, group.id);\n }\n};\n\nconst slugify = (value: string) => {\n const slug = value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\n return slug || value;\n};\n\nconst escapeODataString = (value: string) => value.replace(/'/g, \"''\");\n\nconst waitForRetry = async (retryAfter: string | null) => {\n const retryAfterSeconds = retryAfter ? Number(retryAfter) : 1;\n const delayMs = Number.isFinite(retryAfterSeconds)\n ? Math.max(retryAfterSeconds, 0) * 1000\n : 1000;\n\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n};\n"],"mappings":";AAsEO,IAAM,wBAAwB,CACnC,WACG;;;ACrCL,IAAM,qBAAqB;AAEpB,IAAM,kBAAkB,CAC7B,YACoB;AACpB,MAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,KAAK,QAAQ,MAAM,WAAW,GAAG;AAC/D,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AAEJ,QAAM,OA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AE;AAEzB,SAAO,QAAQ;AACjB;AAEA,IAAM,oBAAoB,CAAC,UAAkB,MAAM,QAAQ,MAAM,IAAI;AAErE,IAAM,eAAe,OAAO,eAA8B;AACxD,QAAM,oBAAoB,aAAa,OAAO,UAAU,IAAI;AAC5D,QAAM,UAAU,OAAO,SAAS,iBAAiB,IAC7C,KAAK,IAAI,mBAAmB,CAAC,IAAI,MACjC;AAEJ,QAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,OAAO,CAAC;AAC7D;","names":["paginate"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/connectors",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Connectors for syncing external systems into EventCatalog Collections",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "tsup",
|
|
7
|
-
"build:bin": "tsup",
|
|
8
|
-
"test": "vitest --run",
|
|
9
|
-
"test:ci": "vitest --run",
|
|
10
|
-
"format": "prettier --write .",
|
|
11
|
-
"format:diff": "prettier --list-different ."
|
|
12
|
-
},
|
|
13
5
|
"publishConfig": {
|
|
14
6
|
"access": "public"
|
|
15
7
|
},
|
|
@@ -45,5 +37,13 @@
|
|
|
45
37
|
"repository": {
|
|
46
38
|
"type": "git",
|
|
47
39
|
"url": "https://github.com/event-catalog/eventcatalog"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"build:bin": "tsup",
|
|
44
|
+
"test": "vitest --run",
|
|
45
|
+
"test:ci": "vitest --run",
|
|
46
|
+
"format": "prettier --write .",
|
|
47
|
+
"format:diff": "prettier --list-different ."
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|