vector_amp 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7147209a61689dee14e2d37581f33cad58fb5291543edb086fcafdf841e71c0a
4
- data.tar.gz: c399a9373b4820d6c141362b29e2b81bc34de71a02ecb0d69c7780febdbd3674
3
+ metadata.gz: 8275404bc4db2f1270091d20315634d273fa140417503bdfea605c9d3baf0c5b
4
+ data.tar.gz: 426ae6dd92df94fd947d92ace32cbae23af4b0b0b69cf6a7eb2e9daf5e380257
5
5
  SHA512:
6
- metadata.gz: 6b2f983acc42db9c33801bcbe726537975af6d6ec9eab12a542a860ac5836fa417e07bb35ddfd6e4f7a55f0b6311c4ee5793d192427e5182c5fff11aae9849c4
7
- data.tar.gz: 2d720c1922917177c98cf7ddab94b9f2f20ef0654e31f673d47f4283459cca5c9808851875bf2a28a40ff9f6d63a7634bd852b0a74539453c6e7dff9d4dd58b1
6
+ metadata.gz: 585008c3ef2c83a95d8e55956ac4e11a6b006f05e3aa8d3af3d5932967edf53ce3f47af88612dd9e56e443eea327b4de30cdd6b82e5732d0d93e15a67edfc7ea
7
+ data.tar.gz: ab6d8685a761322203f41278049106953c0c3a12a3e3b12cd844cc2c7c3d89745027d3df9c1745ac41b656708a84b742eb199156dcf6e8e038c795ba7a5c5a5f
data/README.md CHANGED
@@ -197,7 +197,8 @@ client.ingestion.list_sources(limit: 50, offset: 0)
197
197
  client.ingestion.get_source("source-uuid")
198
198
 
199
199
  # Typed builders cover the supported source_type values:
