@galadrim/galadmin 0.1.139 → 0.1.141

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,396 +1,404 @@
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
- dataType: 'foreign',
66
- name: string,
67
- table: string,
68
- foreignName?: string,
69
- limit?: number,
70
- selectExpression?: string,
71
- join?: string,
72
- filters?: Filter[],
73
- orderBy?: string,
74
- optional?: boolean,
75
- formatForeignValue?: (record: any) => string,
76
- }
64
+ dataType: 'foreign';
65
+ name: string;
66
+ table: string;
67
+ foreignName?: string;
68
+ limit?: number;
69
+ selectExpression?: string;
70
+ join?: string;
71
+ filters?: Filter[];
72
+ orderBy?: string;
73
+ optional?: boolean;
74
+ formatForeignValue?: (record: any) => string;
75
+ };
77
76
 
78
77
  export type ForeignDatalistColumn = {
79
- dataType: 'datalist',
80
- name: string,
81
- table: string,
82
- foreignName?: string,
83
- wholeSearch?: boolean,
84
- limit?: number,
85
- selectExpression?: string,
86
- join?: string,
87
- filters?: Filter[],
88
- orderBy?: string,
89
- optional?: boolean,
90
- formatForeignValue?: (record: any) => string,
91
- }
78
+ dataType: 'datalist';
79
+ name: string;
80
+ table: string;
81
+ foreignName?: string;
82
+ wholeSearch?: boolean;
83
+ limit?: number;
84
+ selectExpression?: string;
85
+ join?: string;
86
+ filters?: Filter[];
87
+ orderBy?: string;
88
+ optional?: boolean;
89
+ formatForeignValue?: (record: any) => string;
90
+ };
92
91
 
93
92
  export type TextareaColumn = {
94
- dataType: 'textarea',
95
- name: string,
96
- }
93
+ dataType: 'textarea';
94
+ name: string;
95
+ };
97
96
 
98
97
  export type RichTextColumn = {
99
- dataType: "richText";
100
- htmlField: string;
101
- contentField?: string;
98
+ dataType: 'richText';
99
+ htmlField: string;
100
+ contentField?: string;
102
101
  };
103
102
 
104
103
  export type BetterRichTextColumn = {
105
- dataType: "betterRichText";
106
- htmlField: string;
107
- fileUploadProperties?: FileUploadProperties;
104
+ dataType: 'betterRichText';
105
+ htmlField: string;
106
+ fileUploadProperties?: FileUploadProperties;
108
107
  };
109
108
 
110
109
  export type FileColumn = {
111
- dataType: 'file',
112
- name: string
113
- } & FileUploadProperties
110
+ dataType: 'file';
111
+ name: string;
112
+ } & FileUploadProperties;
114
113
 
115
114
  export type FileUploadProperties = {
116
- publicPath?: string,
117
- subdirectory?: string,
118
- aspectRatioField?: string,
119
- originalNameField?: string,
120
- s3Config?: {
121
- host: string,
122
- accessKeyId: string,
123
- secretAccessKey: string,
124
- bucket: string,
125
- subfolder?: string
126
- signedUrlNeeded?: boolean,
127
- region?: string,
128
- },
129
- sftpConfig?: {
130
- host: string,
131
- user: string,
132
- password: string
133
- }
134
- }
135
-
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
- )
115
+ publicPath?: string;
116
+ subdirectory?: string;
117
+ aspectRatioField?: string;
118
+ originalNameField?: string;
119
+ s3Config?: {
120
+ host: string;
121
+ accessKeyId: string;
122
+ secretAccessKey: string;
123
+ bucket: string;
124
+ subfolder?: string;
125
+ signedUrlNeeded?: boolean;
126
+ region?: string;
127
+ };
128
+ sftpConfig?: {
129
+ host: string;
130
+ user: string;
131
+ password: string;
132
+ };
133
+ };
134
+
135
+ export type Column = BaseTypeColumn &
136
+ (
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
+ );
150
150
 
151
151
  export type CreateType = {
152
- canCreate: true,
153
- aNewSingular: string,
154
- createFilters?: { [key: string]: string },
155
- createConfig?: {
156
- redirectToCreatedItems?: boolean
157
- }
158
- }
152
+ canCreate: true;
153
+ aNewSingular: string;
154
+ createFilters?: { [key: string]: string };
155
+ createConfig?: {
156
+ redirectToCreatedItems?: boolean;
157
+ };
158
+ };
159
159
 
160
160
  export type CustomAction = {
161
- label: string,
162
- action: (record: any) => void,
163
- successMessage?: string
164
- }
161
+ label: string;
162
+ action: (record: any) => void;
163
+ successMessage?: string;
164
+ };
165
165
 
166
166
  export type FormDataFile = {
167
- fieldName: string,
168
- originalFilename: string,
169
- path: string,
170
- headers: { [key: string]: string },
171
- size: number
172
- }
167
+ fieldName: string;
168
+ originalFilename: string;
169
+ path: string;
170
+ headers: { [key: string]: string };
171
+ size: number;
172
+ };
173
173
 
