alepha 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -17
- package/batch.d.ts +83 -117
- package/bucket.cjs +8 -0
- package/bucket.d.ts +194 -0
- package/bucket.js +1 -0
- package/cache/redis.d.ts +14 -14
- package/cache.d.ts +101 -238
- package/command.d.ts +79 -70
- package/core.d.ts +1012 -855
- package/datetime.d.ts +90 -116
- package/file.d.ts +23 -13
- package/lock/redis.d.ts +11 -11
- package/lock.d.ts +121 -111
- package/package.json +54 -40
- package/postgres.d.ts +218 -393
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +84 -198
- package/react/auth.d.ts +47 -53
- package/react/head.d.ts +4 -7
- package/react.d.ts +48 -183
- package/redis.d.ts +31 -16
- package/retry.d.ts +70 -59
- package/router.d.ts +9 -9
- package/scheduler.d.ts +54 -93
- package/security.d.ts +95 -276
- package/server/cache.d.ts +22 -28
- package/server/compress.d.ts +16 -7
- package/server/cookies.d.ts +65 -233
- package/server/cors.d.ts +15 -13
- package/server/health.d.ts +23 -23
- package/server/helmet.d.ts +17 -18
- package/server/links.d.ts +108 -88
- package/server/metrics.d.ts +25 -21
- package/server/multipart.d.ts +12 -14
- package/server/proxy.d.ts +22 -17
- package/server/security.cjs +8 -0
- package/server/security.d.ts +92 -0
- package/server/security.js +1 -0
- package/server/static.d.ts +63 -67
- package/server/swagger.d.ts +73 -62
- package/server.d.ts +253 -448
- package/topic/redis.d.ts +25 -24
- package/topic.d.ts +68 -115
package/README.md
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1 >
|
|
3
|
+
<img
|
|
4
|
+
src="https://raw.githubusercontent.com/feunard/alepha/main/assets/logo.png"
|
|
5
|
+
width="128"
|
|
6
|
+
height="128"
|
|
7
|
+
alt="Logo"
|
|
8
|
+
valign="middle"
|
|
9
|
+
/>
|
|
10
|
+
Alepha
|
|
11
|
+
</h1>
|
|
12
|
+
<p style="max-width: 512px">
|
|
13
|
+
🚧
|
|
14
|
+
</p>
|
|
15
|
+
<a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/v/alepha.svg" alt="npm"/></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/l/alepha.svg" alt="npm"/></a>
|
|
17
|
+
<a href="https://codecov.io/gh/feunard/alepha"><img src="https://codecov.io/gh/feunard/alepha/graph/badge.svg?token=ZDLWI514CP" alt="npm"/></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/dt/alepha.svg" alt="npm"/></a>
|
|
19
|
+
<a href="https://github.com/feunard/alepha"><img src="https://img.shields.io/github/stars/feunard/alepha.svg?style=social" alt="GitHub stars"/></a>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
Alepha is a convention-driven TypeScript framework for building robust, end-to-end type-safe applications, from serverless APIs to full-stack React apps.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install alepha
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Minimalist http server with a single endpoint.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { run } from "alepha";
|
|
36
|
+
import { $action } from "alepha/server";
|
|
37
|
+
|
|
38
|
+
class App {
|
|
39
|
+
hello = $action({
|
|
40
|
+
handler: () => "Hello world!",
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
run(App);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
👉 For more information, please visit the [documentation](https://feunard.github.io/alepha/).
|
package/batch.d.ts
CHANGED
|
@@ -1,147 +1,113 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Descriptor, KIND, Static, TSchema } from "alepha";
|
|
4
|
+
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
5
|
+
import * as _alepha_retry0 from "alepha/retry";
|
|
3
6
|
import { RetryDescriptorOptions } from "alepha/retry";
|
|
4
7
|
|
|
5
8
|
//#region src/descriptors/$batch.d.ts
|
|
6
|
-
declare const KEY = "BATCH";
|
|
7
9
|
/**
|
|
8
|
-
* Creates a batch processor. This is useful for grouping multiple operations
|
|
9
|
-
* (like API calls or database writes) into a single one to improve performance.
|
|
10
|
-
*/
|
|
10
|
+
* Creates a batch processor. This is useful for grouping multiple operations
|
|
11
|
+
* (like API calls or database writes) into a single one to improve performance.
|
|
12
|
+
*/
|
|
11
13
|
declare const $batch: {
|
|
12
14
|
<TItem extends TSchema, TResponse>(options: BatchDescriptorOptions<TItem, TResponse>): BatchDescriptor<TItem, TResponse>;
|
|
13
|
-
[KIND]:
|
|
15
|
+
[KIND]: typeof BatchDescriptor;
|
|
14
16
|
};
|
|
15
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
16
17
|
interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
|
|
17
18
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
* A TypeBox schema to validate each item pushed to the batch.
|
|
20
|
+
*/
|
|
20
21
|
schema: TItem;
|
|
21
22
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
* The handler function that processes a batch of items.
|
|
24
|
+
*/
|
|
24
25
|
handler: (items: Static<TItem>[]) => TResponse;
|
|
25
26
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
* The maximum number of items in a batch. When this size is reached,
|
|
28
|
+
* the batch is flushed automatically.
|
|
29
|
+
* @default 10
|
|
30
|
+
*/
|
|
30
31
|
maxSize?: number;
|
|
31
32
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
* The maximum duration to wait before flushing a batch, even if it's not full.
|
|
34
|
+
* Starts from the moment the first item is added to a partition.
|
|
35
|
+
* @default [1, "second"]
|
|
36
|
+
*/
|
|
36
37
|
maxDuration?: DurationLike;
|
|
37
38
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
* A function to determine the partition key for an item. Items with the
|
|
40
|
+
* same key are batched together. If not provided, all items are placed in a single, default partition.
|
|
41
|
+
*/
|
|
41
42
|
partitionBy?: (item: Static<TItem>) => string;
|
|
42
43
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* The maximum number of concurrent `handler` executions.
|
|
45
|
+
* @default 1
|
|
46
|
+
*/
|
|
46
47
|
concurrency?: number;
|
|
47
48
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
* Retry options for the batch handler if it fails.
|
|
50
|
+
* Leverages the `@alepha/retry` module.
|
|
51
|
+
*/
|
|
51
52
|
retry?: Omit<RetryDescriptorOptions<() => Array<Static<TItem>>>, "handler">;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends Descriptor<BatchDescriptorOptions<TItem, TResponse>> {
|
|
55
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
56
|
+
protected readonly dateTime: DateTimeProvider;
|
|
57
|
+
protected readonly partitions: Map<any, any>;
|
|
58
|
+
protected activeHandlers: PromiseWithResolvers<void>[];
|
|
59
|
+
protected retry: _alepha_retry0.RetryDescriptorFn<(items: (TItem & {
|
|
60
|
+
params: [];
|
|
61
|
+
})["static"][]) => TResponse>;
|
|
56
62
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
push
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
flush: (partitionKey?: string) => Promise<TResponse>;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/providers/BatchDescriptorProvider.d.ts
|
|
69
|
-
interface PartitionState<TItem extends TSchema> {
|
|
70
|
-
items: Static<TItem>[];
|
|
71
|
-
timeout?: Timeout;
|
|
72
|
-
// Promises to resolve/reject when the batch is processed
|
|
73
|
-
resolvers: Array<{
|
|
74
|
-
resolve: (result?: any) => void;
|
|
75
|
-
reject: (reason?: any) => void;
|
|
76
|
-
}>;
|
|
77
|
-
}
|
|
78
|
-
interface BatchInstance<TItem extends TSchema> {
|
|
79
|
-
id: string;
|
|
80
|
-
options: BatchDescriptorOptions<TItem>;
|
|
81
|
-
partitions: Map<string, PartitionState<TItem>>;
|
|
82
|
-
activeHandlers: PromiseWithResolvers<void>[];
|
|
83
|
-
handler: (items: Static<TItem>[]) => Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Process every $batch.
|
|
87
|
-
*/
|
|
88
|
-
declare class BatchDescriptorProvider {
|
|
89
|
-
protected readonly alepha: Alepha;
|
|
90
|
-
protected readonly log: Logger;
|
|
91
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
92
|
-
protected readonly instances: Map<string, BatchInstance<any>>;
|
|
93
|
-
protected readonly configure: HookDescriptor<"configure">;
|
|
94
|
-
// On application stop, flush all pending batches gracefully.
|
|
95
|
-
protected readonly onStop: HookDescriptor<"stop">;
|
|
96
|
-
protected push<TItem>(id: string, item: TItem): Promise<void>;
|
|
97
|
-
protected flush(id: string, partitionKey?: string): Promise<void>;
|
|
98
|
-
protected flushPartition<TItem extends TSchema>(instance: BatchInstance<TItem>, partitionKey: string): Promise<void>;
|
|
63
|
+
* Pushes an item into the batch. The item will be processed
|
|
64
|
+
* asynchronously with other items when the batch is flushed.
|
|
65
|
+
*/
|
|
66
|
+
push(item: Static<TItem>): Promise<TResponse>;
|
|
67
|
+
flush(partitionKey?: string): Promise<void>;
|
|
68
|
+
protected flushPartition(partitionKey: string): Promise<void>;
|
|
69
|
+
protected readonly dispose: _alepha_core0$1.HookDescriptor<"stop">;
|
|
99
70
|
}
|
|
71
|
+
//# sourceMappingURL=$batch.d.ts.map
|
|
100
72
|
//#endregion
|
|
101
73
|
//#region src/index.d.ts
|
|
102
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
103
74
|
/**
|
|
104
|
-
* This module allows you to group multiple asynchronous operations into a single "batch," which is then processed together.
|
|
105
|
-
* This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*/
|
|
141
|
-
declare class AlephaBatch implements Module {
|
|
142
|
-
readonly name = "alepha.batch";
|
|
143
|
-
readonly $services: (alepha: Alepha) => Alepha;
|
|
144
|
-
}
|
|
75
|
+
* This module allows you to group multiple asynchronous operations into a single "batch," which is then processed together.
|
|
76
|
+
* This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { Alepha, $hook, run, t } from "alepha";
|
|
80
|
+
* import { $batch } from "alepha/batch";
|
|
81
|
+
*
|
|
82
|
+
* class LoggingService {
|
|
83
|
+
* // define the batch processor
|
|
84
|
+
* logBatch = $batch({
|
|
85
|
+
* schema: t.string(),
|
|
86
|
+
* maxSize: 10,
|
|
87
|
+
* maxDuration: [5, "seconds"],
|
|
88
|
+
* handler: async (items) => {
|
|
89
|
+
* console.log(`[BATCH LOG] Processing ${items.length} events:`, items);
|
|
90
|
+
* },
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* // example of how to use it
|
|
94
|
+
* onReady = $hook({
|
|
95
|
+
* on: "ready",
|
|
96
|
+
* handler: async () => {
|
|
97
|
+
* this.logBatch.push("Application started.");
|
|
98
|
+
* this.logBatch.push("User authenticated.");
|
|
99
|
+
* // ... more events pushed from elsewhere in the app
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @see {@link $batch}
|
|
106
|
+
* @module alepha.batch
|
|
107
|
+
*/
|
|
108
|
+
declare const AlephaBatch: _alepha_core0.ModuleDescriptor;
|
|
109
|
+
//# sourceMappingURL=index.d.ts.map
|
|
110
|
+
|
|
145
111
|
//#endregion
|
|
146
|
-
export { $batch, AlephaBatch, BatchDescriptor, BatchDescriptorOptions
|
|
112
|
+
export { $batch, AlephaBatch, BatchDescriptor, BatchDescriptorOptions };
|
|
147
113
|
//# sourceMappingURL=index.d.ts.map
|
package/bucket.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/bucket');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
package/bucket.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha, Descriptor, FileLike, KIND, Service } from "alepha";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
6
|
+
|
|
7
|
+
//#region src/providers/FileStorageProvider.d.ts
|
|
8
|
+
declare abstract class FileStorageProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Uploads a file to the storage.
|
|
11
|
+
*
|
|
12
|
+
* @param bucketName - Container name
|
|
13
|
+
* @param file - File to upload
|
|
14
|
+
* @param fileId - Optional file identifier. If not provided, a unique ID will be generated.
|
|
15
|
+
* @return The identifier of the uploaded file.
|
|
16
|
+
*/
|
|
17
|
+
abstract upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Downloads a file from the storage.
|
|
20
|
+
*
|
|
21
|
+
* @param bucketName - Container name
|
|
22
|
+
* @param fileId - Identifier of the file to download
|
|
23
|
+
* @return The downloaded file as a FileLike object.
|
|
24
|
+
*/
|
|
25
|
+
abstract download(bucketName: string, fileId: string): Promise<FileLike>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if fileId exists in the storage bucket.
|
|
28
|
+
*
|
|
29
|
+
* @param bucketName - Container name
|
|
30
|
+
* @param fileId - Identifier of the file to stream
|
|
31
|
+
* @return True is the file exists, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
abstract exists(bucketName: string, fileId: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete permanently a file from the storage.
|
|
36
|
+
*
|
|
37
|
+
* @param bucketName - Container name
|
|
38
|
+
* @param fileId - Identifier of the file to delete
|
|
39
|
+
*/
|
|
40
|
+
abstract delete(bucketName: string, fileId: string): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=FileStorageProvider.d.ts.map
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/providers/MemoryFileStorageProvider.d.ts
|
|
45
|
+
declare class MemoryFileStorageProvider implements FileStorageProvider {
|
|
46
|
+
readonly files: Record<string, FileLike>;
|
|
47
|
+
upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
|
|
48
|
+
download(bucketName: string, fileId: string): Promise<FileLike>;
|
|
49
|
+
exists(bucketName: string, fileId: string): Promise<boolean>;
|
|
50
|
+
delete(bucketName: string, fileId: string): Promise<void>;
|
|
51
|
+
protected createId(): string;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=MemoryFileStorageProvider.d.ts.map
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/descriptors/$bucket.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Create a container for storing files.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { $bucket } from "alepha/bucket";
|
|
63
|
+
*
|
|
64
|
+
* class App {
|
|
65
|
+
* images = $bucket();
|
|
66
|
+
*
|
|
67
|
+
* uploadImage(file: FileLike): Promise<string> {
|
|
68
|
+
* return this.images.upload(file);
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare const $bucket: {
|
|
74
|
+
(options: BucketDescriptorOptions): BucketDescriptor;
|
|
75
|
+
[KIND]: typeof BucketDescriptor;
|
|
76
|
+
};
|
|
77
|
+
interface BucketDescriptorOptions extends BucketFileOptions {
|
|
78
|
+
/**
|
|
79
|
+
* File storage provider. If not provided, the default provider will be used.
|
|
80
|
+
*/
|
|
81
|
+
provider?: Service<FileStorageProvider> | "memory";
|
|
82
|
+
/**
|
|
83
|
+
* Optional name of the bucket. If not provided, the key of the descriptor will be used.
|
|
84
|
+
*/
|
|
85
|
+
name?: string;
|
|
86
|
+
}
|
|
87
|
+
declare class BucketDescriptor extends Descriptor<BucketDescriptorOptions> {
|
|
88
|
+
readonly provider: MemoryFileStorageProvider | FileStorageProvider;
|
|
89
|
+
get name(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Uploads a file to the bucket.
|
|
92
|
+
*/
|
|
93
|
+
upload(file: FileLike, options?: BucketFileOptions): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Delete permanently a file from the bucket.
|
|
96
|
+
*/
|
|
97
|
+
delete(fileId: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if a file exists in the bucket.
|
|
100
|
+
*/
|
|
101
|
+
exists(fileId: string): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Downloads a file from the bucket.
|
|
104
|
+
*/
|
|
105
|
+
download(fileId: string): Promise<FileLike>;
|
|
106
|
+
protected $provider(): MemoryFileStorageProvider | FileStorageProvider;
|
|
107
|
+
}
|
|
108
|
+
interface BucketFileOptions {
|
|
109
|
+
/**
|
|
110
|
+
* Optional description of the bucket.
|
|
111
|
+
*/
|
|
112
|
+
description?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Allowed MIME types.
|
|
115
|
+
*/
|
|
116
|
+
mimeTypes?: string[];
|
|
117
|
+
/**
|
|
118
|
+
* Maximum size of the files in the bucket.
|
|
119
|
+
*
|
|
120
|
+
* @default 10
|
|
121
|
+
*/
|
|
122
|
+
maxSize?: number;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=$bucket.d.ts.map
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/errors/FileNotFoundError.d.ts
|
|
127
|
+
declare class FileNotFoundError extends Error {
|
|
128
|
+
readonly status = 404;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=FileNotFoundError.d.ts.map
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/providers/LocalFileStorageProvider.d.ts
|
|
133
|
+
declare class LocalFileStorageProvider implements FileStorageProvider {
|
|
134
|
+
static METADATA_HEADER_LENGTH: number;
|
|
135
|
+
protected readonly alepha: Alepha;
|
|
136
|
+
options: {
|
|
137
|
+
storagePath: string;
|
|
138
|
+
};
|
|
139
|
+
protected readonly configure: _alepha_core0$1.HookDescriptor<"start">;
|
|
140
|
+
upload(bucketName: string, file: FileLike, fileId?: string): Promise<string>;
|
|
141
|
+
download(bucketName: string, fileId: string): Promise<FileLike>;
|
|
142
|
+
exists(bucketName: string, fileId: string): Promise<boolean>;
|
|
143
|
+
delete(bucketName: string, fileId: string): Promise<void>;
|
|
144
|
+
protected stat(container: string, fileId: string): Promise<fs.Stats>;
|
|
145
|
+
protected createId(): string;
|
|
146
|
+
protected path(container: string, fileId?: string): string;
|
|
147
|
+
protected isErrorNoEntry(error: unknown): boolean;
|
|
148
|
+
}
|
|
149
|
+
declare const fileMetadataSchema: _sinclair_typebox0.TObject<{
|
|
150
|
+
name: _sinclair_typebox0.TString;
|
|
151
|
+
type: _sinclair_typebox0.TString;
|
|
152
|
+
size: _sinclair_typebox0.TNumber;
|
|
153
|
+
}>;
|
|
154
|
+
//# sourceMappingURL=LocalFileStorageProvider.d.ts.map
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/index.d.ts
|
|
157
|
+
declare module "alepha" {
|
|
158
|
+
interface Hooks {
|
|
159
|
+
/**
|
|
160
|
+
* Triggered when a file is uploaded to a bucket.
|
|
161
|
+
* Can be used to perform actions after a file is uploaded, like creating a database record!
|
|
162
|
+
*/
|
|
163
|
+
"bucket:file:uploaded": {
|
|
164
|
+
id: string;
|
|
165
|
+
file: FileLike;
|
|
166
|
+
bucket: BucketDescriptor;
|
|
167
|
+
options: BucketFileOptions;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Triggered when a file is deleted from a bucket.
|
|
171
|
+
*/
|
|
172
|
+
"bucket:file:deleted": {
|
|
173
|
+
id: string;
|
|
174
|
+
bucket: BucketDescriptor;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Provides file storage capabilities through declarative bucket descriptors with support for multiple storage backends.
|
|
180
|
+
*
|
|
181
|
+
* The bucket module enables unified file operations across different storage systems using the `$bucket` descriptor
|
|
182
|
+
* on class properties. It abstracts storage provider differences, offering consistent APIs for local filesystem,
|
|
183
|
+
* cloud storage, or in-memory storage for testing environments.
|
|
184
|
+
*
|
|
185
|
+
* @see {@link $bucket}
|
|
186
|
+
* @see {@link FileStorageProvider}
|
|
187
|
+
* @module alepha.bucket
|
|
188
|
+
*/
|
|
189
|
+
declare const AlephaBucket: _alepha_core0.ModuleDescriptor;
|
|
190
|
+
//# sourceMappingURL=index.d.ts.map
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
export { $bucket, AlephaBucket, BucketDescriptor, BucketDescriptorOptions, BucketFileOptions, FileNotFoundError, FileStorageProvider, LocalFileStorageProvider, MemoryFileStorageProvider, fileMetadataSchema };
|
|
194
|
+
//# sourceMappingURL=index.d.ts.map
|
package/bucket.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/bucket'
|
package/cache/redis.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CacheProvider } from "alepha/cache";
|
|
2
|
-
import
|
|
2
|
+
import * as _alepha_core0$1 from "alepha";
|
|
3
|
+
import * as _alepha_core0 from "alepha";
|
|
4
|
+
import { Alepha, Logger, Static } from "alepha";
|
|
3
5
|
import { RedisProvider } from "alepha/redis";
|
|
4
6
|
|
|
5
7
|
//#region src/providers/RedisCacheProvider.d.ts
|
|
6
|
-
declare const envSchema: TObject<{
|
|
7
|
-
REDIS_CACHE_PREFIX: TOptional<TString>;
|
|
8
|
+
declare const envSchema: _alepha_core0$1.TObject<{
|
|
9
|
+
REDIS_CACHE_PREFIX: _alepha_core0$1.TOptional<_alepha_core0$1.TString>;
|
|
8
10
|
}>;
|
|
9
11
|
declare module "alepha" {
|
|
10
12
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -18,22 +20,20 @@ declare class RedisCacheProvider implements CacheProvider {
|
|
|
18
20
|
set(name: string, key: string, value: Uint8Array | string, ttl?: number): Promise<Uint8Array>;
|
|
19
21
|
del(name: string, ...keys: string[]): Promise<void>;
|
|
20
22
|
has(name: string, key: string): Promise<boolean>;
|
|
21
|
-
keys(name: string): Promise<string[]>;
|
|
23
|
+
keys(name: string, filter?: string): Promise<string[]>;
|
|
22
24
|
protected prefix(...path: string[]): string;
|
|
23
25
|
}
|
|
24
26
|
//#endregion
|
|
25
27
|
//#region src/index.d.ts
|
|
26
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
27
28
|
/**
|
|
28
|
-
* Plugin for Alepha Cache that provides Redis caching capabilities.
|
|
29
|
-
*
|
|
30
|
-
* @see {@link RedisCacheProvider}
|
|
31
|
-
* @module alepha.cache.redis
|
|
32
|
-
*/
|
|
33
|
-
declare
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
29
|
+
* Plugin for Alepha Cache that provides Redis caching capabilities.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link RedisCacheProvider}
|
|
32
|
+
* @module alepha.cache.redis
|
|
33
|
+
*/
|
|
34
|
+
declare const AlephaCacheRedis: _alepha_core0.ModuleDescriptor;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
36
|
+
|
|
37
37
|
//#endregion
|
|
38
38
|
export { AlephaCacheRedis, RedisCacheProvider };
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|