sodas-sdk 1.1.11 → 1.1.12

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.
@@ -46,6 +46,8 @@ declare class Dataset extends DCAT_RESOURCE {
46
46
  toDTO(): DatasetDTO;
47
47
  populateFromDTO(dto: DCAT_MODEL_DTO): Promise<void>;
48
48
  populateDistributionFromDTO(dto: DatasetDTO): Promise<void>;
49
+ static syncToCurrentHub(dataset: Dataset): Promise<void>;
50
+ populateToSync(source: Dataset): void;
49
51
  createDBRecord(): Promise<void>;
50
52
  private deleteNotMaintainedDistributions;
51
53
  updateDBRecord(): Promise<void>;
@@ -27,6 +27,19 @@ declare class DatasetSeries extends DCAT_RESOURCE {
27
27
  private WasGeneratedBy;
28
28
  private SeriesMembers;
29
29
  private SeriesMemberIDs;
30
+ static syncToCurrentHub(datasetSeries: DatasetSeries): Promise<void>;
31
+ /**
32
+ * Populates this instance with values from the given DatasetSeries, except for:
33
+ * - DB identity / temporal fields (ID, IRI, Issued, Modified, CreatedAt, UpdatedAt)
34
+ * - Version/lineage fields (IsVersionOf, PreviousVersionID, NextVersionID, VersionInfos)
35
+ * - Series identity fields (DatasetSeriesID, InSeriesID)
36
+ * - Fields explicitly set to `undefined` on the source instance
37
+ *
38
+ * Additionally, when SeriesMembers are present on the source, this method
39
+ * resolves each member via Dataset.getDBRecordByAssetID (by AssetID) and
40
+ * replaces this.SeriesMemberIDs with the resolved IDs.
41
+ */
42
+ populateToSync(source: DatasetSeries): Promise<void>;
30
43
  /**
31
44
  * Initializes or updates the API_URL and LIST_URL for Dataset.
32
45
  *
@@ -38,10 +51,17 @@ declare class DatasetSeries extends DCAT_RESOURCE {
38
51
  populateFromDTO(dto: DCAT_MODEL_DTO): Promise<void>;
39
52
  populateSeriesMembersFromDTO(dto: DatasetSeriesDTO): Promise<void>;
40
53
  deleteDBRecord(): Promise<void>;
54
+ /**
55
+ * Creates a dataset series DB record in an interoperated context
56
+ * (e.g. together with related Dataset instances or other resources).
57
+ *
58
+ * The implementation will be added later.
59
+ */
60
+ createInteroperatedDBRecord(): Promise<void>;
41
61
  appendSeriesMember(dataset: Dataset): void;
42
62
  switchSeriesMembers(index1: number, index2: number): void;
43
63
  get datasetSeriesID(): IDType;
44
- get seriesMembereIDs(): IDType[];
64
+ get seriesMemberIDs(): IDType[];
45
65
  get seriesMembers(): Dataset[];
46
66
  get frequency(): string;
47
67
  set frequency(value: string);
@@ -44,6 +44,12 @@ declare class Distribution extends DCAT_MODEL {
44
44
  private TitleML;
45
45
  private HasPolicy;
46
46
  private Checksum;
47
+ /**
48
+ * Populates this instance with values from the given Distribution, except for:
49
+ * - DB identity / temporal fields (ID, IRI, Issued, Modified, CreatedAt, UpdatedAt)
50
+ * - Fields that are explicitly set to `undefined` on the source instance
51
+ */
52
+ populateToSync(source: Distribution): void;
47
53
  toDTO(): DistributionDTO;
48
54
  populateFromDTO(dto: DCAT_MODEL_DTO): Promise<void>;
49
55
  /**
@@ -23,6 +23,13 @@ declare abstract class DCAT_MODEL extends SODAS_SDK_CLASS {
23
23
  createDBRecord(): Promise<void>;
24
24
  static getDBRecord<GENERIC_DCAT_MODEL extends DCAT_MODEL>(this: DCAT_MODEL_STATIC<GENERIC_DCAT_MODEL>, ID: IDType): Promise<GENERIC_DCAT_MODEL>;
25
25
  static getDBRecordByAssetID<GENERIC_DCAT_MODEL extends DCAT_MODEL>(this: DCAT_MODEL_STATIC<GENERIC_DCAT_MODEL>, assetID: IDType): Promise<GENERIC_DCAT_MODEL>;
26
+ /**
27
+ * Checks whether a DB record exists for the given AssetID and returns its ID.
28
+ *
29
+ * This method wraps getDBRecordByAssetID and converts a 404 response to `null`,
30
+ * while rethrowing any other kind of error.
31
+ */
32
+ static checkDBRecordOfAssetID(assetID: IDType): Promise<IDType | null>;
26
33
  updateDBRecord(): Promise<void>;
27
34
  deleteDBRecord(): Promise<void>;
28
35
  get createdAt(): Date;
@@ -2501,6 +2501,70 @@ class Dataset extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"] {
2501
2501
  }
2502
2502
  });
