alepha 0.13.2 → 0.13.4

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 (91) hide show
  1. package/README.md +7 -7
  2. package/dist/api-files/index.browser.js +80 -0
  3. package/dist/api-files/index.browser.js.map +1 -0
  4. package/dist/api-files/index.d.ts +175 -175
  5. package/dist/api-jobs/index.browser.js +56 -0
  6. package/dist/api-jobs/index.browser.js.map +1 -0
  7. package/dist/api-jobs/index.d.ts +156 -156
  8. package/dist/api-notifications/index.browser.js +382 -0
  9. package/dist/api-notifications/index.browser.js.map +1 -0
  10. package/dist/api-notifications/index.d.ts +221 -166
  11. package/dist/api-notifications/index.js +107 -55
  12. package/dist/api-notifications/index.js.map +1 -1
  13. package/dist/api-parameters/index.browser.js +29 -0
  14. package/dist/api-parameters/index.browser.js.map +1 -0
  15. package/dist/api-users/index.d.ts +16 -3
  16. package/dist/api-users/index.js +75 -28
  17. package/dist/api-users/index.js.map +1 -1
  18. package/dist/api-verifications/index.browser.js +52 -0
  19. package/dist/api-verifications/index.browser.js.map +1 -0
  20. package/dist/api-verifications/index.d.ts +120 -98
  21. package/dist/api-verifications/index.js +1 -1
  22. package/dist/api-verifications/index.js.map +1 -1
  23. package/dist/batch/index.js +0 -5
  24. package/dist/batch/index.js.map +1 -1
  25. package/dist/bucket/index.js +7 -5
  26. package/dist/bucket/index.js.map +1 -1
  27. package/dist/cli/{dist-Dl9Vl7Ur.js → dist-lGnqsKpu.js} +11 -15
  28. package/dist/cli/dist-lGnqsKpu.js.map +1 -0
  29. package/dist/cli/index.d.ts +26 -45
  30. package/dist/cli/index.js +40 -58
  31. package/dist/cli/index.js.map +1 -1
  32. package/dist/command/index.d.ts +1 -0
  33. package/dist/command/index.js +9 -0
  34. package/dist/command/index.js.map +1 -1
  35. package/dist/core/index.browser.js +5 -1
  36. package/dist/core/index.browser.js.map +1 -1
  37. package/dist/core/index.d.ts +221 -219
  38. package/dist/core/index.js +5 -1
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/core/index.native.js +5 -1
  41. package/dist/core/index.native.js.map +1 -1
  42. package/dist/email/index.d.ts +4 -4
  43. package/dist/email/index.js +5 -0
  44. package/dist/email/index.js.map +1 -1
  45. package/dist/orm/index.d.ts +19 -19
  46. package/dist/orm/index.js +3 -3
  47. package/dist/orm/index.js.map +1 -1
  48. package/dist/redis/index.d.ts +10 -10
  49. package/dist/security/index.d.ts +28 -28
  50. package/dist/security/index.js +3 -3
  51. package/dist/security/index.js.map +1 -1
  52. package/dist/server/index.d.ts +9 -9
  53. package/dist/server-auth/index.d.ts +152 -152
  54. package/dist/server-cookies/index.js +2 -2
  55. package/dist/server-cookies/index.js.map +1 -1
  56. package/dist/server-links/index.d.ts +33 -33
  57. package/dist/server-security/index.d.ts +9 -9
  58. package/dist/server-static/index.js +18 -2
  59. package/dist/server-static/index.js.map +1 -1
  60. package/package.json +16 -6
  61. package/src/api-files/index.browser.ts +17 -0
  62. package/src/api-jobs/index.browser.ts +15 -0
  63. package/src/api-notifications/controllers/NotificationController.ts +26 -1
  64. package/src/api-notifications/index.browser.ts +17 -0
  65. package/src/api-notifications/index.ts +1 -0
  66. package/src/api-notifications/schemas/notificationQuerySchema.ts +13 -0
  67. package/src/api-notifications/services/NotificationService.ts +45 -2
  68. package/src/api-parameters/index.browser.ts +12 -0
  69. package/src/api-users/atoms/realmAuthSettingsAtom.ts +3 -1
  70. package/src/api-users/controllers/UserController.ts +21 -1
  71. package/src/api-users/primitives/$userRealm.ts +33 -10
  72. package/src/api-users/providers/UserRealmProvider.ts +1 -0
  73. package/src/api-users/services/SessionService.ts +2 -0
  74. package/src/api-users/services/UserService.ts +56 -16
  75. package/src/api-verifications/index.browser.ts +15 -0
  76. package/src/api-verifications/index.ts +1 -0
  77. package/src/batch/providers/BatchProvider.ts +0 -7
  78. package/src/bucket/index.ts +7 -5
  79. package/src/cli/apps/AlephaCli.ts +27 -1
  80. package/src/cli/apps/AlephaPackageBuilderCli.ts +3 -0
  81. package/src/cli/commands/CoreCommands.ts +6 -2
  82. package/src/cli/commands/ViteCommands.ts +2 -1
  83. package/src/cli/services/ProjectUtils.ts +40 -75
  84. package/src/command/helpers/Asker.ts +10 -0
  85. package/src/core/Alepha.ts +14 -0
  86. package/src/core/primitives/$module.ts +1 -1
  87. package/src/email/index.ts +13 -5
  88. package/src/orm/providers/drivers/NodeSqliteProvider.ts +3 -3
  89. package/src/server-cookies/providers/ServerCookiesProvider.ts +2 -1
  90. package/src/server-static/providers/ServerStaticProvider.ts +18 -3
  91. package/dist/cli/dist-Dl9Vl7Ur.js.map +0 -1
