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.
Files changed (116) hide show
  1. package/package.json +3 -16
  2. package/src/admin/ActivityLog.js +153 -52
  3. package/src/admin/Admin.js +400 -167
  4. package/src/admin/AdminAuth.js +213 -98
  5. package/src/admin/FormGenerator.js +372 -0
  6. package/src/admin/HookRegistry.js +256 -0
  7. package/src/admin/QueryEngine.js +263 -0
  8. package/src/admin/ViewContext.js +309 -0
  9. package/src/admin/WidgetRegistry.js +406 -0
  10. package/src/admin/index.js +17 -0
  11. package/src/admin/resources/AdminResource.js +383 -97
  12. package/src/admin/static/admin.css +1341 -0
  13. package/src/admin/static/date-picker.css +157 -0
  14. package/src/admin/static/date-picker.js +316 -0
  15. package/src/admin/static/json-editor.css +649 -0
  16. package/src/admin/static/json-editor.js +1429 -0
  17. package/src/admin/static/ui.js +1044 -0
  18. package/src/admin/views/layouts/base.njk +65 -1013
  19. package/src/admin/views/pages/detail.njk +40 -16
  20. package/src/admin/views/pages/form.njk +47 -599
  21. package/src/admin/views/pages/list.njk +145 -62
  22. package/src/admin/views/partials/form-field.njk +53 -0
  23. package/src/admin/views/partials/form-footer.njk +28 -0
  24. package/src/admin/views/partials/form-readonly.njk +114 -0
  25. package/src/admin/views/partials/form-scripts.njk +476 -0
  26. package/src/admin/views/partials/form-widget.njk +296 -0
  27. package/src/admin/views/partials/json-dialog.njk +80 -0
  28. package/src/admin/views/partials/json-editor.njk +37 -0
  29. package/src/admin.zip +0 -0
  30. package/src/auth/Auth.js +31 -10
  31. package/src/auth/AuthController.js +3 -1
  32. package/src/auth/AuthUser.js +119 -0
  33. package/src/cli.js +4 -2
  34. package/src/commands/createsuperuser.js +254 -0
  35. package/src/commands/lang.js +589 -0
  36. package/src/commands/migrate.js +154 -81
  37. package/src/commands/serve.js +82 -110
  38. package/src/container/AppInitializer.js +215 -0
  39. package/src/container/Application.js +278 -253
  40. package/src/container/HttpServer.js +156 -0
  41. package/src/container/MillasApp.js +29 -279
  42. package/src/container/MillasConfig.js +192 -0
  43. package/src/core/admin.js +5 -0
  44. package/src/core/auth.js +9 -0
  45. package/src/core/db.js +9 -0
  46. package/src/core/foundation.js +59 -0
  47. package/src/core/http.js +11 -0
  48. package/src/core/lang.js +1 -0
  49. package/src/core/mail.js +6 -0
  50. package/src/core/queue.js +7 -0
  51. package/src/core/validation.js +29 -0
  52. package/src/facades/Admin.js +1 -1
  53. package/src/facades/Auth.js +22 -39
  54. package/src/facades/Cache.js +21 -10
  55. package/src/facades/Database.js +1 -1
  56. package/src/facades/Events.js +18 -17
  57. package/src/facades/Facade.js +197 -0
  58. package/src/facades/Http.js +42 -45
  59. package/src/facades/Log.js +25 -49
  60. package/src/facades/Mail.js +27 -32
  61. package/src/facades/Queue.js +22 -15
  62. package/src/facades/Storage.js +18 -10
  63. package/src/facades/Url.js +53 -0
  64. package/src/http/HttpClient.js +673 -0
  65. package/src/http/ResponseDispatcher.js +18 -111
  66. package/src/http/UrlGenerator.js +375 -0
  67. package/src/http/WelcomePage.js +273 -0
  68. package/src/http/adapters/ExpressAdapter.js +315 -0
  69. package/src/http/adapters/HttpAdapter.js +168 -0
  70. package/src/http/adapters/index.js +9 -0
  71. package/src/i18n/I18nServiceProvider.js +91 -0
  72. package/src/i18n/Translator.js +635 -0
  73. package/src/i18n/defaults.js +122 -0
  74. package/src/i18n/index.js +164 -0
  75. package/src/i18n/locales/en.js +55 -0
  76. package/src/i18n/locales/sw.js +48 -0
  77. package/src/index.js +5 -144
  78. package/src/logger/formatters/PrettyFormatter.js +103 -57
  79. package/src/logger/internal.js +2 -2
  80. package/src/logger/patchConsole.js +91 -81
  81. package/src/middleware/MiddlewareRegistry.js +62 -82
  82. package/src/migrations/system/0001_users.js +21 -0
  83. package/src/migrations/system/0002_admin_log.js +25 -0
  84. package/src/migrations/system/0003_sessions.js +23 -0
  85. package/src/orm/fields/index.js +210 -188
  86. package/src/orm/migration/DefaultValueParser.js +325 -0
  87. package/src/orm/migration/InteractiveResolver.js +191 -0
  88. package/src/orm/migration/Makemigrations.js +312 -0
  89. package/src/orm/migration/MigrationGraph.js +227 -0
  90. package/src/orm/migration/MigrationRunner.js +202 -108
  91. package/src/orm/migration/MigrationWriter.js +463 -0
  92. package/src/orm/migration/ModelInspector.js +412 -344
  93. package/src/orm/migration/ModelScanner.js +225 -0
  94. package/src/orm/migration/ProjectState.js +213 -0
  95. package/src/orm/migration/RenameDetector.js +175 -0
  96. package/src/orm/migration/SchemaBuilder.js +8 -81
  97. package/src/orm/migration/operations/base.js +57 -0
  98. package/src/orm/migration/operations/column.js +191 -0
  99. package/src/orm/migration/operations/fields.js +252 -0
  100. package/src/orm/migration/operations/index.js +55 -0
  101. package/src/orm/migration/operations/models.js +152 -0
  102. package/src/orm/migration/operations/registry.js +131 -0
  103. package/src/orm/migration/operations/special.js +51 -0
  104. package/src/orm/migration/utils.js +208 -0
  105. package/src/orm/model/Model.js +81 -13
  106. package/src/providers/AdminServiceProvider.js +66 -9
  107. package/src/providers/AuthServiceProvider.js +46 -7
  108. package/src/providers/CacheStorageServiceProvider.js +5 -3
  109. package/src/providers/DatabaseServiceProvider.js +3 -2
  110. package/src/providers/EventServiceProvider.js +2 -1
  111. package/src/providers/LogServiceProvider.js +7 -3
  112. package/src/providers/MailServiceProvider.js +4 -3
  113. package/src/providers/QueueServiceProvider.js +4 -3
  114. package/src/router/Router.js +119 -152
  115. package/src/scaffold/templates.js +83 -26
  116. package/src/facades/Validation.js +0 -69
