Prepare GVL raw evidence schema
Dieser Commit ist enthalten in:
@@ -1,12 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const VENDORGET_DB_NAME = "vendorget_iv";
|
const VENDORGET_DB_NAME = "vendorget_iv";
|
||||||
const VENDORGET_DB_VERSION = 5;
|
const VENDORGET_DB_VERSION = 6;
|
||||||
|
|
||||||
const VENDORGET_STORE_NAMES = {
|
const VENDORGET_STORE_NAMES = {
|
||||||
consentStates: "consent_states",
|
consentStates: "consent_states",
|
||||||
consentEvents: "consent_events",
|
consentEvents: "consent_events",
|
||||||
observedRequests: "observed_requests",
|
observedRequests: "observed_requests",
|
||||||
|
gvlRawEvidence: "gvl_raw_evidence",
|
||||||
gvlSnapshots: "gvl_snapshots",
|
gvlSnapshots: "gvl_snapshots",
|
||||||
gvlSnapshotEvents: "gvl_snapshot_events",
|
gvlSnapshotEvents: "gvl_snapshot_events",
|
||||||
gvlVendors: "gvl_vendors",
|
gvlVendors: "gvl_vendors",
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ function openVendorGetDb() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureGvlStores(db);
|
ensureGvlStores(db, event.target.transaction);
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onsuccess = () => resolve(request.result);
|
request.onsuccess = () => resolve(request.result);
|
||||||
@@ -110,18 +110,73 @@ async function deleteVendorGetDatabase() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureGvlStores(db) {
|
function ensureGvlStores(db, upgradeTransaction) {
|
||||||
|
if (!db.objectStoreNames.contains("gvl_raw_evidence")) {
|
||||||
|
const gvlRawEvidence = db.createObjectStore("gvl_raw_evidence", {
|
||||||
|
keyPath: "rawGvlSha256"
|
||||||
|
});
|
||||||
|
|
||||||
|
createIndexesIfMissing(gvlRawEvidence, [
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"vendorListVersion",
|
||||||
|
"fetchedAt",
|
||||||
|
"sourceUrl",
|
||||||
|
"ingestionSource",
|
||||||
|
"contentType",
|
||||||
|
"parseStatus"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gvlRawEvidence = getUpgradeObjectStore(
|
||||||
|
db,
|
||||||
|
upgradeTransaction,
|
||||||
|
"gvl_raw_evidence"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (gvlRawEvidence) {
|
||||||
|
createIndexesIfMissing(gvlRawEvidence, [
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"vendorListVersion",
|
||||||
|
"fetchedAt",
|
||||||
|
"sourceUrl",
|
||||||
|
"ingestionSource",
|
||||||
|
"contentType",
|
||||||
|
"parseStatus"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!db.objectStoreNames.contains("gvl_snapshots")) {
|
if (!db.objectStoreNames.contains("gvl_snapshots")) {
|
||||||
const gvlSnapshots = db.createObjectStore("gvl_snapshots", {
|
const gvlSnapshots = db.createObjectStore("gvl_snapshots", {
|
||||||
keyPath: "sha256"
|
keyPath: "sha256"
|
||||||
});
|
});
|
||||||
|
|
||||||
gvlSnapshots.createIndex("gvlRevision", "gvlRevision", { unique: false });
|
createIndexesIfMissing(gvlSnapshots, [
|
||||||
gvlSnapshots.createIndex("vendorListVersion", "vendorListVersion", {
|
"gvlRevision",
|
||||||
unique: false
|
"vendorListVersion",
|
||||||
});
|
"fetchedAt",
|
||||||
gvlSnapshots.createIndex("fetchedAt", "fetchedAt", { unique: false });
|
"sourceUrl",
|
||||||
gvlSnapshots.createIndex("sourceUrl", "sourceUrl", { unique: false });
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gvlSnapshots = getUpgradeObjectStore(
|
||||||
|
db,
|
||||||
|
upgradeTransaction,
|
||||||
|
"gvl_snapshots"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (gvlSnapshots) {
|
||||||
|
createIndexesIfMissing(gvlSnapshots, [
|
||||||
|
"gvlRevision",
|
||||||
|
"vendorListVersion",
|
||||||
|
"fetchedAt",
|
||||||
|
"sourceUrl",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!db.objectStoreNames.contains("gvl_snapshot_events")) {
|
if (!db.objectStoreNames.contains("gvl_snapshot_events")) {
|
||||||
@@ -130,22 +185,43 @@ function ensureGvlStores(db) {
|
|||||||
autoIncrement: true
|
autoIncrement: true
|
||||||
});
|
});
|
||||||
|
|
||||||
gvlSnapshotEvents.createIndex("eventType", "eventType", { unique: false });
|
createIndexesIfMissing(gvlSnapshotEvents, [
|
||||||
gvlSnapshotEvents.createIndex("capturedAt", "capturedAt", { unique: false });
|
"eventType",
|
||||||
gvlSnapshotEvents.createIndex("gvlRevision", "gvlRevision", {
|
"capturedAt",
|
||||||
unique: false
|
"gvlRevision",
|
||||||
});
|
"vendorListVersion",
|
||||||
gvlSnapshotEvents.createIndex("vendorListVersion", "vendorListVersion", {
|
"sha256",
|
||||||
unique: false
|
"sourceUrl",
|
||||||
});
|
"rawGvlSha256",
|
||||||
gvlSnapshotEvents.createIndex("sha256", "sha256", { unique: false });
|
"canonicalGvlSha256",
|
||||||
gvlSnapshotEvents.createIndex("sourceUrl", "sourceUrl", { unique: false });
|
"snapshotSha256"
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureGvlRelationshipStores(db);
|
const gvlSnapshotEvents = getUpgradeObjectStore(
|
||||||
|
db,
|
||||||
|
upgradeTransaction,
|
||||||
|
"gvl_snapshot_events"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (gvlSnapshotEvents) {
|
||||||
|
createIndexesIfMissing(gvlSnapshotEvents, [
|
||||||
|
"eventType",
|
||||||
|
"capturedAt",
|
||||||
|
"gvlRevision",
|
||||||
|
"vendorListVersion",
|
||||||
|
"sha256",
|
||||||
|
"sourceUrl",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ensureGvlRelationshipStores(db, upgradeTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureGvlRelationshipStores(db) {
|
function ensureGvlRelationshipStores(db, upgradeTransaction) {
|
||||||
const gvlRelationshipStoreDefinitions = [
|
const gvlRelationshipStoreDefinitions = [
|
||||||
{
|
{
|
||||||
name: "gvl_vendors",
|
name: "gvl_vendors",
|
||||||
@@ -154,28 +230,66 @@ function ensureGvlRelationshipStores(db) {
|
|||||||
"vendorId",
|
"vendorId",
|
||||||
"name",
|
"name",
|
||||||
"policyUrl",
|
"policyUrl",
|
||||||
"deletedDate"
|
"deletedDate",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_purposes",
|
name: "gvl_purposes",
|
||||||
indexes: ["vendorListVersion", "purposeId", "name"]
|
indexes: [
|
||||||
|
"vendorListVersion",
|
||||||
|
"purposeId",
|
||||||
|
"name",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_special_purposes",
|
name: "gvl_special_purposes",
|
||||||
indexes: ["vendorListVersion", "specialPurposeId", "name"]
|
indexes: [
|
||||||
|
"vendorListVersion",
|
||||||
|
"specialPurposeId",
|
||||||
|
"name",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_features",
|
name: "gvl_features",
|
||||||
indexes: ["vendorListVersion", "featureId", "name"]
|
indexes: [
|
||||||
|
"vendorListVersion",
|
||||||
|
"featureId",
|
||||||
|
"name",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_special_features",
|
name: "gvl_special_features",
|
||||||
indexes: ["vendorListVersion", "specialFeatureId", "name"]
|
indexes: [
|
||||||
|
"vendorListVersion",
|
||||||
|
"specialFeatureId",
|
||||||
|
"name",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_data_categories",
|
name: "gvl_data_categories",
|
||||||
indexes: ["vendorListVersion", "dataCategoryId", "name"]
|
indexes: [
|
||||||
|
"vendorListVersion",
|
||||||
|
"dataCategoryId",
|
||||||
|
"name",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "gvl_vendor_relationships",
|
name: "gvl_vendor_relationships",
|
||||||
@@ -183,13 +297,26 @@ function ensureGvlRelationshipStores(db) {
|
|||||||
"vendorListVersion",
|
"vendorListVersion",
|
||||||
"vendorId",
|
"vendorId",
|
||||||
"relationshipType",
|
"relationshipType",
|
||||||
"relatedId"
|
"relatedId",
|
||||||
|
"rawGvlSha256",
|
||||||
|
"canonicalGvlSha256",
|
||||||
|
"snapshotSha256"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
gvlRelationshipStoreDefinitions.forEach((storeDefinition) => {
|
gvlRelationshipStoreDefinitions.forEach((storeDefinition) => {
|
||||||
if (db.objectStoreNames.contains(storeDefinition.name)) {
|
if (db.objectStoreNames.contains(storeDefinition.name)) {
|
||||||
|
const objectStore = getUpgradeObjectStore(
|
||||||
|
db,
|
||||||
|
upgradeTransaction,
|
||||||
|
storeDefinition.name
|
||||||
|
);
|
||||||
|
|
||||||
|
if (objectStore) {
|
||||||
|
createIndexesIfMissing(objectStore, storeDefinition.indexes);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,8 +324,24 @@ function ensureGvlRelationshipStores(db) {
|
|||||||
keyPath: "id"
|
keyPath: "id"
|
||||||
});
|
});
|
||||||
|
|
||||||
storeDefinition.indexes.forEach((indexName) => {
|
createIndexesIfMissing(objectStore, storeDefinition.indexes);
|
||||||
objectStore.createIndex(indexName, indexName, { unique: false });
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function getUpgradeObjectStore(db, upgradeTransaction, storeName) {
|
||||||
|
if (!upgradeTransaction || !db.objectStoreNames.contains(storeName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return upgradeTransaction.objectStore(storeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createIndexesIfMissing(objectStore, indexNames) {
|
||||||
|
indexNames.forEach((indexName) => {
|
||||||
|
if (objectStore.indexNames.contains(indexName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
objectStore.createIndex(indexName, indexName, { unique: false });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren