@lv-x-software-house/x_view 1.2.7 → 1.2.8-dev.10
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 +387 -208
- package/dist/index.mjs +387 -208
- 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,43 +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
|
-
if (nodeMesh) {
|
|
18299
|
-
nodeMesh.userData = {
|
|
18300
|
-
...nodeMesh.userData,
|
|
18301
|
-
...updatedNodeData
|
|
18302
|
-
};
|
|
18303
|
-
}
|
|
18304
|
-
if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
|
|
18305
|
-
setDetailsNode((prev) => ({
|
|
18306
|
-
...prev,
|
|
18307
|
-
quest_tree: formattedTree,
|
|
18308
|
-
quest_abstraction_tree: formattedAbstractionTree
|
|
18309
|
-
}));
|
|
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);
|
|
18310
18392
|
}
|
|
18311
|
-
setSceneVersion((v) => v + 1);
|
|
18312
18393
|
}
|
|
18313
18394
|
}
|
|
18314
18395
|
};
|
|
@@ -18357,7 +18438,6 @@ function XViewScene({
|
|
|
18357
18438
|
ownerId: ownerId2
|
|
18358
18439
|
} = context;
|
|
18359
18440
|
if (!graphDataRef2.current || (viewType == null ? void 0 : viewType.toLowerCase()) !== "view") return;
|
|
18360
|
-
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18361
18441
|
const newNode = {
|
|
18362
18442
|
id: short2.generate(),
|
|
18363
18443
|
...newQuestData,
|
|
@@ -18368,23 +18448,16 @@ function XViewScene({
|
|
|
18368
18448
|
graphDataRef2.current[sceneConfigId2] = { nodes: [], links: [] };
|
|
18369
18449
|
}
|
|
18370
18450
|
graphDataRef2.current[sceneConfigId2].nodes.push(newNode);
|
|
18371
|
-
const
|
|
18372
|
-
|
|
18373
|
-
quest_counter: currentCounter + 1
|
|
18374
|
-
};
|
|
18375
|
-
delete sceneFileData.quest_nodes;
|
|
18376
|
-
delete sceneFileData.quest_links;
|
|
18377
|
-
delete sceneFileData.milestones;
|
|
18378
|
-
const questFileData = {
|
|
18379
|
-
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18380
|
-
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18381
|
-
milestones: sceneDataRef2.current.milestones || []
|
|
18382
|
-
};
|
|
18451
|
+
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18452
|
+
const nextCounter = currentCounter + 1;
|
|
18383
18453
|
try {
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18387
|
-
|
|
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;
|
|
18388
18461
|
stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
|
|
18389
18462
|
parentFileId: sceneConfigId2,
|
|
18390
18463
|
ownerId: ownerId2,
|
|
@@ -18463,9 +18536,6 @@ function XViewScene({
|
|
|
18463
18536
|
...sceneDataRef2.current,
|
|
18464
18537
|
quest_counter: sceneDataRef2.current.quest_counter || 1
|
|
18465
18538
|
};
|
|
18466
|
-
delete viewFilePayload.quest_nodes;
|
|
18467
|
-
delete viewFilePayload.quest_links;
|
|
18468
|
-
delete viewFilePayload.milestones;
|
|
18469
18539
|
const questFilePayload = {
|
|
18470
18540
|
nodes: specificParentData.nodes,
|
|
18471
18541
|
links: specificParentData.links,
|
|
@@ -18509,7 +18579,9 @@ function XViewScene({
|
|
|
18509
18579
|
if (line.material) line.material.dispose();
|
|
18510
18580
|
});
|
|
18511
18581
|
renderedAncestries.splice(renderIndex, 1);
|
|
18512
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18582
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18583
|
+
(a) => a.lines
|
|
18584
|
+
);
|
|
18513
18585
|
}
|
|
18514
18586
|
}, []);
|
|
18515
18587
|
const handleRenderAncestry = useCallback7(
|
|
@@ -19082,7 +19154,9 @@ function XViewScene({
|
|
|
19082
19154
|
});
|
|
19083
19155
|
};
|
|
19084
19156
|
renderVertical(fullTree, rootNodeMesh, rootTargetPos, 1);
|
|
19085
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19157
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19158
|
+
(a) => a.lines
|
|
19159
|
+
);
|
|
19086
19160
|
tweenToTarget(rootTargetPos, 0.7);
|
|
19087
19161
|
},
|
|
19088
19162
|
[
|
|
@@ -19217,7 +19291,10 @@ function XViewScene({
|
|
|
19217
19291
|
};
|
|
19218
19292
|
const descriptionText = targetAncestryInfo.description || "";
|
|
19219
19293
|
const savedSections = targetAncestryInfo.description_sections || [];
|
|
19220
|
-
const sections = parseDescriptionSections(
|
|
19294
|
+
const sections = parseDescriptionSections(
|
|
19295
|
+
descriptionText,
|
|
19296
|
+
savedSections
|
|
19297
|
+
);
|
|
19221
19298
|
let focusTargetId = null;
|
|
19222
19299
|
if (popped && popped.nodeId) {
|
|
19223
19300
|
const mentionTag = `[[MENTION:node:${popped.nodeId}]]`;
|
|
@@ -19994,7 +20071,10 @@ function XViewScene({
|
|
|
19994
20071
|
}
|
|
19995
20072
|
if (ancestry_save_url && isExternalSave && get_ancestry_file) {
|
|
19996
20073
|
try {
|
|
19997
|
-
const viewDbResponse = await get_ancestry_file(
|
|
20074
|
+
const viewDbResponse = await get_ancestry_file(
|
|
20075
|
+
sceneConfigId,
|
|
20076
|
+
ownerId
|
|
20077
|
+
);
|
|
19998
20078
|
if (viewDbResponse.success && Array.isArray(viewDbResponse.data)) {
|
|
19999
20079
|
const hasInViewDb = viewDbResponse.data.some(
|
|
20000
20080
|
(anc) => String(anc.ancestry_id) === String(ancestryIdToDelete)
|
|
@@ -20188,27 +20268,19 @@ function XViewScene({
|
|
|
20188
20268
|
setSceneVersion((v) => v + 1);
|
|
20189
20269
|
const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
|
|
20190
20270
|
if (!isView || !save_view_data || !sceneSaveUrl) return;
|
|
20191
|
-
const sceneFileData = {
|
|
20192
|
-
...sceneDataRef.current,
|
|
20193
|
-
nodes: sceneDataRef.current.nodes || [],
|
|
20194
|
-
links: sceneDataRef.current.links || [],
|
|
20195
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20196
|
-
};
|
|
20197
|
-
delete sceneFileData.quest_nodes;
|
|
20198
|
-
delete sceneFileData.quest_links;
|
|
20199
|
-
delete sceneFileData.milestones;
|
|
20200
20271
|
const questFileData = {
|
|
20201
20272
|
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20202
20273
|
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20203
20274
|
milestones: newMilestones
|
|
20204
20275
|
};
|
|
20205
20276
|
try {
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20210
|
-
|
|
20211
|
-
|
|
20277
|
+
if (upsert_milestone_firestore) {
|
|
20278
|
+
await upsert_milestone_firestore(
|
|
20279
|
+
ownerId,
|
|
20280
|
+
sceneConfigId,
|
|
20281
|
+
newMilestones
|
|
20282
|
+
);
|
|
20283
|
+
}
|
|
20212
20284
|
} catch (error) {
|
|
20213
20285
|
console.error("Erro ao salvar milestones:", error);
|
|
20214
20286
|
}
|
|
@@ -20216,7 +20288,7 @@ function XViewScene({
|
|
|
20216
20288
|
[sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
|
|
20217
20289
|
);
|
|
20218
20290
|
const handleSaveCurrentView = useCallback7(async () => {
|
|
20219
|
-
var _a2
|
|
20291
|
+
var _a2;
|
|
20220
20292
|
const { nodeObjects, allLinks } = stateRef.current;
|
|
20221
20293
|
if (!nodeObjects || !allLinks || !sceneSaveUrl || !parentDataRef.current) {
|
|
20222
20294
|
console.warn(
|
|
@@ -20246,26 +20318,10 @@ function XViewScene({
|
|
|
20246
20318
|
const sceneFileData = {
|
|
20247
20319
|
...sceneDataRef.current,
|
|
20248
20320
|
nodes: currentNodes,
|
|
20249
|
-
links: currentLinks
|
|
20250
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20251
|
-
};
|
|
20252
|
-
delete sceneFileData.quest_nodes;
|
|
20253
|
-
delete sceneFileData.quest_links;
|
|
20254
|
-
delete sceneFileData.milestones;
|
|
20255
|
-
const questFileData = {
|
|
20256
|
-
nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
|
|
20257
|
-
links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
|
|
20258
|
-
milestones: sceneDataRef.current.milestones || []
|
|
20321
|
+
links: currentLinks
|
|
20259
20322
|
};
|
|
20260
20323
|
try {
|
|
20261
20324
|
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20262
|
-
if (isView) {
|
|
20263
|
-
const questSaveUrl = sceneSaveUrl.replace(
|
|
20264
|
-
"x_view_scenes",
|
|
20265
|
-
"x_view_quests"
|
|
20266
|
-
);
|
|
20267
|
-
await save_view_data(questSaveUrl, questFileData);
|
|
20268
|
-
}
|
|
20269
20325
|
} catch (error) {
|
|
20270
20326
|
console.error("Erro na chamada de save_view_data:", error);
|
|
20271
20327
|
}
|
|
@@ -20964,12 +21020,18 @@ function XViewScene({
|
|
|
20964
21020
|
data: multiContextMenu,
|
|
20965
21021
|
userRole: userPermissionRole,
|
|
20966
21022
|
onClose: () => setMultiContextMenu((prev) => ({ ...prev, visible: false })),
|
|
20967
|
-
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
21023
|
+
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
21024
|
+
actionHandlerContext,
|
|
21025
|
+
ids
|
|
21026
|
+
),
|
|
20968
21027
|
onDismissOtherNodes: (ids) => userActionHandlers.handleDismissOtherMultipleNodes(
|
|
20969
21028
|
actionHandlerContext,
|
|
20970
21029
|
ids
|
|
20971
21030
|
),
|
|
20972
|
-
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
21031
|
+
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
21032
|
+
actionHandlerContext,
|
|
21033
|
+
ids
|
|
21034
|
+
)
|
|
20973
21035
|
}
|
|
20974
21036
|
),
|
|
20975
21037
|
/* @__PURE__ */ React32.createElement(
|
|
@@ -21127,20 +21189,35 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21127
21189
|
if (!session || !session.user) {
|
|
21128
21190
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
21129
21191
|
}
|
|
21130
|
-
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
|
+
);
|
|
21131
21198
|
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
21132
21199
|
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
21133
|
-
return {
|
|
21200
|
+
return {
|
|
21201
|
+
success: false,
|
|
21202
|
+
error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio."
|
|
21203
|
+
};
|
|
21134
21204
|
}
|
|
21135
|
-
const sceneResponse = await db_services.get_file(
|
|
21205
|
+
const sceneResponse = await db_services.get_file(
|
|
21206
|
+
`x_view_scenes/${owner_id}/${scene_config}`
|
|
21207
|
+
);
|
|
21136
21208
|
if (!sceneResponse || !sceneResponse.success) {
|
|
21137
21209
|
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
21138
|
-
return {
|
|
21210
|
+
return {
|
|
21211
|
+
success: false,
|
|
21212
|
+
error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}`
|
|
21213
|
+
};
|
|
21139
21214
|
}
|
|
21140
21215
|
const sceneData = sceneResponse.data;
|
|
21141
21216
|
const parentDbObjects = sceneData.parent_dbs || [];
|
|
21142
21217
|
if (type && type.toLowerCase().includes("database")) {
|
|
21143
|
-
const selfExists = parentDbObjects.some(
|
|
21218
|
+
const selfExists = parentDbObjects.some(
|
|
21219
|
+
(db) => String(db.db_id) === String(scene_config)
|
|
21220
|
+
);
|
|
21144
21221
|
if (!selfExists) {
|
|
21145
21222
|
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
21146
21223
|
}
|
|
@@ -21150,11 +21227,42 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21150
21227
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21151
21228
|
);
|
|
21152
21229
|
if (isView) {
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
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
|
+
return legacyResponse;
|
|
21254
|
+
}
|
|
21255
|
+
return legacyResponse;
|
|
21256
|
+
}
|
|
21257
|
+
} catch (err) {
|
|
21258
|
+
return { success: false, error: err.message };
|
|
21259
|
+
}
|
|
21260
|
+
})();
|
|
21261
|
+
parentResponsesPromises.push(questFetchWithMigrationPromise);
|
|
21156
21262
|
}
|
|
21157
|
-
const parentResponsesResults = await Promise.allSettled(
|
|
21263
|
+
const parentResponsesResults = await Promise.allSettled(
|
|
21264
|
+
parentResponsesPromises
|
|
21265
|
+
);
|
|
21158
21266
|
const parentData = {};
|
|
21159
21267
|
let questDataObj = null;
|
|
21160
21268
|
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
@@ -21162,6 +21270,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21162
21270
|
if (isView && i === parentResponsesResults.length - 1) {
|
|
21163
21271
|
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21164
21272
|
questDataObj = result.value.data;
|
|
21273
|
+
if (result.value.quest_counter !== void 0) {
|
|
21274
|
+
sceneData.quest_counter = result.value.quest_counter;
|
|
21275
|
+
}
|
|
21165
21276
|
}
|
|
21166
21277
|
continue;
|
|
21167
21278
|
}
|
|
@@ -21175,9 +21286,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21175
21286
|
);
|
|
21176
21287
|
}
|
|
21177
21288
|
}
|
|
21178
|
-
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) ||
|
|
21179
|
-
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) ||
|
|
21180
|
-
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) ||
|
|
21289
|
+
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
|
|
21290
|
+
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
|
|
21291
|
+
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
|
|
21181
21292
|
if (isView) {
|
|
21182
21293
|
parentData[scene_config] = {
|
|
21183
21294
|
dataset_name: "Quests Internas (View)",
|
|
@@ -21187,13 +21298,19 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21187
21298
|
}
|
|
21188
21299
|
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
21189
21300
|
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
21190
|
-
const parentNodeMap = new Map(
|
|
21191
|
-
|
|
21301
|
+
const parentNodeMap = new Map(
|
|
21302
|
+
allNodes.map((node) => [String(node.id), node])
|
|
21303
|
+
);
|
|
21304
|
+
const parentLinkMap = new Map(
|
|
21305
|
+
allLinks.map((link) => [`${link.source}-${link.target}`, link])
|
|
21306
|
+
);
|
|
21192
21307
|
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
21193
21308
|
var _a2, _b2;
|
|
21194
21309
|
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
21195
21310
|
if (nodeTypes.includes("quest")) {
|
|
21196
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21311
|
+
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21312
|
+
(qn) => String(qn.id) === String(sceneNode.id)
|
|
21313
|
+
);
|
|
21197
21314
|
if (dbQuestNode) {
|
|
21198
21315
|
return { ...sceneNode, ...dbQuestNode };
|
|
21199
21316
|
}
|
|
@@ -21205,18 +21322,22 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21205
21322
|
}
|
|
21206
21323
|
return null;
|
|
21207
21324
|
}).filter(Boolean);
|
|
21208
|
-
const validNodeIdsInScene = new Set(
|
|
21325
|
+
const validNodeIdsInScene = new Set(
|
|
21326
|
+
validatedNodes.map((node) => String(node.id))
|
|
21327
|
+
);
|
|
21209
21328
|
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
21210
|
-
const linkExistsInParent = parentLinkMap.has(
|
|
21329
|
+
const linkExistsInParent = parentLinkMap.has(
|
|
21330
|
+
`${sceneLink.source}-${sceneLink.target}`
|
|
21331
|
+
);
|
|
21211
21332
|
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
21212
21333
|
return linkExistsInParent && nodesAreValidForScene;
|
|
21213
|
-
}).map(
|
|
21334
|
+
}).map(
|
|
21335
|
+
(sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`)
|
|
21336
|
+
);
|
|
21214
21337
|
const validatedSceneData = {
|
|
21215
21338
|
...sceneData,
|
|
21216
21339
|
nodes: validatedNodes,
|
|
21217
21340
|
links: validatedLinks,
|
|
21218
|
-
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21219
|
-
// continue acessando as quests sem perceber a separação física
|
|
21220
21341
|
quest_nodes: currentQuestNodes,
|
|
21221
21342
|
quest_links: currentQuestLinks,
|
|
21222
21343
|
milestones: currentMilestones
|
|
@@ -21236,7 +21357,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21236
21357
|
isSceneFile: false
|
|
21237
21358
|
});
|
|
21238
21359
|
});
|
|
21239
|
-
const ancestryPromises = ancestryFilePaths.map(
|
|
21360
|
+
const ancestryPromises = ancestryFilePaths.map(
|
|
21361
|
+
(file) => db_services.get_file(file.path)
|
|
21362
|
+
);
|
|
21240
21363
|
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
21241
21364
|
const ancestriesFromSceneFile = [];
|
|
21242
21365
|
const ancestriesFromDbFiles = [];
|
|
@@ -21262,15 +21385,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21262
21385
|
}
|
|
21263
21386
|
});
|
|
21264
21387
|
const ancestryMap = /* @__PURE__ */ new Map();
|
|
21265
|
-
ancestriesFromDbFiles.forEach(
|
|
21266
|
-
|
|
21388
|
+
ancestriesFromDbFiles.forEach(
|
|
21389
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21390
|
+
);
|
|
21391
|
+
ancestriesFromSceneFile.forEach(
|
|
21392
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21393
|
+
);
|
|
21267
21394
|
let ancestryData = Array.from(ancestryMap.values());
|
|
21268
21395
|
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
21269
21396
|
ancestryData.forEach((anc) => {
|
|
21270
21397
|
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
21271
21398
|
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
21272
21399
|
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
21273
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21400
|
+
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21401
|
+
(db) => String(db.db_id) === String(targetSourceId)
|
|
21402
|
+
);
|
|
21274
21403
|
if (!isAlreadyLoadedAsParent) {
|
|
21275
21404
|
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
21276
21405
|
externalSourcesToRefresh.set(key, {
|
|
@@ -21311,12 +21440,16 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21311
21440
|
return false;
|
|
21312
21441
|
}
|
|
21313
21442
|
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
21314
|
-
const stillExists = freshAncestryMap.has(
|
|
21443
|
+
const stillExists = freshAncestryMap.has(
|
|
21444
|
+
String(localAnc.ancestry_id)
|
|
21445
|
+
);
|
|
21315
21446
|
return stillExists;
|
|
21316
21447
|
}
|
|
21317
21448
|
return true;
|
|
21318
21449
|
}).map((localAnc) => {
|
|
21319
|
-
const freshVersion = freshAncestryMap.get(
|
|
21450
|
+
const freshVersion = freshAncestryMap.get(
|
|
21451
|
+
String(localAnc.ancestry_id)
|
|
21452
|
+
);
|
|
21320
21453
|
if (freshVersion) {
|
|
21321
21454
|
return {
|
|
21322
21455
|
...freshVersion,
|
|
@@ -21355,7 +21488,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21355
21488
|
parallel_branches: validBranches
|
|
21356
21489
|
};
|
|
21357
21490
|
};
|
|
21358
|
-
const originalAncestryDataString = JSON.stringify(
|
|
21491
|
+
const originalAncestryDataString = JSON.stringify(
|
|
21492
|
+
Array.from(ancestryMap.values())
|
|
21493
|
+
);
|
|
21359
21494
|
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
21360
21495
|
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
21361
21496
|
const cleanedTree = pruneTree(ancestry.tree);
|
|
@@ -21375,7 +21510,10 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21375
21510
|
try {
|
|
21376
21511
|
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
21377
21512
|
} catch (saveError) {
|
|
21378
|
-
console.error(
|
|
21513
|
+
console.error(
|
|
21514
|
+
"Falha ao salvar o arquivo de ancestralidade da cena atualizado:",
|
|
21515
|
+
saveError
|
|
21516
|
+
);
|
|
21379
21517
|
}
|
|
21380
21518
|
}
|
|
21381
21519
|
if (!isFullMember) {
|
|
@@ -21383,7 +21521,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21383
21521
|
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
21384
21522
|
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
21385
21523
|
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
21386
|
-
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21524
|
+
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21525
|
+
(db) => db.nodes || []
|
|
21526
|
+
);
|
|
21387
21527
|
const extractDependenciesFromText = (text) => {
|
|
21388
21528
|
if (!text) return;
|
|
21389
21529
|
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
@@ -21410,9 +21550,12 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21410
21550
|
if (branch.linked_ancestry_id) {
|
|
21411
21551
|
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
21412
21552
|
}
|
|
21413
|
-
if (branch.description)
|
|
21553
|
+
if (branch.description)
|
|
21554
|
+
extractDependenciesFromText(branch.description);
|
|
21414
21555
|
if (branch.description_sections) {
|
|
21415
|
-
branch.description_sections.forEach(
|
|
21556
|
+
branch.description_sections.forEach(
|
|
21557
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21558
|
+
);
|
|
21416
21559
|
}
|
|
21417
21560
|
extractTreeDependencies(branch.tree);
|
|
21418
21561
|
});
|
|
@@ -21426,7 +21569,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21426
21569
|
if (anc && !anc.is_private) {
|
|
21427
21570
|
if (anc.description) extractDependenciesFromText(anc.description);
|
|
21428
21571
|
if (anc.description_sections) {
|
|
21429
|
-
anc.description_sections.forEach(
|
|
21572
|
+
anc.description_sections.forEach(
|
|
21573
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21574
|
+
);
|
|
21430
21575
|
}
|
|
21431
21576
|
extractTreeDependencies(anc.tree);
|
|
21432
21577
|
extractTreeDependencies(anc.abstraction_tree);
|
|
@@ -21437,22 +21582,38 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21437
21582
|
if (node) {
|
|
21438
21583
|
if (node.description) extractDependenciesFromText(node.description);
|
|
21439
21584
|
if (node.description_sections) {
|
|
21440
|
-
node.description_sections.forEach(
|
|
21585
|
+
node.description_sections.forEach(
|
|
21586
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21587
|
+
);
|
|
21441
21588
|
}
|
|
21442
21589
|
}
|
|
21443
21590
|
});
|
|
21444
21591
|
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
21445
|
-
const restrictedSceneData = {
|
|
21592
|
+
const restrictedSceneData = {
|
|
21593
|
+
...validatedSceneData,
|
|
21594
|
+
nodes: [],
|
|
21595
|
+
links: []
|
|
21596
|
+
};
|
|
21446
21597
|
const restrictedParentData = {};
|
|
21447
|
-
const restrictedAncestryData = ancestryData.filter(
|
|
21598
|
+
const restrictedAncestryData = ancestryData.filter(
|
|
21599
|
+
(a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private
|
|
21600
|
+
);
|
|
21448
21601
|
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
21449
|
-
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21602
|
+
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21603
|
+
(n) => requiredNodeIds.has(String(n.id))
|
|
21604
|
+
);
|
|
21450
21605
|
if (filteredNodes.length > 0) {
|
|
21451
|
-
restrictedParentData[dbId] = {
|
|
21606
|
+
restrictedParentData[dbId] = {
|
|
21607
|
+
...dbContent,
|
|
21608
|
+
nodes: filteredNodes,
|
|
21609
|
+
links: []
|
|
21610
|
+
};
|
|
21452
21611
|
}
|
|
21453
21612
|
}
|
|
21454
21613
|
if (focusNodeId) {
|
|
21455
|
-
const mainNode = allNodesFromDb.find(
|
|
21614
|
+
const mainNode = allNodesFromDb.find(
|
|
21615
|
+
(n) => String(n.id) === String(focusNodeId)
|
|
21616
|
+
);
|
|
21456
21617
|
if (mainNode) {
|
|
21457
21618
|
restrictedSceneData.nodes = [mainNode];
|
|
21458
21619
|
}
|
|
@@ -21468,7 +21629,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21468
21629
|
}
|
|
21469
21630
|
return {
|
|
21470
21631
|
success: true,
|
|
21471
|
-
data: {
|
|
21632
|
+
data: {
|
|
21633
|
+
scene: validatedSceneData,
|
|
21634
|
+
parent: parentData,
|
|
21635
|
+
ancestry: ancestryData
|
|
21636
|
+
}
|
|
21472
21637
|
};
|
|
21473
21638
|
} catch (error) {
|
|
21474
21639
|
console.error("Erro em get_scene_view_data_logic:", error);
|
|
@@ -21488,13 +21653,18 @@ async function import_parent_file_modal_get_logic(db_services, session) {
|
|
|
21488
21653
|
}
|
|
21489
21654
|
};
|
|
21490
21655
|
} catch (error) {
|
|
21491
|
-
console.error(
|
|
21656
|
+
console.error(
|
|
21657
|
+
"catch (error) em import_parent_file_modal_get_logic:",
|
|
21658
|
+
error
|
|
21659
|
+
);
|
|
21492
21660
|
return { success: false, error: error.message };
|
|
21493
21661
|
}
|
|
21494
21662
|
}
|
|
21495
21663
|
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
21496
21664
|
try {
|
|
21497
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21665
|
+
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21666
|
+
`x_view_dbs/${session.user.id}/${file_id}`
|
|
21667
|
+
);
|
|
21498
21668
|
return call_GCP_cloud_storage_get_file;
|
|
21499
21669
|
} catch (error) {
|
|
21500
21670
|
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
@@ -21528,7 +21698,13 @@ async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
|
21528
21698
|
async function save_boards_logic(db_services, scene_id, type, boardItems, session, owner_id) {
|
|
21529
21699
|
try {
|
|
21530
21700
|
const targetOwnerId = owner_id || session.user.id;
|
|
21531
|
-
return await db_services.save_boards(
|
|
21701
|
+
return await db_services.save_boards(
|
|
21702
|
+
session,
|
|
21703
|
+
scene_id,
|
|
21704
|
+
type,
|
|
21705
|
+
boardItems,
|
|
21706
|
+
targetOwnerId
|
|
21707
|
+
);
|
|
21532
21708
|
} catch (error) {
|
|
21533
21709
|
console.error("Erro em save_boards_logic:", error);
|
|
21534
21710
|
return { success: false, error: error.message };
|
|
@@ -21557,7 +21733,10 @@ async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
|
21557
21733
|
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
21558
21734
|
try {
|
|
21559
21735
|
if (!db_services.get_view_members) {
|
|
21560
|
-
return {
|
|
21736
|
+
return {
|
|
21737
|
+
success: false,
|
|
21738
|
+
error: "Servi\xE7o de busca de membros n\xE3o configurado."
|
|
21739
|
+
};
|
|
21561
21740
|
}
|
|
21562
21741
|
return await db_services.get_view_members(ownerId, type, itemId);
|
|
21563
21742
|
} catch (error) {
|