create-mantiq 0.5.1 → 0.7.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mantiq",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "Scaffold a new MantiqJS application",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/templates.ts CHANGED
@@ -20,9 +20,9 @@ export function getTemplates(ctx: TemplateContext): Record<string, string> {
20
20
  mantiq: 'bun run mantiq.ts',
21
21
  },
22
22
  dependencies: {
23
- '@mantiq/auth': '^0.1.2',
23
+ '@mantiq/auth': '^0.2.0',
24
24
  '@mantiq/cli': '^0.1.6',
25
- '@mantiq/core': '^0.1.4',
25
+ '@mantiq/core': '^0.2.0',
26
26
  '@mantiq/database': '^0.1.4',
27
27
  '@mantiq/events': '^0.1.2',
28
28
  '@mantiq/filesystem': '^0.1.2',
@@ -34,6 +34,8 @@ export function getTemplates(ctx: TemplateContext): Record<string, string> {
34
34
  '@mantiq/validation': '^0.1.2',
35
35
  '@mantiq/mail': '^0.2.0',
36
36
  '@mantiq/notify': '^0.1.0',
37
+ '@mantiq/search': '^0.1.0',
38
+ '@mantiq/health': '^0.1.0',
37
39
  },
38
40
  devDependencies: {
39
41
  'bun-types': 'latest',
@@ -107,7 +109,7 @@ storage/heartbeat/
107
109
  // ── Entry points ────────────────────────────────────────────────────────
108
110
 
109
111
  'index.ts': `import { Application, CoreServiceProvider, HttpKernel, RouterImpl, CorsMiddleware, StartSession, EncryptCookies, VerifyCsrfToken } from '@mantiq/core'
110
- import { AuthServiceProvider, Authenticate, RedirectIfAuthenticated } from '@mantiq/auth'
112
+ import { AuthServiceProvider, Authenticate, RedirectIfAuthenticated, CheckAbilities, CheckForAnyAbility } from '@mantiq/auth'
111
113
  import { FilesystemServiceProvider } from '@mantiq/filesystem'
112
114
  import { LoggingServiceProvider } from '@mantiq/logging'
113
115
  import { EventServiceProvider } from '@mantiq/events'
@@ -117,6 +119,7 @@ import { HeartbeatServiceProvider, HeartbeatMiddleware } from '@mantiq/heartbeat
117
119
  import { RealtimeServiceProvider } from '@mantiq/realtime'
118
120
  import { MailServiceProvider } from '@mantiq/mail'
119
121
  import { NotificationServiceProvider } from '@mantiq/notify'
122
+ import { SearchServiceProvider } from '@mantiq/search'
120
123
  import { DatabaseServiceProvider } from './app/Providers/DatabaseServiceProvider.ts'
121
124
 
122
125
  // ── Load .env ─────────────────────────────────────────────────────────────────
@@ -150,6 +153,7 @@ await app.registerProviders([
150
153
  RealtimeServiceProvider,
151
154
  MailServiceProvider,
152
155
  NotificationServiceProvider,
156
+ SearchServiceProvider,
153
157
  ])
154
158
  await app.bootProviders()
155
159
 
@@ -165,6 +169,8 @@ kernel.registerMiddleware('csrf', VerifyCsrfToken)
165
169
  kernel.registerMiddleware('auth', Authenticate)
166
170
  kernel.registerMiddleware('guest', RedirectIfAuthenticated)
167
171
  kernel.registerMiddleware('heartbeat', HeartbeatMiddleware)
172
+ kernel.registerMiddleware('abilities', CheckAbilities)
173
+ kernel.registerMiddleware('ability', CheckForAnyAbility)
168
174
 
169
175
  // Global middleware
170
176
  kernel.setGlobalMiddleware(['cors', 'encrypt.cookies', 'session', 'heartbeat'])
@@ -318,6 +324,7 @@ export default {
318
324
 
319
325
  guards: {
320
326
  web: { driver: 'session', provider: 'users' },
327
+ api: { driver: 'token', provider: 'users' },
321
328
  },
322
329
 
323
330
  providers: {
@@ -456,6 +463,33 @@ export default {
456
463
  'config/notify.ts': `export default {
457
464
  channels: {},
458
465
  }
466
+ `,
467
+
468
+ 'config/search.ts': `export default {
469
+ default: 'collection',
470
+ prefix: '',
471
+ queue: false,
472
+ softDelete: false,
473
+
474
+ engines: {
475
+ collection: {
476
+ driver: 'collection' as const,
477
+ },
478
+ database: {
479
+ driver: 'database' as const,
480
+ },
481
+ // algolia: {
482
+ // driver: 'algolia' as const,
483
+ // applicationId: env('ALGOLIA_APP_ID', ''),
484
+ // apiKey: env('ALGOLIA_SECRET', ''),
485
+ // },
486
+ // meilisearch: {
487
+ // driver: 'meilisearch' as const,
488
+ // host: env('MEILISEARCH_HOST', 'http://127.0.0.1:7700'),
489
+ // apiKey: env('MEILISEARCH_KEY', ''),
490
+ // },
491
+ },
492
+ }
459
493
  `,
460
494
 
461
495
  'config/heartbeat.ts': `export default {
@@ -632,10 +666,19 @@ export class User extends Model implements Authenticatable {
632
666
  setRememberToken(token: string | null): void { this.setAttribute('remember_token', token) }
633
667
  getRememberTokenName(): string { return 'remember_token' }
634
668
  }
669
+ `,
670
+
671
+ 'app/Models/PersonalAccessToken.ts': `import { PersonalAccessToken as BaseToken } from '@mantiq/auth'
672
+
673
+ // Re-export the built-in PersonalAccessToken.
674
+ // Extend this class if you need to add custom logic.
675
+ export class PersonalAccessToken extends BaseToken {}
635
676
  `,
636
677
 
637
678
  'app/Providers/DatabaseServiceProvider.ts': `import { ServiceProvider, config } from '@mantiq/core'
638
679
  import { DatabaseManager, setupModels, setManager, Migrator } from '@mantiq/database'
680
+ import { applyHasApiTokens, PersonalAccessToken } from '@mantiq/auth'
681
+ import { User } from '../Models/User.ts'
639
682
 
640
683
  export class DatabaseServiceProvider extends ServiceProvider {
641
684
  override register(): void {
@@ -652,7 +695,11 @@ export class DatabaseServiceProvider extends ServiceProvider {
652
695
 
653
696
  override async boot(): Promise<void> {
654
697
  // Resolve the manager (triggers creation via the singleton factory)
655
- this.app.make(DatabaseManager)
698
+ const manager = this.app.make(DatabaseManager)
699
+
700
+ // Set up PersonalAccessToken connection and apply HasApiTokens mixin
701
+ PersonalAccessToken.setConnection(manager.connection())
702
+ applyHasApiTokens(User)
656
703
  }
657
704
  }
658
705
  `,
@@ -678,6 +725,30 @@ export default class CreateUsersTable extends Migration {
678
725
  await schema.dropIfExists('users')
679
726
  }
680
727
  }
728
+ `,
729
+
730
+ 'database/migrations/002_create_personal_access_tokens_table.ts': `import { Migration } from '@mantiq/database'
731
+ import type { SchemaBuilder } from '@mantiq/database'
732
+
733
+ export default class CreatePersonalAccessTokensTable extends Migration {
734
+ override async up(schema: SchemaBuilder) {
735
+ await schema.create('personal_access_tokens', (t) => {
736
+ t.id()
737
+ t.string('tokenable_type')
738
+ t.unsignedBigInteger('tokenable_id')
739
+ t.string('name')
740
+ t.string('token', 64).unique()
741
+ t.json('abilities').nullable()
742
+ t.timestamp('last_used_at').nullable()
743
+ t.timestamp('expires_at').nullable()
744
+ t.timestamps()
745
+ })
746
+ }
747
+
748
+ override async down(schema: SchemaBuilder) {
749
+ await schema.dropIfExists('personal_access_tokens')
750
+ }
751
+ }
681
752
  `,
682
753
 
683
754
  'database/seeders/DatabaseSeeder.ts': `import { Seeder } from '@mantiq/database'
@@ -735,9 +806,9 @@ function applyKitOverrides(templates: Record<string, string>, ctx: TemplateConte
735
806
  postinstall: 'rm -rf node_modules/@mantiq/*/node_modules/@mantiq 2>/dev/null; true',
736
807
  },
737
808
  dependencies: {
738
- '@mantiq/auth': '^0.1.2',
809
+ '@mantiq/auth': '^0.2.0',
739
810
  '@mantiq/cli': '^0.1.6',
740
- '@mantiq/core': '^0.1.4',
811
+ '@mantiq/core': '^0.2.0',
741
812
  '@mantiq/database': '^0.1.4',
742
813
  '@mantiq/events': '^0.1.2',
743
814
  '@mantiq/filesystem': '^0.1.2',
@@ -749,6 +820,8 @@ function applyKitOverrides(templates: Record<string, string>, ctx: TemplateConte
749
820
  '@mantiq/validation': '^0.1.2',
750
821
  '@mantiq/mail': '^0.2.0',
751
822
  '@mantiq/notify': '^0.1.0',
823
+ '@mantiq/search': '^0.1.0',
824
+ '@mantiq/health': '^0.1.0',
752
825
  '@mantiq/vite': '^0.1.3',
753
826
  ...uiDeps,
754
827
  },
@@ -816,7 +889,7 @@ bootstrap/
816
889
  // ── index.ts ────────────────────────────────────────────────────────────
817
890
  templates['index.ts'] = `import { Application, CoreServiceProvider, HttpKernel, RouterImpl, CorsMiddleware, StartSession, EncryptCookies, VerifyCsrfToken } from '@mantiq/core'
818
891
  import { ViteServiceProvider, ServeStaticFiles } from '@mantiq/vite'
819
- import { AuthServiceProvider, Authenticate, RedirectIfAuthenticated } from '@mantiq/auth'
892
+ import { AuthServiceProvider, Authenticate, RedirectIfAuthenticated, CheckAbilities, CheckForAnyAbility } from '@mantiq/auth'
820
893
  import { FilesystemServiceProvider } from '@mantiq/filesystem'
821
894
  import { LoggingServiceProvider } from '@mantiq/logging'
822
895
  import { EventServiceProvider } from '@mantiq/events'
@@ -826,6 +899,7 @@ import { HeartbeatServiceProvider, HeartbeatMiddleware } from '@mantiq/heartbeat
826
899
  import { RealtimeServiceProvider } from '@mantiq/realtime'
827
900
  import { MailServiceProvider } from '@mantiq/mail'
828
901
  import { NotificationServiceProvider } from '@mantiq/notify'
902
+ import { SearchServiceProvider } from '@mantiq/search'
829
903
  import { DatabaseServiceProvider } from './app/Providers/DatabaseServiceProvider.ts'
830
904
 
831
905
  // ── Load .env ─────────────────────────────────────────────────────────────────
@@ -860,6 +934,7 @@ await app.registerProviders([
860
934
  RealtimeServiceProvider,
861
935
  MailServiceProvider,
862
936
  NotificationServiceProvider,
937
+ SearchServiceProvider,
863
938
  ])
864
939
  await app.bootProviders()
865
940
 
@@ -886,6 +961,8 @@ kernel.registerMiddleware('csrf', VerifyCsrfToken)
886
961
  kernel.registerMiddleware('auth', Authenticate)
887
962
  kernel.registerMiddleware('guest', RedirectIfAuthenticated)
888
963
  kernel.registerMiddleware('heartbeat', HeartbeatMiddleware)
964
+ kernel.registerMiddleware('abilities', CheckAbilities)
965
+ kernel.registerMiddleware('ability', CheckForAnyAbility)
889
966
 
890
967
  // Global middleware
891
968
  kernel.setGlobalMiddleware(['static', 'cors', 'encrypt.cookies', 'session', 'heartbeat'])
@@ -87,7 +87,7 @@ export function NavUser({ user, navigate, onLogout }: NavUserProps) {
87
87
  </div>
88
88
  </DropdownMenuLabel>
89
89
  <DropdownMenuSeparator />
90
- <DropdownMenuItem onClick={() => navigate('/account')}>
90
+ <DropdownMenuItem onClick={() => navigate('/account/profile')}>
91
91
  <User className="mr-2 h-4 w-4" />
92
92
  Account
93
93
  </DropdownMenuItem>
@@ -44,7 +44,7 @@ export const sidebarData: NavGroup[] = [
44
44
  items: [
45
45
  {
46
46
  title: 'Settings',
47
- url: '/account',
47
+ url: '/account/profile',
48
48
  icon: Settings,
49
49
  items: [
50
50
  { title: 'Profile', url: '/account/profile', icon: User },
@@ -44,7 +44,7 @@ export const sidebarData: NavGroup[] = [
44
44
  items: [
45
45
  {
46
46
  title: 'Settings',
47
- url: '/account',
47
+ url: '/account/profile',
48
48
  icon: Settings,
49
49
  items: [
50
50
  { title: 'Profile', url: '/account/profile', icon: User },
@@ -44,7 +44,7 @@ export const sidebarData: NavGroup[] = [
44
44
  items: [
45
45
  {
46
46
  title: 'Settings',
47
- url: '/account',
47
+ url: '/account/profile',
48
48
  icon: Settings,
49
49
  items: [
50
50
  { title: 'Profile', url: '/account/profile', icon: User },