@alepha/devtools 0.10.6 → 0.10.7

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.
@@ -23,249 +23,249 @@ import type { DevSchedulerMetadata } from "./schemas/DevSchedulerMetadata.ts";
23
23
  import type { DevTopicMetadata } from "./schemas/DevTopicMetadata.ts";
24
24
 
25
25
  export class DevCollectorProvider {
26
- protected readonly alepha = $inject(Alepha);
27
- protected readonly logs: DevLogEntry[] = [];
28
- protected readonly maxLogs = 10000;
26
+ protected readonly alepha = $inject(Alepha);
27
+ protected readonly logs: DevLogEntry[] = [];
28
+ protected readonly maxLogs = 10000;
29
29
 
30
- protected readonly onLog = $hook({
31
- on: "log",
32
- handler: (ev: { message: string; entry: LogEntry }) => {
33
- this.logs.push({
34
- formatted: ev.message,
35
- entry: ev.entry,
36
- });
30
+ protected readonly onLog = $hook({
31
+ on: "log",
32
+ handler: (ev: { message: string; entry: LogEntry }) => {
33
+ this.logs.push({
34
+ formatted: ev.message,
35
+ entry: ev.entry,
36
+ });
37
37
 
38
- // Keep only the last 10000 logs
39
- if (this.logs.length > this.maxLogs) {
40
- this.logs.shift();
41
- }
42
- },
43
- });
38
+ // Keep only the last 10000 logs
39
+ if (this.logs.length > this.maxLogs) {
40
+ this.logs.shift();
41
+ }
42
+ },
43
+ });
44
44
 
45
- protected readonly uiRoute = $route({
46
- method: "GET",
47
- path: "/devtools",
48
- schema: {
49
- response: t.text(),
50
- },
51
- handler: () => {
52
- return ui;
53
- },
54
- });
45
+ protected readonly uiRoute = $route({
46
+ method: "GET",
47
+ path: "/devtools",
48
+ schema: {
49
+ response: t.text(),
50
+ },
51
+ handler: () => {
52
+ return ui;
53
+ },
54
+ });
55
55
 
56
- protected readonly metadataRoute = $route({
57
- method: "GET",
58
- path: "/devtools/metadata",
59
- schema: {
60
- response: devMetadataSchema,
61
- },
62
- handler: () => {
63
- return this.getMetadata();
64
- },
65
- });
56
+ protected readonly metadataRoute = $route({
57
+ method: "GET",
58
+ path: "/devtools/metadata",
59
+ schema: {
60
+ response: devMetadataSchema,
61
+ },
62
+ handler: () => {
63
+ return this.getMetadata();
64
+ },
65
+ });
66
66
 
67
- protected readonly logsRoute = $route({
68
- method: "GET",
69
- path: "/devtools/logs",
70
- schema: {
71
- response: t.array(
72
- t.object({
73
- formatted: t.text(),
74
- entry: t.any(),
75
- }),
76
- ),
77
- },
78
- handler: () => {
79
- return this.getLogs();
80
- },
81
- });
67
+ protected readonly logsRoute = $route({
68
+ method: "GET",
69
+ path: "/devtools/logs",
70
+ schema: {
71
+ response: t.array(
72
+ t.object({
73
+ formatted: t.text(),
74
+ entry: t.any(),
75
+ }),
76
+ ),
77
+ },
78
+ handler: () => {
79
+ return this.getLogs();
80
+ },
81
+ });
82
82
 
83
- public getLogs(): DevLogEntry[] {
84
- return this.logs;
85
- }
83
+ public getLogs(): DevLogEntry[] {
84
+ return this.logs;
85
+ }
86
86
 
87
- public getActions(): DevActionMetadata[] {
88
- const actionDescriptors = this.alepha.descriptors($action);
87
+ public getActions(): DevActionMetadata[] {
88
+ const actionDescriptors = this.alepha.descriptors($action);
89
89
 
90
- return actionDescriptors.map((action) => {
91
- const schema = action.schema;
92
- const options = action.options as any; // Allow accessing augmented properties
90
+ return actionDescriptors.map((action) => {
91
+ const schema = action.schema;
92
+ const options = action.options as any; // Allow accessing augmented properties
93
93
 
94
- return {
95
- name: action.name,
96
- group: action.group,
97
- method: action.method,
98
- path: action.path,
99
- prefix: action.prefix,
100
- fullPath: action.route.path,
101
- description: action.options.description,
102
- summary: options.summary,
103
- disabled: action.options.disabled,
104
- secure: options.secure,
105
- hide: options.hide,
106
- body: schema?.body,
107
- params: schema?.params,
108
- query: schema?.query,
109
- response: schema?.response,
110
- bodyContentType: action.getBodyContentType(),
111
- };
112
- });
113
- }
94
+ return {
95
+ name: action.name,
96
+ group: action.group,
97
+ method: action.method,
98
+ path: action.path,
99
+ prefix: action.prefix,
100
+ fullPath: action.route.path,
101
+ description: action.options.description,
102
+ summary: options.summary,
103
+ disabled: action.options.disabled,
104
+ secure: options.secure,
105
+ hide: options.hide,
106
+ body: schema?.body,
107
+ params: schema?.params,
108
+ query: schema?.query,
109
+ response: schema?.response,
110
+ bodyContentType: action.getBodyContentType(),
111
+ };
112
+ });
113
+ }
114
114
 
115
- public getQueues(): DevQueueMetadata[] {
116
- const queueDescriptors = this.alepha.descriptors($queue);
115
+ public getQueues(): DevQueueMetadata[] {
116
+ const queueDescriptors = this.alepha.descriptors($queue);
117
117
 
118
- return queueDescriptors.map((queue) => ({
119
- name: queue.name,
120
- description: queue.options.description,
121
- schema: queue.options.schema,
122
- provider: this.getProviderName(queue.options.provider),
123
- }));
124
- }
118
+ return queueDescriptors.map((queue) => ({
119
+ name: queue.name,
120
+ description: queue.options.description,
121
+ schema: queue.options.schema,
122
+ provider: this.getProviderName(queue.options.provider),
123
+ }));
124
+ }
125
125
 
126
- public getSchedulers(): DevSchedulerMetadata[] {
127
- const schedulerDescriptors = this.alepha.descriptors($scheduler);
126
+ public getSchedulers(): DevSchedulerMetadata[] {
127
+ const schedulerDescriptors = this.alepha.descriptors($scheduler);
128
128
 
129
- return schedulerDescriptors.map((scheduler) => ({
130
- name: scheduler.name,
131
- description: scheduler.options.description,
132
- cron: scheduler.options.cron,
133
- interval: scheduler.options.interval,
134
- lock: scheduler.options.lock,
135
- }));
136
- }
129
+ return schedulerDescriptors.map((scheduler) => ({
130
+ name: scheduler.name,
131
+ description: scheduler.options.description,
132
+ cron: scheduler.options.cron,
133
+ interval: scheduler.options.interval,
134
+ lock: scheduler.options.lock,
135
+ }));
136
+ }
137
137
 
138
- public getTopics(): DevTopicMetadata[] {
139
- const topicDescriptors = this.alepha.descriptors($topic);
138
+ public getTopics(): DevTopicMetadata[] {
139
+ const topicDescriptors = this.alepha.descriptors($topic);
140
140
 
141
- return topicDescriptors.map((topic) => ({
142
- name: topic.name,
143
- description: topic.options.description,
144
- schema: topic.options.schema,
145
- provider: this.getProviderName(topic.options.provider),
146
- }));
147
- }
141
+ return topicDescriptors.map((topic) => ({
142
+ name: topic.name,
143
+ description: topic.options.description,
144
+ schema: topic.options.schema,
145
+ provider: this.getProviderName(topic.options.provider),
146
+ }));
147
+ }
148
148
 
149
- public getBuckets(): DevBucketMetadata[] {
150
- const bucketDescriptors = this.alepha.descriptors($bucket);
149
+ public getBuckets(): DevBucketMetadata[] {
150
+ const bucketDescriptors = this.alepha.descriptors($bucket);
151
151
 
152
- return bucketDescriptors.map((bucket) => ({
153
- name: bucket.name,
154
- description: bucket.options.description,
155
- mimeTypes: bucket.options.mimeTypes,
156
- maxSize: bucket.options.maxSize,
157
- provider: this.getProviderName(bucket.options.provider),
158
- }));
159
- }
152
+ return bucketDescriptors.map((bucket) => ({
153
+ name: bucket.name,
154
+ description: bucket.options.description,
155
+ mimeTypes: bucket.options.mimeTypes,
156
+ maxSize: bucket.options.maxSize,
157
+ provider: this.getProviderName(bucket.options.provider),
158
+ }));
159
+ }
160
160
 
161
- public getRealms(): DevRealmMetadata[] {
162
- const realmDescriptors = this.alepha.descriptors($realm);
161
+ public getRealms(): DevRealmMetadata[] {
162
+ const realmDescriptors = this.alepha.descriptors($realm);
163
163
 
164
- return realmDescriptors.map((realm) => ({
165
- name: realm.name,
166
- description: realm.options.description,
167
- roles: realm.options.roles,
168
- type: "secret" in realm.options ? "internal" : "external",
169
- settings: {
170
- accessTokenExpiration: realm.options.settings?.accessToken?.expiration,
171
- refreshTokenExpiration:
172
- realm.options.settings?.refreshToken?.expiration,
173
- hasOnCreateSession: !!realm.options.settings?.onCreateSession,
174
- hasOnRefreshSession: !!realm.options.settings?.onRefreshSession,
175
- hasOnDeleteSession: !!realm.options.settings?.onDeleteSession,
176
- },
177
- }));
178
- }
164
+ return realmDescriptors.map((realm) => ({
165
+ name: realm.name,
166
+ description: realm.options.description,
167
+ roles: realm.options.roles,
168
+ type: "secret" in realm.options ? "internal" : "external",
169
+ settings: {
170
+ accessTokenExpiration: realm.options.settings?.accessToken?.expiration,
171
+ refreshTokenExpiration:
172
+ realm.options.settings?.refreshToken?.expiration,
173
+ hasOnCreateSession: !!realm.options.settings?.onCreateSession,
174
+ hasOnRefreshSession: !!realm.options.settings?.onRefreshSession,
175
+ hasOnDeleteSession: !!realm.options.settings?.onDeleteSession,
176
+ },
177
+ }));
178
+ }
179
179
 
180
- public getCaches(): DevCacheMetadata[] {
181
- const cacheDescriptors = this.alepha.descriptors($cache);
180
+ public getCaches(): DevCacheMetadata[] {
181
+ const cacheDescriptors = this.alepha.descriptors($cache);
182
182
 
183
- return cacheDescriptors.map((cache) => ({
184
- name: cache.container,
185
- ttl: cache.options.ttl,
186
- disabled: cache.options.disabled,
187
- provider: this.getProviderName(cache.options.provider),
188
- }));
189
- }
183
+ return cacheDescriptors.map((cache) => ({
184
+ name: cache.container,
185
+ ttl: cache.options.ttl,
186
+ disabled: cache.options.disabled,
187
+ provider: this.getProviderName(cache.options.provider),
188
+ }));
189
+ }
190
190
 
191
- public getPages(): DevPageMetadata[] {
192
- const pageDescriptors = this.alepha.descriptors($page);
191
+ public getPages(): DevPageMetadata[] {
192
+ const pageDescriptors = this.alepha.descriptors($page);
193
193
 
194
- return pageDescriptors.map((page) => ({
195
- name: page.name,
196
- description: page.options.description,
197
- path: page.options.path,
198
- params: page.options.schema?.params,
199
- query: page.options.schema?.query,
200
- hasComponent: !!page.options.component,
201
- hasLazy: !!page.options.lazy,
202
- hasResolve: !!page.options.resolve,
203
- hasChildren: !!page.options.children,
204
- hasParent: !!page.options.parent,
205
- hasErrorHandler: !!page.options.errorHandler,
206
- static:
207
- typeof page.options.static === "boolean"
208
- ? page.options.static
209
- : !!page.options.static,
210
- cache: page.options.cache,
211
- client: page.options.client,
212
- animation: page.options.animation,
213
- }));
214
- }
194
+ return pageDescriptors.map((page) => ({
195
+ name: page.name,
196
+ description: page.options.description,
197
+ path: page.options.path,
198
+ params: page.options.schema?.params,
199
+ query: page.options.schema?.query,
200
+ hasComponent: !!page.options.component,
201
+ hasLazy: !!page.options.lazy,
202
+ hasResolve: !!page.options.resolve,
203
+ hasChildren: !!page.options.children,
204
+ hasParent: !!page.options.parent,
205
+ hasErrorHandler: !!page.options.errorHandler,
206
+ static:
207
+ typeof page.options.static === "boolean"
208
+ ? page.options.static
209
+ : !!page.options.static,
210
+ cache: page.options.cache,
211
+ client: page.options.client,
212
+ animation: page.options.animation,
213
+ }));
214
+ }
215
215
 
216
- public getProviders(): DevProviderMetadata[] {
217
- const graph = this.alepha.graph();
216
+ public getProviders(): DevProviderMetadata[] {
217
+ const graph = this.alepha.graph();
218
218
 
219
- return Object.entries(graph).map(([name, info]) => ({
220
- name,
221
- module: info.module,
222
- dependencies: info.from,
223
- aliases: info.as,
224
- }));
225
- }
219
+ return Object.entries(graph).map(([name, info]) => ({
220
+ name,
221
+ module: info.module,
222
+ dependencies: info.from,
223
+ aliases: info.as,
224
+ }));
225
+ }
226
226
 
227
- public getModules(): DevModuleMetadata[] {
228
- const graph = this.alepha.graph();
229
- const moduleMap = new Map<string, Set<string>>();
227
+ public getModules(): DevModuleMetadata[] {
228
+ const graph = this.alepha.graph();
229
+ const moduleMap = new Map<string, Set<string>>();
230
230
 
231
- // Group providers by module
232
- for (const [providerName, info] of Object.entries(graph)) {
233
- if (info.module) {
234
- if (!moduleMap.has(info.module)) {
235
- moduleMap.set(info.module, new Set());
236
- }
237
- moduleMap.get(info.module)!.add(providerName);
238
- }
239
- }
231
+ // Group providers by module
232
+ for (const [providerName, info] of Object.entries(graph)) {
233
+ if (info.module) {
234
+ if (!moduleMap.has(info.module)) {
235
+ moduleMap.set(info.module, new Set());
236
+ }
237
+ moduleMap.get(info.module)!.add(providerName);
238
+ }
239
+ }
240
240
 
241
- return Array.from(moduleMap.entries()).map(([name, providers]) => ({
242
- name,
243
- providers: Array.from(providers),
244
- }));
245
- }
241
+ return Array.from(moduleMap.entries()).map(([name, providers]) => ({
242
+ name,
243
+ providers: Array.from(providers),
244
+ }));
245
+ }
246
246
 
247
- public getMetadata(): DevMetadata {
248
- return {
249
- actions: this.getActions(),
250
- queues: this.getQueues(),
251
- schedulers: this.getSchedulers(),
252
- topics: this.getTopics(),
253
- buckets: this.getBuckets(),
254
- realms: this.getRealms(),
255
- caches: this.getCaches(),
256
- pages: this.getPages(),
257
- providers: this.getProviders(),
258
- modules: this.getModules(),
259
- };
260
- }
247
+ public getMetadata(): DevMetadata {
248
+ return {
249
+ actions: this.getActions(),
250
+ queues: this.getQueues(),
251
+ schedulers: this.getSchedulers(),
252
+ topics: this.getTopics(),
253
+ buckets: this.getBuckets(),
254
+ realms: this.getRealms(),
255
+ caches: this.getCaches(),
256
+ pages: this.getPages(),
257
+ providers: this.getProviders(),
258
+ modules: this.getModules(),
259
+ };
260
+ }
261
261
 
262
- protected getProviderName(provider?: "memory" | any): string {
263
- if (!provider) {
264
- return "default";
265
- }
266
- if (provider === "memory") {
267
- return "memory";
268
- }
269
- return provider.name || "custom";
270
- }
262
+ protected getProviderName(provider?: "memory" | any): string {
263
+ if (!provider) {
264
+ return "default";
265
+ }
266
+ if (provider === "memory") {
267
+ return "memory";
268
+ }
269
+ return provider.name || "custom";
270
+ }
271
271
  }
