adminforth 1.3.54-next.3 → 1.3.54-next.30

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.
Files changed (135) hide show
  1. package/dist/auth.js +42 -56
  2. package/dist/auth.js.map +1 -0
  3. package/dist/basePlugin.js +1 -0
  4. package/dist/basePlugin.js.map +1 -0
  5. package/dist/dataConnectors/baseConnector.js +108 -122
  6. package/dist/dataConnectors/baseConnector.js.map +1 -0
  7. package/dist/dataConnectors/clickhouse.js +132 -150
  8. package/dist/dataConnectors/clickhouse.js.map +1 -0
  9. package/dist/dataConnectors/mongo.js +75 -101
  10. package/dist/dataConnectors/mongo.js.map +1 -0
  11. package/dist/dataConnectors/postgres.js +124 -143
  12. package/dist/dataConnectors/postgres.js.map +1 -0
  13. package/dist/dataConnectors/sqlite.js +113 -130
  14. package/dist/dataConnectors/sqlite.js.map +1 -0
  15. package/dist/index.js +197 -217
  16. package/dist/index.js.map +1 -0
  17. package/dist/modules/codeInjector.js +480 -486
  18. package/dist/modules/codeInjector.js.map +1 -0
  19. package/dist/modules/configValidator.js +31 -22
  20. package/dist/modules/configValidator.js.map +1 -0
  21. package/dist/modules/operationalResource.js +50 -70
  22. package/dist/modules/operationalResource.js.map +1 -0
  23. package/dist/modules/restApi.js +104 -116
  24. package/dist/modules/restApi.js.map +1 -0
  25. package/dist/modules/styleGenerator.js +1 -0
  26. package/dist/modules/styleGenerator.js.map +1 -0
  27. package/dist/modules/styles.js +1 -0
  28. package/dist/modules/styles.js.map +1 -0
  29. package/dist/modules/utils.js +1 -0
  30. package/dist/modules/utils.js.map +1 -0
  31. package/dist/plugins/audit-log/types.js +2 -0
  32. package/dist/plugins/audit-log/types.js.map +1 -0
  33. package/dist/plugins/chat-gpt/types.js +2 -0
  34. package/dist/plugins/chat-gpt/types.js.map +1 -0
  35. package/dist/plugins/email-password-reset/types.js +2 -0
  36. package/dist/plugins/email-password-reset/types.js.map +1 -0
  37. package/dist/plugins/foreign-inline-list/types.js +2 -0
  38. package/dist/plugins/foreign-inline-list/types.js.map +1 -0
  39. package/dist/plugins/import-export/types.js +2 -0
  40. package/dist/plugins/import-export/types.js.map +1 -0
  41. package/dist/plugins/rich-editor/custom/async-queue.js +29 -0
  42. package/dist/plugins/rich-editor/custom/async-queue.js.map +1 -0
  43. package/dist/plugins/rich-editor/dist/async-queue.js +41 -0
  44. package/dist/plugins/rich-editor/dist/custom/async-queue.js +29 -0
  45. package/dist/plugins/rich-editor/dist/custom/async-queue.js.map +1 -0
  46. package/dist/plugins/rich-editor/types.js +16 -0
  47. package/dist/plugins/rich-editor/types.js.map +1 -0
  48. package/dist/plugins/two-factors-auth/types.js +2 -0
  49. package/dist/plugins/two-factors-auth/types.js.map +1 -0
  50. package/dist/plugins/upload/types.js +2 -0
  51. package/dist/plugins/upload/types.js.map +1 -0
  52. package/dist/servers/express.js +30 -42
  53. package/dist/servers/express.js.map +1 -0
  54. package/dist/types/AdminForthConfig.js +1 -0
  55. package/dist/types/AdminForthConfig.js.map +1 -0
  56. package/dist/types/FrontendAPI.js +1 -0
  57. package/dist/types/FrontendAPI.js.map +1 -0
  58. package/package.json +7 -4
  59. package/auth.ts +0 -140
  60. package/basePlugin.ts +0 -70
  61. package/dataConnectors/baseConnector.ts +0 -216
  62. package/dataConnectors/clickhouse.ts +0 -341
  63. package/dataConnectors/mongo.ts +0 -202
  64. package/dataConnectors/postgres.ts +0 -306
  65. package/dataConnectors/sqlite.ts +0 -254
  66. package/index.ts +0 -428
  67. package/modules/codeInjector.ts +0 -736
  68. package/modules/configValidator.ts +0 -571
  69. package/modules/operationalResource.ts +0 -98
  70. package/modules/restApi.ts +0 -718
  71. package/modules/styleGenerator.ts +0 -55
  72. package/modules/styles.ts +0 -126
  73. package/modules/utils.ts +0 -472
  74. package/servers/express.ts +0 -259
  75. package/spa/.eslintrc.cjs +0 -14
  76. package/spa/README.md +0 -39
  77. package/spa/env.d.ts +0 -1
  78. package/spa/index.html +0 -23
  79. package/spa/package-lock.json +0 -4573
  80. package/spa/package.json +0 -49
  81. package/spa/postcss.config.js +0 -6
  82. package/spa/public/assets/favicon.png +0 -0
  83. package/spa/src/App.vue +0 -418
  84. package/spa/src/assets/base.css +0 -2
  85. package/spa/src/assets/logo.svg +0 -19
  86. package/spa/src/components/AcceptModal.vue +0 -45
  87. package/spa/src/components/Breadcrumbs.vue +0 -41
  88. package/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  89. package/spa/src/components/CustomDatePicker.vue +0 -176
  90. package/spa/src/components/CustomDateRangePicker.vue +0 -218
  91. package/spa/src/components/CustomRangePicker.vue +0 -156
  92. package/spa/src/components/Dropdown.vue +0 -168
  93. package/spa/src/components/Filters.vue +0 -222
  94. package/spa/src/components/HelloWorld.vue +0 -17
  95. package/spa/src/components/MenuLink.vue +0 -27
  96. package/spa/src/components/ResourceForm.vue +0 -290
  97. package/spa/src/components/ResourceListTable.vue +0 -460
  98. package/spa/src/components/SingleSkeletLoader.vue +0 -13
  99. package/spa/src/components/SkeleteLoader.vue +0 -23
  100. package/spa/src/components/ThreeDotsMenu.vue +0 -43
  101. package/spa/src/components/Toast.vue +0 -78
  102. package/spa/src/components/ValueRenderer.vue +0 -114
  103. package/spa/src/components/icons/IconCalendar.vue +0 -5
  104. package/spa/src/components/icons/IconCommunity.vue +0 -7
  105. package/spa/src/components/icons/IconDocumentation.vue +0 -7
  106. package/spa/src/components/icons/IconEcosystem.vue +0 -7
  107. package/spa/src/components/icons/IconSupport.vue +0 -7
  108. package/spa/src/components/icons/IconTime.vue +0 -5
  109. package/spa/src/components/icons/IconTooling.vue +0 -19
  110. package/spa/src/composables/useFrontendApi.ts +0 -26
  111. package/spa/src/composables/useStores.ts +0 -131
  112. package/spa/src/index.scss +0 -31
  113. package/spa/src/main.ts +0 -18
  114. package/spa/src/router/index.ts +0 -59
  115. package/spa/src/spa_types/core.ts +0 -53
  116. package/spa/src/stores/core.ts +0 -148
  117. package/spa/src/stores/filters.ts +0 -27
  118. package/spa/src/stores/modal.ts +0 -48
  119. package/spa/src/stores/toast.ts +0 -31
  120. package/spa/src/stores/user.ts +0 -72
  121. package/spa/src/utils.ts +0 -149
  122. package/spa/src/views/CreateView.vue +0 -167
  123. package/spa/src/views/EditView.vue +0 -170
  124. package/spa/src/views/ListView.vue +0 -279
  125. package/spa/src/views/LoginView.vue +0 -192
  126. package/spa/src/views/ResourceParent.vue +0 -17
  127. package/spa/src/views/ShowView.vue +0 -186
  128. package/spa/tailwind.config.js +0 -17
  129. package/spa/tsconfig.app.json +0 -14
  130. package/spa/tsconfig.json +0 -11
  131. package/spa/tsconfig.node.json +0 -19
  132. package/spa/vite.config.ts +0 -56
  133. package/tsconfig.json +0 -112
  134. package/types/AdminForthConfig.ts +0 -1762
  135. package/types/FrontendAPI.ts +0 -143