2503
2503
  }
2504
+ static syncToCurrentHub(dataset) {
2505
+ return __awaiter(this, void 0, void 0, function* () {
2506
+ var _a;
2507
+ try {
2508
+ const checkExisting = yield Dataset.getDBRecordByAssetID((0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(dataset.assetID));
2509
+ if (checkExisting) {
2510
+ checkExisting.populateToSync(dataset);
2511
+ yield checkExisting.updateDBRecord();
2512
+ }
2513
+ }
2514
+ catch (error) {
2515
+ if (axios__WEBPACK_IMPORTED_MODULE_6__["default"].isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
2516
+ const newDataset = new Dataset();
2517
+ newDataset.populateToSync(dataset);
2518
+ yield newDataset.createDBRecord();
2519
+ }
2520
+ else {
2521
+ throw error;
2522
+ }
2523
+ }
2524
+ });
2525
+ }
2526
+ populateToSync(source) {
2527
+ const excludedKeys = new Set([
2528
+ "ID",
2529
+ "DatasetID",
2530
+ "IsVersionOf",
2531
+ "PreviousVersionID",
2532
+ "NextVersionID",
2533
+ "VersionInfos",
2534
+ "InSeriesID",
2535
+ "FirstID",
2536
+ "PreviousID",
2537
+ "NextID",
2538
+ "LastID",
2539
+ "DistributionIDs",
2540
+ ]);
2541
+ for (const key in source) {
2542
+ if (!Object.prototype.hasOwnProperty.call(source, key))
2543
+ continue;
2544
+ if (key === "Distributions")
2545
+ continue;
2546
+ if (excludedKeys.has(key))
2547
+ continue;
2548
+ const value = source[key];
2549
+ if (value !== undefined) {
2550
+ this[key] = value;
2551
+ }
2552
+ }
2553
+ // Handle distributions separately so that we can preserve identity fields
2554
+ // of existing distributions while syncing other fields, and create new
2555
+ // distributions for any additional ones in the source.
2556
+ const sourceDistributions = source.Distributions;
2557
+ if (!sourceDistributions || sourceDistributions.length === 0) {
2558
+ return;
2559
+ }
2560
+ this.Distributions = [];
2561
+ for (let i = 0; i < sourceDistributions.length; i++) {
2562
+ const srcDist = sourceDistributions[i];
2563
+ const targetDist = new _distribution__WEBPACK_IMPORTED_MODULE_5__["default"]();
2564
+ targetDist.populateToSync(srcDist);
2565
+ this.Distributions.push(targetDist);
2566
+ }
2567
+ }
2504
2568
  createDBRecord() {
2505
2569
  const _super = Object.create(null, {
2506
2570
  createDBRecord: { get: () => super.createDBRecord }
@@ -2690,6 +2754,7 @@ __webpack_require__.r(__webpack_exports__);
2690
2754
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2691
2755
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2692
2756
  /* harmony export */ });
2757
+ /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! axios */ "./node_modules/axios/lib/axios.js");
2693
2758
  /* harmony import */ var _core_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../core/error */ "./lib/core/error.ts");
2694
2759
  /* harmony import */ var _core_type__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../core/type */ "./lib/core/type.ts");
2695
2760
  /* harmony import */ var _core_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../core/util */ "./lib/core/util.ts");
@@ -2709,10 +2774,105 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
2709
2774
 
2710
2775
 
2711
2776
 
2777
+
2712
2778
  /**
2713
2779
  * Represents a series of datasets.
2714
2780
  */
2715
2781
  class DatasetSeries extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"] {
