create-nexwire 4.2.3 → 4.2.5

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 (87) hide show
  1. package/express/.vscode/extensions.json +6 -0
  2. package/express/.vscode/settings.json +37 -26
  3. package/express/biome.json +99 -66
  4. package/express/package.json +54 -27
  5. package/express/src/database/migrations/sqlite/0000_init.sql +47 -60
  6. package/express/src/database/migrations/sqlite/meta/0000_snapshot.json +1 -89
  7. package/express/src/database/migrations/sqlite/meta/_journal.json +1 -1
  8. package/express/src/database/schema.ts +0 -1
  9. package/express/src/framework/facade.ts +12 -1
  10. package/express/src/framework/maker-cli/db/core.mjs +291 -288
  11. package/express/src/framework/maker-cli/module/core.mjs +125 -87
  12. package/express/src/framework/maker-cli/module/index.mjs +3 -3
  13. package/express/src/framework/maker-cli/stubs/notification/controller.ts.stub +61 -62
  14. package/express/src/framework/maker-cli/stubs/notification/job.ts.stub +11 -13
  15. package/express/src/framework/maker-cli/stubs/notification/model.ts.stub +29 -0
  16. package/express/src/framework/maker-cli/stubs/notification/provider.ts.stub +174 -0
  17. package/express/src/framework/maker-cli/stubs/notification/route.api.ts.stub +11 -10
  18. package/express/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +1 -1
  19. package/express/src/framework/maker-cli/stubs/notification/schema.plain.ts.stub +25 -25
  20. package/express/src/framework/maker-cli/stubs/notification/schema.ts.stub +25 -25
  21. package/express/src/framework/notification/index.ts +49 -87
  22. package/express/src/framework/providers/adapter.ts +24 -10
  23. package/express/src/framework/providers/contracts.ts +80 -10
  24. package/express/src/framework/providers/registry.ts +27 -1
  25. package/express/src/resources/src/components/Checkbox.vue +32 -29
  26. package/express/src/resources/src/components/Input.vue +243 -223
  27. package/express/src/resources/src/components/InputGroup.vue +147 -145
  28. package/express/src/resources/src/components/InputPasswordToggle.vue +229 -213
  29. package/express/src/resources/src/components/Modal.vue +71 -55
  30. package/express/src/resources/src/components/Refresh.vue +19 -0
  31. package/express/src/resources/src/helpers/assets.ts +51 -0
  32. package/express/src/resources/src/main.ts +4 -2
  33. package/express/src/resources/src/pages/auth/forgetPassword.vue +1 -1
  34. package/express/src/resources/src/pages/auth/login.vue +1 -1
  35. package/express/src/resources/src/pages/auth/register.vue +1 -1
  36. package/express/src/resources/src/pages/auth/resetPassword.vue +1 -1
  37. package/express/src/resources/src/pages/auth/verifyEmail.vue +1 -1
  38. package/express/src/resources/src/pages/dashboard/index.vue +66 -66
  39. package/express/src/resources/src/plugins/gum.ts +1 -1
  40. package/express/src/resources/src/stores/auth.ts +184 -164
  41. package/express/src/resources/vite.config.ts +9 -2
  42. package/express/src/storage/database/nexwire.sqlite +0 -0
  43. package/hono/.vscode/extensions.json +6 -0
  44. package/hono/.vscode/settings.json +37 -26
  45. package/hono/biome.json +25 -2
  46. package/hono/package.json +50 -23
  47. package/hono/src/database/migrations/sqlite/0000_init.sql +47 -60
  48. package/hono/src/database/migrations/sqlite/meta/0000_snapshot.json +1 -89
  49. package/hono/src/database/migrations/sqlite/meta/_journal.json +1 -1
  50. package/hono/src/database/schema.ts +0 -1
  51. package/hono/src/framework/facade.ts +12 -1
  52. package/hono/src/framework/maker-cli/db/core.mjs +291 -288
  53. package/hono/src/framework/maker-cli/module/core.mjs +93 -52
  54. package/hono/src/framework/maker-cli/module/index.mjs +3 -3
  55. package/hono/src/framework/maker-cli/stubs/notification/controller.ts.stub +63 -58
  56. package/hono/src/framework/maker-cli/stubs/notification/job.ts.stub +10 -12
  57. package/hono/src/framework/maker-cli/stubs/notification/model.ts.stub +29 -0
  58. package/hono/src/framework/maker-cli/stubs/notification/provider.ts.stub +174 -0
  59. package/hono/src/framework/maker-cli/stubs/notification/route.api.ts.stub +11 -10
  60. package/hono/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +1 -1
  61. package/hono/src/framework/maker-cli/stubs/notification/schema.plain.ts.stub +25 -25
  62. package/hono/src/framework/maker-cli/stubs/notification/schema.ts.stub +25 -25
  63. package/hono/src/framework/notification/index.ts +49 -87
  64. package/hono/src/framework/providers/adapter.ts +24 -10
  65. package/hono/src/framework/providers/contracts.ts +80 -10
  66. package/hono/src/framework/providers/registry.ts +27 -1
  67. package/hono/src/resources/src/components/Checkbox.vue +32 -29
  68. package/hono/src/resources/src/components/Input.vue +243 -234
  69. package/hono/src/resources/src/components/InputGroup.vue +147 -149
  70. package/hono/src/resources/src/components/InputPasswordToggle.vue +229 -222
  71. package/hono/src/resources/src/components/Modal.vue +71 -55
  72. package/hono/src/resources/src/components/Refresh.vue +19 -0
  73. package/hono/src/resources/src/helpers/assets.ts +51 -0
  74. package/hono/src/resources/src/main.ts +4 -2
  75. package/hono/src/resources/src/pages/auth/forgetPassword.vue +1 -1
  76. package/hono/src/resources/src/pages/auth/login.vue +1 -1
  77. package/hono/src/resources/src/pages/auth/register.vue +1 -1
  78. package/hono/src/resources/src/pages/auth/resetPassword.vue +1 -1
  79. package/hono/src/resources/src/pages/auth/verifyEmail.vue +1 -1
  80. package/hono/src/resources/src/pages/dashboard/index.vue +66 -66
  81. package/hono/src/resources/src/plugins/gum.ts +1 -1
  82. package/hono/src/resources/src/stores/auth.ts +184 -164
  83. package/hono/src/resources/vite.config.ts +9 -2
  84. package/hono/src/storage/database/nexwire.sqlite +0 -0
  85. package/package.json +10 -10
  86. package/express/src/modules/auth/database/models/notification.ts +0 -24
  87. package/hono/src/modules/auth/database/models/notification.ts +0 -24
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Why: Defines the shapes a pluggable provider has to satisfy.
3
- * When: A developer replaces a framework default (auth today, payments later).
3
+ * When: A developer replaces a framework default (auth, notifications, payments later).
4
4
  * Where: Imported through the framework facade, never from framework internals.
