adminforth 1.3.54-next.8 → 1.3.55-next.0
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/auth.d.ts +31 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +42 -56
- package/dist/auth.js.map +1 -0
- package/dist/basePlugin.d.ts +18 -0
- package/dist/basePlugin.d.ts.map +1 -0
- package/dist/basePlugin.js +1 -0
- package/dist/basePlugin.js.map +1 -0
- package/dist/dataConnectors/baseConnector.d.ts +94 -0
- package/dist/dataConnectors/baseConnector.d.ts.map +1 -0
- package/dist/dataConnectors/baseConnector.js +108 -122
- package/dist/dataConnectors/baseConnector.js.map +1 -0
- package/dist/dataConnectors/clickhouse.d.ts +92 -0
- package/dist/dataConnectors/clickhouse.d.ts.map +1 -0
- package/dist/dataConnectors/clickhouse.js +132 -149
- package/dist/dataConnectors/clickhouse.js.map +1 -0
- package/dist/dataConnectors/mongo.d.ts +93 -0
- package/dist/dataConnectors/mongo.d.ts.map +1 -0
- package/dist/dataConnectors/mongo.js +75 -101
- package/dist/dataConnectors/mongo.js.map +1 -0
- package/dist/dataConnectors/postgres.d.ts +71 -0
- package/dist/dataConnectors/postgres.d.ts.map +1 -0
- package/dist/dataConnectors/postgres.js +124 -143
- package/dist/dataConnectors/postgres.js.map +1 -0
- package/dist/dataConnectors/sqlite.d.ts +67 -0
- package/dist/dataConnectors/sqlite.d.ts.map +1 -0
- package/dist/dataConnectors/sqlite.js +113 -130
- package/dist/dataConnectors/sqlite.js.map +1 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -217
- package/dist/index.js.map +1 -0
- package/dist/modules/codeInjector.d.ts +35 -0
- package/dist/modules/codeInjector.d.ts.map +1 -0
- package/dist/modules/codeInjector.js +480 -486
- package/dist/modules/codeInjector.js.map +1 -0
- package/dist/modules/configValidator.d.ts +12 -0
- package/dist/modules/configValidator.d.ts.map +1 -0
- package/dist/modules/configValidator.js +31 -22
- package/dist/modules/configValidator.js.map +1 -0
- package/dist/modules/operationalResource.d.ts +17 -0
- package/dist/modules/operationalResource.d.ts.map +1 -0
- package/dist/modules/operationalResource.js +50 -70
- package/dist/modules/operationalResource.js.map +1 -0
- package/dist/modules/restApi.d.ts +10 -0
- package/dist/modules/restApi.d.ts.map +1 -0
- package/dist/modules/restApi.js +104 -116
- package/dist/modules/restApi.js.map +1 -0
- package/dist/modules/styleGenerator.d.ts +9 -0
- package/dist/modules/styleGenerator.d.ts.map +1 -0
- package/dist/modules/styleGenerator.js +1 -0
- package/dist/modules/styleGenerator.js.map +1 -0
- package/dist/modules/styles.d.ts +96 -0
- package/dist/modules/styles.d.ts.map +1 -0
- package/dist/modules/styles.js +1 -0
- package/dist/modules/styles.js.map +1 -0
- package/dist/modules/utils.d.ts +39 -0
- package/dist/modules/utils.d.ts.map +1 -0
- package/dist/modules/utils.js +1 -0
- package/dist/modules/utils.js.map +1 -0
- package/dist/plugins/audit-log/types.d.ts +35 -0
- package/dist/plugins/audit-log/types.d.ts.map +1 -0
- package/dist/plugins/audit-log/types.js +2 -0
- package/dist/plugins/audit-log/types.js.map +1 -0
- package/dist/plugins/chat-gpt/types.d.ts +82 -0
- package/dist/plugins/chat-gpt/types.d.ts.map +1 -0
- package/dist/plugins/chat-gpt/types.js +2 -0
- package/dist/plugins/chat-gpt/types.js.map +1 -0
- package/dist/plugins/email-password-reset/types.d.ts +28 -0
- package/dist/plugins/email-password-reset/types.d.ts.map +1 -0
- package/dist/plugins/email-password-reset/types.js +2 -0
- package/dist/plugins/email-password-reset/types.js.map +1 -0
- package/dist/plugins/foreign-inline-list/types.d.ts +19 -0
- package/dist/plugins/foreign-inline-list/types.d.ts.map +1 -0
- package/dist/plugins/foreign-inline-list/types.js +2 -0
- package/dist/plugins/foreign-inline-list/types.js.map +1 -0
- package/dist/plugins/import-export/types.d.ts +3 -0
- package/dist/plugins/import-export/types.d.ts.map +1 -0
- package/dist/plugins/import-export/types.js +2 -0
- package/dist/plugins/import-export/types.js.map +1 -0
- package/dist/plugins/rich-editor/custom/async-queue.d.ts +8 -0
- package/dist/plugins/rich-editor/custom/async-queue.d.ts.map +1 -0
- package/dist/plugins/rich-editor/custom/async-queue.js +29 -0
- package/dist/plugins/rich-editor/custom/async-queue.js.map +1 -0
- package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts +8 -0
- package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts.map +1 -0
- package/dist/plugins/rich-editor/dist/custom/async-queue.js +29 -0
- package/dist/plugins/rich-editor/dist/custom/async-queue.js.map +1 -0
- package/dist/plugins/rich-editor/types.d.ts +153 -0
- package/dist/plugins/rich-editor/types.d.ts.map +1 -0
- package/dist/plugins/rich-editor/types.js +16 -0
- package/dist/plugins/rich-editor/types.js.map +1 -0
- package/dist/plugins/two-factors-auth/types.d.ts +18 -0
- package/dist/plugins/two-factors-auth/types.d.ts.map +1 -0
- package/dist/plugins/two-factors-auth/types.js +2 -0
- package/dist/plugins/two-factors-auth/types.js.map +1 -0
- package/dist/plugins/upload/types.d.ts +132 -0
- package/dist/plugins/upload/types.d.ts.map +1 -0
- package/dist/plugins/upload/types.js +2 -0
- package/dist/plugins/upload/types.js.map +1 -0
- package/dist/servers/express.d.ts +18 -0
- package/dist/servers/express.d.ts.map +1 -0
- package/dist/servers/express.js +30 -42
- package/dist/servers/express.js.map +1 -0
- package/dist/types/AdminForthConfig.d.ts +1619 -0
- package/dist/types/AdminForthConfig.d.ts.map +1 -0
- package/dist/types/AdminForthConfig.js +1 -0
- package/dist/types/AdminForthConfig.js.map +1 -0
- package/{types/FrontendAPI.ts → dist/types/FrontendAPI.d.ts} +27 -52
- package/dist/types/FrontendAPI.d.ts.map +1 -0
- package/dist/types/FrontendAPI.js +1 -0
- package/dist/types/FrontendAPI.js.map +1 -0
- package/package.json +15 -5
- package/auth.ts +0 -140
- package/basePlugin.ts +0 -70
- package/dataConnectors/baseConnector.ts +0 -216
- package/dataConnectors/clickhouse.ts +0 -338
- package/dataConnectors/mongo.ts +0 -202
- package/dataConnectors/postgres.ts +0 -306
- package/dataConnectors/sqlite.ts +0 -254
- package/dist/spa/.eslintrc.cjs +0 -14
- package/dist/spa/README.md +0 -39
- package/dist/spa/env.d.ts +0 -1
- package/dist/spa/index.html +0 -23
- package/dist/spa/package-lock.json +0 -4573
- package/dist/spa/package.json +0 -49
- package/dist/spa/postcss.config.js +0 -6
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +0 -314
- package/dist/spa/src/assets/base.css +0 -2
- package/dist/spa/src/assets/logo.svg +0 -19
- package/dist/spa/src/components/AcceptModal.vue +0 -45
- package/dist/spa/src/components/Breadcrumbs.vue +0 -41
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
- package/dist/spa/src/components/CustomDatePicker.vue +0 -176
- package/dist/spa/src/components/CustomDateRangePicker.vue +0 -218
- package/dist/spa/src/components/CustomRangePicker.vue +0 -152
- package/dist/spa/src/components/Dropdown.vue +0 -168
- package/dist/spa/src/components/Filters.vue +0 -222
- package/dist/spa/src/components/HelloWorld.vue +0 -17
- package/dist/spa/src/components/MenuLink.vue +0 -24
- package/dist/spa/src/components/ResourceForm.vue +0 -294
- package/dist/spa/src/components/ResourceListTable.vue +0 -394
- package/dist/spa/src/components/SingleSkeletLoader.vue +0 -13
- package/dist/spa/src/components/SkeleteLoader.vue +0 -23
- package/dist/spa/src/components/Toast.vue +0 -77
- package/dist/spa/src/components/ValueRenderer.vue +0 -66
- package/dist/spa/src/components/icons/IconCalendar.vue +0 -5
- package/dist/spa/src/components/icons/IconCommunity.vue +0 -7
- package/dist/spa/src/components/icons/IconDocumentation.vue +0 -7
- package/dist/spa/src/components/icons/IconEcosystem.vue +0 -7
- package/dist/spa/src/components/icons/IconSupport.vue +0 -7
- package/dist/spa/src/components/icons/IconTime.vue +0 -5
- package/dist/spa/src/components/icons/IconTooling.vue +0 -19
- package/dist/spa/src/composables/useFrontendApi.ts +0 -26
- package/dist/spa/src/composables/useStores.ts +0 -127
- package/dist/spa/src/index.scss +0 -27
- package/dist/spa/src/main.ts +0 -18
- package/dist/spa/src/router/index.ts +0 -63
- package/dist/spa/src/spa_types/core.ts +0 -51
- package/dist/spa/src/stores/core.ts +0 -144
- package/dist/spa/src/stores/filters.ts +0 -22
- package/dist/spa/src/stores/modal.ts +0 -48
- package/dist/spa/src/stores/toast.ts +0 -15
- package/dist/spa/src/stores/user.ts +0 -72
- package/dist/spa/src/types/AdminForthConfig.ts +0 -1477
- package/dist/spa/src/types/FrontendAPI.ts +0 -121
- package/dist/spa/src/utils.ts +0 -103
- package/dist/spa/src/views/CreateView.vue +0 -156
- package/dist/spa/src/views/EditView.vue +0 -157
- package/dist/spa/src/views/ListView.vue +0 -258
- package/dist/spa/src/views/LoginView.vue +0 -160
- package/dist/spa/src/views/ResourceParent.vue +0 -17
- package/dist/spa/src/views/ShowView.vue +0 -184
- package/dist/spa/tailwind.config.js +0 -17
- package/dist/spa/tsconfig.app.json +0 -14
- package/dist/spa/tsconfig.json +0 -11
- package/dist/spa/tsconfig.node.json +0 -19
- package/dist/spa/vite.config.ts +0 -56
- package/index.ts +0 -428
- package/modules/codeInjector.ts +0 -736
- package/modules/configValidator.ts +0 -571
- package/modules/operationalResource.ts +0 -98
- package/modules/restApi.ts +0 -718
- package/modules/styleGenerator.ts +0 -55
- package/modules/styles.ts +0 -126
- package/modules/utils.ts +0 -472
- package/servers/express.ts +0 -259
- package/spa/.eslintrc.cjs +0 -14
- package/spa/README.md +0 -39
- package/spa/env.d.ts +0 -1
- package/spa/index.html +0 -23
- package/spa/package-lock.json +0 -4602
- package/spa/package.json +0 -51
- package/spa/postcss.config.js +0 -6
- package/spa/public/assets/favicon.png +0 -0
- package/spa/src/App.vue +0 -418
- package/spa/src/assets/base.css +0 -2
- package/spa/src/assets/logo.svg +0 -19
- package/spa/src/components/AcceptModal.vue +0 -45
- package/spa/src/components/Breadcrumbs.vue +0 -41
- package/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
- package/spa/src/components/CustomDatePicker.vue +0 -176
- package/spa/src/components/CustomDateRangePicker.vue +0 -218
- package/spa/src/components/CustomRangePicker.vue +0 -156
- package/spa/src/components/Dropdown.vue +0 -168
- package/spa/src/components/Filters.vue +0 -222
- package/spa/src/components/HelloWorld.vue +0 -17
- package/spa/src/components/MenuLink.vue +0 -27
- package/spa/src/components/ResourceForm.vue +0 -290
- package/spa/src/components/ResourceListTable.vue +0 -466
- package/spa/src/components/SingleSkeletLoader.vue +0 -13
- package/spa/src/components/SkeleteLoader.vue +0 -23
- package/spa/src/components/ThreeDotsMenu.vue +0 -43
- package/spa/src/components/Toast.vue +0 -78
- package/spa/src/components/ValueRenderer.vue +0 -114
- package/spa/src/components/icons/IconCalendar.vue +0 -5
- package/spa/src/components/icons/IconCommunity.vue +0 -7
- package/spa/src/components/icons/IconDocumentation.vue +0 -7
- package/spa/src/components/icons/IconEcosystem.vue +0 -7
- package/spa/src/components/icons/IconSupport.vue +0 -7
- package/spa/src/components/icons/IconTime.vue +0 -5
- package/spa/src/components/icons/IconTooling.vue +0 -19
- package/spa/src/composables/useFrontendApi.ts +0 -26
- package/spa/src/composables/useStores.ts +0 -131
- package/spa/src/index.scss +0 -31
- package/spa/src/main.ts +0 -18
- package/spa/src/renderers/CompactUUID.vue +0 -48
- package/spa/src/renderers/CountryFlag.vue +0 -69
- package/spa/src/router/index.ts +0 -59
- package/spa/src/spa_types/core.ts +0 -53
- package/spa/src/stores/core.ts +0 -148
- package/spa/src/stores/filters.ts +0 -27
- package/spa/src/stores/modal.ts +0 -48
- package/spa/src/stores/toast.ts +0 -31
- package/spa/src/stores/user.ts +0 -72
- package/spa/src/utils.ts +0 -160
- package/spa/src/views/CreateView.vue +0 -167
- package/spa/src/views/EditView.vue +0 -170
- package/spa/src/views/ListView.vue +0 -352
- package/spa/src/views/LoginView.vue +0 -192
- package/spa/src/views/ResourceParent.vue +0 -17
- package/spa/src/views/ShowView.vue +0 -186
- package/spa/tailwind.config.js +0 -17
- package/spa/tsconfig.app.json +0 -14
- package/spa/tsconfig.json +0 -11
- package/spa/tsconfig.node.json +0 -19
- package/spa/vite.config.ts +0 -56
- package/tsconfig.json +0 -112
- package/types/AdminForthConfig.ts +0 -1762
package/dataConnectors/sqlite.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import betterSqlite3 from 'better-sqlite3';
|
|
2
|
-
import { AdminForthDataTypes, AdminForthFilterOperators, AdminForthSortDirections, IAdminForthDataSourceConnector, AdminForthResource, AdminForthResourceColumn } from '../types/AdminForthConfig.js';
|
|
3
|
-
import AdminForthBaseConnector from './baseConnector.js';
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
|
|
6
|
-
class SQLiteConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
|
|
7
|
-
|
|
8
|
-
db: any;
|
|
9
|
-
|
|
10
|
-
constructor({ url }: { url: string }) {
|
|
11
|
-
super();
|
|
12
|
-
// create connection here
|
|
13
|
-
this.db = betterSqlite3(url.replace('sqlite://', ''));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async discoverFields(resource: AdminForthResource): Promise<{[key: string]: AdminForthResourceColumn}> {
|
|
17
|
-
const tableName = resource.table;
|
|
18
|
-
const stmt = this.db.prepare(`PRAGMA table_info(${tableName})`);
|
|
19
|
-
const rows = await stmt.all();
|
|
20
|
-
const fieldTypes = {};
|
|
21
|
-
rows.forEach((row) => {
|
|
22
|
-
const field: any = {};
|
|
23
|
-
const baseType = row.type.toLowerCase();
|
|
24
|
-
if (baseType == 'int') {
|
|
25
|
-
field.type = AdminForthDataTypes.INTEGER;
|
|
26
|
-
field._underlineType = 'int';
|
|
27
|
-
} else if (baseType.includes('varchar(')) {
|
|
28
|
-
field.type = AdminForthDataTypes.STRING;
|
|
29
|
-
field._underlineType = 'varchar';
|
|
30
|
-
const length = baseType.match(/\d+/);
|
|
31
|
-
field.maxLength = length ? parseInt(length[0]) : null;
|
|
32
|
-
} else if (baseType == 'text') {
|
|
33
|
-
field.type = AdminForthDataTypes.TEXT;
|
|
34
|
-
field._underlineType = 'text';
|
|
35
|
-
} else if (baseType.includes('decimal(')) {
|
|
36
|
-
field.type = AdminForthDataTypes.DECIMAL;
|
|
37
|
-
field._underlineType = 'decimal';
|
|
38
|
-
const [precision, scale] = baseType.match(/\d+/g);
|
|
39
|
-
field.precision = parseInt(precision);
|
|
40
|
-
field.scale = parseInt(scale);
|
|
41
|
-
} else if (baseType == 'real') {
|
|
42
|
-
field.type = AdminForthDataTypes.FLOAT; //8-byte IEEE floating point number. It
|
|
43
|
-
field._underlineType = 'real';
|
|
44
|
-
} else if (baseType == 'timestamp') {
|
|
45
|
-
field.type = AdminForthDataTypes.DATETIME;
|
|
46
|
-
field._underlineType = 'timestamp';
|
|
47
|
-
} else if (baseType == 'boolean') {
|
|
48
|
-
field.type = AdminForthDataTypes.BOOLEAN;
|
|
49
|
-
field._underlineType = 'boolean';
|
|
50
|
-
} else if (baseType == 'datetime') {
|
|
51
|
-
field.type = AdminForthDataTypes.DATETIME;
|
|
52
|
-
field._underlineType = 'datetime';
|
|
53
|
-
} else {
|
|
54
|
-
field.type = 'unknown'
|
|
55
|
-
}
|
|
56
|
-
field._baseTypeDebug = baseType;
|
|
57
|
-
field.required = row.notnull == 1;
|
|
58
|
-
field.primaryKey = row.pk == 1;
|
|
59
|
-
field.default = row.dflt_value;
|
|
60
|
-
fieldTypes[row.name] = field
|
|
61
|
-
});
|
|
62
|
-
return fieldTypes;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
getFieldValue(field: AdminForthResourceColumn, value: any): any {
|
|
66
|
-
if (field.type == AdminForthDataTypes.DATETIME) {
|
|
67
|
-
if (!value) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
if (field._underlineType == 'timestamp' || field._underlineType == 'int') {
|
|
71
|
-
return dayjs.unix(+value).toISOString();
|
|
72
|
-
} else if (field._underlineType == 'varchar') {
|
|
73
|
-
return dayjs(value).toISOString();
|
|
74
|
-
} else if (field._underlineType == 'datetime') {
|
|
75
|
-
return dayjs(value).toISOString();
|
|
76
|
-
} else {
|
|
77
|
-
throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps). Issue in field "${field.name}"`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
} else if (field.type == AdminForthDataTypes.DATE) {
|
|
81
|
-
if (!value) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return dayjs(value).toISOString().split('T')[0];
|
|
85
|
-
|
|
86
|
-
} else if (field.type == AdminForthDataTypes.BOOLEAN) {
|
|
87
|
-
return !!value;
|
|
88
|
-
} else if (field.type == AdminForthDataTypes.JSON) {
|
|
89
|
-
if (field._underlineType == 'text' || field._underlineType == 'varchar') {
|
|
90
|
-
return JSON.parse(value);
|
|
91
|
-
} else {
|
|
92
|
-
console.error(`AdminForth: JSON field is not a string/text but ${field._underlineType}, this is not supported yet`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setFieldValue(field: AdminForthResourceColumn, value: any): any {
|
|
100
|
-
if (field.type == AdminForthDataTypes.DATETIME) {
|
|
101
|
-
if (!value) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
if (field._underlineType == 'timestamp' || field._underlineType == 'int') {
|
|
105
|
-
// value is iso string now, convert to unix timestamp
|
|
106
|
-
return dayjs(value).unix();
|
|
107
|
-
} else if (field._underlineType == 'varchar') {
|
|
108
|
-
// value is iso string now, convert to unix timestamp
|
|
109
|
-
return dayjs(value).toISOString();
|
|
110
|
-
} else {
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
} else if (field.type == AdminForthDataTypes.BOOLEAN) {
|
|
114
|
-
return value ? 1 : 0;
|
|
115
|
-
} else if (field.type == AdminForthDataTypes.JSON) {
|
|
116
|
-
// check underline type is text or string
|
|
117
|
-
if (field._underlineType == 'text' || field._underlineType == 'varchar') {
|
|
118
|
-
return JSON.stringify(value);
|
|
119
|
-
} else {
|
|
120
|
-
console.error(`AdminForth: JSON field is not a string/text but ${field._underlineType}, this is not supported yet`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
OperatorsMap = {
|
|
128
|
-
[AdminForthFilterOperators.EQ]: '=',
|
|
129
|
-
[AdminForthFilterOperators.NE]: '!=',
|
|
130
|
-
[AdminForthFilterOperators.GT]: '>',
|
|
131
|
-
[AdminForthFilterOperators.LT]: '<',
|
|
132
|
-
[AdminForthFilterOperators.GTE]: '>=',
|
|
133
|
-
[AdminForthFilterOperators.LTE]: '<=',
|
|
134
|
-
[AdminForthFilterOperators.LIKE]: 'LIKE',
|
|
135
|
-
[AdminForthFilterOperators.ILIKE]: 'ILIKE',
|
|
136
|
-
[AdminForthFilterOperators.IN]: 'IN',
|
|
137
|
-
[AdminForthFilterOperators.NIN]: 'NOT IN',
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
SortDirectionsMap = {
|
|
141
|
-
[AdminForthSortDirections.asc]: 'ASC',
|
|
142
|
-
[AdminForthSortDirections.desc]: 'DESC',
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
whereClause(filters) {
|
|
146
|
-
return filters.length ? `WHERE ${filters.map((f, i) => {
|
|
147
|
-
let placeholder = '?';
|
|
148
|
-
let field = f.field;
|
|
149
|
-
let operator = this.OperatorsMap[f.operator];
|
|
150
|
-
if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
151
|
-
placeholder = `(${f.value.map(() => '?').join(', ')})`;
|
|
152
|
-
} else if (f.operator == AdminForthFilterOperators.ILIKE) {
|
|
153
|
-
placeholder = `LOWER(?)`;
|
|
154
|
-
field = `LOWER(${f.field})`;
|
|
155
|
-
operator = 'LIKE';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return `${field} ${operator} ${placeholder}`
|
|
159
|
-
}).join(' AND ')}` : '';
|
|
160
|
-
}
|
|
161
|
-
whereParams(filters) {
|
|
162
|
-
return filters.reduce((acc, f) => {
|
|
163
|
-
if (f.operator == AdminForthFilterOperators.LIKE || f.operator == AdminForthFilterOperators.ILIKE) {
|
|
164
|
-
acc.push(`%${f.value}%`);
|
|
165
|
-
} else if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
166
|
-
acc.push(...f.value);
|
|
167
|
-
} else {
|
|
168
|
-
acc.push(f.value);
|
|
169
|
-
}
|
|
170
|
-
return acc;
|
|
171
|
-
}, []);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async getDataWithOriginalTypes({ resource, limit, offset, sort, filters }): Promise<any[]> {
|
|
175
|
-
const columns = resource.dataSourceColumns.map((col) => col.name).join(', ');
|
|
176
|
-
const tableName = resource.table;
|
|
177
|
-
|
|
178
|
-
const where = this.whereClause(filters);
|
|
179
|
-
|
|
180
|
-
const filterValues = this.whereParams(filters);
|
|
181
|
-
|
|
182
|
-
const orderBy = sort.length ? `ORDER BY ${sort.map((s) => `${s.field} ${this.SortDirectionsMap[s.direction]}`).join(', ')}` : '';
|
|
183
|
-
|
|
184
|
-
const q = `SELECT ${columns} FROM ${tableName} ${where} ${orderBy} LIMIT ? OFFSET ?`;
|
|
185
|
-
const stmt = this.db.prepare(q);
|
|
186
|
-
const d = [...filterValues, limit, offset];
|
|
187
|
-
|
|
188
|
-
if (process.env.HEAVY_DEBUG) {
|
|
189
|
-
console.log('🪲📜 SQLITE Q', q, 'params:', d);
|
|
190
|
-
}
|
|
191
|
-
const rows = await stmt.all(d);
|
|
192
|
-
|
|
193
|
-
return rows.map((row) => {
|
|
194
|
-
const newRow = {};
|
|
195
|
-
for (const [key, value] of Object.entries(row)) {
|
|
196
|
-
newRow[key] = value;
|
|
197
|
-
}
|
|
198
|
-
return newRow;
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async getCount({ resource, filters }) {
|
|
203
|
-
const tableName = resource.table;
|
|
204
|
-
const where = this.whereClause(filters);
|
|
205
|
-
const filterValues = this.whereParams(filters);
|
|
206
|
-
const totalStmt = this.db.prepare(`SELECT COUNT(*) FROM ${tableName} ${where}`);
|
|
207
|
-
return totalStmt.get([...filterValues])['COUNT(*)'];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }> {
|
|
211
|
-
const tableName = resource.table;
|
|
212
|
-
const result = {};
|
|
213
|
-
await Promise.all(columns.map(async (col) => {
|
|
214
|
-
const stmt = await this.db.prepare(`SELECT MIN(${col.name}) as min, MAX(${col.name}) as max FROM ${tableName}`);
|
|
215
|
-
const { min, max } = stmt.get();
|
|
216
|
-
result[col.name] = {
|
|
217
|
-
min, max,
|
|
218
|
-
};
|
|
219
|
-
}))
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async createRecordOriginalValues({ resource, record }: { resource: AdminForthResource, record: any }) {
|
|
224
|
-
const tableName = resource.table;
|
|
225
|
-
const columns = Object.keys(record);
|
|
226
|
-
const placeholders = columns.map(() => '?').join(', ');
|
|
227
|
-
const values = columns.map((colName) => record[colName]);
|
|
228
|
-
const q = this.db.prepare(`INSERT INTO ${tableName} (${columns.join(', ')}) VALUES (${placeholders})`)
|
|
229
|
-
await q.run(values);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async updateRecordOriginalValues({ resource, recordId, newValues }: { resource: AdminForthResource, recordId: any, newValues: any }) {
|
|
233
|
-
const columnsWithPlaceholders = Object.keys(newValues).map((col) => `${col} = ?`);
|
|
234
|
-
const values = [...Object.values(newValues), recordId];
|
|
235
|
-
|
|
236
|
-
const q = this.db.prepare(
|
|
237
|
-
`UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE ${this.getPrimaryKey(resource)} = ?`
|
|
238
|
-
)
|
|
239
|
-
process.env.HEAVY_DEBUG && console.log('🪲 SQLITE Query', `UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE ${this.getPrimaryKey(resource)} = ?`, 'params:', values);
|
|
240
|
-
await q.run(values);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
async deleteRecord({ resource, recordId }: { resource: AdminForthResource, recordId: any }): Promise<boolean> {
|
|
244
|
-
const q = this.db.prepare(`DELETE FROM ${resource.table} WHERE ${this.getPrimaryKey(resource)} = ?`);
|
|
245
|
-
const res = await q.run(recordId);
|
|
246
|
-
return res.changes > 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
close() {
|
|
250
|
-
this.db.close();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export default SQLiteConnector;
|
package/dist/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/dist/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/dist/spa/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/dist/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=" ">
|
|
20
|
-
<div id="app" class="min-h-screen bg-lightHtml dark:bg-darkHtml"></div>
|
|
21
|
-
<script type="module" src="/src/main.ts"></script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|