@lv-x-software-house/x_view 1.2.8-dev.1 → 1.2.8-dev.11
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.
- package/dist/index.js +385 -190
- package/dist/index.mjs +385 -190
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -283,7 +283,12 @@ var updateExistingNodeVisuals = (state, updatedNode) => {
|
|
|
283
283
|
if (oldLabelObject.material) oldLabelObject.material.dispose();
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
const newMesh = createNodeMesh(
|
|
286
|
+
const newMesh = createNodeMesh(
|
|
287
|
+
updatedNode,
|
|
288
|
+
position,
|
|
289
|
+
state.glowTexture,
|
|
290
|
+
hadQuestDateLabel
|
|
291
|
+
);
|
|
287
292
|
if (oldTimelineBar) {
|
|
288
293
|
newMesh.userData.timelineIntervalBar = oldTimelineBar;
|
|
289
294
|
}
|
|
@@ -835,7 +840,12 @@ var removeNodeFromScene = (state, nodeId) => {
|
|
|
835
840
|
var addStandaloneNodeToScene = (state, nodeData, position, forceShowQuestDate = false) => {
|
|
836
841
|
const { graphGroup, nodeObjects, clickableNodes, glowTexture } = state;
|
|
837
842
|
if (!graphGroup) return;
|
|
838
|
-
const mesh = createNodeMesh(
|
|
843
|
+
const mesh = createNodeMesh(
|
|
844
|
+
nodeData,
|
|
845
|
+
position,
|
|
846
|
+
glowTexture,
|
|
847
|
+
forceShowQuestDate
|
|
848
|
+
);
|
|
839
849
|
mesh.scale.set(0.01, 0.01, 0.01);
|
|
840
850
|
graphGroup.add(mesh);
|
|
841
851
|
if (mesh.userData.labelObject) {
|
|
@@ -1053,7 +1063,9 @@ var userActionHandlers = {
|
|
|
1053
1063
|
if (isCrossDataset) {
|
|
1054
1064
|
graphDataRef.current[finalTargetDatasetId] = targetDataToUpdate;
|
|
1055
1065
|
}
|
|
1056
|
-
if (sceneDataRef.current.parent_dbs.some(
|
|
1066
|
+
if (sceneDataRef.current.parent_dbs.some(
|
|
1067
|
+
(db) => String(db.db_id) === String(sourceParentInfo.parentFileId)
|
|
1068
|
+
)) {
|
|
1057
1069
|
}
|
|
1058
1070
|
const finalPosition = stateRef.current.ghostElements.node.position.clone();
|
|
1059
1071
|
addNewNodeToScene(stateRef.current, newNode, newLink, finalPosition);
|
|
@@ -1248,7 +1260,10 @@ var userActionHandlers = {
|
|
|
1248
1260
|
context.sceneSaveUrl,
|
|
1249
1261
|
viewFilePayload
|
|
1250
1262
|
);
|
|
1251
|
-
const questSaveUrl = context.sceneSaveUrl.replace(
|
|
1263
|
+
const questSaveUrl = context.sceneSaveUrl.replace(
|
|
1264
|
+
"x_view_scenes",
|
|
1265
|
+
"x_view_quests"
|
|
1266
|
+
);
|
|
1252
1267
|
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
1253
1268
|
} else {
|
|
1254
1269
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
@@ -1503,20 +1518,19 @@ var userActionHandlers = {
|
|
|
1503
1518
|
const viewFilePayload = {
|
|
1504
1519
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1505
1520
|
nodes: sceneDataRef.current.nodes,
|
|
1506
|
-
links: sceneDataRef.current.links
|
|
1507
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1508
|
-
};
|
|
1509
|
-
const questFilePayload = {
|
|
1510
|
-
nodes: specificParentData.nodes,
|
|
1511
|
-
links: specificParentData.links,
|
|
1512
|
-
milestones: sceneDataRef.current.milestones || []
|
|
1521
|
+
links: sceneDataRef.current.links
|
|
1513
1522
|
};
|
|
1514
1523
|
await context.actions.save_view_data(
|
|
1515
1524
|
context.sceneSaveUrl,
|
|
1516
1525
|
viewFilePayload
|
|
1517
1526
|
);
|
|
1518
|
-
|
|
1519
|
-
|
|
1527
|
+
if (context.actions.upsert_quest_link_firestore) {
|
|
1528
|
+
await context.actions.upsert_quest_link_firestore(
|
|
1529
|
+
context.ownerId,
|
|
1530
|
+
context.sceneConfigId,
|
|
1531
|
+
newLink
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1520
1534
|
} else {
|
|
1521
1535
|
const specificParentData = JSON.parse(
|
|
1522
1536
|
JSON.stringify(graphDataRef.current[parentFileIdToSave])
|
|
@@ -1665,18 +1679,12 @@ var userActionHandlers = {
|
|
|
1665
1679
|
const viewFilePayload = {
|
|
1666
1680
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1667
1681
|
nodes: sceneDataRef.current.nodes,
|
|
1668
|
-
links: sceneDataRef.current.links
|
|
1669
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1682
|
+
links: sceneDataRef.current.links
|
|
1670
1683
|
};
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
};
|
|
1676
|
-
const p1 = context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
|
|
1677
|
-
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
1678
|
-
const p2 = context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
1679
|
-
return Promise.all([p1, p2]);
|
|
1684
|
+
return context.actions.save_view_data(
|
|
1685
|
+
context.sceneSaveUrl,
|
|
1686
|
+
viewFilePayload
|
|
1687
|
+
);
|
|
1680
1688
|
} else {
|
|
1681
1689
|
return context.actions.save_view_data(
|
|
1682
1690
|
`x_view_dbs/${fileOwnerId}/${fileId}`,
|
|
@@ -1701,6 +1709,15 @@ var userActionHandlers = {
|
|
|
1701
1709
|
updatedOriginalParentData
|
|
1702
1710
|
)
|
|
1703
1711
|
);
|
|
1712
|
+
if (oldGoverningFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
|
|
1713
|
+
savePromises.push(
|
|
1714
|
+
context.actions.delete_quest_link_firestore(
|
|
1715
|
+
context.ownerId,
|
|
1716
|
+
context.sceneConfigId,
|
|
1717
|
+
linkId
|
|
1718
|
+
)
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1704
1721
|
const updatedNewParentData = JSON.parse(
|
|
1705
1722
|
JSON.stringify(graphDataRef.current[newGoverningFileId])
|
|
1706
1723
|
);
|
|
@@ -1714,6 +1731,15 @@ var userActionHandlers = {
|
|
|
1714
1731
|
updatedNewParentData
|
|
1715
1732
|
)
|
|
1716
1733
|
);
|
|
1734
|
+
if (newGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
|
|
1735
|
+
savePromises.push(
|
|
1736
|
+
context.actions.upsert_quest_link_firestore(
|
|
1737
|
+
context.ownerId,
|
|
1738
|
+
context.sceneConfigId,
|
|
1739
|
+
newLinkData
|
|
1740
|
+
)
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1717
1743
|
} else {
|
|
1718
1744
|
const updatedParentData = JSON.parse(
|
|
1719
1745
|
JSON.stringify(graphDataRef.current[oldGoverningFileId])
|
|
@@ -1730,6 +1756,15 @@ var userActionHandlers = {
|
|
|
1730
1756
|
updatedParentData
|
|
1731
1757
|
)
|
|
1732
1758
|
);
|
|
1759
|
+
if (oldGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
|
|
1760
|
+
savePromises.push(
|
|
1761
|
+
context.actions.upsert_quest_link_firestore(
|
|
1762
|
+
context.ownerId,
|
|
1763
|
+
context.sceneConfigId,
|
|
1764
|
+
newLinkData
|
|
1765
|
+
)
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1733
1768
|
}
|
|
1734
1769
|
try {
|
|
1735
1770
|
await Promise.all(savePromises);
|
|
@@ -1789,8 +1824,6 @@ var userActionHandlers = {
|
|
|
1789
1824
|
specificParentData.links = newLinks;
|
|
1790
1825
|
let filenameToSave;
|
|
1791
1826
|
let payloadToSave;
|
|
1792
|
-
let questSaveUrl;
|
|
1793
|
-
let questFilePayload;
|
|
1794
1827
|
const isView = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
|
|
1795
1828
|
if (isView && parentFileId === context.sceneConfigId) {
|
|
1796
1829
|
filenameToSave = context.sceneSaveUrl;
|
|
@@ -1800,14 +1833,7 @@ var userActionHandlers = {
|
|
|
1800
1833
|
payloadToSave = {
|
|
1801
1834
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1802
1835
|
nodes: sceneDataRef.current.nodes,
|
|
1803
|
-
links: sceneDataRef.current.links
|
|
1804
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1805
|
-
};
|
|
1806
|
-
questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
1807
|
-
questFilePayload = {
|
|
1808
|
-
nodes: specificParentData.nodes,
|
|
1809
|
-
links: specificParentData.links,
|
|
1810
|
-
milestones: sceneDataRef.current.milestones || []
|
|
1836
|
+
links: sceneDataRef.current.links
|
|
1811
1837
|
};
|
|
1812
1838
|
} else {
|
|
1813
1839
|
filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
@@ -1815,8 +1841,12 @@ var userActionHandlers = {
|
|
|
1815
1841
|
}
|
|
1816
1842
|
try {
|
|
1817
1843
|
await context.actions.save_view_data(filenameToSave, payloadToSave);
|
|
1818
|
-
if (
|
|
1819
|
-
await context.actions.
|
|
1844
|
+
if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
|
|
1845
|
+
await context.actions.delete_quest_link_firestore(
|
|
1846
|
+
context.ownerId,
|
|
1847
|
+
context.sceneConfigId,
|
|
1848
|
+
linkIdToDelete
|
|
1849
|
+
);
|
|
1820
1850
|
}
|
|
1821
1851
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
1822
1852
|
setters.setDetailsLink(
|
|
@@ -2045,16 +2075,30 @@ var userActionHandlers = {
|
|
|
2045
2075
|
payloadToSave = {
|
|
2046
2076
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2047
2077
|
nodes: sceneDataRef.current.nodes,
|
|
2048
|
-
links: sceneDataRef.current.links
|
|
2049
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2050
|
-
};
|
|
2051
|
-
const questFilePayload = {
|
|
2052
|
-
nodes: originalData.nodes,
|
|
2053
|
-
links: originalData.links,
|
|
2054
|
-
milestones: sceneDataRef.current.milestones || []
|
|
2078
|
+
links: sceneDataRef.current.links
|
|
2055
2079
|
};
|
|
2056
|
-
|
|
2057
|
-
|
|
2080
|
+
if (context.actions.delete_quest_firestore) {
|
|
2081
|
+
nodesToDelete.forEach((nodeIdToDelete) => {
|
|
2082
|
+
savePromises.push(
|
|
2083
|
+
context.actions.delete_quest_firestore(
|
|
2084
|
+
context.ownerId,
|
|
2085
|
+
context.sceneConfigId,
|
|
2086
|
+
nodeIdToDelete
|
|
2087
|
+
)
|
|
2088
|
+
);
|
|
2089
|
+
});
|
|
2090
|
+
if (context.actions.delete_quest_link_firestore) {
|
|
2091
|
+
linksToDelete.forEach((linkIdToDelete) => {
|
|
2092
|
+
savePromises.push(
|
|
2093
|
+
context.actions.delete_quest_link_firestore(
|
|
2094
|
+
context.ownerId,
|
|
2095
|
+
context.sceneConfigId,
|
|
2096
|
+
linkIdToDelete
|
|
2097
|
+
)
|
|
2098
|
+
);
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2058
2102
|
} else {
|
|
2059
2103
|
filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2060
2104
|
payloadToSave = originalData;
|
|
@@ -2125,6 +2169,9 @@ var userActionHandlers = {
|
|
|
2125
2169
|
const newLinks = (specificParentData.links || []).filter(
|
|
2126
2170
|
(l) => String(l.source) !== strNodeId && String(l.target) !== strNodeId
|
|
2127
2171
|
);
|
|
2172
|
+
const linksToDelete = (specificParentData.links || []).filter(
|
|
2173
|
+
(l) => String(l.source) === strNodeId || String(l.target) === strNodeId
|
|
2174
|
+
);
|
|
2128
2175
|
specificParentData.nodes = newNodes;
|
|
2129
2176
|
specificParentData.links = newLinks;
|
|
2130
2177
|
let filenameToSave;
|
|
@@ -2143,18 +2190,27 @@ var userActionHandlers = {
|
|
|
2143
2190
|
payloadToSave = {
|
|
2144
2191
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2145
2192
|
nodes: newVisualNodes,
|
|
2146
|
-
links: newVisualLinks
|
|
2147
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2193
|
+
links: newVisualLinks
|
|
2148
2194
|
};
|
|
2149
|
-
const questFilePayload = {
|
|
2150
|
-
nodes: specificParentData.nodes,
|
|
2151
|
-
links: specificParentData.links,
|
|
2152
|
-
milestones: sceneDataRef.current.milestones || []
|
|
2153
|
-
};
|
|
2154
|
-
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
2155
2195
|
try {
|
|
2156
2196
|
await context.actions.save_view_data(filenameToSave, payloadToSave);
|
|
2157
|
-
|
|
2197
|
+
if (context.actions.delete_quest_firestore) {
|
|
2198
|
+
await context.actions.delete_quest_firestore(
|
|
2199
|
+
context.ownerId,
|
|
2200
|
+
context.sceneConfigId,
|
|
2201
|
+
nodeIdToDelete
|
|
2202
|
+
);
|
|
2203
|
+
if (context.actions.delete_quest_link_firestore && linksToDelete.length > 0) {
|
|
2204
|
+
const linkDeletePromises = linksToDelete.map(
|
|
2205
|
+
(link) => context.actions.delete_quest_link_firestore(
|
|
2206
|
+
context.ownerId,
|
|
2207
|
+
context.sceneConfigId,
|
|
2208
|
+
link.id
|
|
2209
|
+
)
|
|
2210
|
+
);
|
|
2211
|
+
await Promise.all(linkDeletePromises);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2158
2214
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
2159
2215
|
setters.setDetailsNode(
|
|
2160
2216
|
(prev) => String(prev == null ? void 0 : prev.id) === String(nodeIdToDelete) ? null : prev
|
|
@@ -2256,12 +2312,10 @@ var userActionHandlers = {
|
|
|
2256
2312
|
}
|
|
2257
2313
|
const nextQuestNode = {
|
|
2258
2314
|
...JSON.parse(JSON.stringify(nodeToSave)),
|
|
2259
|
-
// Deep copy properties
|
|
2260
2315
|
id: short.generate(),
|
|
2261
2316
|
name: nextName,
|
|
2262
2317
|
status: "Backlog",
|
|
2263
2318
|
color: "#64748b",
|
|
2264
|
-
// QUEST_STATUS_COLORS["Backlog"]
|
|
2265
2319
|
assignee_id: nodeToSave.recurrence_config.next_assignee_id || "",
|
|
2266
2320
|
Date: nextDateObj,
|
|
2267
2321
|
timeline: [
|
|
@@ -2286,14 +2340,28 @@ var userActionHandlers = {
|
|
|
2286
2340
|
})),
|
|
2287
2341
|
recurrence_config: nextRecurrenceConfig
|
|
2288
2342
|
};
|
|
2289
|
-
|
|
2343
|
+
await context.actions.upsert_quest_firestore(
|
|
2344
|
+
context.ownerId,
|
|
2345
|
+
context.sceneConfigId,
|
|
2346
|
+
nextQuestNode
|
|
2347
|
+
);
|
|
2348
|
+
await context.actions.update_view_counter(
|
|
2349
|
+
context.ownerId,
|
|
2350
|
+
context.sceneConfigId,
|
|
2351
|
+
nextCounter
|
|
2352
|
+
);
|
|
2290
2353
|
if (stateRef.current.nodeObjects[String(nodeToSave.id)]) {
|
|
2291
2354
|
const oldMeshPosition = stateRef.current.nodeObjects[String(nodeToSave.id)].position.clone();
|
|
2292
2355
|
setTimeout(() => {
|
|
2293
2356
|
if (stateRef.current && stateRef.current.graphGroup) {
|
|
2294
2357
|
const pos = oldMeshPosition.clone();
|
|
2295
2358
|
pos.x += 12;
|
|
2296
|
-
addStandaloneNodeToScene(
|
|
2359
|
+
addStandaloneNodeToScene(
|
|
2360
|
+
stateRef.current,
|
|
2361
|
+
nextQuestNode,
|
|
2362
|
+
pos,
|
|
2363
|
+
true
|
|
2364
|
+
);
|
|
2297
2365
|
}
|
|
2298
2366
|
}, 2e3);
|
|
2299
2367
|
}
|
|
@@ -2314,8 +2382,7 @@ var userActionHandlers = {
|
|
|
2314
2382
|
const viewFilePayload = {
|
|
2315
2383
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2316
2384
|
nodes: sceneDataRef.current.nodes,
|
|
2317
|
-
links: sceneDataRef.current.links
|
|
2318
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2385
|
+
links: sceneDataRef.current.links
|
|
2319
2386
|
};
|
|
2320
2387
|
const questFilePayload = {
|
|
2321
2388
|
nodes: specificParentData.nodes,
|
|
@@ -2326,8 +2393,13 @@ var userActionHandlers = {
|
|
|
2326
2393
|
context.sceneSaveUrl,
|
|
2327
2394
|
viewFilePayload
|
|
2328
2395
|
);
|
|
2329
|
-
|
|
2330
|
-
|
|
2396
|
+
if (context.actions.upsert_quest_firestore) {
|
|
2397
|
+
await context.actions.upsert_quest_firestore(
|
|
2398
|
+
context.ownerId,
|
|
2399
|
+
context.sceneConfigId,
|
|
2400
|
+
nodeToSave
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2331
2403
|
} else {
|
|
2332
2404
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2333
2405
|
await context.actions.save_view_data(
|
|
@@ -2338,7 +2410,6 @@ var userActionHandlers = {
|
|
|
2338
2410
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
2339
2411
|
if (isView && parentFileId === context.sceneConfigId) {
|
|
2340
2412
|
sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
|
|
2341
|
-
sceneDataRef.current.quest_counter = specificParentData.quest_counter || sceneDataRef.current.quest_counter;
|
|
2342
2413
|
}
|
|
2343
2414
|
updateExistingNodeVisuals(stateRef.current, nodeToSave);
|
|
2344
2415
|
setters.setSceneVersion((v) => v + 1);
|
|
@@ -2395,8 +2466,7 @@ var userActionHandlers = {
|
|
|
2395
2466
|
const viewFilePayload = {
|
|
2396
2467
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2397
2468
|
nodes: sceneDataRef.current.nodes,
|
|
2398
|
-
links: sceneDataRef.current.links
|
|
2399
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2469
|
+
links: sceneDataRef.current.links
|
|
2400
2470
|
};
|
|
2401
2471
|
const questFilePayload = {
|
|
2402
2472
|
nodes: specificParentData.nodes,
|
|
@@ -2407,8 +2477,13 @@ var userActionHandlers = {
|
|
|
2407
2477
|
context.sceneSaveUrl,
|
|
2408
2478
|
viewFilePayload
|
|
2409
2479
|
);
|
|
2410
|
-
|
|
2411
|
-
|
|
2480
|
+
if (context.actions.upsert_quest_link_firestore) {
|
|
2481
|
+
await context.actions.upsert_quest_link_firestore(
|
|
2482
|
+
context.ownerId,
|
|
2483
|
+
context.sceneConfigId,
|
|
2484
|
+
linkToSave
|
|
2485
|
+
);
|
|
2486
|
+
}
|
|
2412
2487
|
} else {
|
|
2413
2488
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2414
2489
|
await context.actions.save_view_data(
|
|
@@ -15540,7 +15615,13 @@ function XViewScene({
|
|
|
15540
15615
|
check_user_permission,
|
|
15541
15616
|
get_view_members,
|
|
15542
15617
|
create_google_doc_action,
|
|
15543
|
-
open_google_picker_action
|
|
15618
|
+
open_google_picker_action,
|
|
15619
|
+
upsert_quest_firestore,
|
|
15620
|
+
delete_quest_firestore,
|
|
15621
|
+
upsert_quest_link_firestore,
|
|
15622
|
+
delete_quest_link_firestore,
|
|
15623
|
+
upsert_milestone_firestore,
|
|
15624
|
+
update_view_counter
|
|
15544
15625
|
}) {
|
|
15545
15626
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
15546
15627
|
const { data: session, status } = useSession();
|
|
@@ -18047,7 +18128,14 @@ function XViewScene({
|
|
|
18047
18128
|
get_single_parent_file,
|
|
18048
18129
|
get_scene_view_data,
|
|
18049
18130
|
upload_file: upload_file_action,
|
|
18050
|
-
delete_file: delete_file_action
|
|
18131
|
+
delete_file: delete_file_action,
|
|
18132
|
+
// Adicionado novas importações aqui
|
|
18133
|
+
upsert_quest_firestore,
|
|
18134
|
+
delete_quest_firestore,
|
|
18135
|
+
upsert_quest_link_firestore,
|
|
18136
|
+
delete_quest_link_firestore,
|
|
18137
|
+
upsert_milestone_firestore,
|
|
18138
|
+
update_view_counter
|
|
18051
18139
|
}
|
|
18052
18140
|
};
|
|
18053
18141
|
},
|
|
@@ -18066,7 +18154,13 @@ function XViewScene({
|
|
|
18066
18154
|
get_single_parent_file,
|
|
18067
18155
|
get_scene_view_data,
|
|
18068
18156
|
upload_file_action,
|
|
18069
|
-
delete_file_action
|
|
18157
|
+
delete_file_action,
|
|
18158
|
+
upsert_quest_firestore,
|
|
18159
|
+
delete_quest_firestore,
|
|
18160
|
+
upsert_quest_link_firestore,
|
|
18161
|
+
delete_quest_link_firestore,
|
|
18162
|
+
upsert_milestone_firestore,
|
|
18163
|
+
update_view_counter
|
|
18070
18164
|
]
|
|
18071
18165
|
);
|
|
18072
18166
|
const handleStartVersioning = (nodeData) => {
|
|
@@ -18272,40 +18366,30 @@ function XViewScene({
|
|
|
18272
18366
|
parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
|
|
18273
18367
|
}
|
|
18274
18368
|
}
|
|
18275
|
-
const
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
)
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
...updatedNodeData
|
|
18299
|
-
};
|
|
18300
|
-
}
|
|
18301
|
-
if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
|
|
18302
|
-
setDetailsNode((prev) => ({
|
|
18303
|
-
...prev,
|
|
18304
|
-
quest_tree: formattedTree,
|
|
18305
|
-
quest_abstraction_tree: formattedAbstractionTree
|
|
18306
|
-
}));
|
|
18369
|
+
const updatedNodeData = sceneData.quest_nodes[questIndex];
|
|
18370
|
+
if (upsert_quest_firestore) {
|
|
18371
|
+
await upsert_quest_firestore(
|
|
18372
|
+
ownerId,
|
|
18373
|
+
sceneConfigId,
|
|
18374
|
+
updatedNodeData
|
|
18375
|
+
);
|
|
18376
|
+
}
|
|
18377
|
+
const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
|
|
18378
|
+
if (nodeMesh) {
|
|
18379
|
+
nodeMesh.userData = {
|
|
18380
|
+
...nodeMesh.userData,
|
|
18381
|
+
...updatedNodeData
|
|
18382
|
+
};
|
|
18383
|
+
}
|
|
18384
|
+
if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
|
|
18385
|
+
setDetailsNode((prev) => ({
|
|
18386
|
+
...prev,
|
|
18387
|
+
quest_tree: formattedTree,
|
|
18388
|
+
quest_abstraction_tree: formattedAbstractionTree
|
|
18389
|
+
}));
|
|
18390
|
+
}
|
|
18391
|
+
setSceneVersion((v) => v + 1);
|
|
18307
18392
|
}
|
|
18308
|
-
setSceneVersion((v) => v + 1);
|
|
18309
18393
|
}
|
|
18310
18394
|
}
|
|
18311
18395
|
};
|
|
@@ -18354,7 +18438,6 @@ function XViewScene({
|
|
|
18354
18438
|
ownerId: ownerId2
|
|
18355
18439
|
} = context;
|
|
18356
18440
|
if (!graphDataRef2.current || (viewType == null ? void 0 : viewType.toLowerCase()) !== "view") return;
|
|
18357
|
-
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18358
18441
|
const newNode = {
|
|
18359
18442
|
id: short2.generate(),
|
|
18360
18443
|
...newQuestData,
|
|
@@ -18365,20 +18448,16 @@ function XViewScene({
|
|
|
18365
18448
|
graphDataRef2.current[sceneConfigId2] = { nodes: [], links: [] };
|
|
18366
18449
|
}
|
|
18367
18450
|
graphDataRef2.current[sceneConfigId2].nodes.push(newNode);
|
|
18368
|
-
const
|
|
18369
|
-
|
|
18370
|
-
quest_counter: currentCounter + 1
|
|
18371
|
-
};
|
|
18372
|
-
const questFileData = {
|
|
18373
|
-
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18374
|
-
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18375
|
-
milestones: sceneDataRef2.current.milestones || []
|
|
18376
|
-
};
|
|
18451
|
+
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18452
|
+
const nextCounter = currentCounter + 1;
|
|
18377
18453
|
try {
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18454
|
+
if (actions.upsert_quest_firestore) {
|
|
18455
|
+
await actions.upsert_quest_firestore(ownerId2, sceneConfigId2, newNode);
|
|
18456
|
+
}
|
|
18457
|
+
if (actions.update_view_counter) {
|
|
18458
|
+
await actions.update_view_counter(ownerId2, sceneConfigId2, nextCounter);
|
|
18459
|
+
}
|
|
18460
|
+
sceneDataRef2.current.quest_counter = nextCounter;
|
|
18382
18461
|
stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
|
|
18383
18462
|
parentFileId: sceneConfigId2,
|
|
18384
18463
|
ownerId: ownerId2,
|
|
@@ -18500,7 +18579,9 @@ function XViewScene({
|
|
|
18500
18579
|
if (line.material) line.material.dispose();
|
|
18501
18580
|
});
|
|
18502
18581
|
renderedAncestries.splice(renderIndex, 1);
|
|
18503
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18582
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18583
|
+
(a) => a.lines
|
|
18584
|
+
);
|
|
18504
18585
|
}
|
|
18505
18586
|
}, []);
|
|
18506
18587
|
const handleRenderAncestry = useCallback7(
|
|
@@ -19073,7 +19154,9 @@ function XViewScene({
|
|
|
19073
19154
|
});
|
|
19074
19155
|
};
|
|
19075
19156
|
renderVertical(fullTree, rootNodeMesh, rootTargetPos, 1);
|
|
19076
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19157
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19158
|
+
(a) => a.lines
|
|
19159
|
+
);
|
|
19077
19160
|
tweenToTarget(rootTargetPos, 0.7);
|
|
19078
19161
|
},
|
|
19079
19162
|
[
|
|
@@ -19208,7 +19291,10 @@ function XViewScene({
|
|
|
19208
19291
|
};
|
|
19209
19292
|
const descriptionText = targetAncestryInfo.description || "";
|
|
19210
19293
|
const savedSections = targetAncestryInfo.description_sections || [];
|
|
19211
|
-
const sections = parseDescriptionSections(
|
|
19294
|
+
const sections = parseDescriptionSections(
|
|
19295
|
+
descriptionText,
|
|
19296
|
+
savedSections
|
|
19297
|
+
);
|
|
19212
19298
|
let focusTargetId = null;
|
|
19213
19299
|
if (popped && popped.nodeId) {
|
|
19214
19300
|
const mentionTag = `[[MENTION:node:${popped.nodeId}]]`;
|
|
@@ -19985,7 +20071,10 @@ function XViewScene({
|
|
|
19985
20071
|
}
|
|
19986
20072
|
if (ancestry_save_url && isExternalSave && get_ancestry_file) {
|
|
19987
20073
|
try {
|
|
19988
|
-
const viewDbResponse = await get_ancestry_file(
|
|
20074
|
+
const viewDbResponse = await get_ancestry_file(
|
|
20075
|
+
sceneConfigId,
|
|
20076
|
+
ownerId
|
|
20077
|
+
);
|
|
19989
20078
|
if (viewDbResponse.success && Array.isArray(viewDbResponse.data)) {
|
|
19990
20079
|
const hasInViewDb = viewDbResponse.data.some(
|
|
19991
20080
|
(anc) => String(anc.ancestry_id) === String(ancestryIdToDelete)
|
|
@@ -20179,24 +20268,19 @@ function XViewScene({
|
|
|
20179
20268
|
setSceneVersion((v) => v + 1);
|
|
20180
20269
|
const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
|
|
20181
20270
|
if (!isView || !save_view_data || !sceneSaveUrl) return;
|
|
20182
|
-
const sceneFileData = {
|
|
20183
|
-
...sceneDataRef.current,
|
|
20184
|
-
nodes: sceneDataRef.current.nodes || [],
|
|
20185
|
-
links: sceneDataRef.current.links || [],
|
|
20186
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20187
|
-
};
|
|
20188
20271
|
const questFileData = {
|
|
20189
20272
|
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20190
20273
|
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20191
20274
|
milestones: newMilestones
|
|
20192
20275
|
};
|
|
20193
20276
|
try {
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
20199
|
-
|
|
20277
|
+
if (upsert_milestone_firestore) {
|
|
20278
|
+
await upsert_milestone_firestore(
|
|
20279
|
+
ownerId,
|
|
20280
|
+
sceneConfigId,
|
|
20281
|
+
newMilestones
|
|
20282
|
+
);
|
|
20283
|
+
}
|
|
20200
20284
|
} catch (error) {
|
|
20201
20285
|
console.error("Erro ao salvar milestones:", error);
|
|
20202
20286
|
}
|
|
@@ -20204,7 +20288,7 @@ function XViewScene({
|
|
|
20204
20288
|
[sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
|
|
20205
20289
|
);
|
|
20206
20290
|
const handleSaveCurrentView = useCallback7(async () => {
|
|
20207
|
-
var _a2
|
|
20291
|
+
var _a2;
|
|
20208
20292
|
const { nodeObjects, allLinks } = stateRef.current;
|
|
20209
20293
|
if (!nodeObjects || !allLinks || !sceneSaveUrl || !parentDataRef.current) {
|
|
20210
20294
|
console.warn(
|
|
@@ -20234,23 +20318,10 @@ function XViewScene({
|
|
|
20234
20318
|
const sceneFileData = {
|
|
20235
20319
|
...sceneDataRef.current,
|
|
20236
20320
|
nodes: currentNodes,
|
|
20237
|
-
links: currentLinks
|
|
20238
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20239
|
-
};
|
|
20240
|
-
const questFileData = {
|
|
20241
|
-
nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
|
|
20242
|
-
links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
|
|
20243
|
-
milestones: sceneDataRef.current.milestones || []
|
|
20321
|
+
links: currentLinks
|
|
20244
20322
|
};
|
|
20245
20323
|
try {
|
|
20246
20324
|
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20247
|
-
if (isView) {
|
|
20248
|
-
const questSaveUrl = sceneSaveUrl.replace(
|
|
20249
|
-
"x_view_scenes",
|
|
20250
|
-
"x_view_quests"
|
|
20251
|
-
);
|
|
20252
|
-
await save_view_data(questSaveUrl, questFileData);
|
|
20253
|
-
}
|
|
20254
20325
|
} catch (error) {
|
|
20255
20326
|
console.error("Erro na chamada de save_view_data:", error);
|
|
20256
20327
|
}
|
|
@@ -20949,12 +21020,18 @@ function XViewScene({
|
|
|
20949
21020
|
data: multiContextMenu,
|
|
20950
21021
|
userRole: userPermissionRole,
|
|
20951
21022
|
onClose: () => setMultiContextMenu((prev) => ({ ...prev, visible: false })),
|
|
20952
|
-
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
21023
|
+
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
21024
|
+
actionHandlerContext,
|
|
21025
|
+
ids
|
|
21026
|
+
),
|
|
20953
21027
|
onDismissOtherNodes: (ids) => userActionHandlers.handleDismissOtherMultipleNodes(
|
|
20954
21028
|
actionHandlerContext,
|
|
20955
21029
|
ids
|
|
20956
21030
|
),
|
|
20957
|
-
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
21031
|
+
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
21032
|
+
actionHandlerContext,
|
|
21033
|
+
ids
|
|
21034
|
+
)
|
|
20958
21035
|
}
|
|
20959
21036
|
),
|
|
20960
21037
|
/* @__PURE__ */ React32.createElement(
|
|
@@ -21112,20 +21189,35 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21112
21189
|
if (!session || !session.user) {
|
|
21113
21190
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
21114
21191
|
}
|
|
21115
|
-
const membershipCheck = await db_services.check_membership(
|
|
21192
|
+
const membershipCheck = await db_services.check_membership(
|
|
21193
|
+
owner_id,
|
|
21194
|
+
type,
|
|
21195
|
+
scene_config,
|
|
21196
|
+
session.user.id
|
|
21197
|
+
);
|
|
21116
21198
|
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
21117
21199
|
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
21118
|
-
return {
|
|
21200
|
+
return {
|
|
21201
|
+
success: false,
|
|
21202
|
+
error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio."
|
|
21203
|
+
};
|
|
21119
21204
|
}
|
|
21120
|
-
const sceneResponse = await db_services.get_file(
|
|
21205
|
+
const sceneResponse = await db_services.get_file(
|
|
21206
|
+
`x_view_scenes/${owner_id}/${scene_config}`
|
|
21207
|
+
);
|
|
21121
21208
|
if (!sceneResponse || !sceneResponse.success) {
|
|
21122
21209
|
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
21123
|
-
return {
|
|
21210
|
+
return {
|
|
21211
|
+
success: false,
|
|
21212
|
+
error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}`
|
|
21213
|
+
};
|
|
21124
21214
|
}
|
|
21125
21215
|
const sceneData = sceneResponse.data;
|
|
21126
21216
|
const parentDbObjects = sceneData.parent_dbs || [];
|
|
21127
21217
|
if (type && type.toLowerCase().includes("database")) {
|
|
21128
|
-
const selfExists = parentDbObjects.some(
|
|
21218
|
+
const selfExists = parentDbObjects.some(
|
|
21219
|
+
(db) => String(db.db_id) === String(scene_config)
|
|
21220
|
+
);
|
|
21129
21221
|
if (!selfExists) {
|
|
21130
21222
|
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
21131
21223
|
}
|
|
@@ -21135,11 +21227,43 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21135
21227
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21136
21228
|
);
|
|
21137
21229
|
if (isView) {
|
|
21138
|
-
|
|
21139
|
-
|
|
21140
|
-
|
|
21230
|
+
const questFetchWithMigrationPromise = (async () => {
|
|
21231
|
+
try {
|
|
21232
|
+
const questsResponse = await db_services.get_view_quests_firestore(
|
|
21233
|
+
owner_id,
|
|
21234
|
+
scene_config
|
|
21235
|
+
);
|
|
21236
|
+
if (questsResponse.success && questsResponse.hasQuests) {
|
|
21237
|
+
return {
|
|
21238
|
+
success: true,
|
|
21239
|
+
data: questsResponse.data,
|
|
21240
|
+
quest_counter: questsResponse.quest_counter
|
|
21241
|
+
};
|
|
21242
|
+
} else {
|
|
21243
|
+
const legacyResponse = await db_services.get_file(
|
|
21244
|
+
`x_view_quests/${owner_id}/${scene_config}`
|
|
21245
|
+
);
|
|
21246
|
+
if (legacyResponse.success && legacyResponse.data) {
|
|
21247
|
+
await db_services.migrate_json_to_firestore(
|
|
21248
|
+
owner_id,
|
|
21249
|
+
scene_config,
|
|
21250
|
+
legacyResponse.data,
|
|
21251
|
+
sceneData.quest_counter
|
|
21252
|
+
);
|
|
21253
|
+
legacyResponse.quest_counter = sceneData.quest_counter || 1;
|
|
21254
|
+
return legacyResponse;
|
|
21255
|
+
}
|
|
21256
|
+
return legacyResponse;
|
|
21257
|
+
}
|
|
21258
|
+
} catch (err) {
|
|
21259
|
+
return { success: false, error: err.message };
|
|
21260
|
+
}
|
|
21261
|
+
})();
|
|
21262
|
+
parentResponsesPromises.push(questFetchWithMigrationPromise);
|
|
21141
21263
|
}
|
|
21142
|
-
const parentResponsesResults = await Promise.allSettled(
|
|
21264
|
+
const parentResponsesResults = await Promise.allSettled(
|
|
21265
|
+
parentResponsesPromises
|
|
21266
|
+
);
|
|
21143
21267
|
const parentData = {};
|
|
21144
21268
|
let questDataObj = null;
|
|
21145
21269
|
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
@@ -21147,6 +21271,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21147
21271
|
if (isView && i === parentResponsesResults.length - 1) {
|
|
21148
21272
|
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21149
21273
|
questDataObj = result.value.data;
|
|
21274
|
+
if (result.value.quest_counter !== void 0) {
|
|
21275
|
+
sceneData.quest_counter = result.value.quest_counter;
|
|
21276
|
+
}
|
|
21150
21277
|
}
|
|
21151
21278
|
continue;
|
|
21152
21279
|
}
|
|
@@ -21172,13 +21299,19 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21172
21299
|
}
|
|
21173
21300
|
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
21174
21301
|
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
21175
|
-
const parentNodeMap = new Map(
|
|
21176
|
-
|
|
21302
|
+
const parentNodeMap = new Map(
|
|
21303
|
+
allNodes.map((node) => [String(node.id), node])
|
|
21304
|
+
);
|
|
21305
|
+
const parentLinkMap = new Map(
|
|
21306
|
+
allLinks.map((link) => [`${link.source}-${link.target}`, link])
|
|
21307
|
+
);
|
|
21177
21308
|
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
21178
21309
|
var _a2, _b2;
|
|
21179
21310
|
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
21180
21311
|
if (nodeTypes.includes("quest")) {
|
|
21181
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21312
|
+
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21313
|
+
(qn) => String(qn.id) === String(sceneNode.id)
|
|
21314
|
+
);
|
|
21182
21315
|
if (dbQuestNode) {
|
|
21183
21316
|
return { ...sceneNode, ...dbQuestNode };
|
|
21184
21317
|
}
|
|
@@ -21190,18 +21323,22 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21190
21323
|
}
|
|
21191
21324
|
return null;
|
|
21192
21325
|
}).filter(Boolean);
|
|
21193
|
-
const validNodeIdsInScene = new Set(
|
|
21326
|
+
const validNodeIdsInScene = new Set(
|
|
21327
|
+
validatedNodes.map((node) => String(node.id))
|
|
21328
|
+
);
|
|
21194
21329
|
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
21195
|
-
const linkExistsInParent = parentLinkMap.has(
|
|
21330
|
+
const linkExistsInParent = parentLinkMap.has(
|
|
21331
|
+
`${sceneLink.source}-${sceneLink.target}`
|
|
21332
|
+
);
|
|
21196
21333
|
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
21197
21334
|
return linkExistsInParent && nodesAreValidForScene;
|
|
21198
|
-
}).map(
|
|
21335
|
+
}).map(
|
|
21336
|
+
(sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`)
|
|
21337
|
+
);
|
|
21199
21338
|
const validatedSceneData = {
|
|
21200
21339
|
...sceneData,
|
|
21201
21340
|
nodes: validatedNodes,
|
|
21202
21341
|
links: validatedLinks,
|
|
21203
|
-
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21204
|
-
// continue acessando as quests sem perceber a separação física
|
|
21205
21342
|
quest_nodes: currentQuestNodes,
|
|
21206
21343
|
quest_links: currentQuestLinks,
|
|
21207
21344
|
milestones: currentMilestones
|
|
@@ -21221,7 +21358,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21221
21358
|
isSceneFile: false
|
|
21222
21359
|
});
|
|
21223
21360
|
});
|
|
21224
|
-
const ancestryPromises = ancestryFilePaths.map(
|
|
21361
|
+
const ancestryPromises = ancestryFilePaths.map(
|
|
21362
|
+
(file) => db_services.get_file(file.path)
|
|
21363
|
+
);
|
|
21225
21364
|
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
21226
21365
|
const ancestriesFromSceneFile = [];
|
|
21227
21366
|
const ancestriesFromDbFiles = [];
|
|
@@ -21247,15 +21386,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21247
21386
|
}
|
|
21248
21387
|
});
|
|
21249
21388
|
const ancestryMap = /* @__PURE__ */ new Map();
|
|
21250
|
-
ancestriesFromDbFiles.forEach(
|
|
21251
|
-
|
|
21389
|
+
ancestriesFromDbFiles.forEach(
|
|
21390
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21391
|
+
);
|
|
21392
|
+
ancestriesFromSceneFile.forEach(
|
|
21393
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21394
|
+
);
|
|
21252
21395
|
let ancestryData = Array.from(ancestryMap.values());
|
|
21253
21396
|
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
21254
21397
|
ancestryData.forEach((anc) => {
|
|
21255
21398
|
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
21256
21399
|
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
21257
21400
|
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
21258
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21401
|
+
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21402
|
+
(db) => String(db.db_id) === String(targetSourceId)
|
|
21403
|
+
);
|
|
21259
21404
|
if (!isAlreadyLoadedAsParent) {
|
|
21260
21405
|
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
21261
21406
|
externalSourcesToRefresh.set(key, {
|
|
@@ -21296,12 +21441,16 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21296
21441
|
return false;
|
|
21297
21442
|
}
|
|
21298
21443
|
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
21299
|
-
const stillExists = freshAncestryMap.has(
|
|
21444
|
+
const stillExists = freshAncestryMap.has(
|
|
21445
|
+
String(localAnc.ancestry_id)
|
|
21446
|
+
);
|
|
21300
21447
|
return stillExists;
|
|
21301
21448
|
}
|
|
21302
21449
|
return true;
|
|
21303
21450
|
}).map((localAnc) => {
|
|
21304
|
-
const freshVersion = freshAncestryMap.get(
|
|
21451
|
+
const freshVersion = freshAncestryMap.get(
|
|
21452
|
+
String(localAnc.ancestry_id)
|
|
21453
|
+
);
|
|
21305
21454
|
if (freshVersion) {
|
|
21306
21455
|
return {
|
|
21307
21456
|
...freshVersion,
|
|
@@ -21340,7 +21489,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21340
21489
|
parallel_branches: validBranches
|
|
21341
21490
|
};
|
|
21342
21491
|
};
|
|
21343
|
-
const originalAncestryDataString = JSON.stringify(
|
|
21492
|
+
const originalAncestryDataString = JSON.stringify(
|
|
21493
|
+
Array.from(ancestryMap.values())
|
|
21494
|
+
);
|
|
21344
21495
|
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
21345
21496
|
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
21346
21497
|
const cleanedTree = pruneTree(ancestry.tree);
|
|
@@ -21360,7 +21511,10 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21360
21511
|
try {
|
|
21361
21512
|
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
21362
21513
|
} catch (saveError) {
|
|
21363
|
-
console.error(
|
|
21514
|
+
console.error(
|
|
21515
|
+
"Falha ao salvar o arquivo de ancestralidade da cena atualizado:",
|
|
21516
|
+
saveError
|
|
21517
|
+
);
|
|
21364
21518
|
}
|
|
21365
21519
|
}
|
|
21366
21520
|
if (!isFullMember) {
|
|
@@ -21368,7 +21522,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21368
21522
|
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
21369
21523
|
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
21370
21524
|
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
21371
|
-
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21525
|
+
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21526
|
+
(db) => db.nodes || []
|
|
21527
|
+
);
|
|
21372
21528
|
const extractDependenciesFromText = (text) => {
|
|
21373
21529
|
if (!text) return;
|
|
21374
21530
|
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
@@ -21395,9 +21551,12 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21395
21551
|
if (branch.linked_ancestry_id) {
|
|
21396
21552
|
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
21397
21553
|
}
|
|
21398
|
-
if (branch.description)
|
|
21554
|
+
if (branch.description)
|
|
21555
|
+
extractDependenciesFromText(branch.description);
|
|
21399
21556
|
if (branch.description_sections) {
|
|
21400
|
-
branch.description_sections.forEach(
|
|
21557
|
+
branch.description_sections.forEach(
|
|
21558
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21559
|
+
);
|
|
21401
21560
|
}
|
|
21402
21561
|
extractTreeDependencies(branch.tree);
|
|
21403
21562
|
});
|
|
@@ -21411,7 +21570,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21411
21570
|
if (anc && !anc.is_private) {
|
|
21412
21571
|
if (anc.description) extractDependenciesFromText(anc.description);
|
|
21413
21572
|
if (anc.description_sections) {
|
|
21414
|
-
anc.description_sections.forEach(
|
|
21573
|
+
anc.description_sections.forEach(
|
|
21574
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21575
|
+
);
|
|
21415
21576
|
}
|
|
21416
21577
|
extractTreeDependencies(anc.tree);
|
|
21417
21578
|
extractTreeDependencies(anc.abstraction_tree);
|
|
@@ -21422,22 +21583,38 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21422
21583
|
if (node) {
|
|
21423
21584
|
if (node.description) extractDependenciesFromText(node.description);
|
|
21424
21585
|
if (node.description_sections) {
|
|
21425
|
-
node.description_sections.forEach(
|
|
21586
|
+
node.description_sections.forEach(
|
|
21587
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21588
|
+
);
|
|
21426
21589
|
}
|
|
21427
21590
|
}
|
|
21428
21591
|
});
|
|
21429
21592
|
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
21430
|
-
const restrictedSceneData = {
|
|
21593
|
+
const restrictedSceneData = {
|
|
21594
|
+
...validatedSceneData,
|
|
21595
|
+
nodes: [],
|
|
21596
|
+
links: []
|
|
21597
|
+
};
|
|
21431
21598
|
const restrictedParentData = {};
|
|
21432
|
-
const restrictedAncestryData = ancestryData.filter(
|
|
21599
|
+
const restrictedAncestryData = ancestryData.filter(
|
|
21600
|
+
(a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private
|
|
21601
|
+
);
|
|
21433
21602
|
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
21434
|
-
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21603
|
+
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21604
|
+
(n) => requiredNodeIds.has(String(n.id))
|
|
21605
|
+
);
|
|
21435
21606
|
if (filteredNodes.length > 0) {
|
|
21436
|
-
restrictedParentData[dbId] = {
|
|
21607
|
+
restrictedParentData[dbId] = {
|
|
21608
|
+
...dbContent,
|
|
21609
|
+
nodes: filteredNodes,
|
|
21610
|
+
links: []
|
|
21611
|
+
};
|
|
21437
21612
|
}
|
|
21438
21613
|
}
|
|
21439
21614
|
if (focusNodeId) {
|
|
21440
|
-
const mainNode = allNodesFromDb.find(
|
|
21615
|
+
const mainNode = allNodesFromDb.find(
|
|
21616
|
+
(n) => String(n.id) === String(focusNodeId)
|
|
21617
|
+
);
|
|
21441
21618
|
if (mainNode) {
|
|
21442
21619
|
restrictedSceneData.nodes = [mainNode];
|
|
21443
21620
|
}
|
|
@@ -21453,7 +21630,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21453
21630
|
}
|
|
21454
21631
|
return {
|
|
21455
21632
|
success: true,
|
|
21456
|
-
data: {
|
|
21633
|
+
data: {
|
|
21634
|
+
scene: validatedSceneData,
|
|
21635
|
+
parent: parentData,
|
|
21636
|
+
ancestry: ancestryData
|
|
21637
|
+
}
|
|
21457
21638
|
};
|
|
21458
21639
|
} catch (error) {
|
|
21459
21640
|
console.error("Erro em get_scene_view_data_logic:", error);
|
|
@@ -21473,13 +21654,18 @@ async function import_parent_file_modal_get_logic(db_services, session) {
|
|
|
21473
21654
|
}
|
|
21474
21655
|
};
|
|
21475
21656
|
} catch (error) {
|
|
21476
|
-
console.error(
|
|
21657
|
+
console.error(
|
|
21658
|
+
"catch (error) em import_parent_file_modal_get_logic:",
|
|
21659
|
+
error
|
|
21660
|
+
);
|
|
21477
21661
|
return { success: false, error: error.message };
|
|
21478
21662
|
}
|
|
21479
21663
|
}
|
|
21480
21664
|
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
21481
21665
|
try {
|
|
21482
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21666
|
+
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21667
|
+
`x_view_dbs/${session.user.id}/${file_id}`
|
|
21668
|
+
);
|
|
21483
21669
|
return call_GCP_cloud_storage_get_file;
|
|
21484
21670
|
} catch (error) {
|
|
21485
21671
|
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
@@ -21513,7 +21699,13 @@ async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
|
21513
21699
|
async function save_boards_logic(db_services, scene_id, type, boardItems, session, owner_id) {
|
|
21514
21700
|
try {
|
|
21515
21701
|
const targetOwnerId = owner_id || session.user.id;
|
|
21516
|
-
return await db_services.save_boards(
|
|
21702
|
+
return await db_services.save_boards(
|
|
21703
|
+
session,
|
|
21704
|
+
scene_id,
|
|
21705
|
+
type,
|
|
21706
|
+
boardItems,
|
|
21707
|
+
targetOwnerId
|
|
21708
|
+
);
|
|
21517
21709
|
} catch (error) {
|
|
21518
21710
|
console.error("Erro em save_boards_logic:", error);
|
|
21519
21711
|
return { success: false, error: error.message };
|
|
@@ -21542,7 +21734,10 @@ async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
|
21542
21734
|
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
21543
21735
|
try {
|
|
21544
21736
|
if (!db_services.get_view_members) {
|
|
21545
|
-
return {
|
|
21737
|
+
return {
|
|
21738
|
+
success: false,
|
|
21739
|
+
error: "Servi\xE7o de busca de membros n\xE3o configurado."
|
|
21740
|
+
};
|
|
21546
21741
|
}
|
|
21547
21742
|
return await db_services.get_view_members(ownerId, type, itemId);
|
|
21548
21743
|
} catch (error) {
|