package/src/index.ts CHANGED
@@ -29,7 +29,7 @@ export * from "./schemas/DevTopicMetadata.ts";
29
29
  * @module alepha.devtools
30
30
  */
31
31
  export const AlephaDevtools = $module({
32
- name: "alepha.devtools",
33
- descriptors: [],
34
- services: [DevCollectorProvider],
32
+ name: "alepha.devtools",
33
+ descriptors: [],
34
+ services: [DevCollectorProvider],
35
35
  });
@@ -1,22 +1,22 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devActionMetadataSchema = t.object({
4
- name: t.text(),
5
- group: t.text(),
6
- method: t.text(),
7
- path: t.text(),
8
- prefix: t.text(),
9
- fullPath: t.text(),
10
- description: t.optional(t.text()),
11
- summary: t.optional(t.text()),
12
- disabled: t.optional(t.boolean()),
13
- secure: t.optional(t.boolean()),
14
- hide: t.optional(t.boolean()),
15
- body: t.optional(t.any()),
16
- params: t.optional(t.any()),
17
- query: t.optional(t.any()),
18
- response: t.optional(t.any()),
19
- bodyContentType: t.optional(t.text()),
4
+ name: t.text(),
5
+ group: t.text(),
6
+ method: t.text(),
7
+ path: t.text(),
8
+ prefix: t.text(),
9
+ fullPath: t.text(),
10
+ description: t.optional(t.text()),
11
+ summary: t.optional(t.text()),
12
+ disabled: t.optional(t.boolean()),
13
+ secure: t.optional(t.boolean()),
14
+ hide: t.optional(t.boolean()),
15
+ body: t.optional(t.any()),
16
+ params: t.optional(t.any()),
17
+ query: t.optional(t.any()),
18
+ response: t.optional(t.any()),
19
+ bodyContentType: t.optional(t.text()),
20
20
  });