2782
+ static syncToCurrentHub(datasetSeries) {
2783
+ return __awaiter(this, void 0, void 0, function* () {
2784
+ var _a;
2785
+ try {
2786
+ const checkExisting = yield DatasetSeries.getDBRecordByAssetID((0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(datasetSeries.assetID));
2787
+ if (checkExisting) {
2788
+ yield checkExisting.populateToSync(datasetSeries);
2789
+ yield checkExisting.updateDBRecord();
2790
+ }
2791
+ }
2792
+ catch (error) {
2793
+ if (axios__WEBPACK_IMPORTED_MODULE_5__["default"].isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
2794
+ const newDatasetSeries = new DatasetSeries();
2795
+ yield newDatasetSeries.populateToSync(datasetSeries);
2796
+ yield newDatasetSeries.createDBRecord();
2797
+ }
2798
+ else {
2799
+ throw error;
2800
+ }
2801
+ }
2802
+ });
2803
+ }
2804
+ /**
2805
+ * Populates this instance with values from the given DatasetSeries, except for:
2806
+ * - DB identity / temporal fields (ID, IRI, Issued, Modified, CreatedAt, UpdatedAt)
2807
+ * - Version/lineage fields (IsVersionOf, PreviousVersionID, NextVersionID, VersionInfos)
2808
+ * - Series identity fields (DatasetSeriesID, InSeriesID)
2809
+ * - Fields explicitly set to `undefined` on the source instance
2810
+ *
2811
+ * Additionally, when SeriesMembers are present on the source, this method
2812
+ * resolves each member via Dataset.getDBRecordByAssetID (by AssetID) and
2813
+ * replaces this.SeriesMemberIDs with the resolved IDs.
2814
+ */
2815
+ populateToSync(source) {
2816
+ return __awaiter(this, void 0, void 0, function* () {
2817
+ var _a;
2818
+ const excludedKeys = new Set([
2819
+ "ID",
2820
+ "IsVersionOf",
2821
+ "PreviousVersionID",
2822
+ "NextVersionID",
2823
+ "VersionInfos",
2824
+ "DatasetSeriesID",
2825
+ "InSeriesID",
2826
+ ]);
2827
+ for (const key in source) {
2828
+ if (!Object.prototype.hasOwnProperty.call(source, key))
2829
+ continue;
2830
+ if (key === "SeriesMembers")
2831
+ continue;
2832
+ if (excludedKeys.has(key))
2833
+ continue;
2834
+ const value = source[key];
2835
+ if (value !== undefined) {
2836
+ this[key] = value;
2837
+ }
2838
+ }
2839
+ this.SeriesMembers = [];
2840
+ const sourceMembers = source.SeriesMembers;
2841
+ if (!sourceMembers || sourceMembers.length === 0) {
2842
+ return;
2843
+ }
2844
+ const resolvedIDs = [];
2845
+ for (const member of sourceMembers) {
2846
+ if (!member)
2847
+ continue;
2848
+ const assetIDStr = member.assetID;
2849
+ if (!assetIDStr)
2850
+ continue;
2851
+ const assetID = (0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(assetIDStr);
2852
+ // Prefer existing record by AssetID; if not found, create a new one.
2853
+ try {
2854
+ const existing = yield _dataset__WEBPACK_IMPORTED_MODULE_3__["default"].getDBRecordByAssetID(assetID);
2855
+ if (existing) {
2856
+ existing.populateToSync(member);
2857
+ yield existing.updateDBRecord();
2858
+ resolvedIDs.push(existing.id);
2859
+ }
2860
+ }
2861
+ catch (error) {
2862
+ if (axios__WEBPACK_IMPORTED_MODULE_5__["default"].isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
2863
+ const newMember = new _dataset__WEBPACK_IMPORTED_MODULE_3__["default"]();
2864
+ newMember.populateToSync(member);
2865
+ yield newMember.createDBRecord();
2866
+ resolvedIDs.push(newMember.id);
2867
+ }
2868
+ else {
2869
+ throw error;
2870
+ }
2871
+ }
2872
+ }
2873
+ this.SeriesMemberIDs = resolvedIDs;
2874
+ });
2875
+ }
2716
2876
  /**
2717
2877
  * Initializes or updates the API_URL and LIST_URL for Dataset.
2718
2878
  *
@@ -2753,11 +2913,17 @@ class DatasetSeries extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"
2753
2913
  }
2754
2914
  populateSeriesMembersFromDTO(dto) {
2755
2915
  return __awaiter(this, void 0, void 0, function* () {
2916
+ this.SeriesMembers = [];
2756
2917
  if (dto.SeriesMemberIDs && dto.SeriesMemberIDs.length != 0) {
2757
2918
  this.SeriesMemberIDs = (0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asIDs)(dto.SeriesMemberIDs);
2758
- this.SeriesMembers = yield Promise.all(dto.SeriesMemberIDs.map((seriesMemberID) => __awaiter(this, void 0, void 0, function* () {
2759
- return yield _dataset__WEBPACK_IMPORTED_MODULE_3__["default"].getDBRecord(seriesMemberID);
2760
- })));
2919
+ if (this.SeriesMemberIDs && this.SeriesMemberIDs.length != 0) {
2920
+ for (const seriesMemberID of this.SeriesMemberIDs) {
2921
+ const seriesMember = yield _dataset__WEBPACK_IMPORTED_MODULE_3__["default"].getDBRecord(seriesMemberID);
2922
+ if (seriesMember) {
2923
+ this.SeriesMembers.push(seriesMember);
2924
+ }
2925
+ }
2926
+ }
2761
2927
  }
2762
2928
  });
2763
2929
  }
@@ -2776,6 +2942,17 @@ class DatasetSeries extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"
2776
2942
  yield _super.deleteDBRecord.call(this);
2777
2943
  });
2778
2944
  }
2945
+ /**
2946
+ * Creates a dataset series DB record in an interoperated context
2947
+ * (e.g. together with related Dataset instances or other resources).
2948
+ *
2949
+ * The implementation will be added later.
2950
+ */
2951
+ createInteroperatedDBRecord() {
2952
+ return __awaiter(this, void 0, void 0, function* () {
2953
+ // TODO: Implement interoperated create logic.
2954
+ });
2955
+ }
2779
2956
  appendSeriesMember(dataset) {
2780
2957
  if (!this.SeriesMemberIDs) {
2781
2958
  this.SeriesMemberIDs = [];
@@ -2808,7 +2985,7 @@ class DatasetSeries extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"
2808
2985
  get datasetSeriesID() {
2809
2986
  return this.DatasetSeriesID;
2810
2987
  }
2811
- get seriesMembereIDs() {
2988
+ get seriesMemberIDs() {
2812
2989
  return this.SeriesMemberIDs;
2813
2990
  }
2814
2991
  get seriesMembers() {
@@ -3232,8 +3409,8 @@ __webpack_require__.r(__webpack_exports__);
3232
3409
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3233
3410
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
3234
3411
  /* harmony export */ });
3235
- /* harmony import */ var _core_type__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../core/type */ "./lib/core/type.ts");
3236
- /* harmony import */ var _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../SODAS_SDK_FILE/dataFile */ "./lib/SODAS_SDK_FILE/dataFile.ts");
3412
+ /* harmony import */ var _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../SODAS_SDK_FILE/dataFile */ "./lib/SODAS_SDK_FILE/dataFile.ts");
3413
+ /* harmony import */ var _core_type__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../core/type */ "./lib/core/type.ts");
3237
3414
  /* harmony import */ var _dcatClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../dcatClass */ "./lib/SODAS_SDK_CLASS/dcatClass.ts");