174
174
  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[],
193
- /** Rendre possible à l'utilisateur de créer des enregistrements */
194
- /** Rendre possible à l'utilisateur de supprimer des enregistrements */
195
- canDelete?: boolean,
196
- /** Rendre possible à l'utilisateur de modifier des enregistrements */
197
- canEdit?: boolean,
198
- /** Rendre possible à l'utilisateur de télécharger les enregistrements (par défaut : true) */
199
- canExport?: boolean,
200
- /** Rendre possible à l'utilisateur d'importer des enregistrements (par défaut : false) */
201
- canImport?: boolean,
202
- /**
203
- * 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
- * @example [".xlsx", ".xls", ".csv"]
205
- */
206
- importFileTypes?: string[],
207
- /** 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 })
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[];
193
+ /** Rendre possible à l'utilisateur de créer des enregistrements */
194
+ /** Rendre possible à l'utilisateur de supprimer des enregistrements */
195
+ canDelete?: boolean;
196
+ /** Rendre possible à l'utilisateur de modifier des enregistrements */
197
+ canEdit?: boolean;
198
+ /** Rendre possible à l'utilisateur de télécharger les enregistrements (par défaut : true) */
199
+ canExport?: boolean;
200
+ /** Rendre possible à l'utilisateur d'importer des enregistrements (par défaut : false) */
201
+ canImport?: boolean;
202
+ /**
203
+ * 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
+ * @example [".xlsx", ".xls", ".csv"]
205
+ */
206
+ importFileTypes?: string[];
207
+ /** 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 });
220
220
 
221
221
  export type Subview = {
222
- label: string,
223
- filters: string,
224
- orderBy?: string
225
- }
222
+ label: string;
223
+ filters: string;
224
+ orderBy?: string;
225
+ };
226
226
 
227
227
  export type BaseTypePanel = {
228
- label: string,
229
- folded?: boolean,
230
- displayCondition?: (record: any) => boolean,
231
- }
228
+ label: string;
229
+ folded?: boolean;
230
+ displayCondition?: (record: any) => boolean;
231
+ };
232
232
 
233
233
  export type CreateConfig = {
234
- label: string,
235
- recordIdKey: string,
236
- columns: Column[],
237
- redirectToCreatedItems?: boolean
238
- }
234
+ label: string;
235
+ recordIdKey: string;
236
+ columns: Column[];
237
+ redirectToCreatedItems?: boolean;
238
+ };
239
239
 
240
240
  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,
249
- /**
250
- * 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
- * @example [".xlsx", ".xls", ".csv"]
252
- */
253
- importFileTypes?: string[],
254
- /** Obligatoire si `canImport` est `true`. Prend le fichier d'import en paramètre et renvoie une liste d'entités. **Ne pas inclure l'identifiant de l'entité parente.** */
255
- parseImportFile?: (file: FormDataFile) => Promise<any[]>,
256
- /** Obligatoire si `canImport` est `true`. */
257
- createConfig?: CreateConfig,
258
- tableName?: string,
259
- primaryId?: string,
260
- 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
- }
241
+ type: 'table';
242
+ query: string;
243
+ formattedQuery?: string;
244
+ canDownload?: boolean;
245
+ canShow?: boolean;
246
+ canDelete?: boolean;
247
+ canCreate?: boolean;
248
+ canImport?: boolean;
249
+ /**
250
+ * 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
+ * @example [".xlsx", ".xls", ".csv"]
252
+ */
253
+ importFileTypes?: string[];
254
+ /** 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?: any) => Promise<any[]>;
256
+ /** Obligatoire si `canImport` est `true`. */
257
+ createConfig?: CreateConfig;
258
+ tableName?: string;
259
+ primaryId?: string;
260
+ 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
+ };
269
269
 
270
270
  export type MapPanel = {
271
- type: "map",
272
- query: string,
273
- latitudeField: string,
274
- longitudeField: string,
275
- zoom?: number,
276
- }
271
+ type: 'map';
272
+ query: string;
273
+ latitudeField: string;
274
+ longitudeField: string;
275
+ zoom?: number;
276
+ };
277
277
 
278
278
  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
- }
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?: ({
293
+ id,
294
+ deletedRecord,
295
+ }: {
296
+ id: number;
297
+ deletedRecord?: any;
298
+ }) => void;
299
+ };
294
300
 
295
301
  export type ChatPanel = {
296
- type: "chat",
297
- /* Requête SQL pour récupérer les messages échangés */
298
- getMessagesQuery: string,
299
- /* URL pour envoyer un message */
300
- postMessageUrl: string,
301
- messageField: string,
302
- isAdminField: string,
303
- datetimeField: string,
304
- /* Clé secrète transmise à la route d'envoi de message */
305
- secretKey?: string
306
- }
307
-
308
- export type ViewPanel = BaseTypePanel & (TablePanel | MapPanel | GalleryPanel | ChatPanel)
302
+ type: 'chat';
303
+ /* Requête SQL pour récupérer les messages échangés */
304
+ getMessagesQuery: string;
305
+ /* URL pour envoyer un message */
306
+ postMessageUrl: string;
307
+ messageField: string;
308
+ isAdminField: string;
309
+ datetimeField: string;
310
+ /* Clé secrète transmise à la route d'envoi de message */
311
+ secretKey?: string;
312
+ };
313
+
314
+ export type ViewPanel = BaseTypePanel &
315
+ (TablePanel | MapPanel | GalleryPanel | ChatPanel);
309
316
 