@@ -1,259 +0,0 @@
1
-
2
- import path from 'path';
3
- import fs from 'fs';
4
- import CodeInjector from '../modules/codeInjector.js';
5
- import { Express } from 'express';
6
- import fetch from 'node-fetch';
7
- import { IAdminForth, IExpressHttpServer } from '../types/AdminForthConfig.js';
8
-
9
-
10
- function replaceAtStart(string, substring) {
11
- if (string.startsWith(substring)) {
12
- return string.slice(substring.length);
13
- }
14
- return string;
15
- }
16
-
17
- async function proxyTo(url, res) {
18
- const actual = await fetch(url);
19
- actual.headers.forEach((v, n) => res.setHeader(n, v));
20
- actual.body.pipe(res);
21
- }
22
-
23
- async function parseExpressCookie(req): Promise<
24
- Array<{
25
- key: string,
26
- value: string
27
- }>
28
- > {
29
- const cookies = req.headers.cookie;
30
- if (!cookies) {
31
- return [];
32
- }
33
- const parts = cookies.split('; ');
34
- const result = [];
35
- parts.forEach(part => {
36
- const [key, value] = part.split('=');
37
- result.push({key, value});
38
- });
39
- return result;
40
- }
41
-
42
-
43
-
44
- const respondNoServer = (title, explanation) => {
45
- return `
46
- <!DOCTYPE html>
47
- <html lang="en">
48
- <head>
49
- <meta charset="UTF-8">
50
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
51
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
52
- <title>AdminForth</title>
53
- </head>
54
- <body>
55
- <div class="center">
56
- <h1>Oops!</h1>
57
- <h2>${title}</h2>
58
- <p>${explanation}</p>
59
- </div>
60
- <style>
61
- body {
62
- font-family: Arial, sans-serif;
63
- background-color: #f0f0f0;
64
- margin: 0;
65
- padding: 0;
66
- }
67
- .center {
68
- display: flex;
69
- justify-content: center;
70
- align-items: center;
71
- height: 100vh;
72
- flex-direction: column;
73
- }
74
- </style>
75
- <script>
76
- setTimeout(() => {
77
- location.reload();
78
- }, 1500);
79
- </script>
80
- </body>
81
- `;
82
- }
83
- class ExpressServer implements IExpressHttpServer {
84
-
85
- expressApp: Express;
86
- adminforth: IAdminForth;
87
-
88
- constructor(adminforth: IAdminForth) {
89
- this.adminforth = adminforth;
90
- }
91
-
92
- setupSpaServer() {
93
- const prefix = this.adminforth.config.baseUrl
94
-
95
- const slashedPrefix = prefix.endsWith('/') ? prefix : `${prefix}/`;
96
-
97
- if (this.adminforth.runningHotReload) {
98
- const handler = async (req, res) => {
99
- // proxy using fetch to webpack dev server
100
- try {
101
- await proxyTo(`http://localhost:5173${req.url}`, res);
102
- } catch (e) {
103
- // console.log('Failed to proxy', e);
104
- res.status(500).send(respondNoServer('AdminForth SPA is not ready yet', 'Vite is still starting up. Please wait a moment...'));
105
- return;
106
- }
107
- }
108
- this.expressApp.get(`${slashedPrefix}assets/*`, handler);
109
- this.expressApp.get(`${prefix}*`, handler);
110
-
111
- } else {
112
- this.expressApp.get(`${slashedPrefix}assets/*`, (req, res) => {
113
- res.sendFile(
114
- path.join(CodeInjector.SPA_TMP_PATH, 'dist', replaceAtStart(req.url, prefix)),
115
- {
116
- cacheControl: false,
117
- // store for a year
118
- headers: {
119
- 'Cache-Control': 'public, max-age=31536000',
120
- 'Pragma': 'public',
121
- }
122
- }
123
- )
124
- })
125
-
126
- this.expressApp.get(`${prefix}*`, async (req, res) => {
127
- const fullPath = path.join(CodeInjector.SPA_TMP_PATH, 'dist', 'index.html');
128
-
129
- let fileExists = true;
130
- try {
131
- await fs.promises.access(fullPath, fs.constants.F_OK);
132
- } catch (e) {
133
- fileExists = false;
134
- }
135
- if (!fileExists) {
136
- res.status(500).send(respondNoServer(`${this.adminforth.config.customization.brandName} is still warming up`, 'Please wait a moment...'));
137
- return;
138
- }
139
- res.sendFile(fullPath, {
140
- cacheControl: false,
141
- headers: {
142
- 'Content-Type': 'text/html',
143
- 'Cache-Control': 'no-cache, no-store, must-revalidate',
144
- 'Pragma': 'no-cache',
145
- 'Expires': '0'
146
- } });
147
- });
148
- }
149
- }
150
-
151
- serve(app) {
152
- this.expressApp = app;
153
- this.adminforth.setupEndpoints(this);
154
- this.setupSpaServer();
155
- }
156
-
157
- authorize(handler) {
158
- return async (req, res, next) => {
159
- const cookies = await parseExpressCookie(req);
160
-
161
- // check if multiple adminforth_jwt providerd and show warning
162
- const jwts = cookies.filter(({key}) => key === 'adminforth_jwt');
163
- if (jwts.length > 1) {
164
- console.error('Multiple adminforth_jwt cookies provided');
165
- }
166
-
167
- const jwt = jwts[0]?.value;
168
-
169
- if (!jwt) {
170
- res.status(401).send('Unauthorized by AdminForth');
171
- return
172
- }
173
- const adminforthUser = await this.adminforth.auth.verify(jwt, 'auth');
174
- if (!adminforthUser) {
175
- res.status(401).send('Unauthorized by AdminForth');
176
- } else {
177
- req.adminUser = adminforthUser;
178
- handler(req, res, next);
179
- }
180
- };
181
- }
182
-
183
- endpoint({ method='GET', path, handler, noAuth=false }) {
184
- if (!path.startsWith('/')) {
185
- throw new Error(`Path must start with /, got: ${path}`);
186
- }
187
- const fullPath = `${this.adminforth.config.baseUrl}/adminapi/v1${path}`;
188
-
189
- const expressHandler = async (req, res) => {
190
- let body = req.body || {};
191
- if (typeof body === 'string') {
192
- try {
193
- body = JSON.parse(body);
194
- } catch (e) {
195
- console.error('Failed to parse body', e);
196
- res.status(400).send('Invalid JSON body');
197
- }
198
- }
199
-
200
- const query = req.query;
201
- const adminUser = req.adminUser;
202
- // lower request headers
203
- const headers = req.headers;
204
- const cookies = await parseExpressCookie(req);
205
-
206
- const response = {
207
- headers: [],
208
- status: 200,
209
- message: undefined,
210
-
211
- setHeader(name, value) {
212
- process.env.HEAVY_DEBUG && console.log(' 🪲Setting header', name, value);
213
- this.headers.push([name, value]);
214
- },
215
-
216
- setStatus(code, message) {
217
- this.status = code;
218
- this.message = message;
219
- },
220
-
221
- blobStream() {
222
- return res;
223
- }
224
-
225
- };
226
- const input = { body, query, headers, cookies, adminUser, response, _raw_express_req: req, _raw_express_res: res};
227
-
228
- let output;
229
- try {
230
- output = await handler(input);
231
- } catch (e) {
232
- console.error('Error in handler', e);
233
- // print full stack trace
234
- console.error(e.stack);
235
- res.status(500).send('Internal server error');
236
- return;
237
- }
238
- response.headers.forEach(([name, value]) => {
239
- res.setHeader(name, value);
240
- });
241
- res.status(response.status);
242
- if (response.message) {
243
- res.send(response.message);
244
- return;
245
- }
246
- if (output === null) {
247
- // nothing should be returned anymore
248
- return;
249
- }
250
- res.json(output);
251
- }
252
-
253
- console.log(`Adding endpoint ${method} ${fullPath}`);
254
- this.expressApp[method.toLowerCase()](fullPath, noAuth ? expressHandler : this.authorize(expressHandler));
255
- }
256
-
257
- }
258
-
259
- export default ExpressServer;
package/spa/.eslintrc.cjs DELETED
@@ -1,14 +0,0 @@
1
- /* eslint-env node */
2
- require('@rushstack/eslint-patch/modern-module-resolution')
3
-
4
- module.exports = {
5
- root: true,
6
- 'extends': [
7
- 'plugin:vue/vue3-essential',
8
- 'eslint:recommended',
9
- '@vue/eslint-config-typescript'
10
- ],
11
- parserOptions: {
12
- ecmaVersion: 'latest'
13
- }
14
- }
package/spa/README.md DELETED
@@ -1,39 +0,0 @@
1
- # spa
2
-
3
- This template should help get you started developing with Vue 3 in Vite.
4
-
5
- ## Recommended IDE Setup
6
-
7
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
8
-
9
- ## Type Support for `.vue` Imports in TS
10
-
11
- TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
12
-
13
- ## Customize configuration
14
-
15
- See [Vite Configuration Reference](https://vitejs.dev/config/).
16
-
17
- ## Project Setup
18
-
19
- ```sh
20
- npm install
21
- ```
22
-
23
- ### Compile and Hot-Reload for Development
24
-
25
- ```sh
26
- npm run dev
27
- ```
28
-
29
- ### Type-Check, Compile and Minify for Production
30
-
31
- ```sh
32
- npm run build
33
- ```
34
-
35
- ### Lint with [ESLint](https://eslint.org/)
36
-
37
- ```sh
38
- npm run lint
39
- ```
package/spa/env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/spa/index.html DELETED
@@ -1,23 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <link rel="icon" href="/* IMPORTANT:ADMINFORTH FAVICON */">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>/* IMPORTANT:ADMINFORTH TITLE */</title>
8
- <!--
9
- <script>
10
- // On page load or when changing themes, best to add inline in `head` to avoid FOUC
11
- if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
12
- document.documentElement.classList.add('dark');
13
- } else {
14
- document.documentElement.classList.remove('dark')
15
- }
16
- </script> -->
17
-
18
- </head>
19
- <body class="min-h-screen flex flex-column">
20
- <div id="app" class="grow bg-lightHtml dark:bg-darkHtml"></div>
21
- <script type="module" src="/src/main.ts"></script>
22
- </body>
23
- </html>