3238
3415
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
3239
3416
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -3248,6 +3425,24 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
3248
3425
 
3249
3426
 
3250
3427
  class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3428
+ /**
3429
+ * Populates this instance with values from the given Distribution, except for:
3430
+ * - DB identity / temporal fields (ID, IRI, Issued, Modified, CreatedAt, UpdatedAt)
3431
+ * - Fields that are explicitly set to `undefined` on the source instance
3432
+ */
3433
+ populateToSync(source) {
3434
+ const excludedKeys = new Set(["ID", "IsDistributionOf", "AccessServiceID"]);
3435
+ for (const key in source) {
3436
+ if (!Object.prototype.hasOwnProperty.call(source, key))
3437
+ continue;
3438
+ if (excludedKeys.has(key))
3439
+ continue;
3440
+ const value = source[key];
3441
+ if (value !== undefined) {
3442
+ this[key] = value;
3443
+ }
3444
+ }
3445
+ }
3251
3446
  toDTO() {
3252
3447
  return Object.assign(Object.assign(Object.assign(Object.assign({}, super.toDTO()), (this.IsDistributionOf && { IsDistributionOf: this.IsDistributionOf })), (this.AccessServiceID && { AccessServiceID: this.AccessServiceID })), { AccessURL: this.AccessURL, ByteSize: this.ByteSize, CompressFormat: this.CompressFormat, DownloadURL: this.DownloadURL, MediaType: this.MediaType, PackageFormat: this.PackageFormat, SpatialResolutionInMeters: this.SpatialResolutionInMeters, TemporalResolution: this.TemporalResolution, AccessRights: this.AccessRights, ConformsTo: this.ConformsTo, DescriptionML: this.DescriptionML, Format: this.Format, License: this.License, Rights: this.Rights, TitleML: this.TitleML, HasPolicy: this.HasPolicy, Checksum: this.Checksum });
3253
3448
  }
