adminforth 1.1.91 → 1.1.93
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/baseConnector.ts +2 -2
- package/dataConnectors/mongo.ts +2 -2
- package/dataConnectors/postgres.ts +2 -2
- package/dataConnectors/sqlite.ts +2 -2
- package/dist/plugins/TwoFactorsAuthPlugin/index.js +2 -3
- package/dist/spa/spa/src/components/Toast.vue +1 -1
- package/index.ts +5 -5
- package/modules/codeInjector.ts +2 -2
- package/package.json +2 -2
- package/plugins/AuditLogPlugin/index.ts +3 -3
- package/plugins/ForeignInlineListPlugin/index.ts +4 -4
- package/plugins/S3UploadPlugin/custom/s3uploader.vue +24 -4
- package/plugins/S3UploadPlugin/index.ts +4 -4
- package/plugins/S3UploadPlugin/package.json +1 -1
- package/plugins/TwoFactorsAuthPlugin/dist/auth.js +108 -0
- package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/baseConnector.js +90 -0
- package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/mongo.js +191 -0
- package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/postgres.js +295 -0
- package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/sqlite.js +246 -0
- package/plugins/TwoFactorsAuthPlugin/dist/index.js +1186 -0
- package/plugins/TwoFactorsAuthPlugin/dist/modules/codeInjector.js +546 -0
- package/plugins/TwoFactorsAuthPlugin/dist/modules/styleGenerator.js +43 -0
- package/plugins/TwoFactorsAuthPlugin/dist/modules/styles.js +92 -0
- package/plugins/TwoFactorsAuthPlugin/dist/modules/utils.js +301 -0
- package/plugins/TwoFactorsAuthPlugin/dist/plugins/TwoFactorsAuthPlugin/index.js +149 -0
- package/plugins/TwoFactorsAuthPlugin/dist/plugins/TwoFactorsAuthPlugin/types.js +1 -0
- package/plugins/TwoFactorsAuthPlugin/dist/plugins/base.js +34 -0
- package/plugins/TwoFactorsAuthPlugin/dist/servers/express.js +230 -0
- package/plugins/TwoFactorsAuthPlugin/dist/types/AdminForthConfig.js +105 -0
- package/plugins/TwoFactorsAuthPlugin/index.ts +10 -10
- package/plugins/TwoFactorsAuthPlugin/package-lock.json +2 -2
- package/plugins/TwoFactorsAuthPlugin/package.json +8 -6
- package/plugins/TwoFactorsAuthPlugin/tsconfig.json +112 -0
- package/plugins/base.ts +4 -4
- package/servers/express.ts +4 -4
- package/spa/src/components/Toast.vue +1 -1
- package/tsconfig.json +1 -1
- package/types/AdminForthConfig.ts +34 -28
- package/types/FrontendAPI.ts +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface ICodeInjector {
|
|
4
4
|
srcFoldersToSync: Object;
|
|
5
5
|
allComponentNames: Object;
|
|
6
6
|
}
|
|
@@ -8,9 +8,9 @@ export interface CodeInjectorType {
|
|
|
8
8
|
/**
|
|
9
9
|
* Implement this interface to create custom HTTP server adapter for AdminForth.
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
11
|
+
export interface IHttpServer {
|
|
12
12
|
|
|
13
|
-
// constructor(adminforth:
|
|
13
|
+
// constructor(adminforth: IAdminForth): void;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Sets up HTTP server to serve AdminForth SPA.
|
|
@@ -51,7 +51,7 @@ export type AdminUser = {
|
|
|
51
51
|
dbUser: any,
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export interface
|
|
54
|
+
export interface IExpressHttpServer extends IHttpServer {
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Call this method to serve AdminForth SPA from Express instance.
|
|
@@ -77,7 +77,7 @@ export interface ExpressHttpServer extends GenericHttpServer {
|
|
|
77
77
|
authorize(callable: Function): void;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export interface
|
|
80
|
+
export interface IAdminForthDataSourceConnector {
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Function which will be called to fetch record from database.
|
|
@@ -100,7 +100,7 @@ export interface AdminForthDataSourceConnector {
|
|
|
100
100
|
* - {@link AdminForthResourceColumn.max}
|
|
101
101
|
* - {@link AdminForthResourceColumn.minValue}, {@link AdminForthResourceColumn.maxValue}, {@link AdminForthResourceColumn.enum}, {@link AdminForthResourceColumn.foreignResource}, {@link AdminForthResourceColumn.sortable}, {@link AdminForthResourceColumn.backendOnly}, {@link AdminForthResourceColumn.masked}, {@link AdminForthResourceColumn.virtual}, {@link AdminForthResourceColumn.components}, {@link AdminForthResourceColumn.allowMinMaxQuery}, {@link AdminForthResourceColumn.editingNote}, {@link AdminForthResourceColumn.showIn}, {@link AdminForthResourceColumn.isUnique}, {@link AdminForthResourceColumn.validation})
|
|
102
102
|
* Also you can additionally save original column type to {@link AdminForthResourceColumn._underlineType}. This might be later used
|
|
103
|
-
* in {@link
|
|
103
|
+
* in {@link IAdminForthDataSourceConnector.getFieldValue} and {@link IAdminForthDataSourceConnector.setFieldValue} methods.
|
|
104
104
|
*
|
|
105
105
|
*
|
|
106
106
|
* @param resource
|
|
@@ -117,7 +117,7 @@ export interface AdminForthDataSourceConnector {
|
|
|
117
117
|
getFieldValue(field: AdminForthResourceColumn, value: any): any;
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* Used to transform record before saving to database. Should perform operation inverse to {@link
|
|
120
|
+
* Used to transform record before saving to database. Should perform operation inverse to {@link IAdminForthDataSourceConnector.getFieldValue}
|
|
121
121
|
* @param field
|
|
122
122
|
* @param value
|
|
123
123
|
*/
|
|
@@ -127,7 +127,7 @@ export interface AdminForthDataSourceConnector {
|
|
|
127
127
|
* Used to fetch data from database.
|
|
128
128
|
* This method is reused both to list records and show one record (by passing limit 1 and offset 0) .
|
|
129
129
|
*
|
|
130
|
-
* Fields are returned from db "as is" then {@link AdminForthBaseConnector.getData} will transform each field using {@link
|
|
130
|
+
* Fields are returned from db "as is" then {@link AdminForthBaseConnector.getData} will transform each field using {@link IAdminForthDataSourceConnector.getFieldValue}
|
|
131
131
|
*/
|
|
132
132
|
getDataWithOriginalTypes({ resource, limit, offset, sort, filters }: {
|
|
133
133
|
resource: AdminForthResource,
|
|
@@ -142,7 +142,7 @@ export interface AdminForthDataSourceConnector {
|
|
|
142
142
|
* Optional method which used to get min and max values for columns in resource.
|
|
143
143
|
* Called only for columns which have {@link AdminForthResourceColumn.allowMinMaxQuery} set to true.
|
|
144
144
|
*
|
|
145
|
-
* Internally should call {@link
|
|
145
|
+
* Internally should call {@link IAdminForthDataSourceConnector.getFieldValue} for both min and max values.
|
|
146
146
|
*/
|
|
147
147
|
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
|
|
148
148
|
|
|
@@ -171,7 +171,7 @@ export interface AdminForthDataSourceConnector {
|
|
|
171
171
|
/**
|
|
172
172
|
* Interface that exposes methods to interact with AdminForth in standard way
|
|
173
173
|
*/
|
|
174
|
-
export interface
|
|
174
|
+
export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourceConnector {
|
|
175
175
|
|
|
176
176
|
getPrimaryKey(resource: AdminForthResource): string;
|
|
177
177
|
|
|
@@ -189,25 +189,31 @@ export interface AdminForthDataSourceConnectorBase extends AdminForthDataSourceC
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
|
|
192
|
-
export interface
|
|
193
|
-
new ({ url }: { url: string }):
|
|
192
|
+
export interface IAdminForthDataSourceConnectorConstructor {
|
|
193
|
+
new ({ url }: { url: string }): IAdminForthDataSourceConnector;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
export interface
|
|
196
|
+
export interface IAdminForthAuth {
|
|
197
|
+
verify(jwt : string, mustHaveType: string): Promise<any>;
|
|
198
|
+
issueJWT(payload: Object, type: string): string;
|
|
199
|
+
|
|
200
|
+
removeCustomCookie({response, name}: {response: any, name: string}): void;
|
|
201
|
+
|
|
202
|
+
setAuthCookie({response, username, pk,}: {response: any, username: string, pk: string}): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface IAdminForth {
|
|
197
206
|
config: AdminForthConfig;
|
|
198
|
-
codeInjector:
|
|
199
|
-
express:
|
|
207
|
+
codeInjector: ICodeInjector;
|
|
208
|
+
express: IHttpServer;
|
|
200
209
|
|
|
201
210
|
connectors: {
|
|
202
|
-
[key: string]:
|
|
211
|
+
[key: string]: IAdminForthDataSourceConnectorBase;
|
|
203
212
|
};
|
|
204
213
|
|
|
205
214
|
createResourceRecord(params: { resource: AdminForthResource, record: any, adminUser: AdminUser }): Promise<any>;
|
|
206
215
|
|
|
207
|
-
auth:
|
|
208
|
-
verify(jwt : string, mustHaveType: string): Promise<any>;
|
|
209
|
-
issueJWT(payload: Object, type: string): string;
|
|
210
|
-
}
|
|
216
|
+
auth: IAdminForthAuth;
|
|
211
217
|
|
|
212
218
|
/**
|
|
213
219
|
* Internal flag which indicates if AdminForth is running in hot reload mode.
|
|
@@ -233,12 +239,12 @@ export interface AdminForthClass {
|
|
|
233
239
|
/**
|
|
234
240
|
* This method will be automatically called from AdminForth HTTP adapter to serve AdminForth SPA.
|
|
235
241
|
*/
|
|
236
|
-
setupEndpoints(server:
|
|
242
|
+
setupEndpoints(server: IHttpServer): void;
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
|
|
240
|
-
export interface
|
|
241
|
-
adminforth:
|
|
246
|
+
export interface IAdminForthPlugin {
|
|
247
|
+
adminforth: IAdminForth;
|
|
242
248
|
pluginDir: string;
|
|
243
249
|
customFolderName: string;
|
|
244
250
|
pluginInstanceId: string;
|
|
@@ -249,10 +255,10 @@ export interface AdminForthPluginType {
|
|
|
249
255
|
* {@link AdminForthResourceColumn.components} object, then add some hook which will modify record before getting or saving it to database.
|
|
250
256
|
*
|
|
251
257
|
* So this method is core of AdminForth plugins. It allows to modify full resource configuration.
|
|
252
|
-
* @param adminforth Instance of
|
|
258
|
+
* @param adminforth Instance of IAdminForth
|
|
253
259
|
* @param resourceConfig Resource configuration object which will be modified by plugin
|
|
254
260
|
*/
|
|
255
|
-
modifyResourceConfig(adminforth:
|
|
261
|
+
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
256
262
|
componentPath(componentFile: string): string;
|
|
257
263
|
|
|
258
264
|
/**
|
|
@@ -260,7 +266,7 @@ export interface AdminForthPluginType {
|
|
|
260
266
|
*
|
|
261
267
|
* @param server
|
|
262
268
|
*/
|
|
263
|
-
setupEndpoints(server:
|
|
269
|
+
setupEndpoints(server: IHttpServer): void;
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
export enum AdminForthMenuTypes {
|
|
@@ -666,7 +672,7 @@ export type AdminForthResource = {
|
|
|
666
672
|
* Array of plugins which will be used to modify resource configuration.
|
|
667
673
|
*
|
|
668
674
|
*/
|
|
669
|
-
plugins?: Array<
|
|
675
|
+
plugins?: Array<IAdminForthPlugin>,
|
|
670
676
|
hooks?: {
|
|
671
677
|
show?: {
|
|
672
678
|
beforeDatasourceRequest?: BeforeDataSourceRequestFunction | Array<BeforeDataSourceRequestFunction>,
|
|
@@ -884,7 +890,7 @@ export type AdminForthConfig = {
|
|
|
884
890
|
*
|
|
885
891
|
*/
|
|
886
892
|
databaseConnectors?: {
|
|
887
|
-
[key: string]:
|
|
893
|
+
[key: string]: IAdminForthDataSourceConnectorConstructor,
|
|
888
894
|
},
|
|
889
895
|
|
|
890
896
|
/**
|
package/types/FrontendAPI.ts
CHANGED
|
@@ -87,13 +87,15 @@ export type AlertParams = {
|
|
|
87
87
|
* The message to display in the alert
|
|
88
88
|
*/
|
|
89
89
|
message?: string;
|
|
90
|
+
|
|
90
91
|
/**
|
|
91
92
|
* The variant of the alert
|
|
92
93
|
*/
|
|
93
94
|
variant?: AlertVariant | keyof typeof AlertVariant;
|
|
94
95
|
|
|
95
96
|
/**
|
|
96
|
-
* The timeout of the alert
|
|
97
|
+
* The timeout of the alert in seconds or 'unlimited' to keep the alert open until the user closes it.
|
|
98
|
+
* Default is 10 seconds;
|
|
97
99
|
*/
|
|
98
100
|
timeout?: number | 'unlimited';
|
|
99
101
|
|