@@ -161,6 +161,7 @@
161
161
  </a>
162
162
  {% elif ra.action %}
163
163
  <form method="POST" action="{{ adminPrefix }}/{{ resource.slug }}/{{ record.id }}/action/{{ ra.action }}" style="display:inline">
164
+ <input type="hidden" name="_csrf" value="{{ csrfToken }}">
164
165
  <button type="submit" class="btn btn-ghost btn-sm">
165
166
  <span class="icon icon-13"><svg viewBox="0 0 24 24"><use href="#ic-{{ ra.icon or 'check' }}"/></svg></span>
166
167
  {{ ra.label }}
@@ -179,6 +180,8 @@
179
180
  {% if inlines | length %}
180
181
  <div style="max-width:860px;margin-top:24px">
181
182
  {% for inline in inlines %}
183
+ {% set inlineIndex = loop.index0 %}
184
+ {% set inlineBase = adminPrefix + '/' + resource.slug + '/' + record.id + '/inline/' + inlineIndex %}
182
185
  <div class="card mb-5">
183
186
  <div class="card-header">
184
187
  <span class="card-title">
@@ -191,14 +194,40 @@
191
194
  {% endif %}
192
195
  </span>
193
196
  {% if inline.canCreate %}
194
- <a href="{{ adminPrefix }}/{{ inline.label | lower | replace(' ', '-') }}/create?{{ inline.foreignKey }}={{ record.id }}"
195
- class="btn btn-ghost btn-sm">
197
+ <button class="btn btn-ghost btn-sm" onclick="document.getElementById('inline-form-{{ inlineIndex }}').style.display='block';this.style.display='none'">
196
198
  <span class="icon icon-13"><svg viewBox="0 0 24 24"><use href="#ic-plus"/></svg></span>
