@galadrim/galadmin 0.1.140 → 0.1.142

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.
@@ -1,65 +1,64 @@
1
- export type Filter = {}
1
+ export type Filter = {};
2
2
 
3
3
  export type BaseTypeColumn = {
4
- label: string,
5
- hideInTable?: boolean,
6
- canEditOnCreation?: boolean,
7
- includedInCreatePayload?: boolean,
8
- canEdit?: boolean,
9
- hidden?: boolean,
10
- formattedValue?: string,
11
- formatValue?: (record: any) => string | Promise<string>,
12
- formatValueForExport?: (record: any) => string | Promise<string>,
13
- searchable?: boolean,
14
- searchableName?: string,
15
- labelTooltip?: string,
16
- required?: boolean,
17
- includeInExport?: boolean,
18
- displayCondition?: (record: any) => boolean,
19
- }
4
+ label: string;
5
+ hideInTable?: boolean;
6
+ canEditOnCreation?: boolean;
7
+ includedInCreatePayload?: boolean;
8
+ canEdit?: boolean;
9
+ hidden?: boolean;
10
+ formattedValue?: string;
11
+ formatValue?: (record: any) => string | Promise<string>;
12
+ formatValueForExport?: (record: any) => string | Promise<string>;
13
+ searchable?: boolean;
14
+ searchableName?: string;
15
+ labelTooltip?: string;
16
+ required?: boolean;
17
+ includeInExport?: boolean;
18
+ displayCondition?: (record: any) => boolean;
19
+ };
20
20
 
21
21
  export type ColorColumn = {
22
- dataType: 'color',
23
- name: string
24
- }
22
+ dataType: 'color';
23
+ name: string;
24
+ };
25
25
 
26
26
  export type StandardColumn = {
27
- name?: string,
28
- dataType?: string
29
- }
30
-
27
+ name?: string;
28
+ dataType?: string;
29
+ };
31
30
 
32
31
  export type SelectColumn = {
33
- dataType: 'select',
34
- name: string,
35
- options: string[] | { [key: string]: string },
36
- defaultOption: string,
37
- optional?: boolean
38
- }
32
+ dataType: 'select';
33
+ name: string;
34
+ options: string[] | { [key: string]: string };
35
+ defaultOption: string;
36
+ optional?: boolean;
37
+ };
39
38
 
40
39
  export type AddressColumn = {
41
- dataType: 'address',
42
- latitudeField?: string,
43
- longitudeField?: string,
44
- addressField?: string,
45
- streetNumberField?: string,
46
- routeField?: string,
47
- localityField?: string,
48
- administrativeAreaLevel2Field?: string,
49
- administrativeAreaLevel1Field?: string,
50
- countryField?: string,
51
- postalCodeField?: string,
52
- }
40
+ dataType: 'address';
41
+ latitudeField?: string;
42
+ longitudeField?: string;
43
+ addressField?: string;
44
+ streetNumberField?: string;
45
+ routeField?: string;
46
+ localityField?: string;
47
+ administrativeAreaLevel2Field?: string;
48
+ administrativeAreaLevel1Field?: string;
49
+ countryField?: string;
50
+ postalCodeField?: string;
51
+ };
53
52
 
54
53
  export type DateColumn = {
55
- dataType: 'date',
56
- name: string
57
- }
54
+ dataType: 'date';
55
+ name: string;
56
+ };
58
57
 
59
58
  export type DatetimeColumn = {
60
- dataType: 'datetime',
61
- name: string
62
- }
59
+ dataType: 'datetime';
60
+ name: string;
61
+ };
63
62
 