@@ -1,180 +1,59 @@
1
- import * as alepha1 from "alepha";
1
+ import * as alepha45 from "alepha";
2
2
  import { Alepha, KIND, Primitive, Static, StaticEncode, TObject } from "alepha";
3
+ import * as alepha_orm15 from "alepha/orm";
4
+ import { Page } from "alepha/orm";
5
+ import * as alepha_server0 from "alepha/server";
3
6
  import * as alepha_batch0 from "alepha/batch";
4
7
  import { DateTimeProvider } from "alepha/datetime";
5
8
  import * as alepha_logger0 from "alepha/logger";
6
- import * as alepha_orm0 from "alepha/orm";
7
9
  import * as alepha_queue0 from "alepha/queue";
8
10
  import { EmailProvider } from "alepha/email";
9
11
  import { SmsProvider } from "alepha/sms";
10
12
 
11
- //#region src/api-notifications/controllers/NotificationController.d.ts
12
- declare class NotificationController {}
13
- //#endregion
14
13
  //#region src/api-notifications/entities/notifications.d.ts
15
- declare const notifications: alepha_orm0.EntityPrimitive<alepha1.TObject<{
16
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
17
- version: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TInteger, typeof alepha_orm0.PG_VERSION>, typeof alepha_orm0.PG_DEFAULT>;
18
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
19
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
20
- type: alepha1.TUnsafe<"email" | "sms">;
21
- template: alepha1.TString;
22
- category: alepha1.TOptional<alepha1.TString>;
23
- critical: alepha1.TOptional<alepha1.TBoolean>;
24
- sensitive: alepha1.TOptional<alepha1.TBoolean>;
25
- contact: alepha1.TString;
26
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
27
- scheduledAt: alepha1.TOptional<alepha1.TString>;
28
- sentAt: alepha1.TOptional<alepha1.TString>;
29
- error: alepha1.TOptional<alepha1.TObject<{
30
- at: alepha1.TString;
31
- name: alepha1.TString;
32
- message: alepha1.TString;
14
+ declare const notifications: alepha_orm15.EntityPrimitive<alepha45.TObject<{
15
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
16
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
17
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
18
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
19
+ type: alepha45.TUnsafe<"email" | "sms">;
20
+ template: alepha45.TString;
21
+ category: alepha45.TOptional<alepha45.TString>;
22
+ critical: alepha45.TOptional<alepha45.TBoolean>;
23
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
24
+ contact: alepha45.TString;
25
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
26
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
27
+ sentAt: alepha45.TOptional<alepha45.TString>;
28
+ error: alepha45.TOptional<alepha45.TObject<{
29
+ at: alepha45.TString;
30
+ name: alepha45.TString;
31
+ message: alepha45.TString;
33
32
  }>>;
34
33
  }>>;
35
34
  type NotificationEntity = Static<typeof notifications.schema>;
36
35
  //#endregion
37
- //#region src/api-notifications/jobs/NotificationJobs.d.ts
38
- declare class NotificationJobs {}
39
- //#endregion
40
36
  //#region src/api-notifications/schemas/notificationCreateSchema.d.ts
41
- declare const notificationCreateSchema: alepha1.TObject<{
42
- type: alepha1.TUnsafe<"email" | "sms">;
43
- template: alepha1.TString;
44
- contact: alepha1.TString;
45
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
37
+ declare const notificationCreateSchema: alepha45.TObject<{
38
+ type: alepha45.TUnsafe<"email" | "sms">;
39
+ template: alepha45.TString;
40
+ contact: alepha45.TString;
41
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
46
42
  }>;
47
43
  type NotificationCreate = Static<typeof notificationCreateSchema>;
48
44
  //#endregion
49
- //#region src/api-notifications/services/NotificationSenderService.d.ts
50
- declare class NotificationSenderService {
51
- protected readonly alepha: Alepha;
52
- protected readonly log: alepha_logger0.Logger;
53
- protected readonly notificationRepository: alepha_orm0.Repository<alepha1.TObject<{
54
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
55
- version: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TInteger, typeof alepha_orm0.PG_VERSION>, typeof alepha_orm0.PG_DEFAULT>;
56
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
57
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
58
- type: alepha1.TUnsafe<"email" | "sms">;
59
- template: alepha1.TString;
60
- category: alepha1.TOptional<alepha1.TString>;
61
- critical: alepha1.TOptional<alepha1.TBoolean>;
62
- sensitive: alepha1.TOptional<alepha1.TBoolean>;
63
- contact: alepha1.TString;
64
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
65
- scheduledAt: alepha1.TOptional<alepha1.TString>;
66
- sentAt: alepha1.TOptional<alepha1.TString>;
67
- error: alepha1.TOptional<alepha1.TObject<{
68
- at: alepha1.TString;
69
- name: alepha1.TString;
70
- message: alepha1.TString;
71
- }>>;
72
- }>>;
73
- protected readonly dateTimeProvider: DateTimeProvider;
74
- protected readonly emailProvider: EmailProvider;
75
- protected readonly smsProvider: SmsProvider;
76
- send(notificationId: string | NotificationEntity): Promise<void>;
77
- renderSms(notification: NotificationEntity): {
78
- to: string;
79
- message: string;
80
- };
81
- renderEmail(notification: NotificationEntity): {
82
- to: string;
83
- subject: string;
84
- body: string;
85
- };
86
- protected load(notification: NotificationEntity): {
87
- template: NotificationPrimitive<alepha1.TObject<alepha1.TProperties>>;
88
- variables: Record<string, any>;
89
- contact: string;
90
- };
91
- }
92
- //#endregion
93
- //#region src/api-notifications/services/NotificationService.d.ts
94
- declare const notificationServiceEnvSchema: alepha1.TObject<{
95
- NOTIFICATION_QUEUE: alepha1.TOptional<alepha1.TBoolean>;
45
+ //#region src/api-notifications/schemas/notificationQuerySchema.d.ts
46
+ declare const notificationQuerySchema: alepha45.TObject<{
47
+ page: alepha45.TOptional<alepha45.TInteger>;
48
+ size: alepha45.TOptional<alepha45.TInteger>;
49
+ sort: alepha45.TOptional<alepha45.TString>;
50
+ type: alepha45.TOptional<alepha45.TUnsafe<"email" | "sms">>;
51
+ template: alepha45.TOptional<alepha45.TString>;
52
+ contact: alepha45.TOptional<alepha45.TString>;
53
+ category: alepha45.TOptional<alepha45.TString>;
54
+ status: alepha45.TOptional<alepha45.TUnsafe<"pending" | "sent" | "failed">>;
96
55
  }>;
97
- declare module "alepha" {
98
- interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}
99
- }
100
- declare class NotificationService {
101
- protected readonly alepha: Alepha;
102
- protected readonly log: alepha_logger0.Logger;
103
- protected readonly env: {
104
- NOTIFICATION_QUEUE?: boolean | undefined;
105
- };
106
- protected readonly notificationRepository: alepha_orm0.Repository<alepha1.TObject<{
107
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
108
- version: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TInteger, typeof alepha_orm0.PG_VERSION>, typeof alepha_orm0.PG_DEFAULT>;
109
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
110
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
111
- type: alepha1.TUnsafe<"email" | "sms">;
112
- template: alepha1.TString;
113
- category: alepha1.TOptional<alepha1.TString>;
114
- critical: alepha1.TOptional<alepha1.TBoolean>;
115
- sensitive: alepha1.TOptional<alepha1.TBoolean>;
116
- contact: alepha1.TString;
117
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
118
- scheduledAt: alepha1.TOptional<alepha1.TString>;
119
- sentAt: alepha1.TOptional<alepha1.TString>;
120
- error: alepha1.TOptional<alepha1.TObject<{
121
- at: alepha1.TString;
122
- name: alepha1.TString;
123
- message: alepha1.TString;
124
- }>>;
125
- }>>;
126
- protected readonly dateTimeProvider: DateTimeProvider;
127
- protected readonly notificationSenderService: NotificationSenderService;
128
- readonly notificationBatch: alepha_batch0.BatchPrimitive<alepha1.TObject<{
129
- type: alepha1.TUnsafe<"email" | "sms">;
130
- template: alepha1.TString;
131
- contact: alepha1.TString;
132
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
133
- }>, Promise<void>>;
134
- findNotificationById(id: string): Promise<alepha_orm0.PgStatic<alepha1.TObject<{
135
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
136
- version: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TInteger, typeof alepha_orm0.PG_VERSION>, typeof alepha_orm0.PG_DEFAULT>;
137
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
138
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
139
- type: alepha1.TUnsafe<"email" | "sms">;
140
- template: alepha1.TString;
141
- category: alepha1.TOptional<alepha1.TString>;
142
- critical: alepha1.TOptional<alepha1.TBoolean>;
143
- sensitive: alepha1.TOptional<alepha1.TBoolean>;
144
- contact: alepha1.TString;
145
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
146
- scheduledAt: alepha1.TOptional<alepha1.TString>;
147
- sentAt: alepha1.TOptional<alepha1.TString>;
148
- error: alepha1.TOptional<alepha1.TObject<{
149
- at: alepha1.TString;
150
- name: alepha1.TString;
151
- message: alepha1.TString;
152
- }>>;
153
- }>, alepha_orm0.PgRelationMap<alepha1.TObject<{
154
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
155
- version: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TInteger, typeof alepha_orm0.PG_VERSION>, typeof alepha_orm0.PG_DEFAULT>;
156
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
157
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
158
- type: alepha1.TUnsafe<"email" | "sms">;
159
- template: alepha1.TString;
160
- category: alepha1.TOptional<alepha1.TString>;
161
- critical: alepha1.TOptional<alepha1.TBoolean>;
162
- sensitive: alepha1.TOptional<alepha1.TBoolean>;
163
- contact: alepha1.TString;
164
- variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
165
- scheduledAt: alepha1.TOptional<alepha1.TString>;
166
- sentAt: alepha1.TOptional<alepha1.TString>;
167
- error: alepha1.TOptional<alepha1.TObject<{
168
- at: alepha1.TString;
169
- name: alepha1.TString;
170
- message: alepha1.TString;
171
- }>>;
172
- }>>>>;
173
- /**
174
- * Create a new notification.
175
- */
176
- createNotification(entry: NotificationCreate): Promise<void>;
177
- }
56
+ type NotificationQuery = Static<typeof notificationQuerySchema>;
178
57
  //#endregion
179
58
  //#region src/api-notifications/primitives/$notification.d.ts
180
59
  /**
@@ -240,18 +119,194 @@ interface NotificationMessage<T extends TObject> {
240
119
  };
241
120
  }
242
121
  //#endregion
122
+ //#region src/api-notifications/services/NotificationSenderService.d.ts
123
+ declare class NotificationSenderService {
124
+ protected readonly alepha: Alepha;
125
+ protected readonly log: alepha_logger0.Logger;
126
+ protected readonly notificationRepository: alepha_orm15.Repository<alepha45.TObject<{
127
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
128
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
129
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
130
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
131
+ type: alepha45.TUnsafe<"email" | "sms">;
132
+ template: alepha45.TString;
133
+ category: alepha45.TOptional<alepha45.TString>;
134
+ critical: alepha45.TOptional<alepha45.TBoolean>;
135
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
136
+ contact: alepha45.TString;
137
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
138
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
139
+ sentAt: alepha45.TOptional<alepha45.TString>;
140
+ error: alepha45.TOptional<alepha45.TObject<{
141
+ at: alepha45.TString;
142
+ name: alepha45.TString;
143
+ message: alepha45.TString;
144
+ }>>;
145
+ }>>;
146
+ protected readonly dateTimeProvider: DateTimeProvider;
147
+ protected readonly emailProvider: EmailProvider;
148
+ protected readonly smsProvider: SmsProvider;
149
+ send(notificationId: string | NotificationEntity): Promise<void>;
150
+ renderSms(notification: NotificationEntity): {
151
+ to: string;
152
+ message: string;
153
+ };
154
+ renderEmail(notification: NotificationEntity): {
155
+ to: string;
156
+ subject: string;
157
+ body: string;
158
+ };
159
+ protected load(notification: NotificationEntity): {
160
+ template: NotificationPrimitive<alepha45.TObject<alepha45.TProperties>>;
161
+ variables: Record<string, any>;
162
+ contact: string;
163
+ };
164
+ }
165
+ //#endregion
166
+ //#region src/api-notifications/services/NotificationService.d.ts
167
+ declare const notificationServiceEnvSchema: alepha45.TObject<{
168
+ NOTIFICATION_QUEUE: alepha45.TOptional<alepha45.TBoolean>;
169
+ }>;
170
+ declare module "alepha" {
171
+ interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}
172
+ }
173
+ declare class NotificationService {
174
+ protected readonly alepha: Alepha;
175
+ protected readonly log: alepha_logger0.Logger;
176
+ protected readonly env: {
177
+ NOTIFICATION_QUEUE?: boolean | undefined;
178
+ };
179
+ protected readonly notificationRepository: alepha_orm15.Repository<alepha45.TObject<{
180
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
181
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
182
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
183
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
184
+ type: alepha45.TUnsafe<"email" | "sms">;
185
+ template: alepha45.TString;
186
+ category: alepha45.TOptional<alepha45.TString>;
187
+ critical: alepha45.TOptional<alepha45.TBoolean>;
188
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
189
+ contact: alepha45.TString;
190
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
191
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
192
+ sentAt: alepha45.TOptional<alepha45.TString>;
193
+ error: alepha45.TOptional<alepha45.TObject<{
194
+ at: alepha45.TString;
195
+ name: alepha45.TString;
196
+ message: alepha45.TString;
197
+ }>>;
198
+ }>>;
199
+ protected readonly dateTimeProvider: DateTimeProvider;
200
+ protected readonly notificationSenderService: NotificationSenderService;
201
+ readonly notificationBatch: alepha_batch0.BatchPrimitive<alepha45.TObject<{
202
+ type: alepha45.TUnsafe<"email" | "sms">;
203
+ template: alepha45.TString;
204
+ contact: alepha45.TString;
205
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
206
+ }>, Promise<void>>;
207
+ findNotificationById(id: string): Promise<alepha_orm15.PgStatic<alepha45.TObject<{
208
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
209
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
210
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
211
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
212
+ type: alepha45.TUnsafe<"email" | "sms">;
213
+ template: alepha45.TString;
214
+ category: alepha45.TOptional<alepha45.TString>;
215
+ critical: alepha45.TOptional<alepha45.TBoolean>;
216
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
217
+ contact: alepha45.TString;
218
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
219
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
220
+ sentAt: alepha45.TOptional<alepha45.TString>;
221
+ error: alepha45.TOptional<alepha45.TObject<{
222
+ at: alepha45.TString;
223
+ name: alepha45.TString;
224
+ message: alepha45.TString;
225
+ }>>;
226
+ }>, alepha_orm15.PgRelationMap<alepha45.TObject<{
227
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
228
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
229
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
230
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
231
+ type: alepha45.TUnsafe<"email" | "sms">;
232
+ template: alepha45.TString;
233
+ category: alepha45.TOptional<alepha45.TString>;
234
+ critical: alepha45.TOptional<alepha45.TBoolean>;
235
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
236
+ contact: alepha45.TString;
237
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
238
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
239
+ sentAt: alepha45.TOptional<alepha45.TString>;
240
+ error: alepha45.TOptional<alepha45.TObject<{
241
+ at: alepha45.TString;
242
+ name: alepha45.TString;
243
+ message: alepha45.TString;
244
+ }>>;
245
+ }>>>>;
246
+ findNotifications(q?: NotificationQuery): Promise<Page<NotificationEntity>>;
247
+ /**
248
+ * Create a new notification.
249
+ */
250
+ createNotification(entry: NotificationCreate): Promise<void>;
251
+ }
252
+ //#endregion
253
+ //#region src/api-notifications/controllers/NotificationController.d.ts
254
+ declare class NotificationController {
255
+ protected readonly url = "/notifications";
256
+ protected readonly group = "notifications";
257
+ protected readonly notificationService: NotificationService;
258
+ /**
259
+ * Find notifications with pagination and filtering.
260
+ */
261
+ readonly findNotifications: alepha_server0.ActionPrimitiveFn<{
262
+ query: alepha45.TObject<{
263
+ page: alepha45.TOptional<alepha45.TInteger>;
264
+ size: alepha45.TOptional<alepha45.TInteger>;
265
+ sort: alepha45.TOptional<alepha45.TString>;
266
+ type: alepha45.TOptional<alepha45.TUnsafe<"email" | "sms">>;
267
+ template: alepha45.TOptional<alepha45.TString>;
268
+ contact: alepha45.TOptional<alepha45.TString>;
269
+ category: alepha45.TOptional<alepha45.TString>;
270
+ status: alepha45.TOptional<alepha45.TUnsafe<"pending" | "sent" | "failed">>;
271
+ }>;
272
+ response: alepha45.TPage<alepha45.TObject<{
273
+ id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
274
+ version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
275
+ createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
276
+ updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
277
+ type: alepha45.TUnsafe<"email" | "sms">;
278
+ template: alepha45.TString;
279
+ category: alepha45.TOptional<alepha45.TString>;
280
+ critical: alepha45.TOptional<alepha45.TBoolean>;
281
+ sensitive: alepha45.TOptional<alepha45.TBoolean>;
282
+ contact: alepha45.TString;
283
+ variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
284
+ scheduledAt: alepha45.TOptional<alepha45.TString>;
285
+ sentAt: alepha45.TOptional<alepha45.TString>;
286
+ error: alepha45.TOptional<alepha45.TObject<{
287
+ at: alepha45.TString;
288
+ name: alepha45.TString;
289
+ message: alepha45.TString;
290
+ }>>;
291
+ }>>;
292
+ }>;
293
+ }
294
+ //#endregion
295
+ //#region src/api-notifications/jobs/NotificationJobs.d.ts
296
+ declare class NotificationJobs {}
297
+ //#endregion
243
298
  //#region src/api-notifications/queues/NotificationQueues.d.ts
244
299
  declare class NotificationQueues {
245
300
  protected readonly notificationSenderService: NotificationSenderService;
246
- readonly processNotification: alepha_queue0.QueuePrimitive<alepha1.TObject<{
247
- notificationId: alepha1.TString;
301
+ readonly processNotification: alepha_queue0.QueuePrimitive<alepha45.TObject<{
302
+ notificationId: alepha45.TString;
248
303
  }>>;
249
304
  }
250
305
  //#endregion
251
306
  //#region src/api-notifications/schemas/notificationContactPreferencesSchema.d.ts
252
- declare const notificationContactPreferencesSchema: alepha1.TObject<{
253
- language: alepha1.TOptional<alepha1.TString>;
254
- exclude: alepha1.TArray<alepha1.TString>;
307
+ declare const notificationContactPreferencesSchema: alepha45.TObject<{
308
+ language: alepha45.TOptional<alepha45.TString>;
309
+ exclude: alepha45.TArray<alepha45.TString>;
255
310
  }>;
256
311
  type NotificationContactPreferences = Static<typeof notificationContactPreferencesSchema>;
257
312
  //#endregion
@@ -266,7 +321,7 @@ type NotificationContactPreferences = Static<typeof notificationContactPreferenc
266
321
  *
267
322
  * @module alepha.api.notifications
268
323
  */
269
- declare const AlephaApiNotifications: alepha1.Service<alepha1.Module>;
324
+ declare const AlephaApiNotifications: alepha45.Service<alepha45.Module>;
270
325
  //#endregion
271
- export { $notification, AlephaApiNotifications, NotificationContactPreferences, NotificationController, NotificationCreate, NotificationEntity, NotificationJobs, NotificationMessage, NotificationPrimitive, NotificationPrimitiveOptions, NotificationPushOptions, NotificationQueues, NotificationSenderService, NotificationService, notificationContactPreferencesSchema, notificationCreateSchema, notificationServiceEnvSchema, notifications };
326
+ export { $notification, AlephaApiNotifications, NotificationContactPreferences, NotificationController, NotificationCreate, NotificationEntity, NotificationJobs, NotificationMessage, NotificationPrimitive, NotificationPrimitiveOptions, NotificationPushOptions, NotificationQuery, NotificationQueues, NotificationSenderService, NotificationService, notificationContactPreferencesSchema, notificationCreateSchema, notificationQuerySchema, notificationServiceEnvSchema, notifications };
272
327
  //# sourceMappingURL=index.d.ts.map
@@ -1,20 +1,13 @@
1
1
  import { $env, $inject, $module, Alepha, AlephaError, KIND, Primitive, createPrimitive, t } from "alepha";
2
+ import { $entity, $repository, pageQuerySchema, pg } from "alepha/orm";
3
+ import { $action } from "alepha/server";
2
4
  import { $batch } from "alepha/batch";
3
5
  import { DateTimeProvider } from "alepha/datetime";
4
6
  import { $logger } from "alepha/logger";
5
- import { $entity, $repository, pg } from "alepha/orm";
6
7
  import { $queue } from "alepha/queue";
7
8
  import { EmailProvider } from "alepha/email";
8
9
  import { SmsProvider } from "alepha/sms";
9
10
 
10
- //#region src/api-notifications/controllers/NotificationController.ts
11
- var NotificationController = class {};
12
-
13
- //#endregion
14
- //#region src/api-notifications/jobs/NotificationJobs.ts
15
- var NotificationJobs = class {};
16
-
17
- //#endregion
18
11
  //#region src/api-notifications/entities/notifications.ts
19
12
  const notifications = $entity({
20
13
  name: "notifications",
@@ -40,6 +33,69 @@ const notifications = $entity({
40
33
  })
41
34
  });
42
35
 
36
+ //#endregion
37
+ //#region src/api-notifications/schemas/notificationQuerySchema.ts
38
+ const notificationQuerySchema = t.extend(pageQuerySchema, {
39
+ type: t.optional(t.enum(["email", "sms"])),
40
+ template: t.optional(t.string()),
41
+ contact: t.optional(t.string()),
42
+ category: t.optional(t.string()),
43
+ status: t.optional(t.enum([
44
+ "pending",
45
+ "sent",
46
+ "failed"
47
+ ]))
48
+ });
49
+
50
+ //#endregion
51
+ //#region src/api-notifications/primitives/$notification.ts
52
+ /**
53
+ * Creates a notification primitive for managing email/SMS notification templates.
54
+ *
55
+ * Provides type-safe, reusable notification templates with multi-language support,
56
+ * variable substitution, and categorization for different notification channels.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * class NotificationTemplates {
61
+ * welcomeEmail = $notification({
62
+ * name: "welcome-email",
63
+ * category: "onboarding",
64
+ * schema: t.object({ username: t.text(), activationLink: t.text() }),
65
+ * email: {
66
+ * subject: "Welcome to our platform!",
67
+ * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`
68
+ * }
69
+ * });
70
+ *
71
+ * async sendWelcome(user: User) {
72
+ * await this.welcomeEmail.push({
73
+ * variables: { username: user.name, activationLink: generateLink() },
74
+ * contact: user.email
75
+ * });
76
+ * }
77
+ * }
78
+ * ```
79
+ */
80
+ const $notification = (options) => createPrimitive(NotificationPrimitive, options);
81
+ var NotificationPrimitive = class extends Primitive {
82
+ notificationService = $inject(NotificationService);
83
+ get name() {
84
+ return this.options.name ?? `${this.config.propertyKey}`;
85
+ }
86
+ async push(options) {
87
+ if (this.options.email) await this.notificationService.createNotification({
88
+ ...options,
89
+ type: "email",
90
+ template: this.name
91
+ });
92
+ }
93
+ configure(options) {
94
+ Object.assign(this.options, options);
95
+ }
96
+ };
97
+ $notification[KIND] = NotificationPrimitive;
98
+
43
99
  //#endregion
44
100
  //#region src/api-notifications/services/NotificationSenderService.ts
45
101
  var NotificationSenderService = class {
@@ -221,6 +277,26 @@ var NotificationService = class {
221
277
  this.log.trace("Finding notification by ID", { id });
222
278
  return this.notificationRepository.findOne({ where: { id } });
223
279
  }
280
+ async findNotifications(q = {}) {
281
+ this.log.trace("Finding notifications", { query: q });
282
+ q.sort ??= "-createdAt";
283
+ const where = this.notificationRepository.createQueryWhere();
284
+ if (q.type) where.type = { eq: q.type };
285
+ if (q.template) where.template = { like: `%${q.template}%` };
286
+ if (q.contact) where.contact = { like: `%${q.contact}%` };
287
+ if (q.category) where.category = { eq: q.category };
288
+ if (q.status) {
289
+ if (q.status === "sent") {
290
+ where.sentAt = { isNotNull: true };
291
+ where.error = { isNull: true };
292
+ } else if (q.status === "failed") where.error = { isNotNull: true };
293
+ else if (q.status === "pending") {
294
+ where.sentAt = { isNull: true };
295
+ where.error = { isNull: true };
296
+ }
297
+ }
298
+ return this.notificationRepository.paginate(q, { where }, { count: true });
299
+ }
224
300
  /**
225
301
  * Create a new notification.
226
302
  */
@@ -257,53 +333,29 @@ var NotificationService = class {
257
333
  };
258
334
 
259
335
  //#endregion
260
- //#region src/api-notifications/primitives/$notification.ts
261
- /**
262
- * Creates a notification primitive for managing email/SMS notification templates.
263
- *
264
- * Provides type-safe, reusable notification templates with multi-language support,
265
- * variable substitution, and categorization for different notification channels.
266
- *
267
- * @example
268
- * ```ts
269
- * class NotificationTemplates {
270
- * welcomeEmail = $notification({
271
- * name: "welcome-email",
272
- * category: "onboarding",
273
- * schema: t.object({ username: t.text(), activationLink: t.text() }),
274
- * email: {
275
- * subject: "Welcome to our platform!",
276
- * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`
277
- * }
278
- * });
279
- *
280
- * async sendWelcome(user: User) {
281
- * await this.welcomeEmail.push({
282
- * variables: { username: user.name, activationLink: generateLink() },
283
- * contact: user.email
284
- * });
285
- * }
286
- * }
287
- * ```
288
- */
289
- const $notification = (options) => createPrimitive(NotificationPrimitive, options);
290
- var NotificationPrimitive = class extends Primitive {
336
+ //#region src/api-notifications/controllers/NotificationController.ts
337
+ var NotificationController = class {
338
+ url = "/notifications";
339
+ group = "notifications";
291
340
  notificationService = $inject(NotificationService);
292
- get name() {
293
- return this.options.name ?? `${this.config.propertyKey}`;
294
- }
295
- async push(options) {
296
- if (this.options.email) await this.notificationService.createNotification({
297
- ...options,
298
- type: "email",
299
- template: this.name
300
- });
301
- }
302
- configure(options) {
303
- Object.assign(this.options, options);
304
- }
341
+ /**
342
+ * Find notifications with pagination and filtering.
343
+ */
344
+ findNotifications = $action({
345
+ path: this.url,
346
+ group: this.group,
347
+ description: "Find notifications with pagination and filtering",
348
+ schema: {
349
+ query: notificationQuerySchema,
350
+ response: pg.page(notifications.schema)
351
+ },
352
+ handler: ({ query }) => this.notificationService.findNotifications(query)
353
+ });
305
354
  };
306
- $notification[KIND] = NotificationPrimitive;
355
+
356
+ //#endregion
357
+ //#region src/api-notifications/jobs/NotificationJobs.ts
358
+ var NotificationJobs = class {};
307
359
 
308
360
  //#endregion
309
361
  //#region src/api-notifications/schemas/notificationContactPreferencesSchema.ts
@@ -341,5 +393,5 @@ const AlephaApiNotifications = $module({
341
393
  });
342
394
 
343
395
  //#endregion
344
- export { $notification, AlephaApiNotifications, NotificationController, NotificationJobs, NotificationPrimitive, NotificationQueues, NotificationSenderService, NotificationService, notificationContactPreferencesSchema, notificationCreateSchema, notificationServiceEnvSchema, notifications };
396
+ export { $notification, AlephaApiNotifications, NotificationController, NotificationJobs, NotificationPrimitive, NotificationQueues, NotificationSenderService, NotificationService, notificationContactPreferencesSchema, notificationCreateSchema, notificationQuerySchema, notificationServiceEnvSchema, notifications };
345
397
  //# sourceMappingURL=index.js.map