5
5
  * How: Interfaces stay deliberately loose so custom user shapes pass through.
6
6
  */
@@ -8,6 +8,9 @@
8
8
  /** Registry key of the built-in auth provider contract. */
9
9
  export const AUTH_PROVIDER_KEY = "auth";
10
10
 
11
+ /** Registry key of the built-in notification storage provider. */
12
+ export const NOTIFICATION_PROVIDER_KEY = "notification";
13
+
11
14
  /**
12
15
  * Registry key for any provider implementation.
13
16
  *
@@ -15,25 +18,25 @@ export const AUTH_PROVIDER_KEY = "auth";
15
18
  * still accepting any custom key, so a project can register its own contracts
16
19
  * (payments, otp, storage, ...) without the framework having to know them.
17
20
  */
18
- export type ProviderKey = typeof AUTH_PROVIDER_KEY | (string & {});
21
+ export type ProviderKey = typeof AUTH_PROVIDER_KEY | typeof NOTIFICATION_PROVIDER_KEY | (string & {});
19
22
 
20
23
  export interface AuthProviderUser {
21
- id: number;
24
+ id: number | string;
22
25
  email?: string | null;
23
26
  [key: string]: any;
24
27
  }
25
28
 
26
29
  export interface AuthProviderRefreshToken {
27
- id: number;
30
+ id: number | string;
28
31
  jti: string;
29
32
  revoked?: boolean | null;
30
33
  expiresAt?: Date | string | null;
31
- userId?: number | null;
34
+ userId?: number | string | null;
32
35
  [key: string]: any;
33
36
  }