64
63
  export type ForeignSelectColumn = {
65
64
  dataType: 'foreign',
@@ -70,6 +69,7 @@ export type ForeignSelectColumn = {
70
69
  selectExpression?: string,
71
70
  join?: string,
72
71
  filters?: Filter[],
72
+ filtersFromUser?: (userId: number) => string,
73
73
  orderBy?: string,
74
74
  optional?: boolean,
75
75
  formatForeignValue?: (record: any) => string,
@@ -85,312 +85,322 @@ export type ForeignDatalistColumn = {
85
85
  selectExpression?: string,
86
86
  join?: string,
87
87
  filters?: Filter[],
88
+ filtersFromUser?: (userId: number) => string,
88
89
  orderBy?: string,
89
90
  optional?: boolean,
90
91
  formatForeignValue?: (record: any) => string,
91
92
  }
92
93
 
93
94
  export type TextareaColumn = {
94
- dataType: 'textarea',
95
- name: string,
96
- }
95
+ dataType: 'textarea';
96
+ name: string;
97
+ };
97
98
 
98
99
  export type RichTextColumn = {
99
- dataType: "richText";
100
+ dataType: 'richText';
100
101
  htmlField: string;
101
102
  contentField?: string;
102
103
  };
103
104
 
104
105
  export type BetterRichTextColumn = {
105
- dataType: "betterRichText";
106
+ dataType: 'betterRichText';
106
107
  htmlField: string;
107
108
  fileUploadProperties?: FileUploadProperties;
108
109
  };
109
110
 
110
111
  export type FileColumn = {
111
- dataType: 'file',
112
- name: string
113
- } & FileUploadProperties
112
+ dataType: 'file';
113
+ name: string;
114
+ } & FileUploadProperties;
114
115
 
115
116
  export type FileUploadProperties = {
116
- publicPath?: string,
117
- subdirectory?: string,
118
- aspectRatioField?: string,
119
- originalNameField?: string,
117
+ publicPath?: string;
118
+ subdirectory?: string;
119
+ aspectRatioField?: string;
120
+ originalNameField?: string;
120
121
  s3Config?: {
121
- host: string,
122
- accessKeyId: string,
123
- secretAccessKey: string,
124
- bucket: string,
125
- subfolder?: string
126
- signedUrlNeeded?: boolean,
127
- region?: string,
128
- },
122
+ host: string;
123
+ accessKeyId: string;
124
+ secretAccessKey: string;
125
+ bucket: string;
126
+ subfolder?: string;
127
+ signedUrlNeeded?: boolean;
128
+ region?: string;
129
+ };
129
130
  sftpConfig?: {
130
- host: string,
131
- user: string,
132
- password: string
133
- }
134
- }
131
+ host: string;
132
+ user: string;
133
+ password: string;
134
+ };
135
+ };
135
136
 
136
- export type Column = BaseTypeColumn & (
137
- StandardColumn |
138
- ColorColumn |
139
- SelectColumn |
140
- AddressColumn |
141
- DateColumn |
142
- DatetimeColumn |
143
- ForeignSelectColumn |
144
- ForeignDatalistColumn |
145
- RichTextColumn |
146
- BetterRichTextColumn |
147
- TextareaColumn |
148
- FileColumn
149
- )
137
+ export type Column = BaseTypeColumn &
138
+ (
139
+ | StandardColumn
140
+ | ColorColumn
141
+ | SelectColumn
142
+ | AddressColumn
143
+ | DateColumn
144
+ | DatetimeColumn
145
+ | ForeignSelectColumn
146
+ | ForeignDatalistColumn
147
+ | RichTextColumn
148
+ | BetterRichTextColumn
149
+ | TextareaColumn
150
+ | FileColumn
151
+ );
150
152
 
151
153
  export type CreateType = {
152
- canCreate: true,
153
- aNewSingular: string,
154
- createFilters?: { [key: string]: string },
154
+ canCreate: true;
155
+ aNewSingular: string;
156
+ createFilters?: { [key: string]: string };
155
157
  createConfig?: {
156
- redirectToCreatedItems?: boolean
157
- }
158
- }
158
+ redirectToCreatedItems?: boolean;
159
+ };
160
+ };
159
161
 
160
162
  export type CustomAction = {
161
- label: string,
162
- action: (record: any) => void,
163
- successMessage?: string
164
- }
163
+ label: string;
164
+ action: (record: any) => void;
165
+ successMessage?: string;
166
+ };
165
167
 
166
168
  export type FormDataFile = {
167
- fieldName: string,
168
- originalFilename: string,
169
- path: string,
170
- headers: { [key: string]: string },
171
- size: number
172
- }
169
+ fieldName: string;
170
+ originalFilename: string;
171
+ path: string;
172
+ headers: { [key: string]: string };
173
+ size: number;
174
+ };
173
175
 