@@ -3259,7 +3454,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3259
3454
  yield _super.populateFromDTO.call(this, dto);
3260
3455
  const distributionDTO = dto;
3261
3456
  distributionDTO.AccessServiceID &&
3262
- (this.AccessServiceID = (0,_core_type__WEBPACK_IMPORTED_MODULE_0__.asID)(distributionDTO.AccessServiceID));
3457
+ (this.AccessServiceID = (0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(distributionDTO.AccessServiceID));
3263
3458
  distributionDTO.AccessURL && (this.AccessURL = distributionDTO.AccessURL);
3264
3459
  distributionDTO.ByteSize && (this.ByteSize = distributionDTO.ByteSize);
3265
3460
  distributionDTO.CompressFormat &&
@@ -3287,7 +3482,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3287
3482
  distributionDTO.HasPolicy && (this.HasPolicy = distributionDTO.HasPolicy);
3288
3483
  distributionDTO.Checksum && (this.Checksum = distributionDTO.Checksum);
3289
3484
  distributionDTO.IsDistributionOf &&
3290
- (this.IsDistributionOf = (0,_core_type__WEBPACK_IMPORTED_MODULE_0__.asID)(distributionDTO.IsDistributionOf));
3485
+ (this.IsDistributionOf = (0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(distributionDTO.IsDistributionOf));
3291
3486
  });
3292
3487
  }
3293
3488
  /**
@@ -3303,7 +3498,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3303
3498
  Distribution.DOWNLOAD_API_URL = `${url}/data/download`;
3304
3499
  }
3305
3500
  static configureBucketName(bucketName) {
3306
- _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_1__["default"].configureBucketName(bucketName);
3501
+ _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_0__["default"].configureBucketName(bucketName);
3307
3502
  }
3308
3503
  /**
3309
3504
  * Sets file information for a browser environment.
@@ -3311,7 +3506,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3311
3506
  */
3312
3507
  setUploadingDataForBrowser(file) {
3313
3508
  if (!this.UploadingData) {
3314
- this.UploadingData = new _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_1__["default"]();
3509
+ this.UploadingData = new _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_0__["default"]();
3315
3510
  }
3316
3511
  this.UploadingData.setFileForBrowser(file);
3317
3512
  }
@@ -3321,7 +3516,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3321
3516
  */
3322
3517
  setUploadingDataForNode(filePath) {
3323
3518
  if (!this.UploadingData) {
3324
- this.UploadingData = new _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_1__["default"]();
3519
+ this.UploadingData = new _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_0__["default"]();
3325
3520
  }
3326
3521
  this.UploadingData.setFileForNode(filePath);
3327
3522
  }
@@ -3514,7 +3709,7 @@ class Distribution extends _dcatClass__WEBPACK_IMPORTED_MODULE_2__["default"] {
3514
3709
  return this.IsDistributionOf;
3515
3710
  }
3516
3711
  set isDistributionOf(value) {
3517
- this.IsDistributionOf = (0,_core_type__WEBPACK_IMPORTED_MODULE_0__.asID)(value);
3712
+ this.IsDistributionOf = (0,_core_type__WEBPACK_IMPORTED_MODULE_1__.asID)(value);
3518
3713
  }
3519
3714
  }
3520
3715
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Distribution);
@@ -3767,6 +3962,27 @@ class DCAT_MODEL extends _sodasSDKClass__WEBPACK_IMPORTED_MODULE_3__["default"]
3767
3962
  }
3768
3963
  });
3769
3964
  }
3965
+ /**
3966
+ * Checks whether a DB record exists for the given AssetID and returns its ID.
3967
+ *
3968
+ * This method wraps getDBRecordByAssetID and converts a 404 response to `null`,
3969
+ * while rethrowing any other kind of error.
3970
+ */
3971
+ static checkDBRecordOfAssetID(assetID) {
3972
+ return __awaiter(this, void 0, void 0, function* () {
3973
+ var _a;
3974
+ try {
3975
+ const record = (yield this.getDBRecordByAssetID(assetID));
3976
+ return record.id;
3977
+ }
3978
+ catch (error) {
3979
+ if (axios__WEBPACK_IMPORTED_MODULE_4__["default"].isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
3980
+ return null;
3981
+ }
3982
+ throw error;
3983
+ }
3984
+ });
3985
+ }
3770
3986
  updateDBRecord() {
3771
3987
  return __awaiter(this, void 0, void 0, function* () {
3772
3988
  this.throwErrorIfAPIURLNotSet();