millas 0.2.12-beta → 0.2.12-beta-2
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/package.json +3 -16
- package/src/admin/ActivityLog.js +153 -52
- package/src/admin/Admin.js +400 -167
- package/src/admin/AdminAuth.js +213 -98
- package/src/admin/FormGenerator.js +372 -0
- package/src/admin/HookRegistry.js +256 -0
- package/src/admin/QueryEngine.js +263 -0
- package/src/admin/ViewContext.js +309 -0
- package/src/admin/WidgetRegistry.js +406 -0
- package/src/admin/index.js +17 -0
- package/src/admin/resources/AdminResource.js +383 -97
- package/src/admin/static/admin.css +1341 -0
- package/src/admin/static/date-picker.css +157 -0
- package/src/admin/static/date-picker.js +316 -0
- package/src/admin/static/json-editor.css +649 -0
- package/src/admin/static/json-editor.js +1429 -0
- package/src/admin/static/ui.js +1044 -0
- package/src/admin/views/layouts/base.njk +65 -1013
- package/src/admin/views/pages/detail.njk +40 -16
- package/src/admin/views/pages/form.njk +47 -599
- package/src/admin/views/pages/list.njk +145 -62
- package/src/admin/views/partials/form-field.njk +53 -0
- package/src/admin/views/partials/form-footer.njk +28 -0
- package/src/admin/views/partials/form-readonly.njk +114 -0
- package/src/admin/views/partials/form-scripts.njk +476 -0
- package/src/admin/views/partials/form-widget.njk +296 -0
- package/src/admin/views/partials/json-dialog.njk +80 -0
- package/src/admin/views/partials/json-editor.njk +37 -0
- package/src/admin.zip +0 -0
- package/src/auth/Auth.js +31 -10
- package/src/auth/AuthController.js +3 -1
- package/src/auth/AuthUser.js +119 -0
- package/src/cli.js +4 -2
- package/src/commands/createsuperuser.js +254 -0
- package/src/commands/lang.js +589 -0
- package/src/commands/migrate.js +154 -81
- package/src/commands/serve.js +82 -110
- package/src/container/AppInitializer.js +215 -0
- package/src/container/Application.js +278 -253
- package/src/container/HttpServer.js +156 -0
- package/src/container/MillasApp.js +29 -279
- package/src/container/MillasConfig.js +192 -0
- package/src/core/admin.js +5 -0
- package/src/core/auth.js +9 -0
- package/src/core/db.js +9 -0
- package/src/core/foundation.js +59 -0
- package/src/core/http.js +11 -0
- package/src/core/lang.js +1 -0
- package/src/core/mail.js +6 -0
- package/src/core/queue.js +7 -0
- package/src/core/validation.js +29 -0
- package/src/facades/Admin.js +1 -1
- package/src/facades/Auth.js +22 -39
- package/src/facades/Cache.js +21 -10
- package/src/facades/Database.js +1 -1
- package/src/facades/Events.js +18 -17
- package/src/facades/Facade.js +197 -0
- package/src/facades/Http.js +42 -45
- package/src/facades/Log.js +25 -49
- package/src/facades/Mail.js +27 -32
- package/src/facades/Queue.js +22 -15
- package/src/facades/Storage.js +18 -10
- package/src/facades/Url.js +53 -0
- package/src/http/HttpClient.js +673 -0
- package/src/http/ResponseDispatcher.js +18 -111
- package/src/http/UrlGenerator.js +375 -0
- package/src/http/WelcomePage.js +273 -0
- package/src/http/adapters/ExpressAdapter.js +315 -0
- package/src/http/adapters/HttpAdapter.js +168 -0
- package/src/http/adapters/index.js +9 -0
- package/src/i18n/I18nServiceProvider.js +91 -0
- package/src/i18n/Translator.js +635 -0
- package/src/i18n/defaults.js +122 -0
- package/src/i18n/index.js +164 -0
- package/src/i18n/locales/en.js +55 -0
- package/src/i18n/locales/sw.js +48 -0
- package/src/index.js +5 -144
- package/src/logger/formatters/PrettyFormatter.js +103 -57
- package/src/logger/internal.js +2 -2
- package/src/logger/patchConsole.js +91 -81
- package/src/middleware/MiddlewareRegistry.js +62 -82
- package/src/migrations/system/0001_users.js +21 -0
- package/src/migrations/system/0002_admin_log.js +25 -0
- package/src/migrations/system/0003_sessions.js +23 -0
- package/src/orm/fields/index.js +210 -188
- package/src/orm/migration/DefaultValueParser.js +325 -0
- package/src/orm/migration/InteractiveResolver.js +191 -0
- package/src/orm/migration/Makemigrations.js +312 -0
- package/src/orm/migration/MigrationGraph.js +227 -0
- package/src/orm/migration/MigrationRunner.js +202 -108
- package/src/orm/migration/MigrationWriter.js +463 -0
- package/src/orm/migration/ModelInspector.js +412 -344
- package/src/orm/migration/ModelScanner.js +225 -0
- package/src/orm/migration/ProjectState.js +213 -0
- package/src/orm/migration/RenameDetector.js +175 -0
- package/src/orm/migration/SchemaBuilder.js +8 -81
- package/src/orm/migration/operations/base.js +57 -0
- package/src/orm/migration/operations/column.js +191 -0
- package/src/orm/migration/operations/fields.js +252 -0
- package/src/orm/migration/operations/index.js +55 -0
- package/src/orm/migration/operations/models.js +152 -0
- package/src/orm/migration/operations/registry.js +131 -0
- package/src/orm/migration/operations/special.js +51 -0
- package/src/orm/migration/utils.js +208 -0
- package/src/orm/model/Model.js +81 -13
- package/src/providers/AdminServiceProvider.js +66 -9
- package/src/providers/AuthServiceProvider.js +46 -7
- package/src/providers/CacheStorageServiceProvider.js +5 -3
- package/src/providers/DatabaseServiceProvider.js +3 -2
- package/src/providers/EventServiceProvider.js +2 -1
- package/src/providers/LogServiceProvider.js +7 -3
- package/src/providers/MailServiceProvider.js +4 -3
- package/src/providers/QueueServiceProvider.js +4 -3
- package/src/router/Router.js +119 -152
- package/src/scaffold/templates.js +83 -26
- package/src/facades/Validation.js +0 -69
package/src/facades/Log.js
CHANGED
|
@@ -1,56 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {createFacade} = require('./Facade');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Application and internal logging.
|
|
7
|
-
*
|
|
8
|
-
* const { Log, LEVELS } = require('millas/facades/Log');
|
|
7
|
+
* Log facade.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* @class
|
|
10
|
+
* @property {function(TAG:string,message:string,...*): void} v
|
|
11
|
+
* @property {function(TAG:string,message:string,...*): void} d
|
|
12
|
+
* @property {function(TAG:string,message:string,...*): void} i
|
|
13
|
+
* @property {function(TAG:string,message:string,...*): void} w
|
|
14
|
+
* @property {function(TAG:string,message:string,...*): void} e
|
|
15
|
+
* @property {function(TAG:string,message:string,...*): void} wtf
|
|
16
|
+
* @property {function(TAG:string,message:string,...*): void} verbose
|
|
17
|
+
* @property {function(TAG:string,message:string,...*): void} debug
|
|
18
|
+
* @property {function(TAG:string,message:string,...*): void} info
|
|
19
|
+
* @property {function(TAG:string,message:string,...*): void} warn
|
|
20
|
+
* @property {function(TAG:string,message:string,...*): void} error
|
|
21
|
+
* @property {function(string): TaggedLogger} tag
|
|
22
|
+
* @property {function(string): function} time
|
|
23
|
+
* @property {function(string, function): Promise<*>} timed
|
|
24
|
+
* @property {function(object): void} swap
|
|
25
|
+
* @property {function(): void} restore
|
|
15
26
|
*
|
|
16
|
-
*
|
|
17
|
-
* const done = Log.time('DB query');
|
|
18
|
-
* const rows = await db.select();
|
|
19
|
-
* done(); // → D Timer DB query: 42ms
|
|
20
|
-
*
|
|
21
|
-
* // Timed async
|
|
22
|
-
* const users = await Log.timed('fetchUsers', () => User.all());
|
|
27
|
+
* @see src/logger/Logger.js
|
|
23
28
|
*/
|
|
29
|
+
class Log extends createFacade('log') {
|
|
30
|
+
}
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
Log,
|
|
27
|
-
Logger,
|
|
28
|
-
LEVELS,
|
|
29
|
-
LEVEL_NAMES,
|
|
30
|
-
PrettyFormatter,
|
|
31
|
-
JsonFormatter,
|
|
32
|
-
SimpleFormatter,
|
|
33
|
-
ConsoleChannel,
|
|
34
|
-
FileChannel,
|
|
35
|
-
NullChannel,
|
|
36
|
-
StackChannel,
|
|
37
|
-
LogServiceProvider,
|
|
38
|
-
} = require('../index');
|
|
39
|
-
|
|
40
|
-
const MillasLog = require('../logger/internal');
|
|
41
|
-
|
|
42
|
-
module.exports = {
|
|
43
|
-
Log,
|
|
44
|
-
MillasLog,
|
|
45
|
-
Logger,
|
|
46
|
-
LEVELS,
|
|
47
|
-
LEVEL_NAMES,
|
|
48
|
-
PrettyFormatter,
|
|
49
|
-
JsonFormatter,
|
|
50
|
-
SimpleFormatter,
|
|
51
|
-
ConsoleChannel,
|
|
52
|
-
FileChannel,
|
|
53
|
-
NullChannel,
|
|
54
|
-
StackChannel,
|
|
55
|
-
LogServiceProvider,
|
|
56
|
-
};
|
|
32
|
+
module.exports = Log;
|
package/src/facades/Mail.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
const { MailMessage, TemplateEngine, SmtpDriver, SendGridDriver, MailgunDriver, LogDriver, MailServiceProvider } = require('../core');
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
7
|
+
* Mail facade.
|
|
5
8
|
*
|
|
6
|
-
*
|
|
9
|
+
* @class
|
|
10
|
+
* @property {function(MailMessage|object): Promise<void>} send
|
|
11
|
+
* @property {function(MailMessage|object): Promise<void>} queue
|
|
12
|
+
* @property {function(string, string=): MailMessage} to
|
|
13
|
+
* @property {function(object): void} swap
|
|
14
|
+
* @property {function(): void} restore
|
|
7
15
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
16
|
+
* — MailMessage builder (returned by Mail.to())
|
|
17
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.to
|
|
18
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.cc
|
|
19
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.bcc
|
|
20
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.from
|
|
21
|
+
* @property {function(string, string=): MailMessage} MailMessage.prototype.replyTo
|
|
22
|
+
* @property {function(string): MailMessage} MailMessage.prototype.subject
|
|
23
|
+
* @property {function(string): MailMessage} MailMessage.prototype.html
|
|
24
|
+
* @property {function(string): MailMessage} MailMessage.prototype.text
|
|
25
|
+
* @property {function(string, object=): MailMessage} MailMessage.prototype.view
|
|
26
|
+
* @property {function(string, string=, string=): MailMessage} MailMessage.prototype.attach
|
|
27
|
+
* @property {function(number): MailMessage} MailMessage.prototype.priority
|
|
28
|
+
* @property {function(): Promise<void>} MailMessage.prototype.send
|
|
29
|
+
* @property {function(): Promise<void>} MailMessage.prototype.queue
|
|
12
30
|
*
|
|
13
|
-
*
|
|
14
|
-
* await Mail.to(user.email)
|
|
15
|
-
* .subject('Reset your password')
|
|
16
|
-
* .view('emails/reset', { token, user })
|
|
17
|
-
* .send();
|
|
31
|
+
* @see src/mail/Mail.js
|
|
18
32
|
*/
|
|
33
|
+
class Mail extends createFacade('mail') {}
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
Mail,
|
|
22
|
-
MailMessage,
|
|
23
|
-
TemplateEngine,
|
|
24
|
-
SmtpDriver,
|
|
25
|
-
SendGridDriver,
|
|
26
|
-
MailgunDriver,
|
|
27
|
-
LogDriver,
|
|
28
|
-
MailServiceProvider,
|
|
29
|
-
} = require('../index');
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
Mail,
|
|
33
|
-
MailMessage,
|
|
34
|
-
TemplateEngine,
|
|
35
|
-
SmtpDriver,
|
|
36
|
-
SendGridDriver,
|
|
37
|
-
MailgunDriver,
|
|
38
|
-
LogDriver,
|
|
39
|
-
MailServiceProvider,
|
|
40
|
-
};
|
|
35
|
+
module.exports = Mail
|
package/src/facades/Queue.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* const { Queue, Job, dispatch } = require('millas/facades/Queue');
|
|
7
|
-
*
|
|
8
|
-
* class SendWelcomeEmail extends Job {
|
|
9
|
-
* async handle() {
|
|
10
|
-
* await Mail.to(this.data.email).subject('Welcome').send();
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
6
|
+
* Queue facade.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* @class
|
|
9
|
+
* @property {function(Job): Promise<void>} push
|
|
10
|
+
* @property {function(string=): Promise<number>} size
|
|
11
|
+
* @property {function(string=): Promise<void>} clear
|
|
12
|
+
* @property {function(function): void} register
|
|
13
|
+
* @property {function(object): void} swap
|
|
14
|
+
* @property {function(): void} restore
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
* await dispatch(new SendWelcomeEmail({ email }), { delay: 60 });
|
|
16
|
+
* @see src/queue/Queue.js
|
|
19
17
|
*/
|
|
18
|
+
class Queue extends createFacade('queue') {}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Shorthand for Queue.push(job).
|
|
22
|
+
*
|
|
23
|
+
* @param {Job} job
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
async function dispatch(job) {
|
|
27
|
+
return Queue.push(job);
|
|
28
|
+
}
|
|
22
29
|
|
|
23
|
-
module.exports =
|
|
30
|
+
module.exports = Queue;
|
package/src/facades/Storage.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { createFacade } = require('./Facade');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Storage facade.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
8
|
+
* @class
|
|
9
|
+
* @property {function(string, Buffer|string, object=): Promise<void>} put
|
|
10
|
+
* @property {function(string): Promise<Buffer|string>} get
|
|
11
|
+
* @property {function(string): Promise<boolean>} exists
|
|
12
|
+
* @property {function(string): Promise<void>} delete
|
|
13
|
+
* @property {function(string): Promise<object>} metadata
|
|
14
|
+
* @property {function(string): string} url
|
|
15
|
+
* @property {function(string): string} path
|
|
16
|
+
* @property {function(string, object, object=): void} stream
|
|
17
|
+
* @property {function(string): Storage} disk
|
|
18
|
+
* @property {function(object): void} swap
|
|
19
|
+
* @property {function(): void} restore
|
|
7
20
|
*
|
|
8
|
-
*
|
|
9
|
-
* const url = await Storage.url('avatars/user-5.jpg');
|
|
10
|
-
* const data = await Storage.get('avatars/user-5.jpg');
|
|
11
|
-
* await Storage.delete('avatars/user-5.jpg');
|
|
12
|
-
* const exists = await Storage.exists('avatars/user-5.jpg');
|
|
21
|
+
* @see src/storage/Storage.js
|
|
13
22
|
*/
|
|
23
|
+
class Storage extends createFacade('storage') {}
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
module.exports = { Storage, LocalDriver, StorageServiceProvider };
|
|
25
|
+
module.exports = Storage;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {createFacade} = require('./Facade');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* URL facade — Laravel-like URL generation.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
*
|
|
10
|
+
* — Base
|
|
11
|
+
* @property {function(): string} base
|
|
12
|
+
*
|
|
13
|
+
* — URL generation
|
|
14
|
+
* @property {function(string, object=): string} to
|
|
15
|
+
* @property {function(string, object=): string} secure
|
|
16
|
+
* @property {function(string, object=): string} relative
|
|
17
|
+
*
|
|
18
|
+
* — Named routes
|
|
19
|
+
* @property {function(string, object=, object=): string} route
|
|
20
|
+
*
|
|
21
|
+
* — Assets
|
|
22
|
+
* @property {function(string): string} asset
|
|
23
|
+
* @property {function(string): string} secureAsset
|
|
24
|
+
*
|
|
25
|
+
* — Current / previous request
|
|
26
|
+
* @property {function(): string|null} current
|
|
27
|
+
* @property {function(): string|null} currentPath
|
|
28
|
+
* @property {function(string=): string} previous
|
|
29
|
+
*
|
|
30
|
+
* — Signed URLs
|
|
31
|
+
* @property {function(string, object=, number=): string} signedRoute
|
|
32
|
+
* @property {function(string, number=): string} signedUrl
|
|
33
|
+
* @property {function(object): boolean} hasValidSignature
|
|
34
|
+
*
|
|
35
|
+
* — Scheme control
|
|
36
|
+
* @property {function(boolean=): UrlGenerator} forceHttps
|
|
37
|
+
* @property {function(string): UrlGenerator} forceScheme
|
|
38
|
+
* @property {function(string): UrlGenerator} useAssetOrigin
|
|
39
|
+
*
|
|
40
|
+
* — Introspection
|
|
41
|
+
* @property {function(string): boolean} isValid
|
|
42
|
+
* @property {function(...string): boolean} is
|
|
43
|
+
*
|
|
44
|
+
* — Testing
|
|
45
|
+
* @property {function(object): void} swap
|
|
46
|
+
* @property {function(): void} restore
|
|
47
|
+
*
|
|
48
|
+
* @see src/http/UrlGenerator.js
|
|
49
|
+
*/
|
|
50
|
+
class URL extends createFacade('url') {
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = URL;
|