174
176
  export type TableView = {
175
- type: 'table',
176
- icon?: string,
177
- label: string,
178
- tableName: string,
179
- primaryId?: string,
180
- customQuery?: string,
181
- selectExpression?: string,
182
- join?: string,
183
- groupBy?: string,
184
- orderBy?: string,
185
- isDesc?: boolean,
186
- limit?: number,
187
- filters?: string,
188
- filtersFromUser?: (userId: number) => string,
189
- notClickable?: boolean,
190
- clickToEdit?: boolean,
191
- openInNewTab?: boolean,
192
- customActions?: CustomAction[],
177
+ type: 'table';
178
+ icon?: string;
179
+ label: string;
180
+ tableName: string;
181
+ primaryId?: string;
182
+ customQuery?: string;
183
+ selectExpression?: string;
184
+ join?: string;
185
+ groupBy?: string;
186
+ orderBy?: string;
187
+ isDesc?: boolean;
188
+ limit?: number;
189
+ filters?: string;
190
+ filtersFromUser?: (userId: number) => string;
191
+ notClickable?: boolean;
192
+ clickToEdit?: boolean;
193
+ openInNewTab?: boolean;
194
+ customActions?: CustomAction[];
193
195
  /** Rendre possible à l'utilisateur de créer des enregistrements */
194
196
  /** Rendre possible à l'utilisateur de supprimer des enregistrements */
195
- canDelete?: boolean,
197
+ canDelete?: boolean;
196
198
  /** Rendre possible à l'utilisateur de modifier des enregistrements */
197
- canEdit?: boolean,
199
+ canEdit?: boolean;
198
200
  /** Rendre possible à l'utilisateur de télécharger les enregistrements (par défaut : true) */
199
- canExport?: boolean,
201
+ canExport?: boolean;
200
202
  /** Rendre possible à l'utilisateur d'importer des enregistrements (par défaut : false) */
201
- canImport?: boolean,
203
+ canImport?: boolean;
202
204
  /**
203
205
  * Types de fichier acceptés pour l'import, au format de l'attribut {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers accept}.
204
206
  * @example [".xlsx", ".xls", ".csv"]
205
207
  */
206
- importFileTypes?: string[],
208
+ importFileTypes?: string[];
207
209
  /** Obligatoire si `canImport` est `true`. Prend le fichier d'import en paramètre et renvoie une liste d'entités. */
208
- parseImportFile?: (file: FormDataFile) => Promise<any[]>,
209
- createCallback?: string,
210
- createCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
211
- editCallback?: string,
212
- editCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
213
- deleteCallback?: string,
214
- deleteCallbackFunction?: ({ id }: { id: number }) => void,
215
- columns: Column[],
216
- subviews?: Subview[],
217
- recordViewPanels?: ViewPanel[],
218
- importFileUniqueField?: string
219
- } & (CreateType | { canCreate?: false })
210
+ parseImportFile?: (file: FormDataFile) => Promise<any[]>;
211
+ createCallback?: string;
212
+ createCallbackFunction?: ({ id, data }: { id: number; data: any }) => void;
213
+ editCallback?: string;
214
+ editCallbackFunction?: ({ id, data }: { id: number; data: any }) => void;
215
+ deleteCallback?: string;
216
+ deleteCallbackFunction?: ({ id }: { id: number }) => void;
217
+ columns: Column[];
218
+ subviews?: Subview[];
219
+ recordViewPanels?: ViewPanel[];
220
+ importFileUniqueField?: string;
221
+ } & (CreateType | { canCreate?: false });
220
222
 
221
223
  export type Subview = {
222
- label: string,
223
- filters: string,
224
- orderBy?: string
225
- }
224
+ label: string;
225
+ filters: string;
226
+ orderBy?: string;
227
+ };
226
228
 
227
229
  export type BaseTypePanel = {
228
- label: string,
229
- folded?: boolean,
230
- displayCondition?: (record: any) => boolean,
231
- }
230
+ label: string;
231
+ folded?: boolean;
232
+ displayCondition?: (record: any) => boolean;
233
+ };
232
234
 
233
235
  export type CreateConfig = {
234
- label: string,
235
- recordIdKey: string,
236
- columns: Column[],
237
- redirectToCreatedItems?: boolean
238
- }
236
+ label: string;
237
+ recordIdKey: string;
238
+ columns: Column[];
239
+ redirectToCreatedItems?: boolean;
240
+ };
239
241
 
