@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.js
CHANGED
|
@@ -322,7 +322,12 @@ var updateExistingNodeVisuals = (state, updatedNode) => {
|
|
|
322
322
|
if (oldLabelObject.material) oldLabelObject.material.dispose();
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
const newMesh = createNodeMesh(
|
|
325
|
+
const newMesh = createNodeMesh(
|
|
326
|
+
updatedNode,
|
|
327
|
+
position,
|
|
328
|
+
state.glowTexture,
|
|
329
|
+
hadQuestDateLabel
|
|
330
|
+
);
|
|
326
331
|
if (oldTimelineBar) {
|
|
327
332
|
newMesh.userData.timelineIntervalBar = oldTimelineBar;
|
|
328
333
|
}
|
|
@@ -874,7 +879,12 @@ var removeNodeFromScene = (state, nodeId) => {
|
|
|
874
879
|
var addStandaloneNodeToScene = (state, nodeData, position, forceShowQuestDate = false) => {
|
|
875
880
|
const { graphGroup, nodeObjects, clickableNodes, glowTexture } = state;
|
|
876
881
|
if (!graphGroup) return;
|
|
877
|
-
const mesh = createNodeMesh(
|
|
882
|
+
const mesh = createNodeMesh(
|
|
883
|
+
nodeData,
|
|
884
|
+
position,
|
|
885
|
+
glowTexture,
|
|
886
|
+
forceShowQuestDate
|
|
887
|
+
);
|
|
878
888
|
mesh.scale.set(0.01, 0.01, 0.01);
|
|
879
889
|
graphGroup.add(mesh);
|
|
880
890
|
if (mesh.userData.labelObject) {
|
|
@@ -1092,7 +1102,9 @@ var userActionHandlers = {
|
|
|
1092
1102
|
if (isCrossDataset) {
|
|
1093
1103
|
graphDataRef.current[finalTargetDatasetId] = targetDataToUpdate;
|
|
1094
1104
|
}
|
|
1095
|
-
if (sceneDataRef.current.parent_dbs.some(
|
|
1105
|
+
if (sceneDataRef.current.parent_dbs.some(
|
|
1106
|
+
(db) => String(db.db_id) === String(sourceParentInfo.parentFileId)
|
|
1107
|
+
)) {
|
|
1096
1108
|
}
|
|
1097
1109
|
const finalPosition = stateRef.current.ghostElements.node.position.clone();
|
|
1098
1110
|
addNewNodeToScene(stateRef.current, newNode, newLink, finalPosition);
|
|
@@ -1287,7 +1299,10 @@ var userActionHandlers = {
|
|
|
1287
1299
|
context.sceneSaveUrl,
|
|
1288
1300
|
viewFilePayload
|
|
1289
1301
|
);
|
|
1290
|
-
const questSaveUrl = context.sceneSaveUrl.replace(
|
|
1302
|
+
const questSaveUrl = context.sceneSaveUrl.replace(
|
|
1303
|
+
"x_view_scenes",
|
|
1304
|
+
"x_view_quests"
|
|
1305
|
+
);
|
|
1291
1306
|
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
1292
1307
|
} else {
|
|
1293
1308
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
@@ -1542,20 +1557,19 @@ var userActionHandlers = {
|
|
|
1542
1557
|
const viewFilePayload = {
|
|
1543
1558
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1544
1559
|
nodes: sceneDataRef.current.nodes,
|
|
1545
|
-
links: sceneDataRef.current.links
|
|
1546
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1547
|
-
};
|
|
1548
|
-
const questFilePayload = {
|
|
1549
|
-
nodes: specificParentData.nodes,
|
|
1550
|
-
links: specificParentData.links,
|
|
1551
|
-
milestones: sceneDataRef.current.milestones || []
|
|
1560
|
+
links: sceneDataRef.current.links
|
|
1552
1561
|
};
|
|
1553
1562
|
await context.actions.save_view_data(
|
|
1554
1563
|
context.sceneSaveUrl,
|
|
1555
1564
|
viewFilePayload
|
|
1556
1565
|
);
|
|
1557
|
-
|
|
1558
|
-
|
|
1566
|
+
if (context.actions.upsert_quest_link_firestore) {
|
|
1567
|
+
await context.actions.upsert_quest_link_firestore(
|
|
1568
|
+
context.ownerId,
|
|
1569
|
+
context.sceneConfigId,
|
|
1570
|
+
newLink
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1559
1573
|
} else {
|
|
1560
1574
|
const specificParentData = JSON.parse(
|
|
1561
1575
|
JSON.stringify(graphDataRef.current[parentFileIdToSave])
|
|
@@ -1704,18 +1718,12 @@ var userActionHandlers = {
|
|
|
1704
1718
|
const viewFilePayload = {
|
|
1705
1719
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1706
1720
|
nodes: sceneDataRef.current.nodes,
|
|
1707
|
-
links: sceneDataRef.current.links
|
|
1708
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1721
|
+
links: sceneDataRef.current.links
|
|
1709
1722
|
};
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
};
|
|
1715
|
-
const p1 = context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
|
|
1716
|
-
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
1717
|
-
const p2 = context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
1718
|
-
return Promise.all([p1, p2]);
|
|
1723
|
+
return context.actions.save_view_data(
|
|
1724
|
+
context.sceneSaveUrl,
|
|
1725
|
+
viewFilePayload
|
|
1726
|
+
);
|
|
1719
1727
|
} else {
|
|
1720
1728
|
return context.actions.save_view_data(
|
|
1721
1729
|
`x_view_dbs/${fileOwnerId}/${fileId}`,
|
|
@@ -1740,6 +1748,15 @@ var userActionHandlers = {
|
|
|
1740
1748
|
updatedOriginalParentData
|
|
1741
1749
|
)
|
|
1742
1750
|
);
|
|
1751
|
+
if (oldGoverningFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
|
|
1752
|
+
savePromises.push(
|
|
1753
|
+
context.actions.delete_quest_link_firestore(
|
|
1754
|
+
context.ownerId,
|
|
1755
|
+
context.sceneConfigId,
|
|
1756
|
+
linkId
|
|
1757
|
+
)
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1743
1760
|
const updatedNewParentData = JSON.parse(
|
|
1744
1761
|
JSON.stringify(graphDataRef.current[newGoverningFileId])
|
|
1745
1762
|
);
|
|
@@ -1753,6 +1770,15 @@ var userActionHandlers = {
|
|
|
1753
1770
|
updatedNewParentData
|
|
1754
1771
|
)
|
|
1755
1772
|
);
|
|
1773
|
+
if (newGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
|
|
1774
|
+
savePromises.push(
|
|
1775
|
+
context.actions.upsert_quest_link_firestore(
|
|
1776
|
+
context.ownerId,
|
|
1777
|
+
context.sceneConfigId,
|
|
1778
|
+
newLinkData
|
|
1779
|
+
)
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1756
1782
|
} else {
|
|
1757
1783
|
const updatedParentData = JSON.parse(
|
|
1758
1784
|
JSON.stringify(graphDataRef.current[oldGoverningFileId])
|
|
@@ -1769,6 +1795,15 @@ var userActionHandlers = {
|
|
|
1769
1795
|
updatedParentData
|
|
1770
1796
|
)
|
|
1771
1797
|
);
|
|
1798
|
+
if (oldGoverningFileId === context.sceneConfigId && context.actions.upsert_quest_link_firestore) {
|
|
1799
|
+
savePromises.push(
|
|
1800
|
+
context.actions.upsert_quest_link_firestore(
|
|
1801
|
+
context.ownerId,
|
|
1802
|
+
context.sceneConfigId,
|
|
1803
|
+
newLinkData
|
|
1804
|
+
)
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1772
1807
|
}
|
|
1773
1808
|
try {
|
|
1774
1809
|
await Promise.all(savePromises);
|
|
@@ -1828,8 +1863,6 @@ var userActionHandlers = {
|
|
|
1828
1863
|
specificParentData.links = newLinks;
|
|
1829
1864
|
let filenameToSave;
|
|
1830
1865
|
let payloadToSave;
|
|
1831
|
-
let questSaveUrl;
|
|
1832
|
-
let questFilePayload;
|
|
1833
1866
|
const isView = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
|
|
1834
1867
|
if (isView && parentFileId === context.sceneConfigId) {
|
|
1835
1868
|
filenameToSave = context.sceneSaveUrl;
|
|
@@ -1839,14 +1872,7 @@ var userActionHandlers = {
|
|
|
1839
1872
|
payloadToSave = {
|
|
1840
1873
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
1841
1874
|
nodes: sceneDataRef.current.nodes,
|
|
1842
|
-
links: sceneDataRef.current.links
|
|
1843
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
1844
|
-
};
|
|
1845
|
-
questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
1846
|
-
questFilePayload = {
|
|
1847
|
-
nodes: specificParentData.nodes,
|
|
1848
|
-
links: specificParentData.links,
|
|
1849
|
-
milestones: sceneDataRef.current.milestones || []
|
|
1875
|
+
links: sceneDataRef.current.links
|
|
1850
1876
|
};
|
|
1851
1877
|
} else {
|
|
1852
1878
|
filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
@@ -1854,8 +1880,12 @@ var userActionHandlers = {
|
|
|
1854
1880
|
}
|
|
1855
1881
|
try {
|
|
1856
1882
|
await context.actions.save_view_data(filenameToSave, payloadToSave);
|
|
1857
|
-
if (
|
|
1858
|
-
await context.actions.
|
|
1883
|
+
if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
|
|
1884
|
+
await context.actions.delete_quest_link_firestore(
|
|
1885
|
+
context.ownerId,
|
|
1886
|
+
context.sceneConfigId,
|
|
1887
|
+
linkIdToDelete
|
|
1888
|
+
);
|
|
1859
1889
|
}
|
|
1860
1890
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
1861
1891
|
setters.setDetailsLink(
|
|
@@ -2084,16 +2114,30 @@ var userActionHandlers = {
|
|
|
2084
2114
|
payloadToSave = {
|
|
2085
2115
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2086
2116
|
nodes: sceneDataRef.current.nodes,
|
|
2087
|
-
links: sceneDataRef.current.links
|
|
2088
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2089
|
-
};
|
|
2090
|
-
const questFilePayload = {
|
|
2091
|
-
nodes: originalData.nodes,
|
|
2092
|
-
links: originalData.links,
|
|
2093
|
-
milestones: sceneDataRef.current.milestones || []
|
|
2117
|
+
links: sceneDataRef.current.links
|
|
2094
2118
|
};
|
|
2095
|
-
|
|
2096
|
-
|
|
2119
|
+
if (context.actions.delete_quest_firestore) {
|
|
2120
|
+
nodesToDelete.forEach((nodeIdToDelete) => {
|
|
2121
|
+
savePromises.push(
|
|
2122
|
+
context.actions.delete_quest_firestore(
|
|
2123
|
+
context.ownerId,
|
|
2124
|
+
context.sceneConfigId,
|
|
2125
|
+
nodeIdToDelete
|
|
2126
|
+
)
|
|
2127
|
+
);
|
|
2128
|
+
});
|
|
2129
|
+
if (context.actions.delete_quest_link_firestore) {
|
|
2130
|
+
linksToDelete.forEach((linkIdToDelete) => {
|
|
2131
|
+
savePromises.push(
|
|
2132
|
+
context.actions.delete_quest_link_firestore(
|
|
2133
|
+
context.ownerId,
|
|
2134
|
+
context.sceneConfigId,
|
|
2135
|
+
linkIdToDelete
|
|
2136
|
+
)
|
|
2137
|
+
);
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2097
2141
|
} else {
|
|
2098
2142
|
filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2099
2143
|
payloadToSave = originalData;
|
|
@@ -2164,6 +2208,9 @@ var userActionHandlers = {
|
|
|
2164
2208
|
const newLinks = (specificParentData.links || []).filter(
|
|
2165
2209
|
(l) => String(l.source) !== strNodeId && String(l.target) !== strNodeId
|
|
2166
2210
|
);
|
|
2211
|
+
const linksToDelete = (specificParentData.links || []).filter(
|
|
2212
|
+
(l) => String(l.source) === strNodeId || String(l.target) === strNodeId
|
|
2213
|
+
);
|
|
2167
2214
|
specificParentData.nodes = newNodes;
|
|
2168
2215
|
specificParentData.links = newLinks;
|
|
2169
2216
|
let filenameToSave;
|
|
@@ -2182,18 +2229,27 @@ var userActionHandlers = {
|
|
|
2182
2229
|
payloadToSave = {
|
|
2183
2230
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2184
2231
|
nodes: newVisualNodes,
|
|
2185
|
-
links: newVisualLinks
|
|
2186
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2232
|
+
links: newVisualLinks
|
|
2187
2233
|
};
|
|
2188
|
-
const questFilePayload = {
|
|
2189
|
-
nodes: specificParentData.nodes,
|
|
2190
|
-
links: specificParentData.links,
|
|
2191
|
-
milestones: sceneDataRef.current.milestones || []
|
|
2192
|
-
};
|
|
2193
|
-
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
2194
2234
|
try {
|
|
2195
2235
|
await context.actions.save_view_data(filenameToSave, payloadToSave);
|
|
2196
|
-
|
|
2236
|
+
if (context.actions.delete_quest_firestore) {
|
|
2237
|
+
await context.actions.delete_quest_firestore(
|
|
2238
|
+
context.ownerId,
|
|
2239
|
+
context.sceneConfigId,
|
|
2240
|
+
nodeIdToDelete
|
|
2241
|
+
);
|
|
2242
|
+
if (context.actions.delete_quest_link_firestore && linksToDelete.length > 0) {
|
|
2243
|
+
const linkDeletePromises = linksToDelete.map(
|
|
2244
|
+
(link) => context.actions.delete_quest_link_firestore(
|
|
2245
|
+
context.ownerId,
|
|
2246
|
+
context.sceneConfigId,
|
|
2247
|
+
link.id
|
|
2248
|
+
)
|
|
2249
|
+
);
|
|
2250
|
+
await Promise.all(linkDeletePromises);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2197
2253
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
2198
2254
|
setters.setDetailsNode(
|
|
2199
2255
|
(prev) => String(prev == null ? void 0 : prev.id) === String(nodeIdToDelete) ? null : prev
|
|
@@ -2295,12 +2351,10 @@ var userActionHandlers = {
|
|
|
2295
2351
|
}
|
|
2296
2352
|
const nextQuestNode = {
|
|
2297
2353
|
...JSON.parse(JSON.stringify(nodeToSave)),
|
|
2298
|
-
// Deep copy properties
|
|
2299
2354
|
id: import_short_uuid.default.generate(),
|
|
2300
2355
|
name: nextName,
|
|
2301
2356
|
status: "Backlog",
|
|
2302
2357
|
color: "#64748b",
|
|
2303
|
-
// QUEST_STATUS_COLORS["Backlog"]
|
|
2304
2358
|
assignee_id: nodeToSave.recurrence_config.next_assignee_id || "",
|
|
2305
2359
|
Date: nextDateObj,
|
|
2306
2360
|
timeline: [
|
|
@@ -2325,14 +2379,28 @@ var userActionHandlers = {
|
|
|
2325
2379
|
})),
|
|
2326
2380
|
recurrence_config: nextRecurrenceConfig
|
|
2327
2381
|
};
|
|
2328
|
-
|
|
2382
|
+
await context.actions.upsert_quest_firestore(
|
|
2383
|
+
context.ownerId,
|
|
2384
|
+
context.sceneConfigId,
|
|
2385
|
+
nextQuestNode
|
|
2386
|
+
);
|
|
2387
|
+
await context.actions.update_view_counter(
|
|
2388
|
+
context.ownerId,
|
|
2389
|
+
context.sceneConfigId,
|
|
2390
|
+
nextCounter
|
|
2391
|
+
);
|
|
2329
2392
|
if (stateRef.current.nodeObjects[String(nodeToSave.id)]) {
|
|
2330
2393
|
const oldMeshPosition = stateRef.current.nodeObjects[String(nodeToSave.id)].position.clone();
|
|
2331
2394
|
setTimeout(() => {
|
|
2332
2395
|
if (stateRef.current && stateRef.current.graphGroup) {
|
|
2333
2396
|
const pos = oldMeshPosition.clone();
|
|
2334
2397
|
pos.x += 12;
|
|
2335
|
-
addStandaloneNodeToScene(
|
|
2398
|
+
addStandaloneNodeToScene(
|
|
2399
|
+
stateRef.current,
|
|
2400
|
+
nextQuestNode,
|
|
2401
|
+
pos,
|
|
2402
|
+
true
|
|
2403
|
+
);
|
|
2336
2404
|
}
|
|
2337
2405
|
}, 2e3);
|
|
2338
2406
|
}
|
|
@@ -2353,8 +2421,7 @@ var userActionHandlers = {
|
|
|
2353
2421
|
const viewFilePayload = {
|
|
2354
2422
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2355
2423
|
nodes: sceneDataRef.current.nodes,
|
|
2356
|
-
links: sceneDataRef.current.links
|
|
2357
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2424
|
+
links: sceneDataRef.current.links
|
|
2358
2425
|
};
|
|
2359
2426
|
const questFilePayload = {
|
|
2360
2427
|
nodes: specificParentData.nodes,
|
|
@@ -2365,8 +2432,13 @@ var userActionHandlers = {
|
|
|
2365
2432
|
context.sceneSaveUrl,
|
|
2366
2433
|
viewFilePayload
|
|
2367
2434
|
);
|
|
2368
|
-
|
|
2369
|
-
|
|
2435
|
+
if (context.actions.upsert_quest_firestore) {
|
|
2436
|
+
await context.actions.upsert_quest_firestore(
|
|
2437
|
+
context.ownerId,
|
|
2438
|
+
context.sceneConfigId,
|
|
2439
|
+
nodeToSave
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2370
2442
|
} else {
|
|
2371
2443
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2372
2444
|
await context.actions.save_view_data(
|
|
@@ -2377,7 +2449,6 @@ var userActionHandlers = {
|
|
|
2377
2449
|
graphDataRef.current[parentFileId] = specificParentData;
|
|
2378
2450
|
if (isView && parentFileId === context.sceneConfigId) {
|
|
2379
2451
|
sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
|
|
2380
|
-
sceneDataRef.current.quest_counter = specificParentData.quest_counter || sceneDataRef.current.quest_counter;
|
|
2381
2452
|
}
|
|
2382
2453
|
updateExistingNodeVisuals(stateRef.current, nodeToSave);
|
|
2383
2454
|
setters.setSceneVersion((v) => v + 1);
|
|
@@ -2434,8 +2505,7 @@ var userActionHandlers = {
|
|
|
2434
2505
|
const viewFilePayload = {
|
|
2435
2506
|
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2436
2507
|
nodes: sceneDataRef.current.nodes,
|
|
2437
|
-
links: sceneDataRef.current.links
|
|
2438
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2508
|
+
links: sceneDataRef.current.links
|
|
2439
2509
|
};
|
|
2440
2510
|
const questFilePayload = {
|
|
2441
2511
|
nodes: specificParentData.nodes,
|
|
@@ -2446,8 +2516,13 @@ var userActionHandlers = {
|
|
|
2446
2516
|
context.sceneSaveUrl,
|
|
2447
2517
|
viewFilePayload
|
|
2448
2518
|
);
|
|
2449
|
-
|
|
2450
|
-
|
|
2519
|
+
if (context.actions.upsert_quest_link_firestore) {
|
|
2520
|
+
await context.actions.upsert_quest_link_firestore(
|
|
2521
|
+
context.ownerId,
|
|
2522
|
+
context.sceneConfigId,
|
|
2523
|
+
linkToSave
|
|
2524
|
+
);
|
|
2525
|
+
}
|
|
2451
2526
|
} else {
|
|
2452
2527
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2453
2528
|
await context.actions.save_view_data(
|
|
@@ -15477,7 +15552,13 @@ function XViewScene({
|
|
|
15477
15552
|
check_user_permission,
|
|
15478
15553
|
get_view_members,
|
|
15479
15554
|
create_google_doc_action,
|
|
15480
|
-
open_google_picker_action
|
|
15555
|
+
open_google_picker_action,
|
|
15556
|
+
upsert_quest_firestore,
|
|
15557
|
+
delete_quest_firestore,
|
|
15558
|
+
upsert_quest_link_firestore,
|
|
15559
|
+
delete_quest_link_firestore,
|
|
15560
|
+
upsert_milestone_firestore,
|
|
15561
|
+
update_view_counter
|
|
15481
15562
|
}) {
|
|
15482
15563
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
15483
15564
|
const { data: session, status } = (0, import_react34.useSession)();
|
|
@@ -17984,7 +18065,14 @@ function XViewScene({
|
|
|
17984
18065
|
get_single_parent_file,
|
|
17985
18066
|
get_scene_view_data,
|
|
17986
18067
|
upload_file: upload_file_action,
|
|
17987
|
-
delete_file: delete_file_action
|
|
18068
|
+
delete_file: delete_file_action,
|
|
18069
|
+
// Adicionado novas importações aqui
|
|
18070
|
+
upsert_quest_firestore,
|
|
18071
|
+
delete_quest_firestore,
|
|
18072
|
+
upsert_quest_link_firestore,
|
|
18073
|
+
delete_quest_link_firestore,
|
|
18074
|
+
upsert_milestone_firestore,
|
|
18075
|
+
update_view_counter
|
|
17988
18076
|
}
|
|
17989
18077
|
};
|
|
17990
18078
|
},
|
|
@@ -18003,7 +18091,13 @@ function XViewScene({
|
|
|
18003
18091
|
get_single_parent_file,
|
|
18004
18092
|
get_scene_view_data,
|
|
18005
18093
|
upload_file_action,
|
|
18006
|
-
delete_file_action
|
|
18094
|
+
delete_file_action,
|
|
18095
|
+
upsert_quest_firestore,
|
|
18096
|
+
delete_quest_firestore,
|
|
18097
|
+
upsert_quest_link_firestore,
|
|
18098
|
+
delete_quest_link_firestore,
|
|
18099
|
+
upsert_milestone_firestore,
|
|
18100
|
+
update_view_counter
|
|
18007
18101
|
]
|
|
18008
18102
|
);
|
|
18009
18103
|
const handleStartVersioning = (nodeData) => {
|
|
@@ -18209,43 +18303,30 @@ function XViewScene({
|
|
|
18209
18303
|
parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
|
|
18210
18304
|
}
|
|
18211
18305
|
}
|
|
18212
|
-
const
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
if (nodeMesh) {
|
|
18236
|
-
nodeMesh.userData = {
|
|
18237
|
-
...nodeMesh.userData,
|
|
18238
|
-
...updatedNodeData
|
|
18239
|
-
};
|
|
18240
|
-
}
|
|
18241
|
-
if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
|
|
18242
|
-
setDetailsNode((prev) => ({
|
|
18243
|
-
...prev,
|
|
18244
|
-
quest_tree: formattedTree,
|
|
18245
|
-
quest_abstraction_tree: formattedAbstractionTree
|
|
18246
|
-
}));
|
|
18306
|
+
const updatedNodeData = sceneData.quest_nodes[questIndex];
|
|
18307
|
+
if (upsert_quest_firestore) {
|
|
18308
|
+
await upsert_quest_firestore(
|
|
18309
|
+
ownerId,
|
|
18310
|
+
sceneConfigId,
|
|
18311
|
+
updatedNodeData
|
|
18312
|
+
);
|
|
18313
|
+
}
|
|
18314
|
+
const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
|
|
18315
|
+
if (nodeMesh) {
|
|
18316
|
+
nodeMesh.userData = {
|
|
18317
|
+
...nodeMesh.userData,
|
|
18318
|
+
...updatedNodeData
|
|
18319
|
+
};
|
|
18320
|
+
}
|
|
18321
|
+
if (detailsNode && String(detailsNode.id) === String(questNodeId)) {
|
|
18322
|
+
setDetailsNode((prev) => ({
|
|
18323
|
+
...prev,
|
|
18324
|
+
quest_tree: formattedTree,
|
|
18325
|
+
quest_abstraction_tree: formattedAbstractionTree
|
|
18326
|
+
}));
|
|
18327
|
+
}
|
|
18328
|
+
setSceneVersion((v) => v + 1);
|
|
18247
18329
|
}
|
|
18248
|
-
setSceneVersion((v) => v + 1);
|
|
18249
18330
|
}
|
|
18250
18331
|
}
|
|
18251
18332
|
};
|
|
@@ -18294,7 +18375,6 @@ function XViewScene({
|
|
|
18294
18375
|
ownerId: ownerId2
|
|
18295
18376
|
} = context;
|
|
18296
18377
|
if (!graphDataRef2.current || (viewType == null ? void 0 : viewType.toLowerCase()) !== "view") return;
|
|
18297
|
-
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18298
18378
|
const newNode = {
|
|
18299
18379
|
id: import_short_uuid2.default.generate(),
|
|
18300
18380
|
...newQuestData,
|
|
@@ -18305,23 +18385,16 @@ function XViewScene({
|
|
|
18305
18385
|
graphDataRef2.current[sceneConfigId2] = { nodes: [], links: [] };
|
|
18306
18386
|
}
|
|
18307
18387
|
graphDataRef2.current[sceneConfigId2].nodes.push(newNode);
|
|
18308
|
-
const
|
|
18309
|
-
|
|
18310
|
-
quest_counter: currentCounter + 1
|
|
18311
|
-
};
|
|
18312
|
-
delete sceneFileData.quest_nodes;
|
|
18313
|
-
delete sceneFileData.quest_links;
|
|
18314
|
-
delete sceneFileData.milestones;
|
|
18315
|
-
const questFileData = {
|
|
18316
|
-
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18317
|
-
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18318
|
-
milestones: sceneDataRef2.current.milestones || []
|
|
18319
|
-
};
|
|
18388
|
+
const currentCounter = sceneDataRef2.current.quest_counter || 1;
|
|
18389
|
+
const nextCounter = currentCounter + 1;
|
|
18320
18390
|
try {
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18391
|
+
if (actions.upsert_quest_firestore) {
|
|
18392
|
+
await actions.upsert_quest_firestore(ownerId2, sceneConfigId2, newNode);
|
|
18393
|
+
}
|
|
18394
|
+
if (actions.update_view_counter) {
|
|
18395
|
+
await actions.update_view_counter(ownerId2, sceneConfigId2, nextCounter);
|
|
18396
|
+
}
|
|
18397
|
+
sceneDataRef2.current.quest_counter = nextCounter;
|
|
18325
18398
|
stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
|
|
18326
18399
|
parentFileId: sceneConfigId2,
|
|
18327
18400
|
ownerId: ownerId2,
|
|
@@ -18400,9 +18473,6 @@ function XViewScene({
|
|
|
18400
18473
|
...sceneDataRef2.current,
|
|
18401
18474
|
quest_counter: sceneDataRef2.current.quest_counter || 1
|
|
18402
18475
|
};
|
|
18403
|
-
delete viewFilePayload.quest_nodes;
|
|
18404
|
-
delete viewFilePayload.quest_links;
|
|
18405
|
-
delete viewFilePayload.milestones;
|
|
18406
18476
|
const questFilePayload = {
|
|
18407
18477
|
nodes: specificParentData.nodes,
|
|
18408
18478
|
links: specificParentData.links,
|
|
@@ -18446,7 +18516,9 @@ function XViewScene({
|
|
|
18446
18516
|
if (line.material) line.material.dispose();
|
|
18447
18517
|
});
|
|
18448
18518
|
renderedAncestries.splice(renderIndex, 1);
|
|
18449
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18519
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
18520
|
+
(a) => a.lines
|
|
18521
|
+
);
|
|
18450
18522
|
}
|
|
18451
18523
|
}, []);
|
|
18452
18524
|
const handleRenderAncestry = (0, import_react33.useCallback)(
|
|
@@ -19019,7 +19091,9 @@ function XViewScene({
|
|
|
19019
19091
|
});
|
|
19020
19092
|
};
|
|
19021
19093
|
renderVertical(fullTree, rootNodeMesh, rootTargetPos, 1);
|
|
19022
|
-
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19094
|
+
stateRef.current.ancestryLinks = renderedAncestries.flatMap(
|
|
19095
|
+
(a) => a.lines
|
|
19096
|
+
);
|
|
19023
19097
|
tweenToTarget(rootTargetPos, 0.7);
|
|
19024
19098
|
},
|
|
19025
19099
|
[
|
|
@@ -19154,7 +19228,10 @@ function XViewScene({
|
|
|
19154
19228
|
};
|
|
19155
19229
|
const descriptionText = targetAncestryInfo.description || "";
|
|
19156
19230
|
const savedSections = targetAncestryInfo.description_sections || [];
|
|
19157
|
-
const sections = parseDescriptionSections(
|
|
19231
|
+
const sections = parseDescriptionSections(
|
|
19232
|
+
descriptionText,
|
|
19233
|
+
savedSections
|
|
19234
|
+
);
|
|
19158
19235
|
let focusTargetId = null;
|
|
19159
19236
|
if (popped && popped.nodeId) {
|
|
19160
19237
|
const mentionTag = `[[MENTION:node:${popped.nodeId}]]`;
|
|
@@ -19931,7 +20008,10 @@ function XViewScene({
|
|
|
19931
20008
|
}
|
|
19932
20009
|
if (ancestry_save_url && isExternalSave && get_ancestry_file) {
|
|
19933
20010
|
try {
|
|
19934
|
-
const viewDbResponse = await get_ancestry_file(
|
|
20011
|
+
const viewDbResponse = await get_ancestry_file(
|
|
20012
|
+
sceneConfigId,
|
|
20013
|
+
ownerId
|
|
20014
|
+
);
|
|
19935
20015
|
if (viewDbResponse.success && Array.isArray(viewDbResponse.data)) {
|
|
19936
20016
|
const hasInViewDb = viewDbResponse.data.some(
|
|
19937
20017
|
(anc) => String(anc.ancestry_id) === String(ancestryIdToDelete)
|
|
@@ -20125,27 +20205,19 @@ function XViewScene({
|
|
|
20125
20205
|
setSceneVersion((v) => v + 1);
|
|
20126
20206
|
const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
|
|
20127
20207
|
if (!isView || !save_view_data || !sceneSaveUrl) return;
|
|
20128
|
-
const sceneFileData = {
|
|
20129
|
-
...sceneDataRef.current,
|
|
20130
|
-
nodes: sceneDataRef.current.nodes || [],
|
|
20131
|
-
links: sceneDataRef.current.links || [],
|
|
20132
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20133
|
-
};
|
|
20134
|
-
delete sceneFileData.quest_nodes;
|
|
20135
|
-
delete sceneFileData.quest_links;
|
|
20136
|
-
delete sceneFileData.milestones;
|
|
20137
20208
|
const questFileData = {
|
|
20138
20209
|
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20139
20210
|
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20140
20211
|
milestones: newMilestones
|
|
20141
20212
|
};
|
|
20142
20213
|
try {
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
20214
|
+
if (upsert_milestone_firestore) {
|
|
20215
|
+
await upsert_milestone_firestore(
|
|
20216
|
+
ownerId,
|
|
20217
|
+
sceneConfigId,
|
|
20218
|
+
newMilestones
|
|
20219
|
+
);
|
|
20220
|
+
}
|
|
20149
20221
|
} catch (error) {
|
|
20150
20222
|
console.error("Erro ao salvar milestones:", error);
|
|
20151
20223
|
}
|
|
@@ -20153,7 +20225,7 @@ function XViewScene({
|
|
|
20153
20225
|
[sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
|
|
20154
20226
|
);
|
|
20155
20227
|
const handleSaveCurrentView = (0, import_react33.useCallback)(async () => {
|
|
20156
|
-
var _a2
|
|
20228
|
+
var _a2;
|
|
20157
20229
|
const { nodeObjects, allLinks } = stateRef.current;
|
|
20158
20230
|
if (!nodeObjects || !allLinks || !sceneSaveUrl || !parentDataRef.current) {
|
|
20159
20231
|
console.warn(
|
|
@@ -20183,26 +20255,10 @@ function XViewScene({
|
|
|
20183
20255
|
const sceneFileData = {
|
|
20184
20256
|
...sceneDataRef.current,
|
|
20185
20257
|
nodes: currentNodes,
|
|
20186
|
-
links: currentLinks
|
|
20187
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20188
|
-
};
|
|
20189
|
-
delete sceneFileData.quest_nodes;
|
|
20190
|
-
delete sceneFileData.quest_links;
|
|
20191
|
-
delete sceneFileData.milestones;
|
|
20192
|
-
const questFileData = {
|
|
20193
|
-
nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
|
|
20194
|
-
links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
|
|
20195
|
-
milestones: sceneDataRef.current.milestones || []
|
|
20258
|
+
links: currentLinks
|
|
20196
20259
|
};
|
|
20197
20260
|
try {
|
|
20198
20261
|
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20199
|
-
if (isView) {
|
|
20200
|
-
const questSaveUrl = sceneSaveUrl.replace(
|
|
20201
|
-
"x_view_scenes",
|
|
20202
|
-
"x_view_quests"
|
|
20203
|
-
);
|
|
20204
|
-
await save_view_data(questSaveUrl, questFileData);
|
|
20205
|
-
}
|
|
20206
20262
|
} catch (error) {
|
|
20207
20263
|
console.error("Erro na chamada de save_view_data:", error);
|
|
20208
20264
|
}
|
|
@@ -20901,12 +20957,18 @@ function XViewScene({
|
|
|
20901
20957
|
data: multiContextMenu,
|
|
20902
20958
|
userRole: userPermissionRole,
|
|
20903
20959
|
onClose: () => setMultiContextMenu((prev) => ({ ...prev, visible: false })),
|
|
20904
|
-
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
20960
|
+
onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
|
|
20961
|
+
actionHandlerContext,
|
|
20962
|
+
ids
|
|
20963
|
+
),
|
|
20905
20964
|
onDismissOtherNodes: (ids) => userActionHandlers.handleDismissOtherMultipleNodes(
|
|
20906
20965
|
actionHandlerContext,
|
|
20907
20966
|
ids
|
|
20908
20967
|
),
|
|
20909
|
-
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
20968
|
+
onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
|
|
20969
|
+
actionHandlerContext,
|
|
20970
|
+
ids
|
|
20971
|
+
)
|
|
20910
20972
|
}
|
|
20911
20973
|
),
|
|
20912
20974
|
/* @__PURE__ */ import_react33.default.createElement(
|
|
@@ -21064,20 +21126,35 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21064
21126
|
if (!session || !session.user) {
|
|
21065
21127
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
21066
21128
|
}
|
|
21067
|
-
const membershipCheck = await db_services.check_membership(
|
|
21129
|
+
const membershipCheck = await db_services.check_membership(
|
|
21130
|
+
owner_id,
|
|
21131
|
+
type,
|
|
21132
|
+
scene_config,
|
|
21133
|
+
session.user.id
|
|
21134
|
+
);
|
|
21068
21135
|
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
21069
21136
|
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
21070
|
-
return {
|
|
21137
|
+
return {
|
|
21138
|
+
success: false,
|
|
21139
|
+
error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio."
|
|
21140
|
+
};
|
|
21071
21141
|
}
|
|
21072
|
-
const sceneResponse = await db_services.get_file(
|
|
21142
|
+
const sceneResponse = await db_services.get_file(
|
|
21143
|
+
`x_view_scenes/${owner_id}/${scene_config}`
|
|
21144
|
+
);
|
|
21073
21145
|
if (!sceneResponse || !sceneResponse.success) {
|
|
21074
21146
|
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
21075
|
-
return {
|
|
21147
|
+
return {
|
|
21148
|
+
success: false,
|
|
21149
|
+
error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}`
|
|
21150
|
+
};
|
|
21076
21151
|
}
|
|
21077
21152
|
const sceneData = sceneResponse.data;
|
|
21078
21153
|
const parentDbObjects = sceneData.parent_dbs || [];
|
|
21079
21154
|
if (type && type.toLowerCase().includes("database")) {
|
|
21080
|
-
const selfExists = parentDbObjects.some(
|
|
21155
|
+
const selfExists = parentDbObjects.some(
|
|
21156
|
+
(db) => String(db.db_id) === String(scene_config)
|
|
21157
|
+
);
|
|
21081
21158
|
if (!selfExists) {
|
|
21082
21159
|
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
21083
21160
|
}
|
|
@@ -21087,11 +21164,42 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21087
21164
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21088
21165
|
);
|
|
21089
21166
|
if (isView) {
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
|
|
21167
|
+
const questFetchWithMigrationPromise = (async () => {
|
|
21168
|
+
try {
|
|
21169
|
+
const questsResponse = await db_services.get_view_quests_firestore(
|
|
21170
|
+
owner_id,
|
|
21171
|
+
scene_config
|
|
21172
|
+
);
|
|
21173
|
+
if (questsResponse.success && questsResponse.hasQuests) {
|
|
21174
|
+
return {
|
|
21175
|
+
success: true,
|
|
21176
|
+
data: questsResponse.data,
|
|
21177
|
+
quest_counter: questsResponse.quest_counter
|
|
21178
|
+
};
|
|
21179
|
+
} else {
|
|
21180
|
+
const legacyResponse = await db_services.get_file(
|
|
21181
|
+
`x_view_quests/${owner_id}/${scene_config}`
|
|
21182
|
+
);
|
|
21183
|
+
if (legacyResponse.success && legacyResponse.data) {
|
|
21184
|
+
await db_services.migrate_json_to_firestore(
|
|
21185
|
+
owner_id,
|
|
21186
|
+
scene_config,
|
|
21187
|
+
legacyResponse.data,
|
|
21188
|
+
sceneData.quest_counter
|
|
21189
|
+
);
|
|
21190
|
+
return legacyResponse;
|
|
21191
|
+
}
|
|
21192
|
+
return legacyResponse;
|
|
21193
|
+
}
|
|
21194
|
+
} catch (err) {
|
|
21195
|
+
return { success: false, error: err.message };
|
|
21196
|
+
}
|
|
21197
|
+
})();
|
|
21198
|
+
parentResponsesPromises.push(questFetchWithMigrationPromise);
|
|
21093
21199
|
}
|
|
21094
|
-
const parentResponsesResults = await Promise.allSettled(
|
|
21200
|
+
const parentResponsesResults = await Promise.allSettled(
|
|
21201
|
+
parentResponsesPromises
|
|
21202
|
+
);
|
|
21095
21203
|
const parentData = {};
|
|
21096
21204
|
let questDataObj = null;
|
|
21097
21205
|
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
@@ -21099,6 +21207,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21099
21207
|
if (isView && i === parentResponsesResults.length - 1) {
|
|
21100
21208
|
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21101
21209
|
questDataObj = result.value.data;
|
|
21210
|
+
if (result.value.quest_counter !== void 0) {
|
|
21211
|
+
sceneData.quest_counter = result.value.quest_counter;
|
|
21212
|
+
}
|
|
21102
21213
|
}
|
|
21103
21214
|
continue;
|
|
21104
21215
|
}
|
|
@@ -21112,9 +21223,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21112
21223
|
);
|
|
21113
21224
|
}
|
|
21114
21225
|
}
|
|
21115
|
-
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) ||
|
|
21116
|
-
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) ||
|
|
21117
|
-
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) ||
|
|
21226
|
+
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
|
|
21227
|
+
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
|
|
21228
|
+
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
|
|
21118
21229
|
if (isView) {
|
|
21119
21230
|
parentData[scene_config] = {
|
|
21120
21231
|
dataset_name: "Quests Internas (View)",
|
|
@@ -21124,13 +21235,19 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21124
21235
|
}
|
|
21125
21236
|
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
21126
21237
|
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
21127
|
-
const parentNodeMap = new Map(
|
|
21128
|
-
|
|
21238
|
+
const parentNodeMap = new Map(
|
|
21239
|
+
allNodes.map((node) => [String(node.id), node])
|
|
21240
|
+
);
|
|
21241
|
+
const parentLinkMap = new Map(
|
|
21242
|
+
allLinks.map((link) => [`${link.source}-${link.target}`, link])
|
|
21243
|
+
);
|
|
21129
21244
|
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
21130
21245
|
var _a2, _b2;
|
|
21131
21246
|
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
21132
21247
|
if (nodeTypes.includes("quest")) {
|
|
21133
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21248
|
+
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21249
|
+
(qn) => String(qn.id) === String(sceneNode.id)
|
|
21250
|
+
);
|
|
21134
21251
|
if (dbQuestNode) {
|
|
21135
21252
|
return { ...sceneNode, ...dbQuestNode };
|
|
21136
21253
|
}
|
|
@@ -21142,18 +21259,22 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21142
21259
|
}
|
|
21143
21260
|
return null;
|
|
21144
21261
|
}).filter(Boolean);
|
|
21145
|
-
const validNodeIdsInScene = new Set(
|
|
21262
|
+
const validNodeIdsInScene = new Set(
|
|
21263
|
+
validatedNodes.map((node) => String(node.id))
|
|
21264
|
+
);
|
|
21146
21265
|
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
21147
|
-
const linkExistsInParent = parentLinkMap.has(
|
|
21266
|
+
const linkExistsInParent = parentLinkMap.has(
|
|
21267
|
+
`${sceneLink.source}-${sceneLink.target}`
|
|
21268
|
+
);
|
|
21148
21269
|
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
21149
21270
|
return linkExistsInParent && nodesAreValidForScene;
|
|
21150
|
-
}).map(
|
|
21271
|
+
}).map(
|
|
21272
|
+
(sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`)
|
|
21273
|
+
);
|
|
21151
21274
|
const validatedSceneData = {
|
|
21152
21275
|
...sceneData,
|
|
21153
21276
|
nodes: validatedNodes,
|
|
21154
21277
|
links: validatedLinks,
|
|
21155
|
-
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21156
|
-
// continue acessando as quests sem perceber a separação física
|
|
21157
21278
|
quest_nodes: currentQuestNodes,
|
|
21158
21279
|
quest_links: currentQuestLinks,
|
|
21159
21280
|
milestones: currentMilestones
|
|
@@ -21173,7 +21294,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21173
21294
|
isSceneFile: false
|
|
21174
21295
|
});
|
|
21175
21296
|
});
|
|
21176
|
-
const ancestryPromises = ancestryFilePaths.map(
|
|
21297
|
+
const ancestryPromises = ancestryFilePaths.map(
|
|
21298
|
+
(file) => db_services.get_file(file.path)
|
|
21299
|
+
);
|
|
21177
21300
|
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
21178
21301
|
const ancestriesFromSceneFile = [];
|
|
21179
21302
|
const ancestriesFromDbFiles = [];
|
|
@@ -21199,15 +21322,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21199
21322
|
}
|
|
21200
21323
|
});
|
|
21201
21324
|
const ancestryMap = /* @__PURE__ */ new Map();
|
|
21202
|
-
ancestriesFromDbFiles.forEach(
|
|
21203
|
-
|
|
21325
|
+
ancestriesFromDbFiles.forEach(
|
|
21326
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21327
|
+
);
|
|
21328
|
+
ancestriesFromSceneFile.forEach(
|
|
21329
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21330
|
+
);
|
|
21204
21331
|
let ancestryData = Array.from(ancestryMap.values());
|
|
21205
21332
|
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
21206
21333
|
ancestryData.forEach((anc) => {
|
|
21207
21334
|
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
21208
21335
|
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
21209
21336
|
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
21210
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21337
|
+
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21338
|
+
(db) => String(db.db_id) === String(targetSourceId)
|
|
21339
|
+
);
|
|
21211
21340
|
if (!isAlreadyLoadedAsParent) {
|
|
21212
21341
|
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
21213
21342
|
externalSourcesToRefresh.set(key, {
|
|
@@ -21248,12 +21377,16 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21248
21377
|
return false;
|
|
21249
21378
|
}
|
|
21250
21379
|
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
21251
|
-
const stillExists = freshAncestryMap.has(
|
|
21380
|
+
const stillExists = freshAncestryMap.has(
|
|
21381
|
+
String(localAnc.ancestry_id)
|
|
21382
|
+
);
|
|
21252
21383
|
return stillExists;
|
|
21253
21384
|
}
|
|
21254
21385
|
return true;
|
|
21255
21386
|
}).map((localAnc) => {
|
|
21256
|
-
const freshVersion = freshAncestryMap.get(
|
|
21387
|
+
const freshVersion = freshAncestryMap.get(
|
|
21388
|
+
String(localAnc.ancestry_id)
|
|
21389
|
+
);
|
|
21257
21390
|
if (freshVersion) {
|
|
21258
21391
|
return {
|
|
21259
21392
|
...freshVersion,
|
|
@@ -21292,7 +21425,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21292
21425
|
parallel_branches: validBranches
|
|
21293
21426
|
};
|
|
21294
21427
|
};
|
|
21295
|
-
const originalAncestryDataString = JSON.stringify(
|
|
21428
|
+
const originalAncestryDataString = JSON.stringify(
|
|
21429
|
+
Array.from(ancestryMap.values())
|
|
21430
|
+
);
|
|
21296
21431
|
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
21297
21432
|
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
21298
21433
|
const cleanedTree = pruneTree(ancestry.tree);
|
|
@@ -21312,7 +21447,10 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21312
21447
|
try {
|
|
21313
21448
|
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
21314
21449
|
} catch (saveError) {
|
|
21315
|
-
console.error(
|
|
21450
|
+
console.error(
|
|
21451
|
+
"Falha ao salvar o arquivo de ancestralidade da cena atualizado:",
|
|
21452
|
+
saveError
|
|
21453
|
+
);
|
|
21316
21454
|
}
|
|
21317
21455
|
}
|
|
21318
21456
|
if (!isFullMember) {
|
|
@@ -21320,7 +21458,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21320
21458
|
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
21321
21459
|
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
21322
21460
|
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
21323
|
-
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21461
|
+
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21462
|
+
(db) => db.nodes || []
|
|
21463
|
+
);
|
|
21324
21464
|
const extractDependenciesFromText = (text) => {
|
|
21325
21465
|
if (!text) return;
|
|
21326
21466
|
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
@@ -21347,9 +21487,12 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21347
21487
|
if (branch.linked_ancestry_id) {
|
|
21348
21488
|
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
21349
21489
|
}
|
|
21350
|
-
if (branch.description)
|
|
21490
|
+
if (branch.description)
|
|
21491
|
+
extractDependenciesFromText(branch.description);
|
|
21351
21492
|
if (branch.description_sections) {
|
|
21352
|
-
branch.description_sections.forEach(
|
|
21493
|
+
branch.description_sections.forEach(
|
|
21494
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21495
|
+
);
|
|
21353
21496
|
}
|
|
21354
21497
|
extractTreeDependencies(branch.tree);
|
|
21355
21498
|
});
|
|
@@ -21363,7 +21506,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21363
21506
|
if (anc && !anc.is_private) {
|
|
21364
21507
|
if (anc.description) extractDependenciesFromText(anc.description);
|
|
21365
21508
|
if (anc.description_sections) {
|
|
21366
|
-
anc.description_sections.forEach(
|
|
21509
|
+
anc.description_sections.forEach(
|
|
21510
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21511
|
+
);
|
|
21367
21512
|
}
|
|
21368
21513
|
extractTreeDependencies(anc.tree);
|
|
21369
21514
|
extractTreeDependencies(anc.abstraction_tree);
|
|
@@ -21374,22 +21519,38 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21374
21519
|
if (node) {
|
|
21375
21520
|
if (node.description) extractDependenciesFromText(node.description);
|
|
21376
21521
|
if (node.description_sections) {
|
|
21377
|
-
node.description_sections.forEach(
|
|
21522
|
+
node.description_sections.forEach(
|
|
21523
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21524
|
+
);
|
|
21378
21525
|
}
|
|
21379
21526
|
}
|
|
21380
21527
|
});
|
|
21381
21528
|
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
21382
|
-
const restrictedSceneData = {
|
|
21529
|
+
const restrictedSceneData = {
|
|
21530
|
+
...validatedSceneData,
|
|
21531
|
+
nodes: [],
|
|
21532
|
+
links: []
|
|
21533
|
+
};
|
|
21383
21534
|
const restrictedParentData = {};
|
|
21384
|
-
const restrictedAncestryData = ancestryData.filter(
|
|
21535
|
+
const restrictedAncestryData = ancestryData.filter(
|
|
21536
|
+
(a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private
|
|
21537
|
+
);
|
|
21385
21538
|
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
21386
|
-
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21539
|
+
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21540
|
+
(n) => requiredNodeIds.has(String(n.id))
|
|
21541
|
+
);
|
|
21387
21542
|
if (filteredNodes.length > 0) {
|
|
21388
|
-
restrictedParentData[dbId] = {
|
|
21543
|
+
restrictedParentData[dbId] = {
|
|
21544
|
+
...dbContent,
|
|
21545
|
+
nodes: filteredNodes,
|
|
21546
|
+
links: []
|
|
21547
|
+
};
|
|
21389
21548
|
}
|
|
21390
21549
|
}
|
|
21391
21550
|
if (focusNodeId) {
|
|
21392
|
-
const mainNode = allNodesFromDb.find(
|
|
21551
|
+
const mainNode = allNodesFromDb.find(
|
|
21552
|
+
(n) => String(n.id) === String(focusNodeId)
|
|
21553
|
+
);
|
|
21393
21554
|
if (mainNode) {
|
|
21394
21555
|
restrictedSceneData.nodes = [mainNode];
|
|
21395
21556
|
}
|
|
@@ -21405,7 +21566,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21405
21566
|
}
|
|
21406
21567
|
return {
|
|
21407
21568
|
success: true,
|
|
21408
|
-
data: {
|
|
21569
|
+
data: {
|
|
21570
|
+
scene: validatedSceneData,
|
|
21571
|
+
parent: parentData,
|
|
21572
|
+
ancestry: ancestryData
|
|
21573
|
+
}
|
|
21409
21574
|
};
|
|
21410
21575
|
} catch (error) {
|
|
21411
21576
|
console.error("Erro em get_scene_view_data_logic:", error);
|
|
@@ -21425,13 +21590,18 @@ async function import_parent_file_modal_get_logic(db_services, session) {
|
|
|
21425
21590
|
}
|
|
21426
21591
|
};
|
|
21427
21592
|
} catch (error) {
|
|
21428
|
-
console.error(
|
|
21593
|
+
console.error(
|
|
21594
|
+
"catch (error) em import_parent_file_modal_get_logic:",
|
|
21595
|
+
error
|
|
21596
|
+
);
|
|
21429
21597
|
return { success: false, error: error.message };
|
|
21430
21598
|
}
|
|
21431
21599
|
}
|
|
21432
21600
|
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
21433
21601
|
try {
|
|
21434
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21602
|
+
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21603
|
+
`x_view_dbs/${session.user.id}/${file_id}`
|
|
21604
|
+
);
|
|
21435
21605
|
return call_GCP_cloud_storage_get_file;
|
|
21436
21606
|
} catch (error) {
|
|
21437
21607
|
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
@@ -21465,7 +21635,13 @@ async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
|
21465
21635
|
async function save_boards_logic(db_services, scene_id, type, boardItems, session, owner_id) {
|
|
21466
21636
|
try {
|
|
21467
21637
|
const targetOwnerId = owner_id || session.user.id;
|
|
21468
|
-
return await db_services.save_boards(
|
|
21638
|
+
return await db_services.save_boards(
|
|
21639
|
+
session,
|
|
21640
|
+
scene_id,
|
|
21641
|
+
type,
|
|
21642
|
+
boardItems,
|
|
21643
|
+
targetOwnerId
|
|
21644
|
+
);
|
|
21469
21645
|
} catch (error) {
|
|
21470
21646
|
console.error("Erro em save_boards_logic:", error);
|
|
21471
21647
|
return { success: false, error: error.message };
|
|
@@ -21494,7 +21670,10 @@ async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
|
21494
21670
|
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
21495
21671
|
try {
|
|
21496
21672
|
if (!db_services.get_view_members) {
|
|
21497
|
-
return {
|
|
21673
|
+
return {
|
|
21674
|
+
success: false,
|
|
21675
|
+
error: "Servi\xE7o de busca de membros n\xE3o configurado."
|
|
21676
|
+
};
|
|
21498
21677
|
}
|
|
21499
21678
|
return await db_services.get_view_members(ownerId, type, itemId);
|
|
21500
21679
|
} catch (error) {
|