21
21
 
22
22
  export type DevActionMetadata = Static<typeof devActionMetadataSchema>;
@@ -1,11 +1,11 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devBucketMetadataSchema = t.object({
4
- name: t.text(),
5
- description: t.optional(t.text()),
6
- mimeTypes: t.optional(t.array(t.text())),
7
- maxSize: t.optional(t.number()),
8
- provider: t.text(),
4
+ name: t.text(),
5
+ description: t.optional(t.text()),
6
+ mimeTypes: t.optional(t.array(t.text())),
7
+ maxSize: t.optional(t.number()),
8
+ provider: t.text(),
9
9
  });
10
10
 
11
11
  export type DevBucketMetadata = Static<typeof devBucketMetadataSchema>;
@@ -1,10 +1,10 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devCacheMetadataSchema = t.object({
4
- name: t.text(),
5
- ttl: t.optional(t.any()),
6
- disabled: t.optional(t.boolean()),
7
- provider: t.text(),
4
+ name: t.text(),
5
+ ttl: t.optional(t.any()),
6
+ disabled: t.optional(t.boolean()),
7
+ provider: t.text(),
8
8
  });
9
9
 
10
10
  export type DevCacheMetadata = Static<typeof devCacheMetadataSchema>;
@@ -2,10 +2,10 @@ import { type Static, t } from "@alepha/core";
2
2
  import type { LogEntry } from "@alepha/logger";