240
242
  export type TablePanel = {
241
- type: "table",
242
- query: string,
243
- formattedQuery?: string,
244
- canDownload?: boolean,
245
- canShow?: boolean,
246
- canDelete?: boolean,
247
- canCreate?: boolean,
248
- canImport?: boolean,
243
+ type: 'table';
244
+ query: string;
245
+ formattedQuery?: string;
246
+ canDownload?: boolean;
247
+ canShow?: boolean;
248
+ canDelete?: boolean;
249
+ canCreate?: boolean;
250
+ canImport?: boolean;
249
251
  /**
250
252
  * Types de fichier acceptés pour l'import, au format de l'attribut {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers accept}.
251
253
  * @example [".xlsx", ".xls", ".csv"]
252
254
  */
253
- importFileTypes?: string[],
255
+ importFileTypes?: string[];
254
256
  /** Obligatoire si `canImport` est `true`. Prend le fichier d'import en paramètre et renvoie une liste d'entités. id correspond a l'identité du parent */
255
- parseImportFile?: (file: FormDataFile, id?: number) => Promise<any[]>,
257
+ parseImportFile?: (file: FormDataFile, id?: any) => Promise<any[]>;
256
258
  /** Obligatoire si `canImport` est `true`. */
257
- createConfig?: CreateConfig,
258
- tableName?: string,
259
- primaryId?: string,
259
+ createConfig?: CreateConfig;
260
+ tableName?: string;
261
+ primaryId?: string;
260
262
  formatValue?: {
261
- [key: string]: (record: any) => string | Promise<string>
262
- },
263
- formattedValues?: { [key: string]: string },
264
- createCallback?: string,
265
- createCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
266
- deleteCallback?: string,
267
- deleteCallbackFunction?: ({ id }: { id: number }) => void,
268
- }
263
+ [key: string]: (record: any) => string | Promise<string>;
264
+ };
265
+ formattedValues?: { [key: string]: string };
266
+ createCallback?: string;
267
+ createCallbackFunction?: ({ id, data }: { id: number; data: any }) => void;
268
+ deleteCallback?: string;
269
+ deleteCallbackFunction?: ({ id }: { id: number }) => void;
270
+ };
269
271
 
270
272
  export type MapPanel = {
271
- type: "map",
272
- query: string,
273
- latitudeField: string,
274
- longitudeField: string,
275
- zoom?: number,
276
- }
273
+ type: 'map';
274
+ query: string;
275
+ latitudeField: string;
276
+ longitudeField: string;
277
+ zoom?: number;
278
+ };
277
279
 
278
280
  export type GalleryPanel = {
279
- type: "gallery",
280
- query: string,
281
- canDelete?: boolean,
282
- canCreate?: boolean,
283
- createConfig?: CreateConfig,
284
- tableName?: string,
285
- primaryId?: string,
286
- baseUrl?: string,
287
- pathField?: string,
288
- objectFit?: 'cover' | 'contain',
289
- createCallback?: string,
290
- createCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
291
- deleteCallback?: string,
292
- deleteCallbackFunction?: ({ id, deletedRecord }: { id: number, deletedRecord?: any }) => void,
293
- }
281
+ type: 'gallery';
282
+ query: string;
283
+ canDelete?: boolean;
284
+ canCreate?: boolean;
285
+ createConfig?: CreateConfig;
286
+ tableName?: string;
287
+ primaryId?: string;
288
+ baseUrl?: string;
289
+ pathField?: string;
290
+ objectFit?: 'cover' | 'contain';
291
+ createCallback?: string;
292
+ createCallbackFunction?: ({ id, data }: { id: number; data: any }) => void;
293
+ deleteCallback?: string;
294
+ deleteCallbackFunction?: ({
295
+ id,
296
+ deletedRecord,
297
+ }: {
298
+ id: number;
299
+ deletedRecord?: any;
300
+ }) => void;
301
+ };
294
302
 
295
303
  export type ChatPanel = {
296
- type: "chat",
304
+ type: 'chat';
297
305
  /* Requête SQL pour récupérer les messages échangés */
298
- getMessagesQuery: string,
306
+ getMessagesQuery: string;
299
307
  /* URL pour envoyer un message */
300
- postMessageUrl: string,
301
- messageField: string,
302
- isAdminField: string,
303
- datetimeField: string,
308
+ postMessageUrl: string;
309
+ messageField: string;
310
+ isAdminField: string;
311
+ datetimeField: string;
304
312
  /* Clé secrète transmise à la route d'envoi de message */
305
- secretKey?: string
306
- }
313
+ secretKey?: string;
314
+ };
307
315
 
