@startinblox/core 2.0.6-beta.1 → 2.0.6-beta.2
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.
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { q as mergeContexts, o as getRawContext, n as normalizeContext } from "./helpers-vZrb1UDN.js";
|
|
5
|
-
import { S as StoreService } from "./store-
|
|
5
|
+
import { S as StoreService } from "./store-DI-dmiKR.js";
|
|
6
6
|
const store = StoreService.getInstance();
|
|
7
7
|
class CustomGetter {
|
|
8
8
|
// search attributes to give to server
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-
|
|
4
|
+
import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-DI-dmiKR.js";
|
|
5
5
|
import { d as defineComponent, n as normalizeContext, u as uniqID, f as fuzzyCompare, a as asyncQuerySelector, i as importInlineCSS, b as importCSS, c as doesResourceContainList, e as findClosingBracketMatchIndex, p as parseFieldsString, g as evalTemplateString, h as compare, j as generalComparator, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-vZrb1UDN.js";
|
|
6
6
|
import { k } from "./helpers-vZrb1UDN.js";
|
|
7
7
|
let index$4, BaseWidgetMixin, index$3, CounterMixin, EdcAssetsDisplay, EdcCatalogDisplay, EdcFederatedCatalogDisplay, FederationMixin, FilterMixin, GrouperMixin, HighlighterMixin, ListMixin, NextMixin, PaginateMixin, RequiredMixin, Sib, SolidAcChecker, SolidDelete, SolidDisplay, SolidForm, SolidFormSearch, SolidLang, SolidMemberAdd, SolidMemberDelete, SolidMembership, SolidTable, SolidTemplateElement, SolidWidget, SorterMixin, StoreMixin, index$2, index$1, index, TranslationMixin, ValidationMixin, WidgetMixin, x, o$2, newWidgetFactory, B, o$1, m, widgetFactory;
|
|
@@ -162,6 +162,20 @@ let __tla = (async () => {
|
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
+
class AssetValidationError extends Error {
|
|
166
|
+
constructor(message, assetId, validationType, reason, details) {
|
|
167
|
+
super(message);
|
|
168
|
+
__publicField(this, "assetId");
|
|
169
|
+
__publicField(this, "validationType");
|
|
170
|
+
__publicField(this, "reason");
|
|
171
|
+
__publicField(this, "details");
|
|
172
|
+
this.name = "AssetValidationError";
|
|
173
|
+
this.assetId = assetId;
|
|
174
|
+
this.validationType = validationType;
|
|
175
|
+
this.reason = reason;
|
|
176
|
+
this.details = details;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
165
179
|
class DataspaceConnectorStore {
|
|
166
180
|
constructor(config) {
|
|
167
181
|
__publicField(this, "cache");
|
|
@@ -900,39 +914,60 @@ let __tla = (async () => {
|
|
|
900
914
|
}
|
|
901
915
|
async updateAsset(assetId, assetInput) {
|
|
902
916
|
await this.ensureAuthenticated();
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
"
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
917
|
+
const hasAgreement = this.hasValidAgreement(assetId);
|
|
918
|
+
if (hasAgreement) {
|
|
919
|
+
const message = `Cannot update asset ${assetId}: Asset has active contract agreements. Deleting an asset with agreements would invalidate existing contracts. Please terminate or complete all negotiations first.`;
|
|
920
|
+
throw new AssetValidationError(message, assetId, "update", "agreements");
|
|
921
|
+
}
|
|
922
|
+
const negotiations = await this.getAllContractNegotiations();
|
|
923
|
+
const activeNegotiations = negotiations.filter((neg) => neg.state !== "FINALIZED" && neg.state !== "TERMINATED" && neg.assetId === assetId);
|
|
924
|
+
if (activeNegotiations.length > 0) {
|
|
925
|
+
const message = `Cannot update asset ${assetId}: Asset has ${activeNegotiations.length} active contract negotiation(s). Please wait for negotiations to complete or terminate them first.`;
|
|
926
|
+
throw new AssetValidationError(message, assetId, "update", "negotiations", {
|
|
927
|
+
negotiationCount: activeNegotiations.length,
|
|
928
|
+
negotiations: activeNegotiations
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
console.log(`\u26A0\uFE0F Using DELETE + POST pattern to update asset ${assetId}`);
|
|
932
|
+
try {
|
|
933
|
+
const deleted = await this.deleteAsset(assetId, true);
|
|
934
|
+
if (!deleted) {
|
|
935
|
+
throw new Error(`Failed to delete existing asset ${assetId} for update`);
|
|
936
|
+
}
|
|
937
|
+
} catch (deleteError) {
|
|
938
|
+
if (deleteError instanceof AssetValidationError) {
|
|
939
|
+
throw new AssetValidationError(deleteError.message.replace("Cannot delete", "Cannot update"), assetId, "update", deleteError.reason, deleteError.details);
|
|
940
|
+
}
|
|
941
|
+
throw deleteError;
|
|
942
|
+
}
|
|
943
|
+
try {
|
|
944
|
+
const updatedAsset = await this.createAsset(assetInput);
|
|
945
|
+
console.log(`\u2705 Asset ${assetId} updated successfully via DELETE + POST`);
|
|
946
|
+
return updatedAsset;
|
|
947
|
+
} catch (createError) {
|
|
948
|
+
console.error(`\u274C Critical: Failed to recreate asset ${assetId} after deletion`, createError);
|
|
949
|
+
const errorMessage = createError instanceof Error ? createError.message : String(createError);
|
|
950
|
+
throw new Error(`Failed to recreate asset after deletion: ${errorMessage}. Asset ${assetId} has been deleted but not recreated.`);
|
|
923
951
|
}
|
|
924
|
-
const updatedAsset = {
|
|
925
|
-
"@type": "Asset",
|
|
926
|
-
"@id": assetInput["@id"],
|
|
927
|
-
properties: assetInput.properties,
|
|
928
|
-
dataAddress: assetInput.dataAddress,
|
|
929
|
-
createdAt: Date.now()
|
|
930
|
-
};
|
|
931
|
-
await this.cache.set(assetId, updatedAsset);
|
|
932
|
-
return updatedAsset;
|
|
933
952
|
}
|
|
934
|
-
async deleteAsset(assetId) {
|
|
953
|
+
async deleteAsset(assetId, skipAgreementCheck = false) {
|
|
935
954
|
await this.ensureAuthenticated();
|
|
955
|
+
if (!skipAgreementCheck) {
|
|
956
|
+
const hasAgreement = this.hasValidAgreement(assetId);
|
|
957
|
+
if (hasAgreement) {
|
|
958
|
+
const message = `Cannot delete asset ${assetId}: Asset has active contract agreements. Deleting an asset with agreements would invalidate existing contracts. Please terminate or complete all negotiations first.`;
|
|
959
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements");
|
|
960
|
+
}
|
|
961
|
+
const negotiations = await this.getAllContractNegotiations();
|
|
962
|
+
const activeNegotiations = negotiations.filter((neg) => neg.state !== "FINALIZED" && neg.state !== "TERMINATED" && neg.assetId === assetId);
|
|
963
|
+
if (activeNegotiations.length > 0) {
|
|
964
|
+
const message = `Cannot delete asset ${assetId}: Asset has ${activeNegotiations.length} active contract negotiation(s). Please wait for negotiations to complete or terminate them first.`;
|
|
965
|
+
throw new AssetValidationError(message, assetId, "delete", "negotiations", {
|
|
966
|
+
negotiationCount: activeNegotiations.length,
|
|
967
|
+
negotiations: activeNegotiations
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
936
971
|
const apiVersion = this.config.apiVersion || "v3";
|
|
937
972
|
const assetsEndpoint = this.config.assetsEndpoint || this.config.catalogEndpoint.replace("/catalog/request", apiVersion === "v3" ? "/assets" : "/assets");
|
|
938
973
|
const response = await this.fetchAuthn(`${assetsEndpoint}/${assetId}`, {
|
|
@@ -941,9 +976,28 @@ let __tla = (async () => {
|
|
|
941
976
|
});
|
|
942
977
|
if (!response.ok) {
|
|
943
978
|
const errorText = await response.text();
|
|
979
|
+
if (response.status === 409) {
|
|
980
|
+
try {
|
|
981
|
+
const errorDetails = JSON.parse(errorText);
|
|
982
|
+
const errorMessage = Array.isArray(errorDetails) && errorDetails.length > 0 ? errorDetails[0].message : errorText;
|
|
983
|
+
const message = `Cannot delete asset ${assetId}: ${errorMessage}`;
|
|
984
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements", {
|
|
985
|
+
apiResponse: errorDetails
|
|
986
|
+
});
|
|
987
|
+
} catch (parseError) {
|
|
988
|
+
if (parseError instanceof AssetValidationError) {
|
|
989
|
+
throw parseError;
|
|
990
|
+
}
|
|
991
|
+
const message = `Cannot delete asset ${assetId}: ${errorText}`;
|
|
992
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements", {
|
|
993
|
+
rawError: errorText
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}
|
|
944
997
|
throw new Error(`Failed to delete asset: ${response.status} ${response.statusText} - ${errorText}`);
|
|
945
998
|
}
|
|
946
999
|
await this.cache.delete(assetId);
|
|
1000
|
+
this.assetAgreements.delete(assetId);
|
|
947
1001
|
return true;
|
|
948
1002
|
}
|
|
949
1003
|
async getAllPolicies(querySpec) {
|
|
@@ -28499,7 +28553,7 @@ sh:property [
|
|
|
28499
28553
|
this.searchProvider = new SolidIndexingSearchProvider(this.getData.bind(this));
|
|
28500
28554
|
}
|
|
28501
28555
|
async initGetter() {
|
|
28502
|
-
const { CustomGetter } = await import("./custom-getter-
|
|
28556
|
+
const { CustomGetter } = await import("./custom-getter-C9i4kdAJ.js");
|
|
28503
28557
|
return CustomGetter;
|
|
28504
28558
|
}
|
|
28505
28559
|
async getData(id, context2, parentId, localData, forceFetch, serverPagination, serverSearch, headers, bypassLoadingList) {
|
package/dist/store.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.2",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|