3
3
 
4
4
  export const devLogEntrySchema = t.object({
5
- formatted: t.text(),
6
- entry: t.any(), // Use any since LogEntry has Date instead of string for timestamp
5
+ formatted: t.text(),
6
+ entry: t.any(), // Use any since LogEntry has Date instead of string for timestamp
7
7
  });
8
8
 
9
9
  export type DevLogEntry = Static<typeof devLogEntrySchema> & {
10
- entry: LogEntry;
10
+ entry: LogEntry;
11
11
  };
@@ -11,17 +11,17 @@ import { devSchedulerMetadataSchema } from "./DevSchedulerMetadata.ts";
11
11
  import { devTopicMetadataSchema } from "./DevTopicMetadata.ts";
12
12
 
13
13
  export const devMetadataSchema = t.object({
14
- actions: t.array(devActionMetadataSchema),
15
- queues: t.array(devQueueMetadataSchema),
16
- schedulers: t.array(devSchedulerMetadataSchema),
17
- topics: t.array(devTopicMetadataSchema),
18
- buckets: t.array(devBucketMetadataSchema),
19
- realms: t.array(devRealmMetadataSchema),
20
- caches: t.array(devCacheMetadataSchema),
21
- pages: t.array(devPageMetadataSchema),
22
- providers: t.array(devProviderMetadataSchema),
23
- modules: t.array(devModuleMetadataSchema),
24
- // More metadata will be added here later
14
+ actions: t.array(devActionMetadataSchema),
15
+ queues: t.array(devQueueMetadataSchema),
16
+ schedulers: t.array(devSchedulerMetadataSchema),
17
+ topics: t.array(devTopicMetadataSchema),
18
+ buckets: t.array(devBucketMetadataSchema),
19
+ realms: t.array(devRealmMetadataSchema),
20
+ caches: t.array(devCacheMetadataSchema),
21
+ pages: t.array(devPageMetadataSchema),
22
+ providers: t.array(devProviderMetadataSchema),
23
+ modules: t.array(devModuleMetadataSchema),
24
+ // More metadata will be added here later
25
25
  });
