adminforth 1.0.16 → 1.0.24
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/dataConnectors/{mongo.js → mongo.ts} +15 -10
- package/dataConnectors/{postgres.js → postgres.ts} +6 -2
- package/dataConnectors/{sqlite.js → sqlite.ts} +6 -2
- package/dist/auth.js +68 -0
- package/dist/dataConnectors/mongo.js +204 -0
- package/dist/dataConnectors/postgres.js +298 -0
- package/dist/dataConnectors/sqlite.js +261 -0
- package/dist/index.js +693 -0
- package/dist/modules/codeInjector.js +337 -0
- package/dist/modules/utils.js +12 -0
- package/dist/servers/express.js +210 -0
- package/dist/spa/src/main.js +16 -0
- package/dist/spa/src/router/index.js +79 -0
- package/dist/spa/src/stores/core.js +154 -0
- package/dist/spa/src/stores/modal.js +35 -0
- package/dist/spa/src/utils.js +59 -0
- package/dist/spa/vite.config.js +44 -0
- package/dist/spa_tmp/src/custom/custom/vueUses.js +10 -0
- package/dist/spa_tmp/src/main.js +29 -0
- package/dist/spa_tmp/src/router/index.js +83 -0
- package/dist/spa_tmp/src/stores/core.js +150 -0
- package/dist/spa_tmp/src/stores/modal.js +35 -0
- package/dist/spa_tmp/src/utils.js +59 -0
- package/dist/spa_tmp/vite.config.js +43 -0
- package/dist/types.js +30 -0
- package/{index.js → index.ts} +115 -6
- package/modules/{codeInjector.js → codeInjector.ts} +20 -16
- package/package.json +9 -3
- package/servers/{express.js → express.ts} +8 -2
- package/spa/package.json +2 -2
- package/spa/src/views/ListView.vue +1 -1
- package/tsconfig.json +112 -0
- package/{types.js → types.ts} +2 -0
- /package/{auth.js → auth.ts} +0 -0
- /package/modules/{utils.js → utils.ts} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_url_1 = require("node:url");
|
|
7
|
+
const vite_1 = require("vite");
|
|
8
|
+
const plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
|
|
9
|
+
const customLogger = {
|
|
10
|
+
info(msg) {
|
|
11
|
+
// Filter out the lines containing '➜ Local:' or '➜ Network:'
|
|
12
|
+
if (!msg.includes('➜')) {
|
|
13
|
+
console.log(msg);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
warn(msg) {
|
|
17
|
+
console.warn(msg);
|
|
18
|
+
},
|
|
19
|
+
error(msg) {
|
|
20
|
+
console.error(msg);
|
|
21
|
+
},
|
|
22
|
+
clear() {
|
|
23
|
+
console.clear();
|
|
24
|
+
},
|
|
25
|
+
hasWarned: false,
|
|
26
|
+
};
|
|
27
|
+
// https://vitejs.dev/config/
|
|
28
|
+
exports.default = (0, vite_1.defineConfig)({
|
|
29
|
+
base: process.env.VITE_ADMINFORTH_PUBLIC_PATH || '/',
|
|
30
|
+
server: {
|
|
31
|
+
port: 5173,
|
|
32
|
+
strictPort: true, // better predictability
|
|
33
|
+
},
|
|
34
|
+
customLogger,
|
|
35
|
+
plugins: [
|
|
36
|
+
(0, plugin_vue_1.default)(),
|
|
37
|
+
],
|
|
38
|
+
resolve: {
|
|
39
|
+
alias: {
|
|
40
|
+
'@': (0, node_url_1.fileURLToPath)(new node_url_1.URL('./src', import.meta.url))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// typical types which AdminForth supports
|
|
2
|
+
//
|
|
3
|
+
export const AdminForthTypes = {
|
|
4
|
+
STRING: 'string',
|
|
5
|
+
INTEGER: 'integer',
|
|
6
|
+
FLOAT: 'float',
|
|
7
|
+
DECIMAL: 'decimal',
|
|
8
|
+
BOOLEAN: 'boolean',
|
|
9
|
+
DATE: 'date',
|
|
10
|
+
DATETIME: 'datetime',
|
|
11
|
+
TIME: 'time',
|
|
12
|
+
TEXT: 'text',
|
|
13
|
+
JSON: 'json',
|
|
14
|
+
};
|
|
15
|
+
export const AdminForthFilterOperators = {
|
|
16
|
+
EQ: 'eq',
|
|
17
|
+
NE: 'ne',
|
|
18
|
+
GT: 'gt',
|
|
19
|
+
LT: 'lt',
|
|
20
|
+
GTE: 'gte',
|
|
21
|
+
LTE: 'lte',
|
|
22
|
+
LIKE: 'like',
|
|
23
|
+
ILIKE: 'ilike',
|
|
24
|
+
IN: 'in',
|
|
25
|
+
NIN: 'nin',
|
|
26
|
+
};
|
|
27
|
+
export const AdminForthSortDirections = {
|
|
28
|
+
ASC: 'asc',
|
|
29
|
+
DESC: 'desc',
|
|
30
|
+
};
|
package/{index.js → index.ts}
RENAMED
|
@@ -10,13 +10,102 @@ import {v1 as uuid} from 'uuid';
|
|
|
10
10
|
import fs from 'fs';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
import { AdminForthFilterOperators, AdminForthTypes } from './types.js';
|
|
13
|
+
import { AdminForthFilterOperators, AdminForthTypes, AdminForthTypesValues } from './types.js';
|
|
14
14
|
|
|
15
15
|
const AVAILABLE_SHOW_IN = ['list', 'edit', 'create', 'filter', 'show'];
|
|
16
16
|
|
|
17
|
+
type AdminForthConfigMenuItem = {
|
|
18
|
+
label: string,
|
|
19
|
+
icon?: string,
|
|
20
|
+
path?: string,
|
|
21
|
+
component?: string,
|
|
22
|
+
resourceId?: string,
|
|
23
|
+
homepage?: boolean,
|
|
24
|
+
children?: Array<AdminForthConfigMenuItem>,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type AdminForthResourceColumn = {
|
|
28
|
+
name: string,
|
|
29
|
+
label?: string,
|
|
30
|
+
type?: AdminForthTypesValues,
|
|
31
|
+
primaryKey?: boolean,
|
|
32
|
+
required?: boolean | { create: boolean, edit: boolean },
|
|
33
|
+
editingNote?: string | { create: string, edit: string },
|
|
34
|
+
showIn?: Array<string>,
|
|
35
|
+
fillOnCreate?: Function,
|
|
36
|
+
isUnique?: boolean,
|
|
37
|
+
virtual?: boolean,
|
|
38
|
+
allowMinMaxQuery?: boolean,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type AdminForthResource = {
|
|
42
|
+
resourceId: string,
|
|
43
|
+
label?: string,
|
|
44
|
+
table: string,
|
|
45
|
+
dataSource: string,
|
|
46
|
+
columns: Array<AdminForthResourceColumn>,
|
|
47
|
+
itemLabel?: Function,
|
|
48
|
+
hooks?: {
|
|
49
|
+
show?: Function,
|
|
50
|
+
create?: {
|
|
51
|
+
beforeSave?: Function,
|
|
52
|
+
afterSave?: Function,
|
|
53
|
+
},
|
|
54
|
+
edit?: {
|
|
55
|
+
beforeSave?: Function,
|
|
56
|
+
afterSave?: Function,
|
|
57
|
+
},
|
|
58
|
+
delete?: {
|
|
59
|
+
beforeSave?: Function,
|
|
60
|
+
afterSave?: Function,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
options?: {
|
|
64
|
+
bulkActions?: Array<{
|
|
65
|
+
label: string,
|
|
66
|
+
state: string,
|
|
67
|
+
icon: string,
|
|
68
|
+
action: Function,
|
|
69
|
+
}>,
|
|
70
|
+
allowDelete?: boolean,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type AdminForthDataSource = {
|
|
75
|
+
id: string,
|
|
76
|
+
url: string,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type AdminForthConfig = {
|
|
80
|
+
rootUser?: {
|
|
81
|
+
username: string,
|
|
82
|
+
password: string,
|
|
83
|
+
},
|
|
84
|
+
auth?: {
|
|
85
|
+
resourceId: string,
|
|
86
|
+
usernameField: string,
|
|
87
|
+
passwordHashField: string,
|
|
88
|
+
loginBackgroundImage?: string,
|
|
89
|
+
userFullName?: string,
|
|
90
|
+
},
|
|
91
|
+
resources: Array<any>,
|
|
92
|
+
menu: Array<AdminForthConfigMenuItem>,
|
|
93
|
+
databaseConnectors?: any,
|
|
94
|
+
dataSources: Array<any>,
|
|
95
|
+
customization?: {
|
|
96
|
+
customComponentsDir?: string,
|
|
97
|
+
vueUsesFile?: string,
|
|
98
|
+
},
|
|
99
|
+
baseUrl?: string,
|
|
100
|
+
brandName?: string,
|
|
101
|
+
datesFormat?: string,
|
|
102
|
+
deleteConfirmation?: boolean,
|
|
103
|
+
}
|
|
104
|
+
|
|
17
105
|
class AdminForth {
|
|
18
106
|
static Types = AdminForthTypes;
|
|
19
107
|
|
|
108
|
+
|
|
20
109
|
static Utils = {
|
|
21
110
|
generatePasswordHash: async (password) => {
|
|
22
111
|
return await Auth.generatePasswordHash(password);
|
|
@@ -29,7 +118,21 @@ class AdminForth {
|
|
|
29
118
|
|
|
30
119
|
}
|
|
31
120
|
|
|
32
|
-
|
|
121
|
+
config: AdminForthConfig;
|
|
122
|
+
express: ExpressServer;
|
|
123
|
+
auth: Auth;
|
|
124
|
+
codeInjector: CodeInjector;
|
|
125
|
+
connectors: any;
|
|
126
|
+
connectorClasses: any;
|
|
127
|
+
runningHotReload?: boolean;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
statuses: {
|
|
131
|
+
dbDiscover?: 'running' | 'done',
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
constructor(config: AdminForthConfig) {
|
|
33
136
|
this.config = {...this.#defaultConfig,...config};
|
|
34
137
|
this.validateConfig();
|
|
35
138
|
this.express = new ExpressServer(this);
|
|
@@ -106,6 +209,8 @@ class AdminForth {
|
|
|
106
209
|
}
|
|
107
210
|
res.columns.forEach((col) => {
|
|
108
211
|
col.label = col.label || guessLabelFromName(col.name);
|
|
212
|
+
//define default sortable
|
|
213
|
+
if (!Object.keys(col).includes('sortable')) {col.sortable = true;}
|
|
109
214
|
if (col.showIn && !Array.isArray(col.showIn)) {
|
|
110
215
|
errors.push(`Resource "${res.resourceId}" column "${col.name}" showIn must be an array`);
|
|
111
216
|
}
|
|
@@ -134,6 +239,8 @@ class AdminForth {
|
|
|
134
239
|
}
|
|
135
240
|
}
|
|
136
241
|
|
|
242
|
+
|
|
243
|
+
|
|
137
244
|
const wrongShowIn = col.showIn && col.showIn.find((c) => !AVAILABLE_SHOW_IN.includes(c));
|
|
138
245
|
if (wrongShowIn) {
|
|
139
246
|
errors.push(`Resource "${res.resourceId}" column "${col.name}" has invalid showIn value "${wrongShowIn}", allowed values are ${AVAILABLE_SHOW_IN.join(', ')}`);
|
|
@@ -267,7 +374,7 @@ class AdminForth {
|
|
|
267
374
|
if (!this.connectors[res.dataSource]) {
|
|
268
375
|
throw new Error(`Resource '${res.table}' refers to unknown dataSource '${res.dataSource}'`);
|
|
269
376
|
}
|
|
270
|
-
const fieldTypes = await this.connectors[res.dataSource].discoverFields(res
|
|
377
|
+
const fieldTypes = await this.connectors[res.dataSource].discoverFields(res);
|
|
271
378
|
if (!Object.keys(fieldTypes).length) {
|
|
272
379
|
throw new Error(`Table '${res.table}' (In resource '${res.resourceId}') has no fields or does not exist`);
|
|
273
380
|
}
|
|
@@ -312,6 +419,7 @@ class AdminForth {
|
|
|
312
419
|
method: 'POST',
|
|
313
420
|
path: '/login',
|
|
314
421
|
handler: async ({ body, response }) => {
|
|
422
|
+
const INVALID_MESSAGE = 'Invalid username or password';
|
|
315
423
|
const { username, password } = body;
|
|
316
424
|
let token;
|
|
317
425
|
if (username === this.config.rootUser.username && password === this.config.rootUser.password) {
|
|
@@ -496,7 +604,7 @@ class AdminForth {
|
|
|
496
604
|
const item = await this.connectors[resource.dataSource].getMinMaxForColumns({
|
|
497
605
|
resource,
|
|
498
606
|
columns: resource.columns.filter((col) => [
|
|
499
|
-
AdminForthTypes.
|
|
607
|
+
AdminForthTypes.INTEGER,
|
|
500
608
|
AdminForthTypes.FLOAT,
|
|
501
609
|
AdminForthTypes.DATE,
|
|
502
610
|
AdminForthTypes.DATETIME,
|
|
@@ -510,7 +618,7 @@ class AdminForth {
|
|
|
510
618
|
server.endpoint({
|
|
511
619
|
method: 'POST',
|
|
512
620
|
path: '/get_record',
|
|
513
|
-
handler: async ({ body }) => {
|
|
621
|
+
handler: async ({ body, adminUser }) => {
|
|
514
622
|
const { resourceId, primaryKey } = body;
|
|
515
623
|
const resource = this.config.resources.find((res) => res.resourceId == resourceId);
|
|
516
624
|
const primaryKeyColumn = resource.columns.find((col) => col.primaryKey);
|
|
@@ -675,8 +783,9 @@ class AdminForth {
|
|
|
675
783
|
noAuth: true, // TODO
|
|
676
784
|
method: 'POST',
|
|
677
785
|
path: '/delete_record',
|
|
678
|
-
handler: async ({ body }) => {
|
|
786
|
+
handler: async ({ body, adminUser }) => {
|
|
679
787
|
const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
|
|
788
|
+
const record = await this.connectors[resource.dataSource].getRecordByPrimaryKey(resource, body['primaryKey']);
|
|
680
789
|
if (!resource) {
|
|
681
790
|
return { error: `Resource '${body['resourceId']}' not found` };
|
|
682
791
|
}
|
|
@@ -7,6 +7,7 @@ import path from 'path';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import crypto from 'crypto';
|
|
9
9
|
import os from 'os';
|
|
10
|
+
import AdminForth from '../index.js';
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -30,18 +31,21 @@ function hashify(obj) {
|
|
|
30
31
|
|
|
31
32
|
class CodeInjector {
|
|
32
33
|
|
|
34
|
+
adminforth: AdminForth;
|
|
35
|
+
|
|
33
36
|
static SPA_TMP_PATH = path.join(TMP_DIR, 'adminforth', 'spa_tmp');
|
|
34
37
|
|
|
35
38
|
constructor(adminforth) {
|
|
36
39
|
this.adminforth = adminforth;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
async runShell({command, verbose = false}) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
42
|
+
// async runShell({command, verbose = false}) {
|
|
43
|
+
// console.log(`⚙️ Running shell ${command}...`);
|
|
44
|
+
// console.time(`${command} done in`);
|
|
45
|
+
// const { stdout: out, stderr: err } = await execAsync(command);
|
|
46
|
+
// console.timeEnd(`${command} done in`);
|
|
47
|
+
// console.log(`Command ${command} output:`, out, err);
|
|
48
|
+
// }
|
|
45
49
|
|
|
46
50
|
async runNpmShell({command, verbose = false, cwd}) {
|
|
47
51
|
const nodeBinary = process.execPath; // Path to the Node.js binary running this script
|
|
@@ -53,12 +57,13 @@ class CodeInjector {
|
|
|
53
57
|
...process.env,
|
|
54
58
|
};
|
|
55
59
|
|
|
56
|
-
console.
|
|
60
|
+
console.log(`⚙️ Running npm ${command}...`);
|
|
61
|
+
console.time(`npm ${command} done in`);
|
|
57
62
|
const { stdout: out, stderr: err } = await execAsync(`${nodeBinary} ${npmPath} ${command}`, {
|
|
58
63
|
cwd,
|
|
59
64
|
env,
|
|
60
65
|
});
|
|
61
|
-
console.timeEnd(`
|
|
66
|
+
console.timeEnd(`npm ${command} done in`);
|
|
62
67
|
|
|
63
68
|
if (verbose) {
|
|
64
69
|
console.log(`npm ${command} output:`, out);
|
|
@@ -78,7 +83,7 @@ class CodeInjector {
|
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
async prepareSources({ filesUpdated, verbose = false }) {
|
|
86
|
+
async prepareSources({ filesUpdated, verbose = false }: { filesUpdated?: string[], verbose?: boolean }) {
|
|
82
87
|
const spaTmpPath = CodeInjector.SPA_TMP_PATH;
|
|
83
88
|
// check SPA_TMP_PATH exists and create if not
|
|
84
89
|
try {
|
|
@@ -132,7 +137,7 @@ class CodeInjector {
|
|
|
132
137
|
|
|
133
138
|
// copy whole custom directory
|
|
134
139
|
if (this.adminforth.config.customization?.customComponentsDir) {
|
|
135
|
-
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(
|
|
140
|
+
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom'), {
|
|
136
141
|
recursive: true,
|
|
137
142
|
});
|
|
138
143
|
}
|
|
@@ -246,7 +251,7 @@ class CodeInjector {
|
|
|
246
251
|
|
|
247
252
|
}
|
|
248
253
|
|
|
249
|
-
|
|
254
|
+
async watchForReprepare({ verbose }) {
|
|
250
255
|
const spaPath = path.join(__dirname, 'spa');
|
|
251
256
|
// get list of all subdirectories in spa recursively
|
|
252
257
|
const directories = [];
|
|
@@ -328,7 +333,7 @@ class CodeInjector {
|
|
|
328
333
|
if (verbose) {
|
|
329
334
|
console.log(`🔎 File ${file} changed, copying to spa_tmp...`);
|
|
330
335
|
}
|
|
331
|
-
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(
|
|
336
|
+
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom'), {
|
|
332
337
|
recursive: true,
|
|
333
338
|
});
|
|
334
339
|
}
|
|
@@ -338,8 +343,8 @@ class CodeInjector {
|
|
|
338
343
|
});
|
|
339
344
|
}
|
|
340
345
|
|
|
341
|
-
async bundleNow({hotReload = false, verbose = false}) {
|
|
342
|
-
this.adminforth.
|
|
346
|
+
async bundleNow({hotReload = false, verbose = false}: {hotReload: boolean, verbose: boolean}) {
|
|
347
|
+
this.adminforth.runningHotReload = hotReload;
|
|
343
348
|
|
|
344
349
|
await this.prepareSources({ verbose });
|
|
345
350
|
|
|
@@ -357,7 +362,7 @@ class CodeInjector {
|
|
|
357
362
|
await this.runNpmShell({command: 'run build-only', verbose, cwd});
|
|
358
363
|
} else {
|
|
359
364
|
const command = 'run dev';
|
|
360
|
-
console.
|
|
365
|
+
console.log(`⚙️ Running npm ${command}...`);
|
|
361
366
|
const nodeBinary = process.execPath;
|
|
362
367
|
const npmPath = path.join(path.dirname(nodeBinary), 'npm');
|
|
363
368
|
const env = {
|
|
@@ -380,7 +385,6 @@ class CodeInjector {
|
|
|
380
385
|
|
|
381
386
|
});
|
|
382
387
|
|
|
383
|
-
console.timeEnd(`Running npm ${command}...`);
|
|
384
388
|
}
|
|
385
389
|
}
|
|
386
390
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adminforth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "OpenSource Vue3 powered forth-generation admin panel",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"rollout": "tsc && npm version patch && npm publish"
|
|
8
11
|
},
|
|
9
12
|
"author": "devforth.io",
|
|
10
13
|
"license": "ISC",
|
|
@@ -19,5 +22,8 @@
|
|
|
19
22
|
"mongodb": "6.6",
|
|
20
23
|
"pg": "^8.11.5",
|
|
21
24
|
"uuid": "^9.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.4.5"
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -3,6 +3,8 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import CodeInjector from '../modules/codeInjector.js';
|
|
6
|
+
import AdminForth from '../index.js';
|
|
7
|
+
import { Express } from 'express';
|
|
6
8
|
|
|
7
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
10
|
const __dirname = path.dirname(__filename);
|
|
@@ -81,6 +83,10 @@ const respondNoServer = (title, explanation) => {
|
|
|
81
83
|
`;
|
|
82
84
|
}
|
|
83
85
|
class ExpressServer {
|
|
86
|
+
|
|
87
|
+
expressApp: Express;
|
|
88
|
+
adminforth: AdminForth;
|
|
89
|
+
|
|
84
90
|
constructor(adminforth) {
|
|
85
91
|
this.adminforth = adminforth;
|
|
86
92
|
}
|
|
@@ -90,7 +96,7 @@ class ExpressServer {
|
|
|
90
96
|
|
|
91
97
|
const slashedPrefix = prefix.endsWith('/') ? prefix : `${prefix}/`;
|
|
92
98
|
|
|
93
|
-
if (this.adminforth.
|
|
99
|
+
if (this.adminforth.runningHotReload) {
|
|
94
100
|
const handler = async (req, res) => {
|
|
95
101
|
// proxy using fetch to webpack dev server
|
|
96
102
|
try {
|
|
@@ -98,7 +104,7 @@ class ExpressServer {
|
|
|
98
104
|
} catch (e) {
|
|
99
105
|
res.status(500).send(respondNoServer('AdminForth SPA is not ready yet', 'Vite is still starting up. Please wait a moment...'));
|
|
100
106
|
return;
|
|
101
|
-
|
|
107
|
+
}
|
|
102
108
|
}
|
|
103
109
|
this.expressApp.get(`${slashedPrefix}assets/*`, handler);
|
|
104
110
|
this.expressApp.get(`${prefix}*`, handler);
|
package/spa/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"build": "
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
9
9
|
"preview": "vite preview",
|
|
10
10
|
"build-only": "vite build",
|
|
11
11
|
"type-check": "vue-tsc --build --force",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
</th>
|
|
102
102
|
|
|
103
103
|
<th v-for="c in columnsListed" scope="col" class="px-6 py-3">
|
|
104
|
-
<div @click="() => c.sortable && onSortButtonClick(c.name)" class="flex items-center cursor-pointer">
|
|
104
|
+
<div @click="() => c.sortable && onSortButtonClick(c.name)" class="flex items-center " :class="{'cursor-pointer':c.sortable}">
|
|
105
105
|
{{ c.label }}
|
|
106
106
|
|
|
107
107
|
<div v-if="c.sortable"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/* Language and Environment */
|
|
15
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
16
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
17
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
18
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
19
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
20
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
21
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
22
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
23
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
24
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
25
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
26
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
|
+
|
|
28
|
+
/* Modules */
|
|
29
|
+
// changed from commmonjs to node16 because The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.
|
|
30
|
+
"module": "node16", /* Specify what module code is generated. */
|
|
31
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
32
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
33
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
34
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
35
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
36
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
37
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
38
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
39
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
40
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
41
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
45
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
46
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
47
|
+
|
|
48
|
+
/* JavaScript Support */
|
|
49
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
50
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
51
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
52
|
+
|
|
53
|
+
/* Emit */
|
|
54
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
55
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
56
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
57
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
58
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
60
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
61
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
62
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
63
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
64
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
65
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
77
|
+
|
|
78
|
+
/* Interop Constraints */
|
|
79
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
80
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
81
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
82
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
83
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
84
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
85
|
+
|
|
86
|
+
/* Type Checking */
|
|
87
|
+
"strict": false, /* TODO */ /* Enable all strict type-checking options. */
|
|
88
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
89
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
90
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
91
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
92
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
93
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
94
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
95
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
96
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
97
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
98
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
99
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
100
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
101
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
102
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
103
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
104
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
105
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
106
|
+
|
|
107
|
+
/* Completeness */
|
|
108
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
109
|
+
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
|
110
|
+
},
|
|
111
|
+
"exclude": ["node_modules", "dist", "spa"], /* Exclude files from compilation. */
|
|
112
|
+
}
|
package/{types.js → types.ts}
RENAMED
/package/{auth.js → auth.ts}
RENAMED
|
File without changes
|
|
File without changes
|