310
317
  export type IframeView = {
311
- type: 'iframe',
312
- src: string,
313
- icon?: string,
314
- label: string
315
- }
318
+ type: 'iframe';
319
+ src: string;
320
+ icon?: string;
321
+ label: string;
322
+ };
316
323
 
317
324
  export type LinkView = {
318
- type: 'link',
319
- src: string,
320
- icon?: string,
321
- label: string
322
- }
325
+ type: 'link';
326
+ src: string;
327
+ icon?: string;
328
+ label: string;
329
+ };
323
330
 
324
331
  export type CustomView = {
325
- type: 'custom',
326
- icon?: string,
327
- label: string,
328
- componentPath: string,
329
- componentProps?: any
330
- }
332
+ type: 'custom';
333
+ icon?: string;
334
+ label: string;
335
+ componentPath: string;
336
+ componentProps?: any;
337
+ };
331
338
 
332
339
  export type BaseTypeView = {
333
- /** Cache la vue dans le menu latéral */
334
- hidden?: boolean,
335
- roles?: string[]
336
- }
340
+ /** Cache la vue dans le menu latéral */
341
+ hidden?: boolean;
342
+ roles?: string[];
343
+ };
337
344
 
338
- export type View = BaseTypeView & (TableView | IframeView | LinkView | CustomView)
345
+ export type View = BaseTypeView &
346
+ (TableView | IframeView | LinkView | CustomView);
339
347
 
340
348
  export type AuthRole = {
341
- role: string,
342
- table: string,
343
- usernameField: string,
344
- passwordField: string,
345
- idField: string,
346
- }
349
+ role: string;
350
+ table: string;
351
+ usernameField: string;
352
+ passwordField: string;
353
+ idField: string;
354
+ };
347
355
 
348
356
  export type Config = {
349
- /** Nom du projet */
350
- name: string,
351
-
352
- /** Chaîne de caractères aléatoires qui permet de chiffrer les cookies de session */
353
- sessionSecret: string,
354
-
355
- useMysql2?: boolean,
356
-
357
- /** Identifiants permettant d'accéder au back-office */
358
- auth: {
359
- /** Nom d'utilisateur */
360
- username: string,
361
-
362
- /** Password */
363
- password: string
364
- },
365
-
366
- authRoles?: AuthRole[],
367
-
368
- /** Identifiants de connexion à la base de données */
369
- mysql?: {
370
- host: string,
371
- user: string,
372
- password: string,
373
- database: string,
374
- port?: number
375
- },
376
-
377
- postgresql?: {
378
- host: string,
379
- user: string,
380
- password: string,
381
- database: string,
382
- port?: number
383
- ssl?: any
384
- },
385
-
386
- /** Clé API Google Maps pour les champs adresses et l'affichage de cartes */
387
- googleMapsKey?: string,
388
-
389
- /** Désactiver la sélection multiple dans les vues de type table */
390
- hideMultiselect?: boolean,
391
-
392
- /** Cache l'inscription Made with love by Galadrim */
393
- hideBranding?: boolean,
394
-
395
- views: View[]
396
- }
357
+ /** Nom du projet */
358
+ name: string;
359
+
360
+ /** Chaîne de caractères aléatoires qui permet de chiffrer les cookies de session */
361
+ sessionSecret: string;
362
+
363
+ useMysql2?: boolean;
364
+
365
+ /** Identifiants permettant d'accéder au back-office */
366
+ auth: {
367
+ /** Nom d'utilisateur */
368
+ username: string;
369
+
370
+ /** Password */
371
+ password: string;
372
+ };
373
+
374
+ authRoles?: AuthRole[];
375
+
376
+ /** Identifiants de connexion à la base de données */
377
+ mysql?: {
378
+ host: string;
379
+ user: string;
380
+ password: string;
381
+ database: string;
382
+ port?: number;
383
+ };
384
+
385
+ postgresql?: {
386
+ host: string;
387
+ user: string;
388
+ password: string;
389
+ database: string;
390
+ port?: number;
391
+ ssl?: any;
392
+ };
393
+
394
+ /** Clé API Google Maps pour les champs adresses et l'affichage de cartes */
395
+ googleMapsKey?: string;
396
+
397
+ /** Désactiver la sélection multiple dans les vues de type table */
398
+ hideMultiselect?: boolean;
399
+
400
+ /** Cache l'inscription Made with love by Galadrim */
401
+ hideBranding?: boolean;
402
+
403
+ views: View[];
404
+ };