alepha 0.8.0 → 0.9.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.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
package/topic/redis.d.ts CHANGED
@@ -1,46 +1,45 @@
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha } from "alepha";
1
4
  import { SubscribeCallback, TopicProvider, UnSubscribeFn } from "alepha/topic";
2
- import { Alepha, HookDescriptor, Logger, Module, Static, TObject, TString } from "alepha";
3
5
  import { RedisProvider, RedisSubscriberProvider } from "alepha/redis";
4
6
 
5
7
  //#region src/providers/RedisTopicProvider.d.ts
6
- declare const envSchema: TObject<{
7
- REDIS_TOPIC_PREFIX: TString;
8
- }>;
9
- declare class RedisTopicProvider implements TopicProvider {
10
- protected readonly env: Static<typeof envSchema>;
8
+ declare class RedisTopicProvider extends TopicProvider {
9
+ protected readonly env: {
10
+ REDIS_TOPIC_PREFIX: string;
11
+ };
12
+ protected readonly alepha: Alepha;
11
13
  protected readonly redisProvider: RedisProvider;
12
14
  protected readonly redisSubscriberProvider: RedisSubscriberProvider;
13
- protected readonly log: Logger;
14
- protected readonly stop: HookDescriptor<"stop">;
15
+ protected readonly log: _alepha_core0$1.Logger;
16
+ protected readonly start: _alepha_core0$1.HookDescriptor<"start">;
15
17
  prefix(queue: string): string;
16
18
  /**
17
- * Publish a message to a topic.
18
- */
19
+ * Publish a message to a topic.
20
+ */
19
21
  publish(topic: string, message: string): Promise<void>;
20
22
  /**
21
- * Subscribe to a topic.
22
- */
23
+ * Subscribe to a topic.
24
+ */
23
25
  subscribe(name: string, callback: SubscribeCallback): Promise<UnSubscribeFn>;
24
26
  /**
25
- * Unsubscribe from a topic.
26
- */
27
+ * Unsubscribe from a topic.
28
+ */
27
29
  unsubscribe(name: string, callback?: SubscribeCallback): Promise<void>;
28
30
  }
31
+ //# sourceMappingURL=RedisTopicProvider.d.ts.map
29
32
  //#endregion
30
33
  //#region src/index.d.ts
31
- // ---------------------------------------------------------------------------------------------------------------------
32
34
  /**
33
- * Alepha Topic Redis Module.
34
- *
35
- * Plugin for Alepha Topic that provides Redis pub/sub capabilities.
36
- *
37
- * @see {@link RedisTopicProvider}
38
- * @module alepha.topic.redis
39
- */
40
- declare class AlephaTopicRedis implements Module {
41
- readonly name = "alepha.topic.redis";
42
- readonly $services: (alepha: Alepha) => Alepha;
43
- }
35
+ * Plugin for Alepha Topic that provides Redis pub/sub capabilities.
36
+ *
37
+ * @see {@link RedisTopicProvider}
38
+ * @module alepha.topic.redis
39
+ */
40
+ declare const AlephaTopicRedis: _alepha_core0.ModuleDescriptor;
41
+ //# sourceMappingURL=index.d.ts.map
42
+
44
43
  //#endregion
45
44
  export { AlephaTopicRedis, RedisTopicProvider };
46
45
  //# sourceMappingURL=index.d.ts.map
package/topic.d.ts CHANGED
@@ -1,60 +1,92 @@
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core1 from "alepha";
1
3
  import * as _alepha_core0 from "alepha";
2
- import { Alepha, KIND, Module, OPTIONS, Static, TSchema } from "alepha";
4
+ import { Alepha, Descriptor, KIND, Service, Static, TSchema } from "alepha";
3
5
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
4
6
 
5
7
  //#region src/providers/TopicProvider.d.ts
6
- declare class TopicProvider {
7
- constructor();
8
+ /**
9
+ * Base class for topic providers.
10
+ */
11
+ declare abstract class TopicProvider {
12
+ protected readonly alepha: Alepha;
8
13
  /**
9
14
  * Publish a message to a topic.
10
15
  *
11
16
  * @param topic - The topic to publish to.
12
17
  * @param message - The message to publish.
13
18
  */
14
- publish(_topic: string, _message: string): Promise<void>;
19
+ abstract publish(topic: string, message: string): Promise<void>;
15
20
  /**
16
21
  * Subscribe to a topic.
17
22
  *
18
23
  * @param topic - The topic to subscribe to.
19
24
  * @param callback - The callback to call when a message is received.
20
25
  */
21
- subscribe(_topic: string, _callback: SubscribeCallback): Promise<UnSubscribeFn>;
26
+ abstract subscribe(topic: string, callback: SubscribeCallback): Promise<UnSubscribeFn>;
22
27
  /**
23
28
  * Unsubscribe from a topic.
24
29
  *
25
30
  * @param topic - The topic to unsubscribe from.
26
31
  */
27
- unsubscribe(_topic: string): Promise<void>;
32
+ abstract unsubscribe(topic: string): Promise<void>;
33
+ /**
34
+ * Returns the list of $subscribers for this provider.
35
+ */
36
+ protected subscribers(): Array<() => Promise<unknown>>;
28
37
  }
29
38
  type SubscribeCallback = (message: string) => Promise<void> | void;
30
39
  type UnSubscribeFn = () => Promise<void>;
31
40
  //# sourceMappingURL=TopicProvider.d.ts.map
32
41
  //#endregion
33
42
  //#region src/descriptors/$topic.d.ts
34
- declare const KEY$1 = "TOPIC";
35
- interface TopicMessageSchema {
36
- headers?: TSchema;
37
- payload: TSchema;
38
- }
39
- interface TopicDescriptorOptions<T extends TopicMessageSchema = TopicMessageSchema> {
43
+ /**
44
+ * Create a new topic.
45
+ */
46
+ declare const $topic: {
47
+ <T extends TopicMessageSchema>(options: TopicDescriptorOptions<T>): TopicDescriptor<T>;
48
+ [KIND]: typeof TopicDescriptor;
49
+ };
50
+ interface TopicDescriptorOptions<T extends TopicMessageSchema> {
51
+ /**
52
+ * Topic key.
53
+ *
54
+ * If not provided, the propertyKey is used as the topic name.
55
+ */
40
56
  name?: string;
57
+ /**
58
+ * Describe the topic. For documentation purposes.
59
+ */
41
60
  description?: string;
42
- provider?: "memory" | (() => TopicProvider);
61
+ /**
62
+ * Override the default topic provider.
63
+ *
64
+ * If not provided, the default provider is used.
65
+ * If "memory" is provided, the default in-memory provider is used.
66
+ * If a class is provided, it must extend `TopicProvider`.
67
+ */
68
+ provider?: "memory" | Service<TopicProvider>;
69
+ /**
70
+ * Topic message schema.
71
+ */
43
72
  schema: T;
44
- handler?: (message: {
45
- payload: Static<T["payload"]>;
46
- }) => Promise<void>;
73
+ /**
74
+ * Add a subscriber handler.
75
+ */
76
+ handler?: TopicHandler<T>;
47
77
  }
48
- interface TopicDescriptor<T extends TopicMessageSchema = TopicMessageSchema> {
49
- [KIND]: typeof KEY$1;
50
- [OPTIONS]: TopicDescriptorOptions<T>;
51
- name(): string;
52
- provider(): TopicProvider;
53
- publish(payload: Static<T["payload"]>): Promise<void>;
54
- subscribe(fn: (message: TopicMessage<T>) => void): Promise<UnSubscribeFn>;
55
- wait(options?: TopicWaitOptions<T>): Promise<Static<T["payload"]>>;
78
+ declare class TopicDescriptor<T extends TopicMessageSchema> extends Descriptor<TopicDescriptorOptions<T>> {
79
+ protected readonly log: _alepha_core0$1.Logger;
80
+ protected readonly dateTimeProvider: DateTimeProvider;
81
+ readonly provider: TopicProvider;
82
+ get name(): string;
83
+ publish(payload: TopicMessage<T>["payload"]): Promise<void>;
84
+ subscribe(handler: TopicHandler<T>): Promise<UnSubscribeFn>;
85
+ wait(options?: TopicWaitOptions<T>): Promise<TopicMessage<T>>;
86
+ protected $provider(): TopicProvider;
87
+ protected parseMessage(message: string): TopicMessage<T>;
56
88
  }
57
- interface TopicMessage<T extends TopicMessageSchema = TopicMessageSchema> {
89
+ interface TopicMessage<T extends TopicMessageSchema> {
58
90
  payload: Static<T["payload"]>;
59
91
  }
60
92
  interface TopicWaitOptions<T extends TopicMessageSchema> {
@@ -63,34 +95,27 @@ interface TopicWaitOptions<T extends TopicMessageSchema> {
63
95
  payload: Static<T["payload"]>;
64
96
  }) => boolean;
65
97
  }
66
- declare const $topic: {
67
- <T extends TopicMessageSchema>(options: TopicDescriptorOptions<T>): TopicDescriptor<T>;
68
- [KIND]: string;
69
- };
98
+ interface TopicMessageSchema {
99
+ headers?: TSchema;
100
+ payload: TSchema;
101
+ }
102
+ type TopicHandler<T extends TopicMessageSchema = TopicMessageSchema> = (message: TopicMessage<T>) => unknown;
103
+ //# sourceMappingURL=$topic.d.ts.map
70
104
  //#endregion
71
105
  //#region src/descriptors/$subscriber.d.ts
72
- declare const KEY = "SUBSCRIBER";
73
- interface SubscriberDescriptorOptions<T extends TopicMessageSchema = TopicMessageSchema> {
74
- topic: TopicDescriptor<T>;
75
- handler: (message: {
76
- payload: Static<T["payload"]>;
77
- }) => Promise<void>;
78
- }
79
- interface SubscriberDescriptor<T extends TopicMessageSchema = TopicMessageSchema> {
80
- [KIND]: typeof KEY;
81
- [OPTIONS]: SubscriberDescriptorOptions<T>;
82
- topic: () => TopicDescriptor<T>;
83
- }
84
106
  /**
85
- * Subscriber descriptor.
86
- *
87
- * @param options - The subscriber options.
88
- * @returns The descriptor value.
107
+ * Subscribe to a $topic.
89
108
  */
90
109
  declare const $subscriber: {
91
110
  <T extends TopicMessageSchema>(options: SubscriberDescriptorOptions<T>): SubscriberDescriptor<T>;
92
- [KIND]: string;
111
+ [KIND]: typeof SubscriberDescriptor;
93
112
  };
113
+ interface SubscriberDescriptorOptions<T extends TopicMessageSchema> {
114
+ topic: TopicDescriptor<T>;
115
+ handler: TopicHandler<T>;
116
+ }
117
+ declare class SubscriberDescriptor<T extends TopicMessageSchema> extends Descriptor<SubscriberDescriptorOptions<T>> {}
118
+ //# sourceMappingURL=$subscriber.d.ts.map
94
119
  //#endregion
95
120
  //#region src/errors/TopicTimeoutError.d.ts
96
121
  declare class TopicTimeoutError extends Error {
@@ -101,8 +126,10 @@ declare class TopicTimeoutError extends Error {
101
126
  //# sourceMappingURL=TopicTimeoutError.d.ts.map
102
127
  //#endregion
103
128
  //#region src/providers/MemoryTopicProvider.d.ts
104
- declare class MemoryTopicProvider implements TopicProvider {
129
+ declare class MemoryTopicProvider extends TopicProvider {
130
+ protected readonly log: _alepha_core1.Logger;
105
131
  protected readonly subscriptions: Record<string, SubscribeCallback[]>;
132
+ protected readonly start: _alepha_core1.HookDescriptor<"start">;
106
133
  /**
107
134
  * Publish a message to a topic.
108
135
  *
@@ -126,78 +153,8 @@ declare class MemoryTopicProvider implements TopicProvider {
126
153
  }
127
154
  //# sourceMappingURL=MemoryTopicProvider.d.ts.map
128
155
  //#endregion
129
- //#region src/providers/TopicDescriptorProvider.d.ts
130
- declare class TopicDescriptorProvider {
131
- protected readonly log: _alepha_core0.Logger;
132
- protected readonly alepha: Alepha;
133
- protected readonly dateTimeProvider: DateTimeProvider;
134
- protected readonly topicProvider: TopicProvider;
135
- protected readonly memoryTopicProvider: MemoryTopicProvider;
136
- protected readonly topics: TopicDescriptor[];
137
- protected readonly subscribers: Array<SubscriberDescriptorOptions & {
138
- unsub?: UnSubscribeFn;
139
- }>;
140
- protected readonly configure: _alepha_core0.HookDescriptor<"configure">;
141
- protected readonly start: _alepha_core0.HookDescriptor<"start">;
142
- /**
143
- * Process the descriptors.
144
- *
145
- * @protected
146
- */
147
- protected processDescriptors(): void;
148
- /**
149
- * Process the queue descriptors.
150
- *
151
- * @protected
152
- */
153
- protected processTopicDescriptors(): void;
154
- /**
155
- * Wait for a message on the topic.
156
- *
157
- * @param topic
158
- * @param options
159
- * @protected
160
- */
161
- protected wait(topic: TopicDescriptor, options?: TopicWaitOptions<any>): Promise<unknown>;
162
- /**
163
- * Process the consumer descriptors.
164
- *
165
- * @protected
166
- */
167
- protected processSubscriberDescriptors(): void;
168
- /**
169
- * Get the provider for the queue.
170
- *
171
- * @param options - The queue options.
172
- * @protected
173
- */
174
- protected provider(options: TopicDescriptorOptions): TopicProvider;
175
- /**
176
- * Publish a message to the topic.
177
- *
178
- * @param topic
179
- * @param message
180
- * @protected
181
- */
182
- protected publish<T extends TopicMessageSchema = TopicMessageSchema>(topic: TopicDescriptor<T>, message: TopicMessage<T>): Promise<void>;
183
- /**
184
- * Process a message.
185
- *
186
- * @param subscriber
187
- * @param message
188
- * @protected
189
- */
190
- protected processMessage(subscriber: SubscriberDescriptorOptions, message: string): Promise<void>;
191
- protected parseMessage(schema: any, message: string): {
192
- payload: any;
193
- };
194
- }
195
- //# sourceMappingURL=TopicDescriptorProvider.d.ts.map
196
- //#endregion
197
156
  //#region src/index.d.ts
198
157
  /**
199
- * Alepha Topic Module
200
- *
201
158
  * Generic interface for pub/sub messaging.
202
159
  * Gives you the ability to create topics and subscribers.
203
160
  * This module provides only a memory implementation of the topic provider.
@@ -206,12 +163,9 @@ declare class TopicDescriptorProvider {
206
163
  * @see {@link $subscriber}
207
164
  * @module alepha.topic
208
165
  */
209
- declare class AlephaTopic implements Module {
210
- readonly name = "alepha.topic";
211
- readonly $services: (alepha: Alepha) => Alepha;
212
- }
166
+ declare const AlephaTopic: _alepha_core0.ModuleDescriptor;
213
167
  //# sourceMappingURL=index.d.ts.map
214
168
 
215
169
  //#endregion
216
- export { $subscriber, $topic, AlephaTopic, MemoryTopicProvider, SubscribeCallback, SubscriberDescriptor, SubscriberDescriptorOptions, TopicDescriptor, TopicDescriptorOptions, TopicDescriptorProvider, TopicMessage, TopicMessageSchema, TopicProvider, TopicTimeoutError, TopicWaitOptions, UnSubscribeFn };
170
+ export { $subscriber, $topic, AlephaTopic, MemoryTopicProvider, SubscribeCallback, SubscriberDescriptor, SubscriberDescriptorOptions, TopicDescriptor, TopicDescriptorOptions, TopicHandler, TopicMessage, TopicMessageSchema, TopicProvider, TopicTimeoutError, TopicWaitOptions, UnSubscribeFn };
217
171
  //# sourceMappingURL=index.d.ts.map
package/vite.d.ts CHANGED
@@ -1,7 +1,56 @@
1
1
  import { BrotliOptions, ZlibOptions } from "node:zlib";
2
2
  import { Alepha } from "alepha";
3
- import { Plugin } from "vite";
3
+ import { Plugin, UserConfig } from "vite";
4
4
 
5
+ //#region src/viteCompress.d.ts
6
+ interface ViteCompressOptions {
7
+ /**
8
+ * If true, the plugin will not compress the files.
9
+ *
10
+ * @default false
11
+ */
12
+ disabled?: boolean;
13
+ /**
14
+ * If true, the plugin will compress the files using brotli.
15
+ * Can also be an object with brotli options.
16
+ *
17
+ * @default true
18
+ */
19
+ brotli?: boolean | BrotliOptions;
20
+ /**
21
+ * If true, the plugin will compress the files using gzip.
22
+ * Can also be an object with gzip options.
23
+ *
24
+ * @default true
25
+ */
26
+ gzip?: boolean | ZlibOptions;
27
+ /**
28
+ * A filter to determine which files to compress.
29
+ * Can be a RegExp or a function that returns true for files to compress.
30
+ *
31
+ * @default /\.(js|mjs|cjs|css|wasm|svg|html)$/
32
+ */
33
+ filter?: RegExp | ((fileName: string) => boolean);
34
+ }
35
+ declare function viteCompress(options?: ViteCompressOptions): Plugin;
36
+ declare function compressFile(options: ViteCompressOptions | undefined, filePath: string): Promise<void>;
37
+ //# sourceMappingURL=viteCompress.d.ts.map
38
+ //#endregion
39
+ //#region src/helpers/buildClient.d.ts
40
+ interface BuildClientOptions {
41
+ dist: string;
42
+ html: string;
43
+ /**
44
+ * @default false
45
+ */
46
+ precompress?: ViteCompressOptions | boolean;
47
+ /**
48
+ * @default false
49
+ */
50
+ prerender?: boolean;
51
+ config?: UserConfig;
52
+ }
53
+ //#endregion
5
54
  //#region src/viteAlephaBuild.d.ts
6
55
  interface ViteAlephaBuildOptions {
7
56
  /**
@@ -13,7 +62,7 @@ interface ViteAlephaBuildOptions {
13
62
  * Set false to skip the client build.
14
63
  * This is useful if you only want to build the server-side application.
15
64
  */
16
- client?: false;
65
+ client?: false | Partial<BuildClientOptions>;
17
66
  /**
18
67
  * If true, the build will be optimized for Vercel deployment.
19
68
  *
@@ -73,39 +122,6 @@ declare function viteAlephaBuildVercel(opts?: ViteAlephaBuildVercelOptions): Pro
73
122
  }>;
74
123
  //# sourceMappingURL=viteAlephaBuildVercel.d.ts.map
75
124
  //#endregion
76
- //#region src/viteCompress.d.ts
77
- interface ViteCompressOptions {
78
- /**
79
- * If true, the plugin will not compress the files.
80
- *
81
- * @default false
82
- */
83
- disabled?: boolean;
84
- /**
85
- * If true, the plugin will compress the files using brotli.
86
- * Can also be an object with brotli options.
87
- *
88
- * @default true
89
- */
90
- brotli?: boolean | BrotliOptions;
91
- /**
92
- * If true, the plugin will compress the files using gzip.
93
- * Can also be an object with gzip options.
94
- *
95
- * @default true
96
- */
97
- gzip?: boolean | ZlibOptions;
98
- /**
99
- * A filter to determine which files to compress.
100
- * Can be a RegExp or a function that returns true for files to compress.
101
- *
102
- * @default /\.(js|mjs|cjs|css|wasm|svg)$/
103
- */
104
- filter?: RegExp | ((fileName: string) => boolean);
105
- }
106
- declare function viteCompress(options?: ViteCompressOptions): Plugin;
107
- //# sourceMappingURL=viteCompress.d.ts.map
108
- //#endregion
109
125
  //#region src/index.d.ts
110
126
  declare global {
111
127
  var __alepha: Alepha;
@@ -113,5 +129,5 @@ declare global {
113
129
  //# sourceMappingURL=index.d.ts.map
114
130
 
115
131
  //#endregion
116
- export { ViteAlephaBuildOptions, ViteAlephaBuildVercelOptions, ViteAlephaDevOptions, ViteAlephaOptions, ViteCompressOptions, viteAlepha, viteAlephaBuild, viteAlephaBuildVercel, viteAlephaDev, viteCompress };
132
+ export { ViteAlephaBuildOptions, ViteAlephaBuildVercelOptions, ViteAlephaDevOptions, ViteAlephaOptions, ViteCompressOptions, compressFile, viteAlepha, viteAlephaBuild, viteAlephaBuildVercel, viteAlephaDev, viteCompress };
117
133
  //# sourceMappingURL=index.d.ts.map