adminforth 1.1.92 → 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.
Files changed (39) hide show
  1. package/dataConnectors/baseConnector.ts +2 -2
  2. package/dataConnectors/mongo.ts +2 -2
  3. package/dataConnectors/postgres.ts +2 -2
  4. package/dataConnectors/sqlite.ts +2 -2
  5. package/dist/plugins/TwoFactorsAuthPlugin/index.js +2 -3
  6. package/dist/spa/spa/src/components/Toast.vue +1 -1
  7. package/index.ts +5 -5
  8. package/modules/codeInjector.ts +2 -2
  9. package/package.json +2 -2
  10. package/plugins/AuditLogPlugin/index.ts +3 -3
  11. package/plugins/ForeignInlineListPlugin/index.ts +4 -4
  12. package/plugins/S3UploadPlugin/custom/s3uploader.vue +24 -4
  13. package/plugins/S3UploadPlugin/index.ts +4 -4
  14. package/plugins/S3UploadPlugin/package.json +1 -1
  15. package/plugins/TwoFactorsAuthPlugin/dist/auth.js +108 -0
  16. package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/baseConnector.js +90 -0
  17. package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/mongo.js +191 -0
  18. package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/postgres.js +295 -0
  19. package/plugins/TwoFactorsAuthPlugin/dist/dataConnectors/sqlite.js +246 -0
  20. package/plugins/TwoFactorsAuthPlugin/dist/index.js +1186 -0
  21. package/plugins/TwoFactorsAuthPlugin/dist/modules/codeInjector.js +546 -0
  22. package/plugins/TwoFactorsAuthPlugin/dist/modules/styleGenerator.js +43 -0
  23. package/plugins/TwoFactorsAuthPlugin/dist/modules/styles.js +92 -0
  24. package/plugins/TwoFactorsAuthPlugin/dist/modules/utils.js +301 -0
  25. package/plugins/TwoFactorsAuthPlugin/dist/plugins/TwoFactorsAuthPlugin/index.js +149 -0
  26. package/plugins/TwoFactorsAuthPlugin/dist/plugins/TwoFactorsAuthPlugin/types.js +1 -0
  27. package/plugins/TwoFactorsAuthPlugin/dist/plugins/base.js +34 -0
  28. package/plugins/TwoFactorsAuthPlugin/dist/servers/express.js +230 -0
  29. package/plugins/TwoFactorsAuthPlugin/dist/types/AdminForthConfig.js +105 -0
  30. package/plugins/TwoFactorsAuthPlugin/index.ts +10 -10
  31. package/plugins/TwoFactorsAuthPlugin/package-lock.json +2 -2
  32. package/plugins/TwoFactorsAuthPlugin/package.json +8 -6
  33. package/plugins/TwoFactorsAuthPlugin/tsconfig.json +112 -0
  34. package/plugins/base.ts +4 -4
  35. package/servers/express.ts +4 -4
  36. package/spa/src/components/Toast.vue +1 -1
  37. package/tsconfig.json +1 -1
  38. package/types/AdminForthConfig.ts +34 -28
  39. package/types/FrontendAPI.ts +2 -1
@@ -1,6 +1,6 @@
1
1
  import { Express } from 'express';
2
2
 
3
- export interface CodeInjectorType {
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 GenericHttpServer {
11
+ export interface IHttpServer {
12
12
 
13
- // constructor(adminforth: AdminForthClass): void;
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 ExpressHttpServer extends GenericHttpServer {
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 AdminForthDataSourceConnector {
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 AdminForthDataSourceConnector.getFieldValue} and {@link AdminForthDataSourceConnector.setFieldValue} methods.
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 AdminForthDataSourceConnector.getFieldValue}
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 AdminForthDataSourceConnector.getFieldValue}
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 AdminForthDataSourceConnector.getFieldValue} for both min and max values.
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 AdminForthDataSourceConnectorBase extends AdminForthDataSourceConnector {
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 AdminForthDataSourceConnectorConstructor {
193
- new ({ url }: { url: string }): AdminForthDataSourceConnector;
192
+ export interface IAdminForthDataSourceConnectorConstructor {
193
+ new ({ url }: { url: string }): IAdminForthDataSourceConnector;
194
194
  }
195
195
 
196
- export interface AdminForthClass {
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: CodeInjectorType;
199
- express: GenericHttpServer;
207
+ codeInjector: ICodeInjector;
208
+ express: IHttpServer;
200
209
 
201
210
  connectors: {
202
- [key: string]: AdminForthDataSourceConnectorBase;
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: GenericHttpServer): void;
242
+ setupEndpoints(server: IHttpServer): void;
237
243
  }
238
244
 
239
245
 
240
- export interface AdminForthPluginType {
241
- adminforth: AdminForthClass;
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 AdminForthClass
258
+ * @param adminforth Instance of IAdminForth
253
259
  * @param resourceConfig Resource configuration object which will be modified by plugin
254
260
  */
255
- modifyResourceConfig(adminforth: AdminForthClass, resourceConfig: AdminForthResource): void;
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: GenericHttpServer): void;
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<AdminForthPluginType>,
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]: AdminForthDataSourceConnectorConstructor,
893
+ [key: string]: IAdminForthDataSourceConnectorConstructor,
888
894
  },
889
895
 
890
896
  /**
@@ -94,7 +94,8 @@ export type AlertParams = {
94
94
  variant?: AlertVariant | keyof typeof AlertVariant;
95
95
 
96
96
  /**
97
- * The timeout of the alert in seconds or 'unlimited' to keep the alert open until the user closes it
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;
98
99
  */
99
100
  timeout?: number | 'unlimited';
100
101