faros-airbyte-common 0.16.24 → 0.16.26

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.
@@ -1,5 +1,6 @@
1
1
  import { FarosClient } from 'faros-js-client';
2
2
  export { bucket, validateBucketingConfig, nextBucketId, applyRoundRobinBucketing, RoundRobinConfig, } from './bucketing';
3
+ export { VCSFilter, VCSFilterConfig, VCSConfigFields, VCSEntityNames, VCSAdapter, RepoInclusion, } from './vcs-filter';
3
4
  export interface FileDiff {
4
5
  deletions: number;
5
6
  additions: number;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.applyRoundRobinBucketing = exports.nextBucketId = exports.validateBucketingConfig = exports.bucket = void 0;
6
+ exports.VCSFilter = exports.applyRoundRobinBucketing = exports.nextBucketId = exports.validateBucketingConfig = exports.bucket = void 0;
7
7
  exports.normalizeString = normalizeString;
8
8
  exports.calculateDateRange = calculateDateRange;
9
9
  exports.collectReposByOrg = collectReposByOrg;
@@ -19,6 +19,8 @@ Object.defineProperty(exports, "bucket", { enumerable: true, get: function () {
19
19
  Object.defineProperty(exports, "validateBucketingConfig", { enumerable: true, get: function () { return bucketing_1.validateBucketingConfig; } });
20
20
  Object.defineProperty(exports, "nextBucketId", { enumerable: true, get: function () { return bucketing_1.nextBucketId; } });
21
21
  Object.defineProperty(exports, "applyRoundRobinBucketing", { enumerable: true, get: function () { return bucketing_1.applyRoundRobinBucketing; } });
22
+ var vcs_filter_1 = require("./vcs-filter");
23
+ Object.defineProperty(exports, "VCSFilter", { enumerable: true, get: function () { return vcs_filter_1.VCSFilter; } });
22
24
  function normalizeString(str) {
23
25
  return str.replace(/\s/g, '').toLowerCase();
24
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[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,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,167 @@
1
+ import { AirbyteLogger } from 'faros-airbyte-cdk';
2
+ import { FarosClient } from 'faros-js-client';
3
+ /**
4
+ * Configuration for VCS entity filtering
5
+ */
6
+ export interface VCSFilterConfig<TConfig, TOrg, TRepo> {
7
+ /** Configuration object containing entity filter arrays */
8
+ config: TConfig;
9
+ /** Logger instance for debug/warning messages */
10
+ logger: AirbyteLogger;
11
+ /** Optional Faros client for graph-based filtering */
12
+ farosClient?: FarosClient;
13
+ /** Configuration field names mapping */
14
+ configFields: VCSConfigFields;
15
+ /** Entity type names for logging and API calls */
16
+ entityNames: VCSEntityNames;
17
+ /** VCS-specific adapter for API operations */
18
+ vcsAdapter: VCSAdapter<TOrg, TRepo>;
19
+ /** Graph name for Faros integration (optional) */
20
+ defaultGraph?: string;
21
+ /** Whether to use Faros graph for repo selection */
22
+ useFarosGraphReposSelection?: boolean;
23
+ }
24
+ /**
25
+ * Maps configuration field names to their corresponding arrays
26
+ */
27
+ export interface VCSConfigFields {
28
+ /** Field name for organization/group/workspace entities (e.g., 'organizations', 'groups', 'workspaces') */
29
+ orgs: string;
30
+ /** Field name for excluded organization/group/workspace entities */
31
+ excludedOrgs: string;
32
+ /** Field name for repository entities */
33
+ repos: string;
34
+ /** Field name for excluded repository entities */
35
+ excludedRepos: string;
36
+ /** Field name for Faros graph repos selection flag */
37
+ useFarosGraphReposSelection?: string;
38
+ /** Field name for Faros graph name */
39
+ graph?: string;
40
+ }
41
+ /**
42
+ * Entity names for logging and display purposes
43
+ */
44
+ export interface VCSEntityNames {
45
+ /** Singular name of organization-level entity (e.g., 'organization', 'group', 'workspace') */
46
+ org: string;
47
+ /** Plural name of organization-level entity */
48
+ orgs: string;
49
+ /** Singular name of repository entity */
50
+ repo: string;
51
+ /** Plural name of repository entities */
52
+ repos: string;
53
+ /** VCS platform name (e.g., 'GitHub', 'GitLab', 'Bitbucket') */
54
+ platform: string;
55
+ }
56
+ /**
57
+ * VCS-specific adapter interface for API operations
58
+ */
59
+ export interface VCSAdapter<TOrg, TRepo> {
60
+ /** Get all visible organization-level entities */
61
+ getOrgs(): Promise<string[]>;
62
+ /** Get a specific organization-level entity by name */
63
+ getOrg(orgName: string): Promise<TOrg>;
64
+ /** Get all repositories for an organization */
65
+ getRepos(orgName: string): Promise<TRepo[]>;
66
+ /** Extract repository name from repository object */
67
+ getRepoName(repo: TRepo): string;
68
+ }
69
+ /**
70
+ * Repository inclusion result
71
+ */
72
+ export type RepoInclusion<TRepo> = {
73
+ repo: TRepo;
74
+ syncRepoData: boolean;
75
+ };
76
+ /**
77
+ * Generic VCS organization/repository filter
78
+ *
79
+ * This class provides a reusable filtering mechanism for VCS sources that follow
80
+ * a two-level hierarchy (organization/group/workspace → repository). It supports:
81
+ *
82
+ * - Include/exclude patterns for both levels
83
+ * - Case-insensitive filtering
84
+ * - Faros Graph integration for dynamic repository selection
85
+ * - Configurable entity names and field mappings
86
+ * - Comprehensive validation and error handling
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * // GitHub usage
91
+ * const filter = new VCSFilter({
92
+ * config: githubConfig,
93
+ * logger: logger,
94
+ * farosClient: farosClient,
95
+ * configFields: {
96
+ * orgs: 'organizations',
97
+ * excludedOrgs: 'excluded_organizations',
98
+ * repos: 'repositories',
99
+ * excludedRepos: 'excluded_repositories',
100
+ * useFarosGraphReposSelection: 'use_faros_graph_repos_selection',
101
+ * graph: 'graph'
102
+ * },
103
+ * entityNames: {
104
+ * org: 'organization',
105
+ * orgs: 'organizations',
106
+ * repo: 'repository',
107
+ * repos: 'repositories',
108
+ * platform: 'GitHub'
109
+ * },
110
+ * vcsAdapter: new GitHubAdapter(githubClient),
111
+ * defaultGraph: 'default-graph'
112
+ * });
113
+ *
114
+ * // GitLab usage
115
+ * const filter = new VCSFilter({
116
+ * config: gitlabConfig,
117
+ * logger: logger,
118
+ * configFields: {
119
+ * orgs: 'groups',
120
+ * excludedOrgs: 'excluded_groups',
121
+ * repos: 'repositories',
122
+ * excludedRepos: 'excluded_repositories'
123
+ * },
124
+ * entityNames: {
125
+ * org: 'group',
126
+ * orgs: 'groups',
127
+ * repo: 'repository',
128
+ * repos: 'repositories',
129
+ * platform: 'GitLab'
130
+ * },
131
+ * vcsAdapter: new GitLabAdapter(gitlabClient)
132
+ * });
133
+ * ```
134
+ */
135
+ export declare class VCSFilter<TConfig extends Record<string, any>, TOrg, TRepo> {
136
+ private readonly options;
137
+ private readonly filterConfig;
138
+ private readonly useFarosGraphReposSelection;
139
+ private orgs?;
140
+ private reposByOrg;
141
+ private loadedSelectedRepos;
142
+ constructor(options: VCSFilterConfig<TConfig, TOrg, TRepo>);
143
+ /**
144
+ * Get all filtered organization names
145
+ */
146
+ getOrgs(): Promise<ReadonlyArray<string>>;
147
+ /**
148
+ * Get all filtered repositories for an organization
149
+ */
150
+ getRepos(org: string): Promise<ReadonlyArray<RepoInclusion<TRepo>>>;
151
+ /**
152
+ * Check if a specific repository should be included and synced
153
+ */
154
+ getRepoInclusion(org: string, repo: string): Promise<{
155
+ included: boolean;
156
+ syncRepoData: boolean;
157
+ }>;
158
+ /**
159
+ * Get a specific repository object by org and name
160
+ */
161
+ getRepository(org: string, name: string): TRepo;
162
+ private filterOrgs;
163
+ private isVisibleOrg;
164
+ private loadSelectedRepos;
165
+ private getSelectedReposByOrg;
166
+ private hasFarosClient;
167
+ }
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.VCSFilter = void 0;
13
+ const lodash_1 = require("lodash");
14
+ const typescript_memoize_1 = require("typescript-memoize");
15
+ const verror_1 = __importDefault(require("verror"));
16
+ const index_1 = require("./index");
17
+ /**
18
+ * Generic VCS organization/repository filter
19
+ *
20
+ * This class provides a reusable filtering mechanism for VCS sources that follow
21
+ * a two-level hierarchy (organization/group/workspace → repository). It supports:
22
+ *
23
+ * - Include/exclude patterns for both levels
24
+ * - Case-insensitive filtering
25
+ * - Faros Graph integration for dynamic repository selection
26
+ * - Configurable entity names and field mappings
27
+ * - Comprehensive validation and error handling
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // GitHub usage
32
+ * const filter = new VCSFilter({
33
+ * config: githubConfig,
34
+ * logger: logger,
35
+ * farosClient: farosClient,
36
+ * configFields: {
37
+ * orgs: 'organizations',
38
+ * excludedOrgs: 'excluded_organizations',
39
+ * repos: 'repositories',
40
+ * excludedRepos: 'excluded_repositories',
41
+ * useFarosGraphReposSelection: 'use_faros_graph_repos_selection',
42
+ * graph: 'graph'
43
+ * },
44
+ * entityNames: {
45
+ * org: 'organization',
46
+ * orgs: 'organizations',
47
+ * repo: 'repository',
48
+ * repos: 'repositories',
49
+ * platform: 'GitHub'
50
+ * },
51
+ * vcsAdapter: new GitHubAdapter(githubClient),
52
+ * defaultGraph: 'default-graph'
53
+ * });
54
+ *
55
+ * // GitLab usage
56
+ * const filter = new VCSFilter({
57
+ * config: gitlabConfig,
58
+ * logger: logger,
59
+ * configFields: {
60
+ * orgs: 'groups',
61
+ * excludedOrgs: 'excluded_groups',
62
+ * repos: 'repositories',
63
+ * excludedRepos: 'excluded_repositories'
64
+ * },
65
+ * entityNames: {
66
+ * org: 'group',
67
+ * orgs: 'groups',
68
+ * repo: 'repository',
69
+ * repos: 'repositories',
70
+ * platform: 'GitLab'
71
+ * },
72
+ * vcsAdapter: new GitLabAdapter(gitlabClient)
73
+ * });
74
+ * ```
75
+ */
76
+ class VCSFilter {
77
+ constructor(options) {
78
+ var _a;
79
+ this.options = options;
80
+ this.reposByOrg = new Map();
81
+ this.loadedSelectedRepos = false;
82
+ const { config, logger, configFields, entityNames } = options;
83
+ this.useFarosGraphReposSelection =
84
+ (_a = config[configFields.useFarosGraphReposSelection || 'use_faros_graph_repos_selection']) !== null && _a !== void 0 ? _a : false;
85
+ const orgs = config[configFields.orgs];
86
+ const repos = config[configFields.repos];
87
+ const excludedRepos = config[configFields.excludedRepos];
88
+ let excludedOrgs = config[configFields.excludedOrgs];
89
+ if ((orgs === null || orgs === void 0 ? void 0 : orgs.length) && (excludedOrgs === null || excludedOrgs === void 0 ? void 0 : excludedOrgs.length)) {
90
+ logger.warn(`Both ${configFields.orgs} and ${configFields.excludedOrgs} are specified, ${configFields.excludedOrgs} will be ignored.`);
91
+ excludedOrgs = undefined;
92
+ }
93
+ let reposByOrg;
94
+ let excludedReposByOrg;
95
+ if (!this.useFarosGraphReposSelection) {
96
+ ({ reposByOrg, excludedReposByOrg } = this.getSelectedReposByOrg(repos, excludedRepos));
97
+ this.loadedSelectedRepos = true;
98
+ }
99
+ else {
100
+ if (!this.hasFarosClient()) {
101
+ throw new verror_1.default(`Faros credentials are required when using Faros Graph for ${entityNames.repos} selection`);
102
+ }
103
+ if ((repos === null || repos === void 0 ? void 0 : repos.length) || (excludedRepos === null || excludedRepos === void 0 ? void 0 : excludedRepos.length)) {
104
+ logger.warn(`Using Faros Graph for ${entityNames.repos} selection but ${configFields.repos} and/or ${configFields.excludedRepos} are specified, both will be ignored.`);
105
+ }
106
+ }
107
+ this.filterConfig = {
108
+ orgs: (orgs === null || orgs === void 0 ? void 0 : orgs.length) ? new Set(orgs) : undefined,
109
+ excludedOrgs: (excludedOrgs === null || excludedOrgs === void 0 ? void 0 : excludedOrgs.length) ? new Set(excludedOrgs) : undefined,
110
+ reposByOrg,
111
+ excludedReposByOrg,
112
+ };
113
+ }
114
+ /**
115
+ * Get all filtered organization names
116
+ */
117
+ async getOrgs() {
118
+ if (!this.orgs) {
119
+ const { vcsAdapter, logger, entityNames } = this.options;
120
+ const visibleOrgs = new Set((await vcsAdapter.getOrgs()).map((o) => (0, lodash_1.toLower)(o)));
121
+ if (!visibleOrgs.size) {
122
+ logger.warn(`No visible ${entityNames.orgs} found`);
123
+ }
124
+ this.orgs = await this.filterOrgs(visibleOrgs);
125
+ }
126
+ if (this.orgs.size === 0) {
127
+ throw new verror_1.default({
128
+ info: {
129
+ code: 'NO_VISIBLE_ORGS'
130
+ }
131
+ }, `No visible ${this.options.entityNames.orgs} remain after applying inclusion and exclusion filters`);
132
+ }
133
+ return Array.from(this.orgs);
134
+ }
135
+ /**
136
+ * Get all filtered repositories for an organization
137
+ */
138
+ async getRepos(org) {
139
+ const lowerOrg = (0, lodash_1.toLower)(org);
140
+ await this.loadSelectedRepos();
141
+ if (!this.reposByOrg.has(lowerOrg)) {
142
+ const repos = new Map();
143
+ const { vcsAdapter, logger, entityNames } = this.options;
144
+ const visibleRepos = await vcsAdapter.getRepos(lowerOrg);
145
+ if (!visibleRepos.length) {
146
+ logger.warn(`No visible ${entityNames.repos} found for ${entityNames.org} ${lowerOrg}`);
147
+ }
148
+ for (const repo of visibleRepos) {
149
+ const lowerRepoName = (0, lodash_1.toLower)(vcsAdapter.getRepoName(repo));
150
+ const { included, syncRepoData } = await this.getRepoInclusion(lowerOrg, lowerRepoName);
151
+ if (included) {
152
+ repos.set(lowerRepoName, { repo, syncRepoData });
153
+ }
154
+ }
155
+ this.reposByOrg.set(lowerOrg, repos);
156
+ }
157
+ return Array.from(this.reposByOrg.get(lowerOrg).values());
158
+ }
159
+ /**
160
+ * Check if a specific repository should be included and synced
161
+ */
162
+ async getRepoInclusion(org, repo) {
163
+ await this.loadSelectedRepos();
164
+ const { reposByOrg, excludedReposByOrg } = this.filterConfig;
165
+ const repos = reposByOrg === null || reposByOrg === void 0 ? void 0 : reposByOrg.get(org);
166
+ const excludedRepos = excludedReposByOrg === null || excludedReposByOrg === void 0 ? void 0 : excludedReposByOrg.get(org);
167
+ if (this.useFarosGraphReposSelection) {
168
+ const included = true;
169
+ const syncRepoData = (!(repos === null || repos === void 0 ? void 0 : repos.size) || repos.has(repo)) && !(excludedRepos === null || excludedRepos === void 0 ? void 0 : excludedRepos.has(repo));
170
+ return { included, syncRepoData };
171
+ }
172
+ if (repos === null || repos === void 0 ? void 0 : repos.size) {
173
+ const included = repos.has(repo);
174
+ return { included, syncRepoData: included };
175
+ }
176
+ if (excludedRepos === null || excludedRepos === void 0 ? void 0 : excludedRepos.size) {
177
+ const included = !excludedRepos.has(repo);
178
+ return { included, syncRepoData: included };
179
+ }
180
+ return { included: true, syncRepoData: true };
181
+ }
182
+ /**
183
+ * Get a specific repository object by org and name
184
+ */
185
+ getRepository(org, name) {
186
+ var _a, _b;
187
+ const lowerOrg = (0, lodash_1.toLower)(org);
188
+ const lowerRepoName = (0, lodash_1.toLower)(name);
189
+ const { repo } = (_b = (_a = this.reposByOrg.get(lowerOrg)) === null || _a === void 0 ? void 0 : _a.get(lowerRepoName)) !== null && _b !== void 0 ? _b : {};
190
+ if (!repo) {
191
+ throw new verror_1.default(`${this.options.entityNames.repo} not found: %s/%s`, lowerOrg, lowerRepoName);
192
+ }
193
+ return repo;
194
+ }
195
+ async filterOrgs(visibleOrgs) {
196
+ var _a;
197
+ const orgs = new Set();
198
+ const { vcsAdapter, logger, entityNames } = this.options;
199
+ if (!this.filterConfig.orgs) {
200
+ for (const org of visibleOrgs) {
201
+ const lowerOrg = (0, lodash_1.toLower)(org);
202
+ if (!((_a = this.filterConfig.excludedOrgs) === null || _a === void 0 ? void 0 : _a.has(lowerOrg))) {
203
+ orgs.add(lowerOrg);
204
+ }
205
+ else {
206
+ logger.info(`Skipping excluded ${entityNames.org} ${lowerOrg}`);
207
+ }
208
+ }
209
+ }
210
+ else {
211
+ for (const org of this.filterConfig.orgs) {
212
+ const lowerOrg = (0, lodash_1.toLower)(org);
213
+ if (await this.isVisibleOrg(visibleOrgs, lowerOrg)) {
214
+ orgs.add(lowerOrg);
215
+ }
216
+ }
217
+ }
218
+ return orgs;
219
+ }
220
+ async isVisibleOrg(visibleOrgs, lowerOrg) {
221
+ if (visibleOrgs.has(lowerOrg)) {
222
+ return true;
223
+ }
224
+ const { vcsAdapter, logger, entityNames } = this.options;
225
+ try {
226
+ await vcsAdapter.getOrg(lowerOrg);
227
+ return true;
228
+ }
229
+ catch (error) {
230
+ logger.warn(`Fetching ${entityNames.org} ${lowerOrg} failed with error: ` +
231
+ `${error.status} - ${error.message}. Skipping.`);
232
+ return false;
233
+ }
234
+ }
235
+ async loadSelectedRepos() {
236
+ var _a;
237
+ if (this.loadedSelectedRepos) {
238
+ return;
239
+ }
240
+ if (this.useFarosGraphReposSelection) {
241
+ const { farosClient, config, configFields, entityNames, defaultGraph } = this.options;
242
+ const graphName = (_a = config[configFields.graph || 'graph']) !== null && _a !== void 0 ? _a : defaultGraph;
243
+ const farosOptions = await (0, index_1.getFarosOptions)('repository', entityNames.platform, farosClient, graphName);
244
+ const { included: repositories, excluded: excludedRepositories } = farosOptions;
245
+ const { reposByOrg, excludedReposByOrg } = this.getSelectedReposByOrg(Array.from(repositories), Array.from(excludedRepositories));
246
+ this.filterConfig.reposByOrg = reposByOrg;
247
+ this.filterConfig.excludedReposByOrg = excludedReposByOrg;
248
+ }
249
+ this.loadedSelectedRepos = true;
250
+ }
251
+ getSelectedReposByOrg(repositories, excludedRepositories) {
252
+ const reposByOrg = new Map();
253
+ const excludedReposByOrg = new Map();
254
+ const { logger, entityNames } = this.options;
255
+ if (repositories === null || repositories === void 0 ? void 0 : repositories.length) {
256
+ (0, index_1.collectReposByOrg)(reposByOrg, repositories);
257
+ }
258
+ if (excludedRepositories === null || excludedRepositories === void 0 ? void 0 : excludedRepositories.length) {
259
+ (0, index_1.collectReposByOrg)(excludedReposByOrg, excludedRepositories);
260
+ }
261
+ for (const org of reposByOrg.keys()) {
262
+ if (excludedReposByOrg.has(org)) {
263
+ logger.warn(`Both ${this.options.configFields.repos} and ${this.options.configFields.excludedRepos} are specified for ${entityNames.org} ${org}, ${this.options.configFields.excludedRepos} for ${entityNames.org} ${org} will be ignored.`);
264
+ excludedReposByOrg.delete(org);
265
+ }
266
+ }
267
+ return { reposByOrg, excludedReposByOrg };
268
+ }
269
+ hasFarosClient() {
270
+ return Boolean(this.options.farosClient);
271
+ }
272
+ }
273
+ exports.VCSFilter = VCSFilter;
274
+ __decorate([
275
+ (0, typescript_memoize_1.Memoize)()
276
+ ], VCSFilter.prototype, "getOrgs", null);
277
+ __decorate([
278
+ (0, typescript_memoize_1.Memoize)()
279
+ ], VCSFilter.prototype, "getRepos", null);
280
+ //# sourceMappingURL=vcs-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vcs-filter.js","sourceRoot":"","sources":["../../src/common/vcs-filter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mCAA+B;AAC/B,2DAA2C;AAC3C,oDAA4B;AAE5B,mCAA2D;AA0F3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAa,SAAS;IAOpB,YAA6B,OAA8C;;QAA9C,YAAO,GAAP,OAAO,CAAuC;QAHnE,eAAU,GAAmD,IAAI,GAAG,EAAE,CAAC;QACvE,wBAAmB,GAAY,KAAK,CAAC;QAG3C,MAAM,EAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAC,GAAG,OAAO,CAAC;QAE5D,IAAI,CAAC,2BAA2B;YAC9B,MAAA,MAAM,CAAC,YAAY,CAAC,2BAA2B,IAAI,iCAAiC,CAAC,mCAAI,KAAK,CAAC;QAEjG,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAyB,CAAC;QAC/D,MAAM,KAAK,GAAG,MAAM,C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,YAAY,CAAC,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,sBAAsB,WAAW,CAAC,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,QAAQ,WAAW,CAAC,GAAG,IAAI,GAAG,mBAAmB,CAChO,CAAC;gBACF,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC;IAC1C,CAAC;IAEO,cAAc;QACpB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAvRD,8BAuRC;AA7NO;IADL,IAAA,4BAAO,GAAE;wCA2BT;AAMK;IADL,IAAA,4BAAO,GAAE;yCA8BT"}
@@ -137,7 +137,35 @@ export declare enum GitHubTool {
137
137
  export type CopilotUsageSummary = {
138
138
  org: string;
139
139
  team: string | null;
140
- } & GetResponseDataTypeFromEndpointMethod<typeof octokit.copilot.usageMetricsForOrg>[0];
140
+ } & {
141
+ day: string;
142
+ total_suggestions_count: number;
143
+ total_acceptances_count: number;
144
+ total_lines_suggested: number;
145
+ total_lines_accepted: number;
146
+ total_active_users: number;
147
+ total_active_chat_users: number;
148
+ total_chats: number;
149
+ total_chat_insertion_events: number;
150
+ total_chat_copy_events: number;
151
+ breakdown: {
152
+ language: string;
153
+ editor: string;
154
+ suggestions_count: number;
155
+ acceptances_count: number;
156
+ lines_suggested: number;
157
+ lines_accepted: number;
158
+ active_users: number;
159
+ model_breakdown?: {
160
+ model: string;
161
+ suggestions_count: number;
162
+ acceptances_count: number;
163
+ lines_suggested: number;
164
+ lines_accepted: number;
165
+ active_users: number;
166
+ }[];
167
+ }[];
168
+ };
141
169
  export type LanguageEditorBreakdown = CopilotUsageSummary['breakdown'][0];
142
170
  export type CodeScanningAlert = {
143
171
  org: string;
@@ -214,5 +242,21 @@ export type EnterpriseCopilotSeatsEmpty = {
214
242
  export type EnterpriseCopilotUsageSummary = {
215
243
  enterprise: string;
216
244
  team: string | null;
217
- } & GetResponseDataTypeFromEndpointMethod<typeof octokit.copilot.usageMetricsForOrg>[0];
245
+ } & Omit<CopilotUsageSummary, 'org' | 'team'>;
246
+ export type EnterpriseCopilotUserEngagement = {
247
+ enterprise: string;
248
+ date: string;
249
+ day: string;
250
+ login: string;
251
+ user_id: string;
252
+ cli_engagement: 0 | 1;
253
+ code_completion_engagement: 0 | 1;
254
+ code_review_engagement: 0 | 1;
255
+ dotcom_chat_engagement: 0 | 1;
256
+ inline_chat_engagement: 0 | 1;
257
+ knowledge_base_chat_engagement: 0 | 1;
258
+ mobile_chat_engagement: 0 | 1;
259
+ panel_chat_engagement: 0 | 1;
260
+ pull_request_summary_engagement: 0 | 1;
261
+ };
218
262
  export {};