308
- export type ViewPanel = BaseTypePanel & (TablePanel | MapPanel | GalleryPanel | ChatPanel)
316
+ export type ViewPanel = BaseTypePanel &
317
+ (TablePanel | MapPanel | GalleryPanel | ChatPanel);
309
318
 
310
319
  export type IframeView = {
311
- type: 'iframe',
312
- src: string,
313
- icon?: string,
314
- label: string
315
- }
320
+ type: 'iframe';
321
+ src: string;
322
+ icon?: string;
323
+ label: string;
324
+ };
316
325
 
317
326
  export type LinkView = {
318
- type: 'link',
319
- src: string,
320
- icon?: string,
321
- label: string
322
- }
327
+ type: 'link';
328
+ src: string;
329
+ icon?: string;
330
+ label: string;
331
+ };
323
332
 
324
333
  export type CustomView = {
325
- type: 'custom',
326
- icon?: string,
327
- label: string,
328
- componentPath: string,
329
- componentProps?: any
330
- }
334
+ type: 'custom';
335
+ icon?: string;
336
+ label: string;
337
+ componentPath: string;
338
+ componentProps?: any;
339
+ };
331
340
 
332
341
  export type BaseTypeView = {
333
342
  /** Cache la vue dans le menu latéral */
334
- hidden?: boolean,
335
- roles?: string[]
336
- }
343
+ hidden?: boolean;
344
+ roles?: string[];
345
+ };
337
346
 
338
- export type View = BaseTypeView & (TableView | IframeView | LinkView | CustomView)
347
+ export type View = BaseTypeView &
348
+ (TableView | IframeView | LinkView | CustomView);
339
349
 
340
350
  export type AuthRole = {
341
- role: string,
342
- table: string,
343
- usernameField: string,
344
- passwordField: string,
345
- idField: string,
346
- }
351
+ role: string;
352
+ table: string;
353
+ usernameField: string;
354
+ passwordField: string;
355
+ idField: string;
356
+ };
347
357
 
348
358
  export type Config = {
349
359
  /** Nom du projet */
350
- name: string,
360
+ name: string;
351
361
 
352
362
  /** Chaîne de caractères aléatoires qui permet de chiffrer les cookies de session */
353
- sessionSecret: string,
363
+ sessionSecret: string;
354
364
 
355
- useMysql2?: boolean,
365
+ useMysql2?: boolean;
356
366
 
357
367
  /** Identifiants permettant d'accéder au back-office */
358
368
  auth: {
359
369
  /** Nom d'utilisateur */
360
- username: string,
370
+ username: string;
361
371
 
362
372
  /** Password */
363
- password: string
364
- },
373
+ password: string;
374
+ };
365
375
 
366
- authRoles?: AuthRole[],
376
+ authRoles?: AuthRole[];
367
377
 
368
378
  /** Identifiants de connexion à la base de données */
369
379
  mysql?: {
370
- host: string,
371
- user: string,
372
- password: string,
373
- database: string,
374
- port?: number
375
- },
380
+ host: string;
381
+ user: string;
382
+ password: string;
383
+ database: string;
384
+ port?: number;
385
+ };
376
386
 
377
387
  postgresql?: {
378
- host: string,
379
- user: string,
380
- password: string,
381
- database: string,
382
- port?: number
383
- ssl?: any
384
- },
388
+ host: string;
389
+ user: string;
390
+ password: string;
391
+ database: string;
392
+ port?: number;
393
+ ssl?: any;
394
+ };
385
395
 
386
396
  /** Clé API Google Maps pour les champs adresses et l'affichage de cartes */
387
- googleMapsKey?: string,
397
+ googleMapsKey?: string;
388
398
 
389
399
  /** Désactiver la sélection multiple dans les vues de type table */
390
- hideMultiselect?: boolean,
400
+ hideMultiselect?: boolean;
391
401
 
392
402
  /** Cache l'inscription Made with love by Galadrim */
393
- hideBranding?: boolean,
403
+ hideBranding?: boolean;
394
404
 
395
- views: View[]
396
- }
405
+ views: View[];
406
+ };