@overmap-ai/core 1.0.58-asset-description.6 → 1.0.58-asset-description.8
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.
|
@@ -1728,6 +1728,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
prevAssets = null;
|
|
1730
1730
|
},
|
|
1731
|
+
updateAssets: (state, action) => {
|
|
1732
|
+
for (const asset of action.payload) {
|
|
1733
|
+
if (asset.offline_id in state.assets) {
|
|
1734
|
+
state.assets[asset.offline_id] = asset;
|
|
1735
|
+
} else {
|
|
1736
|
+
throw new Error(`Tried to update asset with ID that doesn't exist: ${asset.offline_id}`);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
prevAssets = null;
|
|
1740
|
+
},
|
|
1731
1741
|
removeAsset: (state, action) => {
|
|
1732
1742
|
if (action.payload in state.assets) {
|
|
1733
1743
|
delete state.assets[action.payload];
|
|
@@ -1736,6 +1746,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1736
1746
|
}
|
|
1737
1747
|
prevAssets = null;
|
|
1738
1748
|
},
|
|
1749
|
+
removeAssets: (state, action) => {
|
|
1750
|
+
for (const assetId of action.payload) {
|
|
1751
|
+
if (assetId in state.assets) {
|
|
1752
|
+
delete state.assets[assetId];
|
|
1753
|
+
} else {
|
|
1754
|
+
throw new Error(`Failed to remove asset because ID doesn't exist: ${assetId}`);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
prevAssets = null;
|
|
1758
|
+
},
|
|
1739
1759
|
removeAllAssetsOfType: (state, action) => {
|
|
1740
1760
|
var _a2;
|
|
1741
1761
|
for (const componentId in state.assets) {
|
|
@@ -1759,7 +1779,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1759
1779
|
const {
|
|
1760
1780
|
addAsset,
|
|
1761
1781
|
updateAsset,
|
|
1782
|
+
updateAssets,
|
|
1762
1783
|
removeAsset,
|
|
1784
|
+
removeAssets,
|
|
1763
1785
|
addAssetsInBatches,
|
|
1764
1786
|
setAssets,
|
|
1765
1787
|
removeAllAssetsOfType,
|
|
@@ -5368,6 +5390,16 @@ var __publicField = (obj, key, value) => {
|
|
|
5368
5390
|
store.dispatch(setCategories(result));
|
|
5369
5391
|
}
|
|
5370
5392
|
}
|
|
5393
|
+
function chunkArray(arr, chunkSize) {
|
|
5394
|
+
const chunks = [];
|
|
5395
|
+
let index2 = 0;
|
|
5396
|
+
const arrLength = arr.length;
|
|
5397
|
+
while (index2 < arrLength) {
|
|
5398
|
+
chunks.push(arr.slice(index2, index2 += chunkSize));
|
|
5399
|
+
}
|
|
5400
|
+
return chunks;
|
|
5401
|
+
}
|
|
5402
|
+
const BULK_ADD_ASSET_BATCH_SIZE = 1e3;
|
|
5371
5403
|
class AssetService extends BaseApiService {
|
|
5372
5404
|
// Basic CRUD functions
|
|
5373
5405
|
add(asset, workspaceId) {
|
|
@@ -5444,36 +5476,45 @@ var __publicField = (obj, key, value) => {
|
|
|
5444
5476
|
throw err;
|
|
5445
5477
|
});
|
|
5446
5478
|
}
|
|
5447
|
-
|
|
5479
|
+
addBulk(assetsToCreate, workspaceId, assetTypeId) {
|
|
5480
|
+
const { store } = this.client;
|
|
5448
5481
|
const fullAssets = assetsToCreate.map((asset) => {
|
|
5449
5482
|
return { ...offline(asset), submitted_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5450
5483
|
});
|
|
5451
|
-
const
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
workspace_id: workspaceId.toString()
|
|
5459
|
-
},
|
|
5460
|
-
payload: {
|
|
5461
|
-
assets: fullAssets
|
|
5462
|
-
},
|
|
5463
|
-
blockers: [assetTypeId],
|
|
5464
|
-
blocks: fullAssets.map((c) => c.offline_id)
|
|
5465
|
-
});
|
|
5466
|
-
void promise.then((result) => {
|
|
5467
|
-
for (const assets of Object.values(result)) {
|
|
5468
|
-
store.dispatch(updateAsset(assets));
|
|
5469
|
-
}
|
|
5470
|
-
}).catch((e) => {
|
|
5471
|
-
for (const asset of fullAssets) {
|
|
5472
|
-
store.dispatch(removeAsset(asset.offline_id));
|
|
5473
|
-
}
|
|
5474
|
-
throw e;
|
|
5484
|
+
const assetBatches = chunkArray(fullAssets, BULK_ADD_ASSET_BATCH_SIZE).map((assetBatch) => {
|
|
5485
|
+
return {
|
|
5486
|
+
batchId: uuid.v4(),
|
|
5487
|
+
payload: {
|
|
5488
|
+
assets: assetBatch
|
|
5489
|
+
}
|
|
5490
|
+
};
|
|
5475
5491
|
});
|
|
5476
|
-
|
|
5492
|
+
store.dispatch(addAssetsInBatches(fullAssets));
|
|
5493
|
+
let prevBatchId = null;
|
|
5494
|
+
const batchPromises = Promise.all(
|
|
5495
|
+
assetBatches.map((assetBatch) => {
|
|
5496
|
+
const { batchId, payload } = assetBatch;
|
|
5497
|
+
const promise = this.client.enqueueRequest({
|
|
5498
|
+
description: "Batch create assets",
|
|
5499
|
+
method: HttpMethod.POST,
|
|
5500
|
+
url: `/assets/types/${assetTypeId}/add-assets/`,
|
|
5501
|
+
queryParams: {
|
|
5502
|
+
workspace_id: workspaceId.toString()
|
|
5503
|
+
},
|
|
5504
|
+
payload,
|
|
5505
|
+
blockers: prevBatchId ? [assetTypeId, prevBatchId] : [assetTypeId],
|
|
5506
|
+
blocks: assetBatch.payload.assets.map((c) => c.offline_id).concat([batchId])
|
|
5507
|
+
});
|
|
5508
|
+
promise.then((result) => {
|
|
5509
|
+
store.dispatch(updateAssets(Object.values(result)));
|
|
5510
|
+
}).catch(() => {
|
|
5511
|
+
store.dispatch(removeAssets(assetBatch.payload.assets.map((c) => c.offline_id)));
|
|
5512
|
+
});
|
|
5513
|
+
prevBatchId = assetBatch.batchId;
|
|
5514
|
+
return promise;
|
|
5515
|
+
})
|
|
5516
|
+
);
|
|
5517
|
+
return [fullAssets, batchPromises.then((result) => result)];
|
|
5477
5518
|
}
|
|
5478
5519
|
async refreshStore() {
|
|
5479
5520
|
const { store } = this.client;
|
|
@@ -7239,15 +7280,6 @@ var __publicField = (obj, key, value) => {
|
|
|
7239
7280
|
store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
|
|
7240
7281
|
}
|
|
7241
7282
|
}
|
|
7242
|
-
function chunkArray(arr, chunkSize) {
|
|
7243
|
-
const chunks = [];
|
|
7244
|
-
let index2 = 0;
|
|
7245
|
-
const arrLength = arr.length;
|
|
7246
|
-
while (index2 < arrLength) {
|
|
7247
|
-
chunks.push(arr.slice(index2, index2 += chunkSize));
|
|
7248
|
-
}
|
|
7249
|
-
return chunks;
|
|
7250
|
-
}
|
|
7251
7283
|
const isArrayOfFiles = (value) => {
|
|
7252
7284
|
return Array.isArray(value) && value[0] instanceof File;
|
|
7253
7285
|
};
|
|
@@ -17063,6 +17095,7 @@ var __publicField = (obj, key, value) => {
|
|
|
17063
17095
|
exports2.removeAssetAttachments = removeAssetAttachments;
|
|
17064
17096
|
exports2.removeAssetTypeAttachment = removeAssetTypeAttachment;
|
|
17065
17097
|
exports2.removeAssetTypeAttachments = removeAssetTypeAttachments;
|
|
17098
|
+
exports2.removeAssets = removeAssets;
|
|
17066
17099
|
exports2.removeAttachmentsOfIssue = removeAttachmentsOfIssue;
|
|
17067
17100
|
exports2.removeCategory = removeCategory;
|
|
17068
17101
|
exports2.removeColor = removeColor;
|
|
@@ -17380,6 +17413,7 @@ var __publicField = (obj, key, value) => {
|
|
|
17380
17413
|
exports2.updateAssetAttachments = updateAssetAttachments;
|
|
17381
17414
|
exports2.updateAssetTypeAttachment = updateAssetTypeAttachment;
|
|
17382
17415
|
exports2.updateAssetTypeAttachments = updateAssetTypeAttachments;
|
|
17416
|
+
exports2.updateAssets = updateAssets;
|
|
17383
17417
|
exports2.updateConversation = updateConversation;
|
|
17384
17418
|
exports2.updateDocumentAttachment = updateDocumentAttachment;
|
|
17385
17419
|
exports2.updateDocumentAttachments = updateDocumentAttachments;
|