26
26
 
27
27
  export type DevMetadata = Static<typeof devMetadataSchema>;
@@ -1,8 +1,8 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devModuleMetadataSchema = t.object({
4
- name: t.text(),
5
- providers: t.array(t.text()),
4
+ name: t.text(),
5
+ providers: t.array(t.text()),
6
6
  });
7
7
 
8
8
  export type DevModuleMetadata = Static<typeof devModuleMetadataSchema>;
@@ -1,21 +1,21 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devPageMetadataSchema = t.object({
4
- name: t.text(),
5
- description: t.optional(t.text()),
6
- path: t.optional(t.text()),
7
- params: t.optional(t.any()),
8
- query: t.optional(t.any()),
9
- hasComponent: t.boolean(),
10
- hasLazy: t.boolean(),
11
- hasResolve: t.boolean(),
12
- hasChildren: t.boolean(),
13
- hasParent: t.boolean(),
14
- hasErrorHandler: t.boolean(),
15
- static: t.optional(t.boolean()),
16
- cache: t.optional(t.any()),
17
- client: t.optional(t.any()),
18
- animation: t.optional(t.any()),
4
+ name: t.text(),
5
+ description: t.optional(t.text()),
6
+ path: t.optional(t.text()),
7
+ params: t.optional(t.any()),
8
+ query: t.optional(t.any()),
9
+ hasComponent: t.boolean(),
10
+ hasLazy: t.boolean(),
11
+ hasResolve: t.boolean(),
12
+ hasChildren: t.boolean(),
13
+ hasParent: t.boolean(),
14
+ hasErrorHandler: t.boolean(),
15
+ static: t.optional(t.boolean()),
16
+ cache: t.optional(t.any()),
17
+ client: t.optional(t.any()),
18
+ animation: t.optional(t.any()),
19
19
  });
20
20
 
21
21
  export type DevPageMetadata = Static<typeof devPageMetadataSchema>;
@@ -1,10 +1,10 @@
1
1
  import { type Static, t } from "@alepha/core";
2
2
 
3
3
  export const devProviderMetadataSchema = t.object({
4
- name: t.text(),
5
- module: t.optional(t.text()),
6
- dependencies: t.array(t.text()),
7
- aliases: t.optional(t.array(t.text())),
4
+ name: t.text(),
5
+ module: t.optional(t.text()),
6
+ dependencies: t.array(t.text()),
7
+ aliases: t.optional(t.array(t.text())),
8
8
  });
9
9
 
10
10
  export type DevProviderMetadata = Static<typeof devProviderMetadataSchema>;