nucleus-core-ts 0.9.3 β 0.9.4
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/package.json +1 -1
- package/public/components/docs/DocsContent.tsx +181 -174
- package/public/components/docs/content/advanced.ts +410 -0
- package/public/components/docs/content/authentication.ts +76 -1623
- package/public/components/docs/content/authorization.ts +139 -0
- package/public/components/docs/content/backup.ts +161 -0
- package/public/components/docs/content/entityCrud.ts +285 -0
- package/public/components/docs/content/gettingStarted.ts +256 -520
- package/public/components/docs/content/multiTenant.ts +217 -0
- package/public/components/docs/docsData.ts +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Γzcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -1,187 +1,194 @@
|
|
|
1
|
-
import { useEffect
|
|
2
|
-
import { docsData } from
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { docsData } from "./docsData";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
interface Window {
|
|
6
|
+
mermaid?: {
|
|
7
|
+
initialize: (config: Record<string, unknown>) => void;
|
|
8
|
+
run: (config?: { nodes?: NodeListOf<Element> }) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface DocsContentProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
activeSection: string;
|
|
15
|
+
activeItem: string;
|
|
16
|
+
activeSubItem: string;
|
|
17
|
+
onSubItemClick: (subItemId: string) => void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function parseMarkdown(content: string): string {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
21
|
+
const codeBlocks: string[] = [];
|
|
22
|
+
const mermaidBlocks: string[] = [];
|
|
23
|
+
const tables: string[] = [];
|
|
24
|
+
|
|
25
|
+
let result = content
|
|
26
|
+
.replace(/```mermaid\n([\s\S]*?)```/g, (_m, code) => {
|
|
27
|
+
const idx = mermaidBlocks.length;
|
|
28
|
+
mermaidBlocks.push(
|
|
29
|
+
`<div class="mermaid-wrapper"><pre class="mermaid">${code.trim()}</pre></div>`,
|
|
30
|
+
);
|
|
31
|
+
return `__MERMAID_${idx}__`;
|
|
32
|
+
})
|
|
33
|
+
.replace(/```(\w*)\n([\s\S]*?)```/g, (_m, lang, code) => {
|
|
34
|
+
const idx = codeBlocks.length;
|
|
35
|
+
const escaped = code
|
|
36
|
+
.replace(/&/g, "&")
|
|
37
|
+
.replace(/</g, "<")
|
|
38
|
+
.replace(/>/g, ">");
|
|
39
|
+
codeBlocks.push(
|
|
40
|
+
`<pre class="code-block"><code class="language-${lang || "text"}">${escaped}</code></pre>`,
|
|
41
|
+
);
|
|
42
|
+
return `__CODE_${idx}__`;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const tableRegex = /(\|.+\|[\r\n]+\|[-| :]+\|[\r\n]+(?:\|.+\|[\r\n]*)+)/g;
|
|
46
|
+
result = result.replace(tableRegex, (match) => {
|
|
47
|
+
const lines = match
|
|
48
|
+
.trim()
|
|
49
|
+
.split("\n")
|
|
50
|
+
.filter((l) => l.trim());
|
|
51
|
+
const headerLine = lines[0];
|
|
52
|
+
if (lines.length < 2 || !headerLine) return match;
|
|
53
|
+
|
|
54
|
+
const headerCells = headerLine
|
|
55
|
+
.split("|")
|
|
56
|
+
.filter((c) => c.trim())
|
|
57
|
+
.map((c) => c.trim());
|
|
58
|
+
const rows = lines.slice(2).map((line) =>
|
|
59
|
+
line
|
|
60
|
+
.split("|")
|
|
61
|
+
.filter((c) => c.trim())
|
|
62
|
+
.map((c) => c.trim()),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const tableHtml = `<table>
|
|
66
|
+
<thead><tr>${headerCells.map((c) => `<th>${c}</th>`).join("")}</tr></thead>
|
|
67
|
+
<tbody>${rows.map((r) => `<tr>${r.map((c) => `<td>${c}</td>`).join("")}</tr>`).join("")}</tbody>
|
|
68
|
+
</table>`;
|
|
69
|
+
|
|
70
|
+
const idx = tables.length;
|
|
71
|
+
tables.push(tableHtml);
|
|
72
|
+
return `__TABLE_${idx}__`;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
result = result
|
|
76
|
+
.replace(/`([^`]+)`/g, '<code class="inline-code">$1</code>')
|
|
77
|
+
.replace(/^### (.+)$/gm, "<h3>$1</h3>")
|
|
78
|
+
.replace(/^## (.+)$/gm, "<h2>$1</h2>")
|
|
79
|
+
.replace(/^# (.+)$/gm, "<h1>$1</h1>")
|
|
80
|
+
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
|
|
81
|
+
.replace(/\*([^*]+)\*/g, "<em>$1</em>")
|
|
82
|
+
.replace(/^> (.+)$/gm, "<blockquote>$1</blockquote>");
|
|
83
|
+
|
|
84
|
+
result = result.replace(
|
|
85
|
+
/^(\d+)\. (.+)$/gm,
|
|
86
|
+
'<li class="ol-item" data-num="$1">$2</li>',
|
|
87
|
+
);
|
|
88
|
+
result = result.replace(/^- (.+)$/gm, '<li class="ul-item">$1</li>');
|
|
89
|
+
|
|
90
|
+
result = result.replace(
|
|
91
|
+
/(<li class="ol-item"[^>]*>[\s\S]*?<\/li>\n?)+/g,
|
|
92
|
+
(m) => `<ol>${m}</ol>`,
|
|
93
|
+
);
|
|
94
|
+
result = result.replace(
|
|
95
|
+
/(<li class="ul-item">[\s\S]*?<\/li>\n?)+/g,
|
|
96
|
+
(m) => `<ul>${m}</ul>`,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
result = result.replace(/\n\n+/g, "</p><p>");
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < codeBlocks.length; i++) {
|
|
102
|
+
result = result.replace(`__CODE_${i}__`, codeBlocks[i] || "");
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < mermaidBlocks.length; i++) {
|
|
105
|
+
result = result.replace(`__MERMAID_${i}__`, mermaidBlocks[i] || "");
|
|
106
|
+
}
|
|
107
|
+
for (let i = 0; i < tables.length; i++) {
|
|
108
|
+
result = result.replace(`__TABLE_${i}__`, tables[i] || "");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return `<p>${result}</p>`
|
|
112
|
+
.replace(/<p>\s*<\/p>/g, "")
|
|
113
|
+
.replace(/<p>(\s*<[houltbd])/gi, "$1")
|
|
114
|
+
.replace(/<\/[houltbd][^>]*>(\s*)<\/p>/gi, (m, _space) =>
|
|
115
|
+
m.replace("</p>", ""),
|
|
116
|
+
);
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
export function DocsContent({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
activeSection,
|
|
121
|
+
activeItem,
|
|
122
|
+
activeSubItem,
|
|
123
|
+
onSubItemClick,
|
|
110
124
|
}: DocsContentProps) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
</button>
|
|
181
|
-
))}
|
|
182
|
-
</div>
|
|
183
|
-
)}
|
|
184
|
-
</div>
|
|
185
|
-
</div>
|
|
186
|
-
)
|
|
125
|
+
const currentSection = docsData.find((s) => s.id === activeSection);
|
|
126
|
+
const currentItem = currentSection?.items.find((i) => i.id === activeItem);
|
|
127
|
+
const currentSubItem = currentItem?.subItems.find(
|
|
128
|
+
(s) => s.id === activeSubItem,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (window.mermaid) {
|
|
133
|
+
window.mermaid.run();
|
|
134
|
+
}
|
|
135
|
+
}, [activeSubItem, currentSubItem]);
|
|
136
|
+
|
|
137
|
+
if (!currentSection || !currentItem) {
|
|
138
|
+
return (
|
|
139
|
+
<div className="docs-content">
|
|
140
|
+
<div className="docs-content-empty">
|
|
141
|
+
<span className="docs-content-empty-icon">π</span>
|
|
142
|
+
<p>Select a topic from the sidebar to get started.</p>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<div className="docs-content">
|
|
150
|
+
<div className="docs-content-header">
|
|
151
|
+
<div className="docs-breadcrumb">
|
|
152
|
+
<span className="docs-breadcrumb-section">
|
|
153
|
+
{currentSection.title}
|
|
154
|
+
</span>
|
|
155
|
+
<span className="docs-breadcrumb-sep">/</span>
|
|
156
|
+
<span className="docs-breadcrumb-item">{currentItem.title}</span>
|
|
157
|
+
</div>
|
|
158
|
+
<h1 className="docs-content-title">{currentItem.title}</h1>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div className="docs-content-body">
|
|
162
|
+
{currentSubItem ? (
|
|
163
|
+
<article
|
|
164
|
+
className="docs-article"
|
|
165
|
+
dangerouslySetInnerHTML={{
|
|
166
|
+
__html: parseMarkdown(currentSubItem.content),
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
) : (
|
|
170
|
+
<div className="docs-cards-grid">
|
|
171
|
+
{currentItem.subItems.map((subItem) => (
|
|
172
|
+
<button
|
|
173
|
+
key={subItem.id}
|
|
174
|
+
type="button"
|
|
175
|
+
className="docs-card"
|
|
176
|
+
onClick={() => onSubItemClick(subItem.id)}
|
|
177
|
+
>
|
|
178
|
+
<h3 className="docs-card-title">{subItem.title}</h3>
|
|
179
|
+
<p className="docs-card-desc">
|
|
180
|
+
{subItem.content
|
|
181
|
+
.slice(0, 120)
|
|
182
|
+
.replace(/[#*`\n]/g, " ")
|
|
183
|
+
.trim()}
|
|
184
|
+
...
|
|
185
|
+
</p>
|
|
186
|
+
<span className="docs-card-arrow">β</span>
|
|
187
|
+
</button>
|
|
188
|
+
))}
|
|
189
|
+
</div>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
187
194
|
}
|