34
37
 
35
38
  export interface AuthUserContext {
36
- id: number;
39
+ id: number | string;
37
40
  email?: string | null;
38
41
  roleId?: number | null;
39
42
  role?: string | null;
@@ -47,10 +50,77 @@ export interface AuthUserContact {
47
50
  }
48
51
 
49
52
  export interface AuthProvider {
50
- getUserById(id: number): Promise<AuthProviderUser | null>;
53
+ getUserById(id: number | string): Promise<AuthProviderUser | null>;
51
54
  findRefreshToken(jti: string): Promise<AuthProviderRefreshToken | null>;
52
- revokeRefreshToken?(tokenId: number): Promise<void>;
53
- deleteRefreshToken?(tokenId: number): Promise<void>;
55
+ revokeRefreshToken?(tokenId: number | string): Promise<void>;
56
+ deleteRefreshToken?(tokenId: number | string): Promise<void>;
54
57
  getAuthContext?(user: AuthProviderUser, payload?: any): Promise<AuthUserContext | any>;
55
- getUserContact?(userId: number): Promise<AuthUserContact | null>;
58
+ getUserContact?(userId: number | string): Promise<AuthUserContact | null>;
59
+ }
60
+
61
+ /**
62
+ * Who a notification belongs to. `id` accepts a numeric auth id and a string
63
+ * id (UUID, ULID, ...) so replacing auth does not force a notification change.
64
+ * The provider always stores the id as text.
65
+ */
66
+ export interface NotifiableTarget {
67
+ /** Notifiable class. Defaults to "user". */
68
+ type?: string;
69
+ id: number | string;
70
+ }
71
+
72
+ /** Payload accepted by `NotificationProvider.create()`. */
73
+ export interface NotificationCreateInput {
74
+ type?: string;
75
+ title: string;
76
+ body?: string | null;
77
+ link?: string | null;
78
+ data?: Record<string, unknown> | null;
79
+ }
80
+
81
+ /** Normalized notification returned by every provider operation. */
82
+ export interface NotificationRecord {
83
+ id: string;
84
+ notifiableType: string;
85
+ notifiableId: string;
86
+ type: string;
87
+ title: string;
88
+ body: string | null;
89
+ data: Record<string, unknown> | null;
90
+ link: string | null;
91
+ readAt: string | null;
92
+ createdAt: string;
93
+ }
94
+
95
+ export interface NotificationListOptions {
96
+ page?: number;
97
+ perPage?: number;
98
+ }
99
+
100
+ export interface NotificationPage {
101
+ data: NotificationRecord[];
102
+ total: number;
103
+ unread: number;
104
+ page: number;
105
+ perPage: number;
106
+ }
107
+
108
+ /**
109
+ * Why: Keeps notification storage replaceable without touching `notify()` or
110
+ * the generated HTTP routes.
111
+ * When: The default `src/modules/notification` store is replaced by a custom
112
+ * implementation (a different table, another service, ...).
113
+ * Where: Registered through `registerNotificationProvider()`.
114
+ * How: The framework only reads through this contract; mail and realtime
115
+ * delivery stay in the runtime so a storage swap cannot disable them.
116
+ */
117
+ export interface NotificationProvider {
118
+ create(target: NotifiableTarget, input: NotificationCreateInput): Promise<NotificationRecord>;
119
+ list(target: NotifiableTarget, options?: NotificationListOptions): Promise<NotificationPage>;
120
+ unreadCount(target: NotifiableTarget): Promise<number>;
121
+ markRead(target: NotifiableTarget, id: number | string): Promise<boolean>;
122
+ markAllRead(target: NotifiableTarget): Promise<number>;
123
+ remove(target: NotifiableTarget, id: number | string): Promise<boolean>;
124
+ /** Optional bulk cleanup when a notifiable target is deleted. */
125
+ deleteForTarget?(target: NotifiableTarget): Promise<number>;
56
126
  }
@@ -1,4 +1,10 @@
1
- import { AUTH_PROVIDER_KEY, type AuthProvider, type ProviderKey } from "./contracts.js";
1
+ import {
2
+ AUTH_PROVIDER_KEY,
3
+ type AuthProvider,
4
+ NOTIFICATION_PROVIDER_KEY,
5
+ type NotificationProvider,
6
+ type ProviderKey
7
+ } from "./contracts.js";
2
8
 
3
9
  /**
4
10
  * Why: Holds the app-wide provider implementations in one place.
@@ -60,3 +66,23 @@ export function hasAuthProvider(): boolean {
60
66
  export function clearAuthProvider(): void {
61
67
  clearProvider(AUTH_PROVIDER_KEY);
62
68
  }
69
+
70
+ /** Registers the storage provider `notify()` and `/api/notification/*` use. */
71
+ export function registerNotificationProvider(provider: NotificationProvider): NotificationProvider {
72
+ return registerProvider(NOTIFICATION_PROVIDER_KEY, provider);
73
+ }
74
+
75
+ /** Returns the registered notification provider, or null when none was registered. */
76
+ export function getNotificationProvider(): NotificationProvider | null {
77
+ return getProvider<NotificationProvider>(NOTIFICATION_PROVIDER_KEY);
78
+ }
79
+
80
+ /** Reports whether a notification provider is registered. */
81
+ export function hasNotificationProvider(): boolean {
82
+ return hasProvider(NOTIFICATION_PROVIDER_KEY);
83
+ }
84
+
85
+ /** Removes the registered notification provider. Mainly useful in tests. */
86
+ export function clearNotificationProvider(): void {
87
+ clearProvider(NOTIFICATION_PROVIDER_KEY);
88
+ }
@@ -1,29 +1,32 @@
1
- <template>
2
- <div class="form-check mb-0" :class="props.topclass">
3
- <input
4
- :id="String(props.id)"
5
- v-model="model"
6
- class="form-check-input shadow-none border-secondary"
7
- type="checkbox"
8
- v-bind="$attrs" />
9
- <label v-if="props.label" class="form-check-label" :for="String(props.id)">{{ props.label }}</label>
10
- </div>
11
- </template>
12
-
13
- <script setup lang="ts">
14
- defineOptions({ name: "Checkbox", inheritAttrs: false });
15
-
16
- interface CheckboxProps {
17
- id?: string | number;
18
- label?: string;
19
- topclass?: string;
20
- }
21
-
22
- const props = defineProps<CheckboxProps>();
23
-
24
- type CheckboxModel = boolean | Array<string | number>;
25
-
26
- const model = defineModel<CheckboxModel>({ default: false });
27
- </script>
28
-
29
- <style lang="scss" scoped></style>
1
+ <template>
2
+ <div class="form-check mb-0" :class="props.topclass">
3
+ <input
4
+ :id="String(props.id)"
5
+ v-model="model"
6
+ class="form-check-input shadow-none"
7
+ type="checkbox"
8
+ v-bind="$attrs"
9
+ />
10
+ <label v-if="props.label" class="form-check-label" :for="String(props.id)">{{
11
+ props.label
12
+ }}</label>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ defineOptions({ name: "Checkbox", inheritAttrs: false });
18
+
19
+ interface CheckboxProps {
20
+ id?: string | number;
21
+ label?: string;
22
+ topclass?: string;
23
+ }
24
+
25
+ const props = defineProps<CheckboxProps>();
26
+
27
+ type CheckboxModel = boolean | Array<string | number>;
28
+
29
+ const model = defineModel<CheckboxModel>({ default: false });
30
+ </script>
31
+
32
+ <style lang="scss" scoped></style>