tsondb 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/node/schema/Node.d.ts +8 -1
- package/dist/src/node/schema/Node.js +34 -18
- package/dist/src/node/schema/Schema.js +14 -10
- package/dist/src/node/schema/TypeParameter.js +1 -1
- package/dist/src/node/schema/declarations/EntityDecl.js +1 -1
- package/dist/src/node/schema/declarations/EnumDecl.js +1 -1
- package/dist/src/node/schema/declarations/TypeAliasDecl.js +1 -1
- package/dist/src/node/schema/types/generic/ArrayType.js +1 -1
- package/dist/src/node/schema/types/generic/EnumType.js +1 -1
- package/dist/src/node/schema/types/generic/ObjectType.js +1 -1
- package/dist/src/node/schema/types/references/ChildEntitiesType.js +1 -1
- package/dist/src/node/schema/types/references/IncludeIdentifierType.js +2 -2
- package/dist/src/node/schema/types/references/NestedEntityMapType.d.ts +12 -2
- package/dist/src/node/schema/types/references/NestedEntityMapType.js +2 -2
- package/dist/src/node/schema/types/references/ReferenceIdentifierType.js +2 -2
- package/dist/src/node/server/api/git.js +156 -24
- package/dist/src/node/server/index.js +4 -0
- package/dist/src/node/utils/instanceOperations.d.ts +1 -1
- package/dist/src/node/utils/instanceOperations.js +2 -2
- package/dist/src/shared/api.d.ts +17 -1
- package/dist/src/shared/schema/declarations/EntityDecl.d.ts +2 -0
- package/dist/src/shared/schema/declarations/EntityDecl.js +2 -0
- package/dist/src/shared/schema/declarations/EnumDecl.d.ts +2 -1
- package/dist/src/shared/schema/declarations/EnumDecl.js +2 -0
- package/dist/src/shared/schema/declarations/TypeAliasDecl.d.ts +2 -1
- package/dist/src/shared/schema/declarations/TypeAliasDecl.js +2 -1
- package/dist/src/shared/utils/git.d.ts +4 -0
- package/dist/src/shared/utils/git.js +6 -1
- package/dist/src/shared/utils/markdown.d.ts +36 -17
- package/dist/src/shared/utils/markdown.js +79 -23
- package/dist/src/shared/utils/object.d.ts +1 -0
- package/dist/src/shared/utils/object.js +1 -0
- package/dist/src/web/api/git.d.ts +5 -1
- package/dist/src/web/api/git.js +6 -2
- package/dist/src/web/components/ContextProviderWrapper.d.ts +7 -0
- package/dist/src/web/components/ContextProviderWrapper.js +5 -0
- package/dist/src/web/components/InstanceRouteSkeleton.d.ts +6 -0
- package/dist/src/web/components/InstanceRouteSkeleton.js +12 -8
- package/dist/src/web/components/LoadingOverlay.d.ts +1 -0
- package/dist/src/web/components/LoadingOverlay.js +3 -0
- package/dist/src/web/components/ModalDialog.js +4 -3
- package/dist/src/web/components/git/Git.js +47 -0
- package/dist/src/web/components/git/GitBranchManager.d.ts +7 -0
- package/dist/src/web/components/git/GitBranchManager.js +17 -0
- package/dist/src/web/components/git/GitFileList.d.ts +17 -0
- package/dist/src/web/components/git/GitFileList.js +11 -0
- package/dist/src/web/components/git/GitFileManager.d.ts +8 -0
- package/dist/src/web/components/git/GitFileManager.js +34 -0
- package/dist/src/web/components/git/GitStatusIndicator.d.ts +7 -0
- package/dist/src/web/components/git/GitStatusIndicator.js +6 -0
- package/dist/src/web/components/typeInputs/StringTypeInput.js +1 -1
- package/dist/src/web/components/typeInputs/utils/MismatchingTypeError.js +2 -2
- package/dist/src/web/context/entities.d.ts +6 -5
- package/dist/src/web/context/git.d.ts +2 -1
- package/dist/src/web/context/gitClient.d.ts +2 -0
- package/dist/src/web/context/gitClient.js +2 -0
- package/dist/src/web/hooks/useGitClient.d.ts +37 -0
- package/dist/src/web/hooks/useGitClient.js +313 -0
- package/dist/src/web/hooks/useSecondaryDeclarations.js +6 -3
- package/dist/src/web/hooks/useSettings.js +0 -1
- package/dist/src/web/index.js +6 -2
- package/dist/src/web/routes/CreateInstance.js +29 -23
- package/dist/src/web/routes/Entity.js +10 -4
- package/dist/src/web/routes/Instance.js +21 -8
- package/dist/src/web/signals/loading.d.ts +2 -0
- package/dist/src/web/signals/loading.js +11 -0
- package/dist/src/web/utils/BlockMarkdown.js +1 -1
- package/dist/src/web/utils/debug.d.ts +1 -0
- package/dist/src/web/utils/debug.js +4 -0
- package/dist/src/web/utils/typeSkeleton.js +1 -1
- package/package.json +3 -3
- package/public/css/styles.css +132 -70
- package/dist/src/web/components/Git.js +0 -164
- /package/dist/src/web/components/{Git.d.ts → git/Git.d.ts} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
import { useLocation } from "preact-iso";
|
|
3
|
-
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
|
|
4
|
-
import { getGitStatusForDisplay, getLabelForGitStatus, isChangedInIndex, isChangedInWorkingDir, } from "../../shared/utils/git.js";
|
|
5
|
-
import { getAllEntities } from "../api/declarations.js";
|
|
6
|
-
import { commitStagedFiles, createBranch, getBranches, getStatus, pullCommits, pushCommits, stageAllFiles, stageFileOfEntity, switchBranch, unstageAllFiles, unstageFileOfEntity, } from "../api/git.js";
|
|
7
|
-
import { GitContext } from "../context/git.js";
|
|
8
|
-
import { useSetting } from "../hooks/useSettings.js";
|
|
9
|
-
const filterFilesForDisplay = (predicate, entities, data) => Object.entries(data.instances)
|
|
10
|
-
.map(([entityName, instances]) => [
|
|
11
|
-
entityName,
|
|
12
|
-
entities.find(entity => entity.name === entityName)?.namePlural ?? entityName,
|
|
13
|
-
instances
|
|
14
|
-
.filter(instance => instance.gitStatus !== undefined && predicate(instance.gitStatus))
|
|
15
|
-
.sort((a, b) => a.displayName.localeCompare(b.displayName, undefined, { numeric: true })),
|
|
16
|
-
])
|
|
17
|
-
.filter(([_1, _2, instances]) => instances.length > 0)
|
|
18
|
-
.sort((a, b) => a[1].localeCompare(b[1]));
|
|
19
|
-
const GitFileList = ({ filesByEntity, onFile, isIndex = false }) => filesByEntity.length === 0 ? (_jsx("p", { class: "no-changes", children: "No changes" })) : (_jsx("ul", { class: "git-entity-list", children: filesByEntity.map(([entityName, entityNamePlural, instances]) => (_jsxs("li", { class: "git-entity-list-item", children: [_jsx("span", { class: "title", children: entityNamePlural }), _jsx("ul", { class: "git-instance-list", children: instances.map(instance => {
|
|
20
|
-
const gitStatusForDisplay = getGitStatusForDisplay(instance.gitStatus);
|
|
21
|
-
return (_jsxs("li", { class: "git-instance-list-item", children: [_jsx("span", { class: "title", children: instance.displayName }), _jsx("span", { class: `git-status git-status--${gitStatusForDisplay ?? ""}`, title: getLabelForGitStatus(gitStatusForDisplay), children: gitStatusForDisplay }), _jsx("button", { onClick: () => {
|
|
22
|
-
onFile(entityName, instance);
|
|
23
|
-
}, children: isIndex ? "Unstage" : "Stage" })] }, instance.id));
|
|
24
|
-
}) })] }, entityName))) }));
|
|
25
|
-
export const Git = () => {
|
|
26
|
-
const [locales] = useSetting("displayedLocales");
|
|
27
|
-
const [isOpen] = useContext(GitContext);
|
|
28
|
-
const [commitsAhead, setCommitsAhead] = useState(0);
|
|
29
|
-
const [commitsBehind, setCommitsBehind] = useState(0);
|
|
30
|
-
const [commitMessage, setCommitMessage] = useState("");
|
|
31
|
-
const [indexFiles, setIndexFiles] = useState([]);
|
|
32
|
-
const [workingTreeFiles, setWorkingTreeFiles] = useState([]);
|
|
33
|
-
const [entities, setEntities] = useState([]);
|
|
34
|
-
const [allBranches, setAllBranches] = useState([]);
|
|
35
|
-
const [currentBranch, setCurrentBranch] = useState("");
|
|
36
|
-
const updateGitStatus = useCallback((localEntities) => Promise.all([getStatus(locales), getBranches(locales)]).then(([statusData, branchesData]) => {
|
|
37
|
-
setIndexFiles(filterFilesForDisplay(isChangedInIndex, localEntities, statusData));
|
|
38
|
-
setWorkingTreeFiles(filterFilesForDisplay(isChangedInWorkingDir, localEntities, statusData));
|
|
39
|
-
setCommitsAhead(statusData.commitsAhead);
|
|
40
|
-
setCommitsBehind(statusData.commitsBehind);
|
|
41
|
-
setAllBranches(branchesData.allBranches);
|
|
42
|
-
setCurrentBranch(branchesData.currentBranch);
|
|
43
|
-
}), [locales]);
|
|
44
|
-
const location = useLocation();
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
getAllEntities(locales)
|
|
47
|
-
.then(async (data) => {
|
|
48
|
-
const entitiesFromServer = data.declarations.map(decl => decl.declaration);
|
|
49
|
-
setEntities(entitiesFromServer);
|
|
50
|
-
return updateGitStatus(entitiesFromServer);
|
|
51
|
-
})
|
|
52
|
-
.catch((error) => {
|
|
53
|
-
if (error instanceof Error) {
|
|
54
|
-
console.error("Error fetching entities:", error.toString());
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}, [location.path, locales, updateGitStatus]);
|
|
58
|
-
const stage = (entityName, instance) => {
|
|
59
|
-
stageFileOfEntity(locales, entityName, instance.id)
|
|
60
|
-
.then(() => updateGitStatus(entities))
|
|
61
|
-
.catch((error) => {
|
|
62
|
-
if (error instanceof Error) {
|
|
63
|
-
console.error("Error staging instance:", error.toString());
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
const stageAll = () => {
|
|
68
|
-
stageAllFiles(locales)
|
|
69
|
-
.then(() => updateGitStatus(entities))
|
|
70
|
-
.catch((error) => {
|
|
71
|
-
if (error instanceof Error) {
|
|
72
|
-
console.error("Error staging all instances:", error.toString());
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
const unstage = (entityName, instance) => {
|
|
77
|
-
unstageFileOfEntity(locales, entityName, instance.id)
|
|
78
|
-
.then(() => updateGitStatus(entities))
|
|
79
|
-
.catch((error) => {
|
|
80
|
-
if (error instanceof Error) {
|
|
81
|
-
console.error("Error unstaging instance:", error.toString());
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const unstageAll = () => {
|
|
86
|
-
unstageAllFiles(locales)
|
|
87
|
-
.then(() => updateGitStatus(entities))
|
|
88
|
-
.catch((error) => {
|
|
89
|
-
if (error instanceof Error) {
|
|
90
|
-
console.error("Error unstaging all instances:", error.toString());
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
const commit = () => {
|
|
95
|
-
if (commitMessage.length > 0 &&
|
|
96
|
-
indexFiles.length > 0 &&
|
|
97
|
-
confirm("Do you want to commit all staged files?")) {
|
|
98
|
-
commitStagedFiles(locales, commitMessage)
|
|
99
|
-
.then(() => {
|
|
100
|
-
setCommitMessage("");
|
|
101
|
-
return updateGitStatus(entities);
|
|
102
|
-
})
|
|
103
|
-
.catch((error) => {
|
|
104
|
-
if (error instanceof Error) {
|
|
105
|
-
console.error("Error committing instances:", error.toString());
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const push = () => {
|
|
111
|
-
pushCommits(locales)
|
|
112
|
-
.then(() => {
|
|
113
|
-
alert("Pushed commits successfully");
|
|
114
|
-
return updateGitStatus(entities);
|
|
115
|
-
})
|
|
116
|
-
.catch((error) => {
|
|
117
|
-
console.error("Error pushing commits:", error);
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
const pull = () => {
|
|
121
|
-
pullCommits(locales)
|
|
122
|
-
.then(() => {
|
|
123
|
-
alert("Pulled commits successfully");
|
|
124
|
-
return updateGitStatus(entities);
|
|
125
|
-
})
|
|
126
|
-
.catch((error) => {
|
|
127
|
-
console.error("Error pulling commits:", error);
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
const onCreateBranch = () => {
|
|
131
|
-
const newBranchName = prompt("Enter new branch name:");
|
|
132
|
-
if (!newBranchName) {
|
|
133
|
-
alert("Branch name cannot be empty");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (allBranches.includes(newBranchName)) {
|
|
137
|
-
alert("Branch name already exists");
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
createBranch(locales, newBranchName)
|
|
141
|
-
.then(() => {
|
|
142
|
-
return updateGitStatus(entities);
|
|
143
|
-
})
|
|
144
|
-
.catch((error) => {
|
|
145
|
-
if (error instanceof Error) {
|
|
146
|
-
alert("Error switching branch:" + error.toString());
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
const onSwitchBranch = (event) => {
|
|
151
|
-
switchBranch(locales, event.currentTarget.value)
|
|
152
|
-
.then(() => {
|
|
153
|
-
return updateGitStatus(entities);
|
|
154
|
-
})
|
|
155
|
-
.catch((error) => {
|
|
156
|
-
if (error instanceof Error) {
|
|
157
|
-
alert("Error switching branch: " + error.toString());
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
return (_jsxs("aside", { class: "git", children: [_jsx("h2", { class: "h1-faded", children: "Version Control" }), _jsxs("div", { className: `git-overlay ${isOpen ? "git-overlay--open" : ""}`, children: [_jsxs("div", { class: "sync", children: [_jsxs("button", { onClick: push, children: ["Push", commitsAhead > 0 ? ` (${commitsAhead.toString()})` : ""] }), _jsxs("button", { onClick: pull, children: ["Pull", commitsBehind > 0 ? ` (${commitsBehind.toString()})` : ""] })] }), _jsxs("div", { className: "branch", children: [_jsx("div", { className: "select-wrapper", children: _jsx("select", { value: currentBranch, onInput: onSwitchBranch, children: allBranches.map(branch => (_jsx("option", { value: branch, children: branch }, branch))) }) }), _jsx("button", { onClick: onCreateBranch, children: "New branch" })] }), _jsxs("div", { class: "commit", children: [_jsx("input", { type: "text", value: commitMessage, onInput: event => {
|
|
162
|
-
setCommitMessage(event.currentTarget.value);
|
|
163
|
-
}, placeholder: "added X to instance Y, \u2026" }), _jsx("button", { onClick: commit, disabled: commitMessage.length === 0 || indexFiles.length === 0, children: "Commit" })] }), _jsxs("div", { className: "git-section-title", children: [_jsx("h3", { children: "Files to be committed" }), _jsx("button", { onClick: unstageAll, children: "Unstage all" })] }), _jsx(GitFileList, { filesByEntity: indexFiles, isIndex: true, onFile: unstage }), _jsxs("div", { className: "git-section-title", children: [_jsx("h3", { children: "Working tree changes" }), _jsx("button", { onClick: stageAll, children: "Stage all" })] }), _jsx(GitFileList, { filesByEntity: workingTreeFiles, onFile: stage })] })] }));
|
|
164
|
-
};
|
|
File without changes
|