dependabot-julia 0.394.0 → 0.396.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.
@@ -0,0 +1,563 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+ require "dependabot/julia/registry_client"
6
+
7
+ module Dependabot
8
+ module Julia
9
+ class RegistryClient
10
+ module Result
11
+ extend T::Sig
12
+
13
+ ObjectHash = T.type_alias { T::Hash[String, Object] }
14
+
15
+ module ValueParser
16
+ extend T::Sig
17
+
18
+ sig { params(value: Object, context: String).returns(ObjectHash) }
19
+ def self.object_hash(value, context)
20
+ raise TypeError, "#{context} must be an object" unless value.is_a?(Hash)
21
+
22
+ result = T.let({}, ObjectHash)
23
+ value.each do |raw_key, raw_value|
24
+ key = T.cast(raw_key, Object)
25
+ raise TypeError, "#{context} keys must be strings" unless key.is_a?(String)
26
+
27
+ result[key] = T.cast(raw_value, Object)
28
+ end
29
+ result
30
+ end
31
+
32
+ sig { params(hash: ObjectHash, key: String, context: String).returns(Object) }
33
+ def self.value(hash, key, context)
34
+ raise TypeError, "#{context} #{key} is required" unless hash.key?(key)
35
+
36
+ hash[key]
37
+ end
38
+
39
+ sig { params(hash: ObjectHash, key: String, context: String).returns(String) }
40
+ def self.string(hash, key, context)
41
+ string_value(value(hash, key, context), "#{context} #{key}")
42
+ end
43
+
44
+ sig { params(hash: ObjectHash, key: String, context: String).returns(T.nilable(String)) }
45
+ def self.nilable_string(hash, key, context)
46
+ optional_string_value(value(hash, key, context), "#{context} #{key}")
47
+ end
48
+
49
+ sig { params(hash: ObjectHash, key: String, context: String).returns(T.nilable(String)) }
50
+ def self.optional_string(hash, key, context)
51
+ optional_string_value(hash[key], "#{context} #{key}")
52
+ end
53
+
54
+ sig { params(value: Object, context: String).returns(String) }
55
+ def self.string_value(value, context)
56
+ return value if value.is_a?(String)
57
+
58
+ raise TypeError, "#{context} must be a string"
59
+ end
60
+
61
+ sig { params(value: Object, context: String).returns(T.nilable(String)) }
62
+ def self.optional_string_value(value, context)
63
+ return if value.nil?
64
+ return value if value.is_a?(String)
65
+
66
+ raise TypeError, "#{context} must be a string or nil"
67
+ end
68
+
69
+ sig { params(value: Object, context: String).returns(T::Array[String]) }
70
+ def self.string_array(value, context)
71
+ raise TypeError, "#{context} must be an array" unless value.is_a?(Array)
72
+
73
+ value.map do |item|
74
+ string_value(T.cast(item, Object), "#{context} entry")
75
+ end
76
+ end
77
+
78
+ sig { params(value: Object, context: String).returns(T::Array[ObjectHash]) }
79
+ def self.object_array(value, context)
80
+ raise TypeError, "#{context} must be an array" unless value.is_a?(Array)
81
+
82
+ value.map do |item|
83
+ object_hash(T.cast(item, Object), "#{context} entry")
84
+ end
85
+ end
86
+
87
+ sig { params(value: Object, context: String).returns(T::Hash[String, String]) }
88
+ def self.string_map(value, context)
89
+ result = T.let({}, T::Hash[String, String])
90
+ object_hash(value, context).each do |key, raw_value|
91
+ result[key] = string_value(raw_value, "#{context} #{key}")
92
+ end
93
+ result
94
+ end
95
+ end
96
+ private_constant :ValueParser
97
+
98
+ class Failure < T::ImmutableStruct
99
+ const :message, String
100
+ end
101
+
102
+ sig { params(hash: ObjectHash, _context: String).returns(T.nilable(Failure)) }
103
+ def self.failure_from(hash, _context)
104
+ error = hash["error"]
105
+ return unless hash.length == 1 && error.is_a?(String)
106
+
107
+ Failure.new(message: error)
108
+ end
109
+
110
+ class Version < T::ImmutableStruct
111
+ extend T::Sig
112
+
113
+ const :version, String
114
+ const :package_uuid, T.nilable(String), default: nil
115
+
116
+ sig { params(value: Object, context: String).returns(T.any(Version, Failure)) }
117
+ def self.from_object(value, context:)
118
+ hash = ValueParser.object_hash(value, context)
119
+ failure = Result.failure_from(hash, context)
120
+ return failure if failure
121
+
122
+ new(
123
+ version: ValueParser.string(hash, "version", context),
124
+ package_uuid: ValueParser.optional_string(hash, "package_uuid", context)
125
+ )
126
+ end
127
+
128
+ sig { params(value: Object, context: String).returns(T.any(Version, Failure)) }
129
+ def self.from_batch_value(value, context:)
130
+ return new(version: value) if value.is_a?(String)
131
+
132
+ from_object(value, context: context)
133
+ end
134
+ end
135
+
136
+ class PackageMetadata < T::ImmutableStruct
137
+ extend T::Sig
138
+
139
+ const :name, String
140
+ const :uuid, String
141
+ const :latest_version, String
142
+ const :available_versions, T::Array[String]
143
+
144
+ sig { params(value: Object, context: String).returns(T.any(PackageMetadata, Failure)) }
145
+ def self.from_object(value, context:)
146
+ hash = ValueParser.object_hash(value, context)
147
+ failure = Result.failure_from(hash, context)
148
+ return failure if failure
149
+
150
+ new(
151
+ name: ValueParser.string(hash, "name", context),
152
+ uuid: ValueParser.string(hash, "uuid", context),
153
+ latest_version: ValueParser.string(hash, "latest_version", context),
154
+ available_versions: ValueParser.string_array(
155
+ ValueParser.value(hash, "available_versions", context),
156
+ "#{context} available_versions"
157
+ )
158
+ )
159
+ end
160
+ end
161
+
162
+ class ProjectDependency < T::ImmutableStruct
163
+ extend T::Sig
164
+
165
+ const :name, String
166
+ const :uuid, String
167
+ const :requirement, T.nilable(String), default: nil
168
+
169
+ sig { params(value: Object).returns(ProjectDependency) }
170
+ def self.from_object(value)
171
+ context = "project dependency"
172
+ hash = ValueParser.object_hash(value, context)
173
+
174
+ new(
175
+ name: ValueParser.string(hash, "name", context),
176
+ uuid: ValueParser.string(hash, "uuid", context),
177
+ requirement: ValueParser.optional_string(hash, "requirement", context)
178
+ )
179
+ end
180
+ end
181
+
182
+ class Project < T::ImmutableStruct
183
+ extend T::Sig
184
+
185
+ const :name, T.nilable(String)
186
+ const :version, T.nilable(String)
187
+ const :uuid, T.nilable(String)
188
+ const :julia_version, String
189
+ const :dependencies, T::Array[ProjectDependency]
190
+ const :weak_dependencies, T::Array[ProjectDependency]
191
+ const :project_path, String
192
+
193
+ sig { params(value: Object).returns(T.any(Project, Failure)) }
194
+ def self.from_object(value)
195
+ context = "project result"
196
+ hash = ValueParser.object_hash(value, context)
197
+ failure = Result.failure_from(hash, context)
198
+ return failure if failure
199
+
200
+ new(
201
+ name: ValueParser.nilable_string(hash, "name", context),
202
+ version: ValueParser.nilable_string(hash, "version", context),
203
+ uuid: ValueParser.nilable_string(hash, "uuid", context),
204
+ julia_version: ValueParser.string(hash, "julia_version", context),
205
+ dependencies: parse_dependencies(hash, "dependencies", context),
206
+ weak_dependencies: parse_dependencies(hash, "weak_dependencies", context),
207
+ project_path: ValueParser.string(hash, "project_path", context)
208
+ )
209
+ end
210
+
211
+ sig do
212
+ params(
213
+ hash: ObjectHash,
214
+ key: String,
215
+ context: String
216
+ ).returns(T::Array[ProjectDependency])
217
+ end
218
+ def self.parse_dependencies(hash, key, context)
219
+ ValueParser.object_array(
220
+ ValueParser.value(hash, key, context),
221
+ "#{context} #{key}"
222
+ ).map { |dependency| ProjectDependency.from_object(dependency) }
223
+ end
224
+ private_class_method :parse_dependencies
225
+ end
226
+
227
+ class ManifestDependency < T::ImmutableStruct
228
+ extend T::Sig
229
+
230
+ const :name, String
231
+ const :uuid, String
232
+ const :version, String
233
+ const :tree_hash, String
234
+ const :repo_url, String
235
+ const :repo_rev, String
236
+ const :path, String
237
+ const :dependencies, T::Hash[String, String]
238
+
239
+ sig { params(value: Object).returns(ManifestDependency) }
240
+ def self.from_object(value)
241
+ context = "manifest dependency"
242
+ hash = ValueParser.object_hash(value, context)
243
+ raw_dependencies = hash["dependencies"]
244
+ dependencies = if raw_dependencies.nil?
245
+ {}
246
+ else
247
+ ValueParser.string_map(raw_dependencies, "#{context} dependencies")
248
+ end
249
+
250
+ new(
251
+ name: ValueParser.string(hash, "name", context),
252
+ uuid: ValueParser.string(hash, "uuid", context),
253
+ version: ValueParser.string(hash, "version", context),
254
+ tree_hash: ValueParser.string(hash, "tree_hash", context),
255
+ repo_url: ValueParser.string(hash, "repo_url", context),
256
+ repo_rev: ValueParser.string(hash, "repo_rev", context),
257
+ path: ValueParser.string(hash, "path", context),
258
+ dependencies: dependencies
259
+ )
260
+ end
261
+ end
262
+
263
+ class Manifest < T::ImmutableStruct
264
+ extend T::Sig
265
+
266
+ const :dependencies, T::Array[ManifestDependency]
267
+ const :manifest_path, String
268
+
269
+ sig { params(value: Object).returns(T.any(Manifest, Failure)) }
270
+ def self.from_object(value)
271
+ context = "manifest result"
272
+ hash = ValueParser.object_hash(value, context)
273
+ failure = Result.failure_from(hash, context)
274
+ return failure if failure
275
+
276
+ dependencies = ValueParser.object_array(
277
+ ValueParser.value(hash, "dependencies", context),
278
+ "#{context} dependencies"
279
+ ).map { |dependency| ManifestDependency.from_object(dependency) }
280
+
281
+ new(
282
+ dependencies: dependencies,
283
+ manifest_path: ValueParser.string(hash, "manifest_path", context)
284
+ )
285
+ end
286
+ end
287
+
288
+ class EnvironmentFiles < T::ImmutableStruct
289
+ extend T::Sig
290
+
291
+ const :project_file, String
292
+ const :manifest_file, String
293
+
294
+ sig { params(value: Object).returns(T.any(EnvironmentFiles, Failure)) }
295
+ def self.from_object(value)
296
+ context = "environment files result"
297
+ hash = ValueParser.object_hash(value, context)
298
+ failure = Result.failure_from(hash, context)
299
+ return failure if failure
300
+
301
+ new(
302
+ project_file: ValueParser.string(hash, "project_file", context),
303
+ manifest_file: ValueParser.string(hash, "manifest_file", context)
304
+ )
305
+ end
306
+ end
307
+
308
+ class WorkspaceFiles < T::ImmutableStruct
309
+ extend T::Sig
310
+
311
+ const :project_files, T::Array[String]
312
+ const :manifest_file, String
313
+ const :workspace_root, String
314
+
315
+ sig { params(value: Object).returns(T.any(WorkspaceFiles, Failure)) }
316
+ def self.from_object(value)
317
+ context = "workspace files result"
318
+ hash = ValueParser.object_hash(value, context)
319
+ failure = Result.failure_from(hash, context)
320
+ return failure if failure
321
+
322
+ new(
323
+ project_files: ValueParser.string_array(
324
+ ValueParser.value(hash, "project_files", context),
325
+ "#{context} project_files"
326
+ ),
327
+ manifest_file: ValueParser.string(hash, "manifest_file", context),
328
+ workspace_root: ValueParser.string(hash, "workspace_root", context)
329
+ )
330
+ end
331
+ end
332
+
333
+ class Source < T::ImmutableStruct
334
+ extend T::Sig
335
+
336
+ const :source_url, String
337
+ const :source_type, String
338
+ const :package_uuid, String
339
+
340
+ sig { params(value: Object).returns(T.any(Source, Failure)) }
341
+ def self.from_object(value)
342
+ context = "package source result"
343
+ hash = ValueParser.object_hash(value, context)
344
+ failure = Result.failure_from(hash, context)
345
+ return failure if failure
346
+
347
+ new(
348
+ source_url: ValueParser.string(hash, "source_url", context),
349
+ source_type: ValueParser.string(hash, "source_type", context),
350
+ package_uuid: ValueParser.string(hash, "package_uuid", context)
351
+ )
352
+ end
353
+ end
354
+
355
+ class ManifestUpdate < T::ImmutableStruct
356
+ extend T::Sig
357
+
358
+ const :manifest_content, String
359
+ const :manifest_path, String
360
+
361
+ sig { params(value: Object).returns(T.any(ManifestUpdate, Failure)) }
362
+ def self.from_object(value)
363
+ context = "manifest update result"
364
+ hash = ValueParser.object_hash(value, context)
365
+ failure = Result.failure_from(hash, context)
366
+ return failure if failure
367
+
368
+ new(
369
+ manifest_content: ValueParser.string(hash, "manifest_content", context),
370
+ manifest_path: ValueParser.string(hash, "manifest_path", context)
371
+ )
372
+ end
373
+ end
374
+
375
+ class AvailableVersions < T::ImmutableStruct
376
+ extend T::Sig
377
+
378
+ const :versions, T::Array[String]
379
+
380
+ sig { params(value: Object, context: String).returns(T.any(AvailableVersions, Failure)) }
381
+ def self.from_object(value, context:)
382
+ hash = ValueParser.object_hash(value, context)
383
+ failure = Result.failure_from(hash, context)
384
+ return failure if failure
385
+
386
+ new(
387
+ versions: ValueParser.string_array(
388
+ ValueParser.value(hash, "versions", context),
389
+ "#{context} versions"
390
+ )
391
+ )
392
+ end
393
+
394
+ sig { params(value: Object, context: String).returns(T.any(AvailableVersions, Failure)) }
395
+ def self.from_batch_value(value, context:)
396
+ return new(versions: ValueParser.string_array(value, context)) if value.is_a?(Array)
397
+
398
+ from_object(value, context: context)
399
+ end
400
+ end
401
+
402
+ class ReleaseDate < T::ImmutableStruct
403
+ extend T::Sig
404
+
405
+ const :release_date, T.nilable(String)
406
+
407
+ sig { params(value: Object, context: String).returns(T.any(ReleaseDate, Failure)) }
408
+ def self.from_object(value, context:)
409
+ hash = ValueParser.object_hash(value, context)
410
+ failure = Result.failure_from(hash, context)
411
+ return failure if failure
412
+
413
+ new(release_date: ValueParser.nilable_string(hash, "release_date", context))
414
+ end
415
+
416
+ sig { params(value: Object, context: String).returns(T.any(ReleaseDate, Failure)) }
417
+ def self.from_batch_value(value, context:)
418
+ return new(release_date: nil) if value.nil?
419
+ return new(release_date: value) if value.is_a?(String)
420
+
421
+ from_object(value, context: context)
422
+ end
423
+ end
424
+
425
+ class PackageInfo < T::ImmutableStruct
426
+ extend T::Sig
427
+
428
+ const :available_versions, T.any(AvailableVersions, Failure)
429
+ const :latest_version, T.any(Version, Failure)
430
+ const :metadata, T.nilable(T.any(PackageMetadata, Failure)), default: nil
431
+
432
+ sig { params(value: Object, context: String).returns(T.any(PackageInfo, Failure)) }
433
+ def self.from_object(value, context:)
434
+ hash = ValueParser.object_hash(value, context)
435
+ failure = Result.failure_from(hash, context)
436
+ return failure if failure
437
+
438
+ metadata = if hash.key?("metadata")
439
+ PackageMetadata.from_object(
440
+ ValueParser.value(hash, "metadata", context),
441
+ context: "#{context} metadata"
442
+ )
443
+ end
444
+
445
+ new(
446
+ available_versions: AvailableVersions.from_batch_value(
447
+ ValueParser.value(hash, "available_versions", context),
448
+ context: "#{context} available_versions"
449
+ ),
450
+ latest_version: Version.from_batch_value(
451
+ ValueParser.value(hash, "latest_version", context),
452
+ context: "#{context} latest_version"
453
+ ),
454
+ metadata: metadata
455
+ )
456
+ end
457
+ end
458
+
459
+ class PackageInfoBatch < T::ImmutableStruct
460
+ extend T::Sig
461
+
462
+ const :packages, T::Hash[String, T.any(PackageInfo, Failure)]
463
+
464
+ sig { params(value: Object).returns(T.any(PackageInfoBatch, Failure)) }
465
+ def self.from_object(value)
466
+ context = "batch package info result"
467
+ hash = ValueParser.object_hash(value, context)
468
+ failure = Result.failure_from(hash, context)
469
+ return failure if failure
470
+
471
+ packages = T.let({}, T::Hash[String, T.any(PackageInfo, Failure)])
472
+ hash.each do |name, raw_info|
473
+ packages[name] = PackageInfo.from_object(raw_info, context: "#{context} #{name}")
474
+ end
475
+ new(packages: packages)
476
+ end
477
+ end
478
+
479
+ class ReleaseDates < T::ImmutableStruct
480
+ extend T::Sig
481
+
482
+ const :dates, T::Hash[String, T.any(ReleaseDate, Failure)]
483
+
484
+ sig { params(value: Object, context: String).returns(T.any(ReleaseDates, Failure)) }
485
+ def self.from_object(value, context:)
486
+ hash = ValueParser.object_hash(value, context)
487
+ failure = Result.failure_from(hash, context)
488
+ return failure if failure
489
+
490
+ dates = T.let({}, T::Hash[String, T.any(ReleaseDate, Failure)])
491
+ hash.each do |version, raw_date|
492
+ dates[version] = ReleaseDate.from_batch_value(raw_date, context: "#{context} #{version}")
493
+ end
494
+ new(dates: dates)
495
+ end
496
+ end
497
+
498
+ class ReleaseDatesBatch < T::ImmutableStruct
499
+ extend T::Sig
500
+
501
+ const :packages, T::Hash[String, T.any(ReleaseDates, Failure)]
502
+
503
+ sig { params(value: Object).returns(T.any(ReleaseDatesBatch, Failure)) }
504
+ def self.from_object(value)
505
+ context = "batch release dates result"
506
+ hash = ValueParser.object_hash(value, context)
507
+ failure = Result.failure_from(hash, context)
508
+ return failure if failure
509
+
510
+ packages = T.let({}, T::Hash[String, T.any(ReleaseDates, Failure)])
511
+ hash.each do |name, raw_dates|
512
+ packages[name] = ReleaseDates.from_object(raw_dates, context: "#{context} #{name}")
513
+ end
514
+ new(packages: packages)
515
+ end
516
+ end
517
+
518
+ class AvailableVersionsBatch < T::ImmutableStruct
519
+ extend T::Sig
520
+
521
+ const :packages, T::Hash[String, T.any(AvailableVersions, Failure)]
522
+
523
+ sig { params(value: Object).returns(T.any(AvailableVersionsBatch, Failure)) }
524
+ def self.from_object(value)
525
+ context = "batch available versions result"
526
+ hash = ValueParser.object_hash(value, context)
527
+ failure = Result.failure_from(hash, context)
528
+ return failure if failure
529
+
530
+ packages = T.let({}, T::Hash[String, T.any(AvailableVersions, Failure)])
531
+ hash.each do |name, raw_versions|
532
+ packages[name] = AvailableVersions.from_object(
533
+ raw_versions,
534
+ context: "#{context} #{name}"
535
+ )
536
+ end
537
+ new(packages: packages)
538
+ end
539
+ end
540
+
541
+ class PackageVersionsRequest < T::ImmutableStruct
542
+ extend T::Sig
543
+
544
+ const :name, String
545
+ const :uuid, String
546
+ const :versions, T::Array[String]
547
+
548
+ sig { returns(T::Hash[Symbol, Object]) }
549
+ def to_h
550
+ T.let(
551
+ {
552
+ name: name,
553
+ uuid: uuid,
554
+ versions: versions
555
+ },
556
+ T::Hash[Symbol, Object]
557
+ )
558
+ end
559
+ end
560
+ end
561
+ end
562
+ end
563
+ end