200
- # "web", "s3", "gcs", "gdrive", "file_upload", "jira", and "confluence".
200
+ # "web", "s3", "gcs", "gdrive", "file_upload", "jira", "confluence",
201
+ # "github", and "gitlab".
201
202
  source = client.sources.create_web(
202
203
  start_urls: ["https://docs.example.com"],
203
204
  max_depth: 1,
@@ -229,6 +230,20 @@ gdrive_source = client.sources.create_google_drive(
229
230
  folder_ids: ["google-drive-folder-id"]
230
231
  )
231
232
 
233
+ # GitHub reads through the VectorAmp GitHub App, so the SDK never takes a token.
234
+ # Install the app from the Sources page and pass the installation id it reports.
235
+ github_source = client.sources.create_github(
236
+ installation_id: 42,
237
+ repositories: ["acme/api", "acme/web"]
238
+ )
239
+
240
+ gitlab_source = client.sources.create_gitlab(
241
+ projects: ["mygroup/myproject"], # and/or groups: ["mygroup"]
242
+ auth_mode: "token", # defaults to "oauth"
243
+ access_token: ENV["GITLAB_TOKEN"],
244
+ gitlab_url: "https://gitlab.com" # override for self-managed
245
+ )
246
+
232
247
  file_source = client.sources.create_file_upload
233
248
 
234
249
  # You can still pass name: when you want control. If omitted, the SDK chooses
@@ -406,7 +421,8 @@ Dataset-object helpers: `search`, `insert`, `add_texts`, `embed`, `delete`, `sta
406
421
 
407
422
  `create(source)`, `create_web(start_urls:)`, `create_s3(bucket:)`, `create_gcs(bucket:)`,
408
423
  `create_google_drive(folder_ids:|file_ids:)`, `create_jira(cloud_id:)`,
409
- `create_confluence(cloud_id:|base_url:)`, `create_file_upload`, `list_sources`, `get_source(id)`.
424
+ `create_confluence(cloud_id:|base_url:)`, `create_github(installation_id:, repositories:)`,
425
+ `create_gitlab(groups:|projects:)`, `create_file_upload`, `list_sources`, `get_source(id)`.
410
426
  Jobs: `start_job(source_id:, dataset_id:)`, `list_jobs`, `get_job(id)`, `retry_job(id)`,
411
427
  `ingest_files(dataset_id:, paths:)`.
412
428
 
@@ -224,6 +224,102 @@ module VectorAmp
224
224
  ))
225
225
  end
226
226
 
227
+ # Create a GitHub source backed by the VectorAmp GitHub App.
228
+ #
229
+ # Install the VectorAmp GitHub App from the Sources page in the app first and
230
+ # pass the resulting installation id here; the SDK never handles a GitHub token.
231
+ # @param installation_id [Integer] required GitHub App installation id.
232
+ # @param repositories [String, Array<String>] required `owner/repo` full names.
233
+ # @param name [String, nil] defaults to `github-<owner>-<repo>` from the first repository.
234
+ # @param ref_mode [String, nil] `active` (server default), `default`, or `explicit`.
235
+ # @param refs [String, Array<String>, nil] explicit branch names for `ref_mode: "explicit"`.
236
+ # @param excluded_refs [String, Array<String>, nil] branch names to skip.
237
+ # @param active_branch_days [Integer, nil] activity window in days (1-90); server default 7.
238
+ # @param include_pull_requests [Boolean, nil] ingest pull requests; server default true.
239
+ # @param include_review_threads [Boolean, nil] ingest review discussions; server default true.
240
+ # @param include_direct_commits [Boolean, nil] ingest commits outside a pull request; server default true.
241
+ # @param include_globs [String, Array<String>, nil] path globs to include; server default `**/*`.
242
+ # @param exclude_globs [String, Array<String>, nil] path globs to skip.
243
+ # @param max_file_size_bytes [Integer, nil] per-file ceiling; server default 1_000_000.
244
+ # @param description [String, nil] optional description.
245
+ # @param metadata [Hash, nil] optional metadata.
246
+ # @param config [Hash] additional GitHub-source config forwarded to the API.
247
+ # @return [Hash] created source response.
248
+ def create_github(installation_id:, repositories:, name: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
249
+ active_branch_days: nil, include_pull_requests: nil, include_review_threads: nil,
250
+ include_direct_commits: nil, include_globs: nil, exclude_globs: nil,
251
+ max_file_size_bytes: nil, description: nil, metadata: nil, **config)
252
+ create_source(GitHubSource.new(
253
+ installation_id: installation_id,
254
+ repositories: repositories,
255
+ name: name,
256
+ ref_mode: ref_mode,
257
+ refs: refs,
258
+ excluded_refs: excluded_refs,
259
+ active_branch_days: active_branch_days,
260
+ include_pull_requests: include_pull_requests,
261
+ include_review_threads: include_review_threads,
262
+ include_direct_commits: include_direct_commits,
263
+ include_globs: include_globs,
264
+ exclude_globs: exclude_globs,
265
+ max_file_size_bytes: max_file_size_bytes,
266
+ description: description,
267
+ metadata: metadata,
268
+ **config
269
+ ))
270
+ end
271
+
272
+ # Create a GitLab source for gitlab.com or a self-managed instance.
273
+ # @param groups [String, Array<String>, nil] group paths; required unless projects is given.
274
+ # @param projects [String, Array<String>, nil] project paths with namespace; required unless groups is given.
275
+ # @param name [String, nil] defaults to `gitlab-<path>` from the first project or group.
276
+ # @param auth_mode [String] `oauth` (default) or `token`.
277
+ # @param gitlab_url [String] instance base URL; defaults to `https://gitlab.com`.
278
+ # @param access_token [String, nil] personal or group access token for `auth_mode: "token"`.
279
+ # @param connection_id [String, nil] optional stored OAuth connection id used instead of a token.
280
+ # @param ref_mode [String, nil] `active` (server default), `default`, or `explicit`.
281
+ # @param refs [String, Array<String>, nil] explicit branch names for `ref_mode: "explicit"`.
282
+ # @param excluded_refs [String, Array<String>, nil] branch names to skip.
283
+ # @param active_branch_days [Integer, nil] activity window in days (1-90); server default 7.
284
+ # @param include_merge_requests [Boolean, nil] ingest merge requests; server default true.
285
+ # @param include_review_threads [Boolean, nil] ingest review discussions; server default true.
286
+ # @param include_direct_commits [Boolean, nil] ingest commits outside a merge request; server default true.
287
+ # @param include_globs [String, Array<String>, nil] path globs to include; server default `**/*`.
288
+ # @param exclude_globs [String, Array<String>, nil] path globs to skip.
289
+ # @param max_file_size_bytes [Integer, nil] per-file ceiling; server default 1_000_000.
290
+ # @param description [String, nil] optional description.
291
+ # @param metadata [Hash, nil] optional metadata.
292
+ # @param config [Hash] additional GitLab-source config forwarded to the API.
293
+ # @return [Hash] created source response.
294
+ def create_gitlab(groups: nil, projects: nil, name: nil, auth_mode: "oauth", gitlab_url: "https://gitlab.com",
295
+ access_token: nil, connection_id: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
296
+ active_branch_days: nil, include_merge_requests: nil, include_review_threads: nil,
297
+ include_direct_commits: nil, include_globs: nil, exclude_globs: nil,
298
+ max_file_size_bytes: nil, description: nil, metadata: nil, **config)
299
+ create_source(GitLabSource.new(
300
+ groups: groups,
301
+ projects: projects,
302
+ name: name,
303
+ auth_mode: auth_mode,
304
+ gitlab_url: gitlab_url,
305
+ access_token: access_token,
306
+ connection_id: connection_id,
307
+ ref_mode: ref_mode,
308
+ refs: refs,
309
+ excluded_refs: excluded_refs,
310
+ active_branch_days: active_branch_days,
311
+ include_merge_requests: include_merge_requests,
312
+ include_review_threads: include_review_threads,
313
+ include_direct_commits: include_direct_commits,
314
+ include_globs: include_globs,
315
+ exclude_globs: exclude_globs,
316
+ max_file_size_bytes: max_file_size_bytes,
317
+ description: description,
318
+ metadata: metadata,
319
+ **config
320
+ ))
321
+ end
322
+
227
323
  # Create a file-upload source.
228
324
  # @param name [String, nil] defaults to timestamped `ruby-sdk-file-upload-YYYYmmddHHMMSS`.
229
325
  # @param description [String, nil] optional description.
@@ -386,6 +482,8 @@ module VectorAmp
386
482
  when "jira" then SourceNames.jira(project_keys: config[:project_keys] || config["project_keys"], cloud_id: config[:cloud_id] || config["cloud_id"])
387
483
  when "confluence" then SourceNames.confluence(spaces: config[:spaces] || config["spaces"], cloud_id: config[:cloud_id] || config["cloud_id"], base_url: config[:base_url] || config["base_url"])
388
484
  when "gdrive" then SourceNames.google_drive(folder_ids: config[:folder_ids] || config["folder_ids"], file_ids: config[:file_ids] || config["file_ids"])
485
+ when "github" then SourceNames.github(repositories: config[:repositories] || config["repositories"])
486
+ when "gitlab" then SourceNames.gitlab(projects: config[:projects] || config["projects"], groups: config[:groups] || config["groups"])
389
487
  end
390
488
  end
391
489
 
@@ -10,7 +10,7 @@ module VectorAmp
10
10
  # create a source or to `dataset.ingest_source(source)` once they include an id
11
11
  # returned by the API.
12
12
  class Source
13
- SUPPORTED_SOURCE_TYPES = %w[s3 web gcs gdrive file_upload jira confluence].freeze
13
+ SUPPORTED_SOURCE_TYPES = %w[s3 web gcs gdrive file_upload jira confluence github gitlab].freeze
14
14
 
15
15
  # @return [String, nil] API source id when returned by the API.
16
16
  # @return [String] source type (`s3`, `web`, `gdrive`, or `file_upload`).
@@ -164,6 +164,28 @@ module VectorAmp
164
164
  nil
165
165
  end
166
166
 
167
+ # @param repositories [String, Array<String>, nil] `owner/repo` full names.
168
+ # @return [String] `github-<owner>-<repo>` from the first repository, or `github-source`.
169
+ def github(repositories: nil)
170
+ repository = Array(repositories).first
171
+ repository ? "github-#{slugify(repository)}" : "github-source"
172
+ end
173
+
174
+ # @param projects [String, Array<String>, nil] project paths with namespace.
175
+ # @param groups [String, Array<String>, nil] group paths.
176
+ # @return [String] `gitlab-<path>` from the first project or group, or `gitlab-source`.
177
+ def gitlab(projects: nil, groups: nil)
178
+ path = Array(projects).first || Array(groups).first
179
+ path ? "gitlab-#{slugify(path)}" : "gitlab-source"
180
+ end
181
+
182
+ # Lowercase a repository/group path into a dash-separated name fragment.
183
+ # @param value [String] path such as `owner/repo` or `group/subgroup/project`.
184
+ # @return [String]
185
+ def slugify(value)
186
+ value.to_s.downcase.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "")
187
+ end
188
+
167
189
  # @param folder_ids [String, Array<String>, nil] folder ids.
168
190
  # @param file_ids [String, Array<String>, nil] file ids.
169
191
  # @return [String] `google-drive-<first id>` or `google-drive-source`.
@@ -360,6 +382,133 @@ module VectorAmp
360
382
  end
361
383
  end
362
384
 
385
+ # GitHub ingestion source backed by the VectorAmp GitHub App.
386
+ #
387
+ # Repositories, active branches, pull requests, and review discussions are read
388
+ # through a GitHub App installation, so no token is passed to the SDK. Install
389
+ # the VectorAmp GitHub App from the Sources page in the app first; the
390
+ # installation id shown there is what this class needs.
391
+ class GitHubSource < Source
392
+ # @param installation_id [Integer] required GitHub App installation id; must be positive.
393
+ # @param repositories [String, Array<String>] required `owner/repo` full names.
394
+ # @param name [String, nil] defaults to `github-<owner>-<repo>` from the first repository.
395
+ # @param ref_mode [String, nil] `active` (server default), `default`, or `explicit`.
396
+ # @param refs [String, Array<String>, nil] explicit branch names for `ref_mode: "explicit"`.
397
+ # @param excluded_refs [String, Array<String>, nil] branch names to skip.
398
+ # @param active_branch_days [Integer, nil] activity window in days (1-90); server default 7.
399
+ # @param include_pull_requests [Boolean, nil] ingest pull requests; server default true.
400
+ # @param include_review_threads [Boolean, nil] ingest review discussions; server default true.
401
+ # @param include_direct_commits [Boolean, nil] ingest commits outside a pull request; server default true.
402
+ # @param include_globs [String, Array<String>, nil] path globs to include; server default `**/*`.
403
+ # @param exclude_globs [String, Array<String>, nil] path globs to skip.
404
+ # @param max_file_size_bytes [Integer, nil] per-file ceiling (1-25_000_000); server default 1_000_000.
405
+ # @param description [String, nil] optional description.
406
+ # @param metadata [Hash, nil] optional metadata.
407
+ # @param id [String, nil] optional API source id.
408
+ # @param config [Hash] additional GitHub-source config forwarded to the API.
409
+ # @return [GitHubSource]
410
+ def initialize(installation_id:, repositories:, name: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
411
+ active_branch_days: nil, include_pull_requests: nil, include_review_threads: nil,
412
+ include_direct_commits: nil, include_globs: nil, exclude_globs: nil, max_file_size_bytes: nil,
413
+ description: nil, metadata: nil, id: nil, **config)
414
+ unless installation_id.is_a?(Integer) && installation_id.positive?
415
+ raise ArgumentError, "installation_id must be a positive Integer"
416
+ end
417
+
418
+ repository_list = Array(repositories)
419
+ raise ArgumentError, "repositories must not be empty" if repository_list.empty?
420
+
421
+ super(
422
+ id: id,
423
+ source_type: "github",
424
+ name: name || SourceNames.github(repositories: repository_list),
425
+ description: description,
426
+ metadata: metadata,
427
+ config: Utils.compact_hash(config.merge(
428
+ installation_id: installation_id,
429
+ repositories: repository_list,
430
+ ref_mode: ref_mode,
431
+ refs: refs.nil? ? nil : Array(refs),
432
+ excluded_refs: excluded_refs.nil? ? nil : Array(excluded_refs),
433
+ active_branch_days: active_branch_days,
434
+ include_pull_requests: include_pull_requests,
435
+ include_review_threads: include_review_threads,
436
+ include_direct_commits: include_direct_commits,
437
+ include_globs: include_globs.nil? ? nil : Array(include_globs),
438
+ exclude_globs: exclude_globs.nil? ? nil : Array(exclude_globs),
439
+ max_file_size_bytes: max_file_size_bytes
440
+ ))
441
+ )
442
+ end
443
+ end
444
+
445
+ # GitLab ingestion source for gitlab.com or a self-managed instance.
446
+ #
447
+ # Authenticates with an access token (`auth_mode: "token"` plus `access_token`)
448
+ # or a stored OAuth connection (`connection_id`). At least one group or project
449
+ # is required.
450
+ class GitLabSource < Source
451
+ # @param groups [String, Array<String>, nil] group paths; required unless projects is given.
452
+ # @param projects [String, Array<String>, nil] project paths with namespace; required unless groups is given.
453
+ # @param name [String, nil] defaults to `gitlab-<path>` from the first project or group.
454
+ # @param auth_mode [String] `oauth` (default) or `token`.
455
+ # @param gitlab_url [String] instance base URL; defaults to `https://gitlab.com`.
456
+ # @param access_token [String, nil] personal or group access token for `auth_mode: "token"`.
457
+ # @param connection_id [String, nil] optional stored OAuth connection id used instead of a token.
458
+ # @param ref_mode [String, nil] `active` (server default), `default`, or `explicit`.
459
+ # @param refs [String, Array<String>, nil] explicit branch names for `ref_mode: "explicit"`.
460
+ # @param excluded_refs [String, Array<String>, nil] branch names to skip.
461
+ # @param active_branch_days [Integer, nil] activity window in days (1-90); server default 7.
462
+ # @param include_merge_requests [Boolean, nil] ingest merge requests; server default true.
463
+ # @param include_review_threads [Boolean, nil] ingest review discussions; server default true.
464
+ # @param include_direct_commits [Boolean, nil] ingest commits outside a merge request; server default true.
465
+ # @param include_globs [String, Array<String>, nil] path globs to include; server default `**/*`.
466
+ # @param exclude_globs [String, Array<String>, nil] path globs to skip.
467
+ # @param max_file_size_bytes [Integer, nil] per-file ceiling (1-25_000_000); server default 1_000_000.
468
+ # @param description [String, nil] optional description.
469
+ # @param metadata [Hash, nil] optional metadata.
470
+ # @param id [String, nil] optional API source id.
471
+ # @param config [Hash] additional GitLab-source config forwarded to the API.
472
+ # @return [GitLabSource]
473
+ def initialize(groups: nil, projects: nil, name: nil, auth_mode: "oauth", gitlab_url: "https://gitlab.com",
474
+ access_token: nil, connection_id: nil, ref_mode: nil, refs: nil, excluded_refs: nil,
475
+ active_branch_days: nil, include_merge_requests: nil, include_review_threads: nil,
476
+ include_direct_commits: nil, include_globs: nil, exclude_globs: nil, max_file_size_bytes: nil,
477
+ description: nil, metadata: nil, id: nil, **config)
478
+ group_list = Array(groups)
479
+ project_list = Array(projects)
480
+ if group_list.empty? && project_list.empty?
481
+ raise ArgumentError, "groups or projects is required"
482
+ end
483
+
484
+ super(
485
+ id: id,
486
+ source_type: "gitlab",
487
+ name: name || SourceNames.gitlab(projects: project_list, groups: group_list),
488
+ description: description,
489
+ metadata: metadata,
490
+ config: Utils.compact_hash(config.merge(
491
+ auth_mode: auth_mode,
492
+ gitlab_url: gitlab_url,
493
+ groups: group_list.empty? ? nil : group_list,
494
+ projects: project_list.empty? ? nil : project_list,
495
+ access_token: access_token,
496
+ connection_id: connection_id,
497
+ ref_mode: ref_mode,
498
+ refs: refs.nil? ? nil : Array(refs),
499
+ excluded_refs: excluded_refs.nil? ? nil : Array(excluded_refs),
500
+ active_branch_days: active_branch_days,
501
+ include_merge_requests: include_merge_requests,
502
+ include_review_threads: include_review_threads,
503
+ include_direct_commits: include_direct_commits,
504
+ include_globs: include_globs.nil? ? nil : Array(include_globs),
505
+ exclude_globs: exclude_globs.nil? ? nil : Array(exclude_globs),
506
+ max_file_size_bytes: max_file_size_bytes
507
+ ))
508
+ )
509
+ end
510
+ end
511
+
363
512
  # Escape hatch for API-compatible source types/configs not yet modeled by the SDK.
364
513
  class GenericSource < Source
365
514
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VectorAmp
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector_amp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VectorAmp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-07-20 00:00:00.000000000 Z
11
+ date: 2026-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest