@lv-x-software-house/x_view 1.2.6-dev.2 → 1.2.6-dev.3
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 +77 -468
- package/dist/index.mjs +77 -457
- package/dist/server.js +480 -0
- package/dist/server.mjs +445 -0
- package/package.json +13 -3
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/XViewScene.jsx
|
|
2
4
|
import React30, {
|
|
3
5
|
useCallback as useCallback4,
|
|
@@ -13076,6 +13078,18 @@ var CustomMention = Mention.extend({
|
|
|
13076
13078
|
"data-mention-type": attributes.type
|
|
13077
13079
|
};
|
|
13078
13080
|
}
|
|
13081
|
+
},
|
|
13082
|
+
label: {
|
|
13083
|
+
default: null,
|
|
13084
|
+
parseHTML: (element) => element.getAttribute("data-label"),
|
|
13085
|
+
renderHTML: (attributes) => {
|
|
13086
|
+
if (!attributes.label) {
|
|
13087
|
+
return {};
|
|
13088
|
+
}
|
|
13089
|
+
return {
|
|
13090
|
+
"data-label": attributes.label
|
|
13091
|
+
};
|
|
13092
|
+
}
|
|
13079
13093
|
}
|
|
13080
13094
|
};
|
|
13081
13095
|
}
|
|
@@ -13084,7 +13098,6 @@ var MentionEditor = ({
|
|
|
13084
13098
|
initialValue = "",
|
|
13085
13099
|
onChange,
|
|
13086
13100
|
onPlay,
|
|
13087
|
-
// Mantido para futura expansão se quisermos badges clicáveis reais no editor
|
|
13088
13101
|
availableItems = [],
|
|
13089
13102
|
canEdit = true,
|
|
13090
13103
|
placeholder = "Escreva algo... use @ para mencionar"
|
|
@@ -13140,7 +13153,8 @@ var MentionEditor = ({
|
|
|
13140
13153
|
showOnCreate: true,
|
|
13141
13154
|
interactive: true,
|
|
13142
13155
|
trigger: "manual",
|
|
13143
|
-
placement: "bottom-start"
|
|
13156
|
+
placement: "bottom-start",
|
|
13157
|
+
theme: "x-view-dark"
|
|
13144
13158
|
});
|
|
13145
13159
|
},
|
|
13146
13160
|
onUpdate(props) {
|
|
@@ -13204,29 +13218,79 @@ var MentionEditor = ({
|
|
|
13204
13218
|
), /* @__PURE__ */ React27.createElement("style", null, `
|
|
13205
13219
|
.tiptap p {
|
|
13206
13220
|
margin: 0;
|
|
13207
|
-
min-height: 1.
|
|
13221
|
+
min-height: 1.25rem;
|
|
13222
|
+
line-height: 1.5;
|
|
13208
13223
|
}
|
|
13209
13224
|
.tiptap .mention {
|
|
13210
13225
|
display: inline-flex;
|
|
13211
13226
|
align-items: center;
|
|
13212
|
-
background
|
|
13213
|
-
border: 1px solid rgba(99, 102, 241, 0.
|
|
13214
|
-
border-radius:
|
|
13215
|
-
padding:
|
|
13227
|
+
background: rgba(99, 102, 241, 0.12);
|
|
13228
|
+
border: 1px solid rgba(99, 102, 241, 0.25);
|
|
13229
|
+
border-radius: 6px;
|
|
13230
|
+
padding: 1px 6px;
|
|
13216
13231
|
color: #a5b4fc;
|
|
13217
|
-
font-weight:
|
|
13232
|
+
font-weight: 600;
|
|
13218
13233
|
cursor: pointer;
|
|
13219
|
-
margin: 0
|
|
13220
|
-
|
|
13234
|
+
margin: 0 1px;
|
|
13235
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
13236
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
13237
|
+
font-size: 0.85rem;
|
|
13238
|
+
text-decoration: none;
|
|
13239
|
+
vertical-align: baseline;
|
|
13221
13240
|
}
|
|
13222
13241
|
.tiptap .mention:hover {
|
|
13223
|
-
background
|
|
13242
|
+
background: rgba(99, 102, 241, 0.22);
|
|
13224
13243
|
border-color: rgba(99, 102, 241, 0.5);
|
|
13225
|
-
color:
|
|
13244
|
+
color: #fff;
|
|
13245
|
+
transform: translateY(-1px);
|
|
13246
|
+
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
|
|
13247
|
+
}
|
|
13248
|
+
.tiptap .mention::before {
|
|
13249
|
+
content: "";
|
|
13250
|
+
display: inline-block;
|
|
13251
|
+
width: 12px;
|
|
13252
|
+
height: 12px;
|
|
13253
|
+
margin-right: 4px;
|
|
13254
|
+
background-size: contain;
|
|
13255
|
+
background-repeat: no-repeat;
|
|
13256
|
+
opacity: 0.8;
|
|
13257
|
+
filter: brightness(1.2);
|
|
13226
13258
|
}
|
|
13259
|
+
|
|
13260
|
+
/* Type specific styles */
|
|
13261
|
+
.tiptap .mention[data-mention-type="ancestry"] {
|
|
13262
|
+
background: rgba(139, 92, 246, 0.15);
|
|
13263
|
+
border-color: rgba(139, 92, 246, 0.3);
|
|
13264
|
+
color: #c4b5fd;
|
|
13265
|
+
}
|
|
13266
|
+
.tiptap .mention[data-mention-type="quest"] {
|
|
13267
|
+
background: rgba(16, 185, 129, 0.15);
|
|
13268
|
+
border-color: rgba(16, 185, 129, 0.3);
|
|
13269
|
+
color: #6ee7b7;
|
|
13270
|
+
}
|
|
13271
|
+
.tiptap .mention[data-mention-type="node"] {
|
|
13272
|
+
background: rgba(59, 130, 246, 0.15);
|
|
13273
|
+
border-color: rgba(59, 130, 246, 0.3);
|
|
13274
|
+
color: #93c5fd;
|
|
13275
|
+
}
|
|
13276
|
+
.tiptap .mention[data-mention-type="version"] {
|
|
13277
|
+
background: rgba(245, 158, 11, 0.15);
|
|
13278
|
+
border-color: rgba(245, 158, 11, 0.3);
|
|
13279
|
+
color: #fcd34d;
|
|
13280
|
+
}
|
|
13281
|
+
|
|
13227
13282
|
.tiptap:focus {
|
|
13228
13283
|
outline: none;
|
|
13229
13284
|
}
|
|
13285
|
+
|
|
13286
|
+
.ProseMirror-placeholder:first-child::before {
|
|
13287
|
+
content: attr(data-placeholder);
|
|
13288
|
+
float: left;
|
|
13289
|
+
color: #475569;
|
|
13290
|
+
pointer-events: none;
|
|
13291
|
+
height: 0;
|
|
13292
|
+
font-style: italic;
|
|
13293
|
+
}
|
|
13230
13294
|
`));
|
|
13231
13295
|
};
|
|
13232
13296
|
var MentionEditor_default = MentionEditor;
|
|
@@ -18737,450 +18801,6 @@ function XViewScene({
|
|
|
18737
18801
|
)
|
|
18738
18802
|
);
|
|
18739
18803
|
}
|
|
18740
|
-
|
|
18741
|
-
// src/x_view_server_logic.js
|
|
18742
|
-
async function save_view_data_logic(db_services, filename, data) {
|
|
18743
|
-
try {
|
|
18744
|
-
const saveResult = await db_services.save_file(filename, data);
|
|
18745
|
-
return saveResult;
|
|
18746
|
-
} catch (error) {
|
|
18747
|
-
console.error("catch (error) em save_view_data_logic:", error);
|
|
18748
|
-
return { success: false, error: error.message };
|
|
18749
|
-
}
|
|
18750
|
-
}
|
|
18751
|
-
async function get_scene_view_data_logic(db_services, scene_config, owner_id, type, session, focusNodeId = null, focusAncestryId = null) {
|
|
18752
|
-
var _a, _b;
|
|
18753
|
-
try {
|
|
18754
|
-
if (!session || !session.user) {
|
|
18755
|
-
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
18756
|
-
}
|
|
18757
|
-
const membershipCheck = await db_services.check_membership(owner_id, type, scene_config, session.user.id);
|
|
18758
|
-
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
18759
|
-
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
18760
|
-
return { success: false, error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio." };
|
|
18761
|
-
}
|
|
18762
|
-
const sceneResponse = await db_services.get_file(`x_view_scenes/${owner_id}/${scene_config}`);
|
|
18763
|
-
if (!sceneResponse || !sceneResponse.success) {
|
|
18764
|
-
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
18765
|
-
return { success: false, error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}` };
|
|
18766
|
-
}
|
|
18767
|
-
const sceneData = sceneResponse.data;
|
|
18768
|
-
const parentDbObjects = sceneData.parent_dbs || [];
|
|
18769
|
-
if (type && type.toLowerCase().includes("database")) {
|
|
18770
|
-
const selfExists = parentDbObjects.some((db) => String(db.db_id) === String(scene_config));
|
|
18771
|
-
if (!selfExists) {
|
|
18772
|
-
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
18773
|
-
}
|
|
18774
|
-
}
|
|
18775
|
-
const parentResponsesPromises = parentDbObjects.map(
|
|
18776
|
-
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
18777
|
-
);
|
|
18778
|
-
const parentResponsesResults = await Promise.allSettled(parentResponsesPromises);
|
|
18779
|
-
const parentData = {};
|
|
18780
|
-
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
18781
|
-
const result = parentResponsesResults[i];
|
|
18782
|
-
const db_info = parentDbObjects[i];
|
|
18783
|
-
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
18784
|
-
parentData[db_info.db_id] = result.value.data;
|
|
18785
|
-
} else {
|
|
18786
|
-
console.warn(
|
|
18787
|
-
`Arquivo pai n\xE3o carregado: ${db_info.db_id}. Pode ter sido deletado.`,
|
|
18788
|
-
result.status === "rejected" ? result.reason : (_b = result.value) == null ? void 0 : _b.error
|
|
18789
|
-
);
|
|
18790
|
-
}
|
|
18791
|
-
}
|
|
18792
|
-
if (type && type.toLowerCase() === "view") {
|
|
18793
|
-
parentData[scene_config] = {
|
|
18794
|
-
dataset_name: "Quests Internas (View)",
|
|
18795
|
-
nodes: sceneData.quest_nodes || [],
|
|
18796
|
-
links: sceneData.quest_links || []
|
|
18797
|
-
};
|
|
18798
|
-
}
|
|
18799
|
-
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
18800
|
-
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
18801
|
-
const parentNodeMap = new Map(allNodes.map((node) => [String(node.id), node]));
|
|
18802
|
-
const parentLinkMap = new Map(allLinks.map((link) => [`${link.source}-${link.target}`, link]));
|
|
18803
|
-
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
18804
|
-
var _a2, _b2;
|
|
18805
|
-
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
18806
|
-
if (nodeTypes.includes("quest")) {
|
|
18807
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find((qn) => String(qn.id) === String(sceneNode.id));
|
|
18808
|
-
if (dbQuestNode) {
|
|
18809
|
-
return { ...sceneNode, ...dbQuestNode };
|
|
18810
|
-
}
|
|
18811
|
-
return sceneNode;
|
|
18812
|
-
}
|
|
18813
|
-
const dbNode = parentNodeMap.get(String(sceneNode.id));
|
|
18814
|
-
if (dbNode) {
|
|
18815
|
-
return { ...sceneNode, ...dbNode };
|
|
18816
|
-
}
|
|
18817
|
-
return null;
|
|
18818
|
-
}).filter(Boolean);
|
|
18819
|
-
const validNodeIdsInScene = new Set(validatedNodes.map((node) => String(node.id)));
|
|
18820
|
-
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
18821
|
-
const linkExistsInParent = parentLinkMap.has(`${sceneLink.source}-${sceneLink.target}`);
|
|
18822
|
-
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
18823
|
-
return linkExistsInParent && nodesAreValidForScene;
|
|
18824
|
-
}).map((sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`));
|
|
18825
|
-
const validatedSceneData = {
|
|
18826
|
-
...sceneData,
|
|
18827
|
-
nodes: validatedNodes,
|
|
18828
|
-
links: validatedLinks
|
|
18829
|
-
};
|
|
18830
|
-
const ancestryFilePaths = [];
|
|
18831
|
-
ancestryFilePaths.push({
|
|
18832
|
-
path: `x_view_ancestry/${owner_id}/${scene_config}`,
|
|
18833
|
-
source_id: scene_config,
|
|
18834
|
-
owner_id,
|
|
18835
|
-
isSceneFile: true
|
|
18836
|
-
});
|
|
18837
|
-
parentDbObjects.forEach((db_info) => {
|
|
18838
|
-
ancestryFilePaths.push({
|
|
18839
|
-
path: `x_view_ancestry/${db_info.owner_id}/${db_info.db_id}`,
|
|
18840
|
-
source_id: db_info.db_id,
|
|
18841
|
-
owner_id: db_info.owner_id,
|
|
18842
|
-
isSceneFile: false
|
|
18843
|
-
});
|
|
18844
|
-
});
|
|
18845
|
-
const ancestryPromises = ancestryFilePaths.map((file) => db_services.get_file(file.path));
|
|
18846
|
-
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
18847
|
-
const ancestriesFromSceneFile = [];
|
|
18848
|
-
const ancestriesFromDbFiles = [];
|
|
18849
|
-
ancestryResults.forEach((result, index) => {
|
|
18850
|
-
var _a2;
|
|
18851
|
-
const fileInfo = ancestryFilePaths[index];
|
|
18852
|
-
if (result.status === "fulfilled" && ((_a2 = result.value) == null ? void 0 : _a2.success) && Array.isArray(result.value.data)) {
|
|
18853
|
-
const ancestriesFromFile = result.value.data.map((ancestry) => {
|
|
18854
|
-
const existingSource = ancestry._source_file_id;
|
|
18855
|
-
const existingOwner = ancestry._source_owner_id;
|
|
18856
|
-
const isImportedItem = existingSource && existingSource !== fileInfo.source_id;
|
|
18857
|
-
return {
|
|
18858
|
-
...ancestry,
|
|
18859
|
-
_source_file_id: isImportedItem ? existingSource : fileInfo.source_id,
|
|
18860
|
-
_source_owner_id: isImportedItem ? existingOwner : fileInfo.owner_id
|
|
18861
|
-
};
|
|
18862
|
-
});
|
|
18863
|
-
if (fileInfo.isSceneFile) {
|
|
18864
|
-
ancestriesFromSceneFile.push(...ancestriesFromFile);
|
|
18865
|
-
} else {
|
|
18866
|
-
ancestriesFromDbFiles.push(...ancestriesFromFile);
|
|
18867
|
-
}
|
|
18868
|
-
}
|
|
18869
|
-
});
|
|
18870
|
-
const ancestryMap = /* @__PURE__ */ new Map();
|
|
18871
|
-
ancestriesFromDbFiles.forEach((anc) => ancestryMap.set(anc.ancestry_id, anc));
|
|
18872
|
-
ancestriesFromSceneFile.forEach((anc) => ancestryMap.set(anc.ancestry_id, anc));
|
|
18873
|
-
let ancestryData = Array.from(ancestryMap.values());
|
|
18874
|
-
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
18875
|
-
ancestryData.forEach((anc) => {
|
|
18876
|
-
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
18877
|
-
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
18878
|
-
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
18879
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some((db) => String(db.db_id) === String(targetSourceId));
|
|
18880
|
-
if (!isAlreadyLoadedAsParent) {
|
|
18881
|
-
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
18882
|
-
externalSourcesToRefresh.set(key, {
|
|
18883
|
-
owner_id: targetOwnerId,
|
|
18884
|
-
source_id: targetSourceId,
|
|
18885
|
-
key
|
|
18886
|
-
});
|
|
18887
|
-
}
|
|
18888
|
-
}
|
|
18889
|
-
});
|
|
18890
|
-
const successfullyFetchedSources = /* @__PURE__ */ new Set();
|
|
18891
|
-
const failedSources = /* @__PURE__ */ new Set();
|
|
18892
|
-
if (externalSourcesToRefresh.size > 0) {
|
|
18893
|
-
const refreshPromises = Array.from(externalSourcesToRefresh.values()).map(
|
|
18894
|
-
(src) => db_services.get_file(`x_view_ancestry/${src.owner_id}/${src.source_id}`).then((res) => ({ ...res, _meta_key: src.key }))
|
|
18895
|
-
);
|
|
18896
|
-
const refreshResults = await Promise.allSettled(refreshPromises);
|
|
18897
|
-
const freshAncestryMap = /* @__PURE__ */ new Map();
|
|
18898
|
-
refreshResults.forEach((result) => {
|
|
18899
|
-
var _a2, _b2;
|
|
18900
|
-
if (result.status === "fulfilled" && ((_a2 = result.value) == null ? void 0 : _a2.success) && Array.isArray(result.value.data)) {
|
|
18901
|
-
successfullyFetchedSources.add(result.value._meta_key);
|
|
18902
|
-
result.value.data.forEach((freshAnc) => {
|
|
18903
|
-
if (!freshAnc.is_private) {
|
|
18904
|
-
freshAncestryMap.set(String(freshAnc.ancestry_id), freshAnc);
|
|
18905
|
-
}
|
|
18906
|
-
});
|
|
18907
|
-
} else if (result.status === "fulfilled" && !((_b2 = result.value) == null ? void 0 : _b2.success)) {
|
|
18908
|
-
failedSources.add(result.value._meta_key);
|
|
18909
|
-
}
|
|
18910
|
-
});
|
|
18911
|
-
ancestryData = ancestryData.filter((localAnc) => {
|
|
18912
|
-
const targetSourceId = localAnc._source_file_id || localAnc._imported_from_view_id;
|
|
18913
|
-
const targetOwnerId = localAnc._source_owner_id || localAnc._imported_from_view_owner_id;
|
|
18914
|
-
if (!targetSourceId || targetSourceId === scene_config) return true;
|
|
18915
|
-
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
18916
|
-
if (failedSources.has(key)) {
|
|
18917
|
-
return false;
|
|
18918
|
-
}
|
|
18919
|
-
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
18920
|
-
const stillExists = freshAncestryMap.has(String(localAnc.ancestry_id));
|
|
18921
|
-
return stillExists;
|
|
18922
|
-
}
|
|
18923
|
-
return true;
|
|
18924
|
-
}).map((localAnc) => {
|
|
18925
|
-
const freshVersion = freshAncestryMap.get(String(localAnc.ancestry_id));
|
|
18926
|
-
if (freshVersion) {
|
|
18927
|
-
return {
|
|
18928
|
-
...freshVersion,
|
|
18929
|
-
_imported_from_view_id: localAnc._imported_from_view_id,
|
|
18930
|
-
_imported_from_view_owner_id: localAnc._imported_from_view_owner_id,
|
|
18931
|
-
_origin_db_ids: localAnc._origin_db_ids,
|
|
18932
|
-
_source_file_id: localAnc._source_file_id,
|
|
18933
|
-
_source_owner_id: localAnc._source_owner_id
|
|
18934
|
-
};
|
|
18935
|
-
}
|
|
18936
|
-
return localAnc;
|
|
18937
|
-
});
|
|
18938
|
-
}
|
|
18939
|
-
const ancestryFilePath = `x_view_ancestry/${owner_id}/${scene_config}`;
|
|
18940
|
-
const parentNodeIds = new Set(allNodes.map((node) => String(node.id)));
|
|
18941
|
-
const pruneTree = (node) => {
|
|
18942
|
-
if (!node) return null;
|
|
18943
|
-
if (node.is_section) {
|
|
18944
|
-
const validChildren2 = (node.children || []).map((child) => pruneTree(child)).filter(Boolean);
|
|
18945
|
-
return { ...node, children: validChildren2 };
|
|
18946
|
-
}
|
|
18947
|
-
if (!parentNodeIds.has(String(node.node_id))) {
|
|
18948
|
-
return null;
|
|
18949
|
-
}
|
|
18950
|
-
const validChildren = (node.children || []).map((child) => pruneTree(child)).filter(Boolean);
|
|
18951
|
-
let validBranches = [];
|
|
18952
|
-
if (node.parallel_branches) {
|
|
18953
|
-
validBranches = node.parallel_branches.map((branch) => ({
|
|
18954
|
-
...branch,
|
|
18955
|
-
tree: pruneTree(branch.tree)
|
|
18956
|
-
})).filter((b) => b.tree !== null);
|
|
18957
|
-
}
|
|
18958
|
-
return {
|
|
18959
|
-
...node,
|
|
18960
|
-
children: validChildren,
|
|
18961
|
-
parallel_branches: validBranches
|
|
18962
|
-
};
|
|
18963
|
-
};
|
|
18964
|
-
const originalAncestryDataString = JSON.stringify(Array.from(ancestryMap.values()));
|
|
18965
|
-
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
18966
|
-
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
18967
|
-
const cleanedTree = pruneTree(ancestry.tree);
|
|
18968
|
-
if (!cleanedTree) return null;
|
|
18969
|
-
let cleanedAbstraction = null;
|
|
18970
|
-
if (ancestry.abstraction_tree) {
|
|
18971
|
-
cleanedAbstraction = pruneTree(ancestry.abstraction_tree);
|
|
18972
|
-
}
|
|
18973
|
-
return {
|
|
18974
|
-
...ancestry,
|
|
18975
|
-
tree: cleanedTree,
|
|
18976
|
-
abstraction_tree: cleanedAbstraction
|
|
18977
|
-
};
|
|
18978
|
-
}).filter(Boolean);
|
|
18979
|
-
if (JSON.stringify(cleanedAncestryData) !== originalAncestryDataString) {
|
|
18980
|
-
ancestryData = cleanedAncestryData;
|
|
18981
|
-
try {
|
|
18982
|
-
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
18983
|
-
} catch (saveError) {
|
|
18984
|
-
console.error("Falha ao salvar o arquivo de ancestralidade da cena atualizado:", saveError);
|
|
18985
|
-
}
|
|
18986
|
-
}
|
|
18987
|
-
if (!isFullMember) {
|
|
18988
|
-
const requiredNodeIds = /* @__PURE__ */ new Set();
|
|
18989
|
-
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
18990
|
-
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
18991
|
-
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
18992
|
-
const allNodesFromDb = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
18993
|
-
const extractDependenciesFromText = (text) => {
|
|
18994
|
-
if (!text) return;
|
|
18995
|
-
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
18996
|
-
const refRegex = /\[\[REF:(node|ancestry):([a-zA-Z0-9\-_]+):([a-zA-Z0-9\-_]+)\]\]/g;
|
|
18997
|
-
let match;
|
|
18998
|
-
while ((match = mentionRegex.exec(text)) !== null) {
|
|
18999
|
-
requiredNodeIds.add(match[1]);
|
|
19000
|
-
}
|
|
19001
|
-
while ((match = refRegex.exec(text)) !== null) {
|
|
19002
|
-
if (match[1] === "node") requiredNodeIds.add(match[2]);
|
|
19003
|
-
if (match[1] === "ancestry") requiredAncestryIds.add(match[2]);
|
|
19004
|
-
}
|
|
19005
|
-
};
|
|
19006
|
-
const extractTreeDependencies = (treeItem) => {
|
|
19007
|
-
var _a2;
|
|
19008
|
-
if (!treeItem) return;
|
|
19009
|
-
if (treeItem.node_id) requiredNodeIds.add(String(treeItem.node_id));
|
|
19010
|
-
if ((_a2 = treeItem.node) == null ? void 0 : _a2.id) requiredNodeIds.add(String(treeItem.node.id));
|
|
19011
|
-
if (treeItem.children) {
|
|
19012
|
-
treeItem.children.forEach(extractTreeDependencies);
|
|
19013
|
-
}
|
|
19014
|
-
if (treeItem.parallel_branches) {
|
|
19015
|
-
treeItem.parallel_branches.forEach((branch) => {
|
|
19016
|
-
if (branch.linked_ancestry_id) {
|
|
19017
|
-
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
19018
|
-
}
|
|
19019
|
-
if (branch.description) extractDependenciesFromText(branch.description);
|
|
19020
|
-
if (branch.description_sections) {
|
|
19021
|
-
branch.description_sections.forEach((s) => extractDependenciesFromText(s.content));
|
|
19022
|
-
}
|
|
19023
|
-
extractTreeDependencies(branch.tree);
|
|
19024
|
-
});
|
|
19025
|
-
}
|
|
19026
|
-
};
|
|
19027
|
-
let previousSize;
|
|
19028
|
-
do {
|
|
19029
|
-
previousSize = requiredNodeIds.size + requiredAncestryIds.size;
|
|
19030
|
-
requiredAncestryIds.forEach((ancId) => {
|
|
19031
|
-
const anc = ancestryData.find((a) => String(a.ancestry_id) === ancId);
|
|
19032
|
-
if (anc && !anc.is_private) {
|
|
19033
|
-
if (anc.description) extractDependenciesFromText(anc.description);
|
|
19034
|
-
if (anc.description_sections) {
|
|
19035
|
-
anc.description_sections.forEach((s) => extractDependenciesFromText(s.content));
|
|
19036
|
-
}
|
|
19037
|
-
extractTreeDependencies(anc.tree);
|
|
19038
|
-
extractTreeDependencies(anc.abstraction_tree);
|
|
19039
|
-
}
|
|
19040
|
-
});
|
|
19041
|
-
requiredNodeIds.forEach((nodeId) => {
|
|
19042
|
-
const node = allNodesFromDb.find((n) => String(n.id) === nodeId);
|
|
19043
|
-
if (node) {
|
|
19044
|
-
if (node.description) extractDependenciesFromText(node.description);
|
|
19045
|
-
if (node.description_sections) {
|
|
19046
|
-
node.description_sections.forEach((s) => extractDependenciesFromText(s.content));
|
|
19047
|
-
}
|
|
19048
|
-
}
|
|
19049
|
-
});
|
|
19050
|
-
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
19051
|
-
const restrictedSceneData = { ...validatedSceneData, nodes: [], links: [] };
|
|
19052
|
-
const restrictedParentData = {};
|
|
19053
|
-
const restrictedAncestryData = ancestryData.filter((a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private);
|
|
19054
|
-
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
19055
|
-
const filteredNodes = (dbContent.nodes || []).filter((n) => requiredNodeIds.has(String(n.id)));
|
|
19056
|
-
if (filteredNodes.length > 0) {
|
|
19057
|
-
restrictedParentData[dbId] = { ...dbContent, nodes: filteredNodes, links: [] };
|
|
19058
|
-
}
|
|
19059
|
-
}
|
|
19060
|
-
if (focusNodeId) {
|
|
19061
|
-
const mainNode = allNodesFromDb.find((n) => String(n.id) === String(focusNodeId));
|
|
19062
|
-
if (mainNode) {
|
|
19063
|
-
restrictedSceneData.nodes = [mainNode];
|
|
19064
|
-
}
|
|
19065
|
-
}
|
|
19066
|
-
return {
|
|
19067
|
-
success: true,
|
|
19068
|
-
data: {
|
|
19069
|
-
scene: restrictedSceneData,
|
|
19070
|
-
parent: restrictedParentData,
|
|
19071
|
-
ancestry: restrictedAncestryData
|
|
19072
|
-
}
|
|
19073
|
-
};
|
|
19074
|
-
}
|
|
19075
|
-
return {
|
|
19076
|
-
success: true,
|
|
19077
|
-
data: { scene: validatedSceneData, parent: parentData, ancestry: ancestryData }
|
|
19078
|
-
};
|
|
19079
|
-
} catch (error) {
|
|
19080
|
-
console.error("Erro em get_scene_view_data_logic:", error);
|
|
19081
|
-
return { success: false, error: error.message };
|
|
19082
|
-
}
|
|
19083
|
-
}
|
|
19084
|
-
async function import_parent_file_modal_get_logic(db_services, session) {
|
|
19085
|
-
try {
|
|
19086
|
-
const call_firestore_get_x_view_data = await db_services.get_firestore_data(session);
|
|
19087
|
-
const x_view_databases = call_firestore_get_x_view_data.data.sub_collections.x_view_databases || [];
|
|
19088
|
-
const x_views = call_firestore_get_x_view_data.data.sub_collections.x_views || [];
|
|
19089
|
-
return {
|
|
19090
|
-
success: true,
|
|
19091
|
-
data: {
|
|
19092
|
-
databases: x_view_databases,
|
|
19093
|
-
views: x_views
|
|
19094
|
-
}
|
|
19095
|
-
};
|
|
19096
|
-
} catch (error) {
|
|
19097
|
-
console.error("catch (error) em import_parent_file_modal_get_logic:", error);
|
|
19098
|
-
return { success: false, error: error.message };
|
|
19099
|
-
}
|
|
19100
|
-
}
|
|
19101
|
-
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
19102
|
-
try {
|
|
19103
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(`x_view_dbs/${session.user.id}/${file_id}`);
|
|
19104
|
-
return call_GCP_cloud_storage_get_file;
|
|
19105
|
-
} catch (error) {
|
|
19106
|
-
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
19107
|
-
return { success: false, error: error.message };
|
|
19108
|
-
}
|
|
19109
|
-
}
|
|
19110
|
-
async function x_view_add_new_parent_file_to_scene_at_firebase(file_id, session, new_parent, db_services) {
|
|
19111
|
-
try {
|
|
19112
|
-
const update_data = {
|
|
19113
|
-
scene_id: file_id,
|
|
19114
|
-
new_parent,
|
|
19115
|
-
session
|
|
19116
|
-
};
|
|
19117
|
-
const call_firestore_add_new_parent_file_to_scene_at_firebase = await db_services.add_new_parent_file_to_scene_at_firebase(update_data);
|
|
19118
|
-
return call_firestore_add_new_parent_file_to_scene_at_firebase;
|
|
19119
|
-
} catch (error) {
|
|
19120
|
-
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
19121
|
-
return { success: false, error: error.message };
|
|
19122
|
-
}
|
|
19123
|
-
}
|
|
19124
|
-
async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
19125
|
-
try {
|
|
19126
|
-
const path = `x_view_ancestry/${owner_id}/${file_id}`;
|
|
19127
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(path);
|
|
19128
|
-
return call_GCP_cloud_storage_get_file;
|
|
19129
|
-
} catch (error) {
|
|
19130
|
-
console.error("catch (error) em get_ancestry_file_logic:", error);
|
|
19131
|
-
return { success: false, error: error.message };
|
|
19132
|
-
}
|
|
19133
|
-
}
|
|
19134
|
-
async function save_ancestry_board_logic(db_services, scene_id, type, groups, session, owner_id) {
|
|
19135
|
-
try {
|
|
19136
|
-
const targetOwnerId = owner_id || session.user.id;
|
|
19137
|
-
return await db_services.save_ancestry_board(session, scene_id, type, groups, targetOwnerId);
|
|
19138
|
-
} catch (error) {
|
|
19139
|
-
console.error("Erro em save_ancestry_board_logic:", error);
|
|
19140
|
-
return { success: false, error: error.message };
|
|
19141
|
-
}
|
|
19142
|
-
}
|
|
19143
|
-
async function get_ancestry_board_logic(db_services, scene_id, type, session, owner_id) {
|
|
19144
|
-
try {
|
|
19145
|
-
const targetOwnerId = owner_id || session.user.id;
|
|
19146
|
-
return await db_services.get_ancestry_board(session, scene_id, type, targetOwnerId);
|
|
19147
|
-
} catch (error) {
|
|
19148
|
-
console.error("Erro em get_ancestry_board_logic:", error);
|
|
19149
|
-
return { success: false, error: error.message };
|
|
19150
|
-
}
|
|
19151
|
-
}
|
|
19152
|
-
async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
19153
|
-
try {
|
|
19154
|
-
if (db_services.delete_public_file) {
|
|
19155
|
-
return await db_services.delete_public_file(fileUrl);
|
|
19156
|
-
}
|
|
19157
|
-
return { success: false, error: "Servi\xE7o de dele\xE7\xE3o n\xE3o configurado." };
|
|
19158
|
-
} catch (error) {
|
|
19159
|
-
console.error("Erro em delete_uploaded_file_logic:", error);
|
|
19160
|
-
return { success: false, error: error.message };
|
|
19161
|
-
}
|
|
19162
|
-
}
|
|
19163
|
-
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
19164
|
-
try {
|
|
19165
|
-
if (!db_services.get_view_members) {
|
|
19166
|
-
return { success: false, error: "Servi\xE7o de busca de membros n\xE3o configurado." };
|
|
19167
|
-
}
|
|
19168
|
-
return await db_services.get_view_members(ownerId, type, itemId);
|
|
19169
|
-
} catch (error) {
|
|
19170
|
-
console.error("Erro em get_view_members_logic:", error);
|
|
19171
|
-
return { success: false, error: error.message };
|
|
19172
|
-
}
|
|
19173
|
-
}
|
|
19174
18804
|
export {
|
|
19175
|
-
XViewScene
|
|
19176
|
-
delete_uploaded_file_logic,
|
|
19177
|
-
get_ancestry_board_logic,
|
|
19178
|
-
get_ancestry_file_logic,
|
|
19179
|
-
get_scene_view_data_logic,
|
|
19180
|
-
get_single_parent_file_logic,
|
|
19181
|
-
get_view_members_logic,
|
|
19182
|
-
import_parent_file_modal_get_logic,
|
|
19183
|
-
save_ancestry_board_logic,
|
|
19184
|
-
save_view_data_logic,
|
|
19185
|
-
x_view_add_new_parent_file_to_scene_at_firebase
|
|
18805
|
+
XViewScene
|
|
19186
18806
|
};
|