1 | import BaseResource from './backend/adapters/base-resource'
|
2 | import BaseDatabase from './backend/adapters/base-database'
|
3 | import { ActionHandler } from './backend/actions/action.interface'
|
4 | import { ResourceOptions } from './backend/decorators/resource-options.interface'
|
5 | import { colors, sizes, fonts, breakpoints } from './frontend/styles/variables'
|
6 |
|
7 | /**
|
8 | * AdminBroOptions
|
9 | *
|
10 | * This is the heart of entire AdminBro - all options resides here.
|
11 | *
|
12 | * @example
|
13 | * const AdminBro = require('admin-bro')
|
14 | * //...
|
15 | * const adminBro = new AdminBro({
|
16 | * rootPath: '/xyz-admin',
|
17 | * logoutPath: '/xyz-admin/exit',
|
18 | * loginPath: '/xyz-admin/sign-in',
|
19 | * databases: [mongooseConnection],
|
20 | * resources: [{ resource: ArticleModel, options: {...}}],
|
21 | * branding: {
|
22 | * companyName: 'XYZ c.o.',
|
23 | * },
|
24 | * })
|
25 | */
|
26 | export default interface AdminBroOptions {
|
27 | /**
|
28 | * path, under which, AdminBro will be available. Default to `/admin`
|
29 | *
|
30 | */
|
31 | rootPath?: string;
|
32 | /**
|
33 | * url to a logout action, default to `/admin/logout`
|
34 | */
|
35 | logoutPath?: string;
|
36 | /**
|
37 | * url to a login page, default to `/admin/login`
|
38 | */
|
39 | loginPath?: string;
|
40 | /**
|
41 | * Array of all Databases which are suported by AdminBro via adapters
|
42 | */
|
43 | databases?: Array<BaseDatabase>;
|
44 |
|
45 | /**
|
46 | * Array of all Resources which are supported by AdminBro via adapters.
|
47 | * You can pass either resource or resource with an options and thus modify it.
|
48 | *
|
49 | * @see ResourceOptions
|
50 | */
|
51 | resources?: Array<BaseResource | {
|
52 | resource: BaseResource;
|
53 | options: ResourceOptions;
|
54 | }>;
|
55 | /**
|
56 | * Option to modify the dashboard
|
57 | */
|
58 | dashboard?: {
|
59 | /**
|
60 | * Handler function which is triggered in the api when user launches the dashboard.
|
61 | */
|
62 | handler?: ActionHandler;
|
63 | /**
|
64 | * Bundled component name which should be rendered when user opens the dashboard
|
65 | */
|
66 | component?: string;
|
67 | };
|
68 | /**
|
69 | * Flag which indicates if version number should be visible on the UI
|
70 | */
|
71 | version?: VersionProps;
|
72 | /**
|
73 | * Options which are related to the branding.
|
74 | */
|
75 | branding?: BrandingOptions;
|
76 | /**
|
77 | * Custom assets you want to pass to AdminBro
|
78 | */
|
79 | assets?: {
|
80 | /**
|
81 | * List to urls of custom stylesheets. You can pass your font - icons here (as an example)
|
82 | */
|
83 | styles?: Array<string>;
|
84 | /**
|
85 | * List of urls to custom scripts. If you use some particular js
|
86 | * library - you can pass its url here.
|
87 | */
|
88 | scripts?: Array<string>;
|
89 | /**
|
90 | * Flag indicates if all default styles and scripts should be fetched from CDN or from local
|
91 | * bundle. Default to CDN. You may change this if your internet connection is slow and you are
|
92 | * developing AdminBro on local machine.
|
93 | */
|
94 | globalsFromCDN: boolean;
|
95 | };
|
96 | /**
|
97 | * Environmental variables passed to the frontend.
|
98 | *
|
99 | * So let say you want to pass some _GOOGLE_MAP_API_TOKEN_ to the frontend.
|
100 | * You can do this by adding it here:
|
101 | *
|
102 | * ```javascript
|
103 | * new AdminBro({env: {
|
104 | * GOOGLE_MAP_API_TOKEN: 'my-token',
|
105 | * }})
|
106 | * ```
|
107 | *
|
108 | * and this token will be available on the frontend by using:
|
109 | *
|
110 | * ```javascript
|
111 | * AdminBro.envs.GOOGLE_MAP_API_TOKEN
|
112 | * ```
|
113 | */
|
114 | env?: Record<string, string>;
|
115 | }
|
116 |
|
117 | /**
|
118 | * Version Props
|
119 | * @alias VersionProps
|
120 | * @memberof AdminBroOptions
|
121 | */
|
122 | export type VersionProps = {
|
123 | /**
|
124 | * if set to true - current admin version will be visible
|
125 | */
|
126 | admin?: boolean;
|
127 | /**
|
128 | * Here you can pass any arbitrary version text which will be seen in the US.
|
129 | * You can pass here your current API version.
|
130 | */
|
131 | app?: string;
|
132 | }
|
133 |
|
134 |
|
135 | /**
|
136 | * Branding Options
|
137 | *
|
138 | * You can use them to change how AdminBro looks. For instance to change name and
|
139 | * colors (dark theme) run:
|
140 | *
|
141 | * ```javascript
|
142 | * const theme = require('admin-bro-theme-dark')
|
143 | *
|
144 | * new AdminBro({
|
145 | * branding: {
|
146 | * companyName: 'John Doe Family Business',
|
147 | * theme,
|
148 | * }
|
149 | * })
|
150 | * ```
|
151 | *
|
152 | * @alias BrandingOptions
|
153 | * @memberof AdminBroOptions
|
154 | */
|
155 | export type BrandingOptions = {
|
156 | /**
|
157 | * URL to a logo.
|
158 | */
|
159 | logo?: string;
|
160 | /**
|
161 | * Name of your company, which will replace "AdminBro".
|
162 | */
|
163 | companyName?: string;
|
164 | /**
|
165 | * CSS theme.
|
166 | */
|
167 | theme?: {
|
168 | colors?: typeof colors;
|
169 | sizes?: typeof sizes;
|
170 | fonts?: typeof fonts;
|
171 | breakpoints?: typeof breakpoints;
|
172 | };
|
173 | /**
|
174 | * Flag indicates if `SoftwareBrothers` tiny hart icon should be visible on the bottom sidebar.
|
175 | */
|
176 | softwareBrothers?: boolean;
|
177 | }
|