197
- Add {{ inline.label | replace('s','') if inline.label | last == 's' else inline.label }}
198
- </a>
199
+ Add
200
+ </button>
199
201
  {% endif %}
200
202
  </div>
201
203
 
204
+ {# ── Inline quick-add form ── #}
205
+ {% if inline.canCreate %}
206
+ <div id="inline-form-{{ inlineIndex }}" style="display:none;padding:12px 16px;border-bottom:1px solid var(--border);background:var(--surface)">
207
+ <form method="POST" action="{{ inlineBase }}">
208
+ <input type="hidden" name="_csrf" value="{{ csrfToken }}">
209
+ <div style="display:flex;gap:8px;flex-wrap:wrap;align-items:flex-end">
210
+ {% for field in inline.fields %}
211
+ {% if field.name != inline.foreignKey %}
212
+ <div style="flex:1;min-width:140px">
213
+ <label class="form-label" style="font-size:11px">{{ field.label }}</label>
214
+ {% if field.type == 'boolean' %}
215
+ <input type="checkbox" name="{{ field.name }}" value="1">
216
+ {% else %}
217
+ <input type="{{ field.type or 'text' }}" name="{{ field.name }}" class="form-control form-control-sm" placeholder="{{ field.label }}">
218
+ {% endif %}
219
+ </div>
220
+ {% endif %}
221
+ {% endfor %}
222
+ <div style="display:flex;gap:6px">
223
+ <button type="submit" class="btn btn-primary btn-sm">Save</button>
224
+ <button type="button" class="btn btn-ghost btn-sm" onclick="document.getElementById('inline-form-{{ inlineIndex }}').style.display='none';this.closest('.card').querySelector('.btn-ghost').style.display=''">Cancel</button>
225
+ </div>
226
+ </div>
227
+ </form>
228
+ </div>
229
+ {% endif %}
230
+
202
231
  {% if inline.rows | length %}
203
232
  <div class="table-wrap">
204
233
  <table>
@@ -222,11 +251,13 @@
222
251
  {% endfor %}
223
252
  {% if inline.canDelete %}
224
253
  <td class="col-actions" style="text-align:right">
225
- <button
226
- onclick="confirmDelete('{{ adminPrefix }}/{{ inline.label | lower | replace(' ','-') }}/{{ row.id }}/delete','{{ inline.label | replace('s','') if inline.label | last == 's' else inline.label }} #{{ row.id }}')"
227
- class="btn btn-danger btn-xs">
228
- <span class="icon icon-12"><svg viewBox="0 0 24 24"><use href="#ic-trash"/></svg></span>
229
- </button>
254
+ <form method="POST" action="{{ inlineBase }}/{{ row.id }}/delete" style="display:inline">
255
+ <input type="hidden" name="_csrf" value="{{ csrfToken }}">
256
+ <button type="submit" class="btn btn-danger btn-xs"
257
+ onclick="return confirm('Delete this record?')">
258
+ <span class="icon icon-12"><svg viewBox="0 0 24 24"><use href="#ic-trash"/></svg></span>
259
+ </button>
260
+ </form>
230
261
  </td>
231
262
  {% endif %}
232
263
  </tr>
@@ -240,13 +271,6 @@
240
271
  <span class="icon icon-16"><svg viewBox="0 0 24 24"><use href="#ic-table"/></svg></span>
241
272
  </div>
242
273
  <div class="empty-title" style="font-size:13px">No {{ inline.label | lower }} yet</div>
243
- {% if inline.canCreate %}
244
- <a href="{{ adminPrefix }}/{{ inline.label | lower | replace(' ', '-') }}/create?{{ inline.foreignKey }}={{ record.id }}"
245
- class="btn btn-ghost btn-sm" style="margin-top:10px">
246
- <span class="icon icon-13"><svg viewBox="0 0 24 24"><use href="#ic-plus"/></svg></span>
247
- Add first
248
- </a>
249
- {% endif %}
250
274
  </div>
251
275
  {% endif %}
252
276
  </div>