@rx-ted/packages-honest-plugins 1.0.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/CHANGELOG.md +13 -0
- package/README.md +45 -0
- package/api-doc/.turbo/turbo-build.log +1 -0
- package/api-doc/.turbo/turbo-test.log +11 -0
- package/api-doc/.turbo/turbo-typecheck.log +1 -0
- package/api-doc/CHANGELOG.md +22 -0
- package/api-doc/README.md +80 -0
- package/api-doc/dist/api-doc.plugin.d.ts +53 -0
- package/api-doc/dist/api-doc.plugin.js +452 -0
- package/api-doc/dist/index.d.ts +5 -0
- package/api-doc/dist/index.js +3 -0
- package/api-doc/dist/interfaces/renderer.interface.d.ts +7 -0
- package/api-doc/dist/interfaces/renderer.interface.js +1 -0
- package/api-doc/dist/renderers/scalar.renderer.d.ts +10 -0
- package/api-doc/dist/renderers/scalar.renderer.js +76 -0
- package/api-doc/dist/renderers/swagger.renderer.d.ts +10 -0
- package/api-doc/dist/renderers/swagger.renderer.js +83 -0
- package/api-doc/node_modules/.bin/esbuild +22 -0
- package/api-doc/node_modules/.bin/jiti +22 -0
- package/api-doc/node_modules/.bin/sass +22 -0
- package/api-doc/node_modules/.bin/tsx +22 -0
- package/api-doc/node_modules/.bin/vite +22 -0
- package/api-doc/node_modules/.bin/vitest +22 -0
- package/api-doc/node_modules/.bin/yaml +22 -0
- package/api-doc/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/api-doc/package.json +48 -0
- package/api-doc/src/api-doc.plugin.ts +554 -0
- package/api-doc/src/index.ts +5 -0
- package/api-doc/src/interfaces/renderer.interface.ts +5 -0
- package/api-doc/src/plugin.test.ts +740 -0
- package/api-doc/src/renderers/scalar.renderer.ts +82 -0
- package/api-doc/src/renderers/swagger.renderer.ts +89 -0
- package/api-doc/tsconfig.json +21 -0
- package/api-doc/vitest.config.ts +13 -0
- package/cache/.turbo/turbo-build.log +1 -0
- package/cache/.turbo/turbo-test.log +16 -0
- package/cache/CHANGELOG.md +23 -0
- package/cache/README.md +79 -0
- package/cache/dist/cache-service.d.ts +8 -0
- package/cache/dist/cache-service.js +21 -0
- package/cache/dist/cacheable.d.ts +2 -0
- package/cache/dist/cacheable.js +10 -0
- package/cache/dist/cloudflare/driver.d.ts +23 -0
- package/cache/dist/cloudflare/driver.js +102 -0
- package/cache/dist/cloudflare/index.d.ts +3 -0
- package/cache/dist/cloudflare/index.js +2 -0
- package/cache/dist/cloudflare/plugin.d.ts +19 -0
- package/cache/dist/cloudflare/plugin.js +58 -0
- package/cache/dist/index.d.ts +11 -0
- package/cache/dist/index.js +14 -0
- package/cache/dist/local/driver.d.ts +2 -0
- package/cache/dist/local/driver.js +98 -0
- package/cache/dist/local/index.d.ts +2 -0
- package/cache/dist/local/index.js +2 -0
- package/cache/dist/local/plugin.d.ts +14 -0
- package/cache/dist/local/plugin.js +24 -0
- package/cache/dist/redis/driver.d.ts +10 -0
- package/cache/dist/redis/driver.js +102 -0
- package/cache/dist/redis/index.d.ts +4 -0
- package/cache/dist/redis/index.js +2 -0
- package/cache/dist/redis/plugin.d.ts +25 -0
- package/cache/dist/redis/plugin.js +61 -0
- package/cache/dist/resolve.d.ts +24 -0
- package/cache/dist/resolve.js +114 -0
- package/cache/dist/types.d.ts +18 -0
- package/cache/dist/types.js +1 -0
- package/cache/node_modules/.bin/esbuild +22 -0
- package/cache/node_modules/.bin/jiti +22 -0
- package/cache/node_modules/.bin/sass +22 -0
- package/cache/node_modules/.bin/tsx +22 -0
- package/cache/node_modules/.bin/vite +22 -0
- package/cache/node_modules/.bin/vitest +22 -0
- package/cache/node_modules/.bin/yaml +22 -0
- package/cache/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/cache/package.json +46 -0
- package/cache/src/cache-service.test.ts +16 -0
- package/cache/src/cache-service.ts +15 -0
- package/cache/src/cacheable.test.ts +78 -0
- package/cache/src/cacheable.ts +16 -0
- package/cache/src/cloudflare/driver.test.ts +188 -0
- package/cache/src/cloudflare/driver.ts +118 -0
- package/cache/src/cloudflare/index.ts +3 -0
- package/cache/src/cloudflare/plugin.ts +71 -0
- package/cache/src/index.test.ts +68 -0
- package/cache/src/index.ts +20 -0
- package/cache/src/local/driver.ts +117 -0
- package/cache/src/local/index.ts +2 -0
- package/cache/src/local/plugin.ts +34 -0
- package/cache/src/redis/driver.test.ts +71 -0
- package/cache/src/redis/driver.ts +124 -0
- package/cache/src/redis/index.ts +4 -0
- package/cache/src/redis/plugin.ts +84 -0
- package/cache/src/resolve.test.ts +257 -0
- package/cache/src/resolve.ts +140 -0
- package/cache/src/types.ts +14 -0
- package/cache/tsconfig.json +21 -0
- package/cache/vitest.config.ts +13 -0
- package/db/.turbo/turbo-build.log +1 -0
- package/db/.turbo/turbo-test.log +21 -0
- package/db/CHANGELOG.md +26 -0
- package/db/README.md +99 -0
- package/db/dist/constants.d.ts +1 -0
- package/db/dist/constants.js +1 -0
- package/db/dist/d1/index.d.ts +3 -0
- package/db/dist/d1/index.js +2 -0
- package/db/dist/d1/plugin.d.ts +18 -0
- package/db/dist/d1/plugin.js +104 -0
- package/db/dist/db-service.d.ts +7 -0
- package/db/dist/db-service.js +21 -0
- package/db/dist/index.d.ts +15 -0
- package/db/dist/index.js +20 -0
- package/db/dist/mysql/client.d.ts +36 -0
- package/db/dist/mysql/client.js +84 -0
- package/db/dist/mysql/driver.d.ts +18 -0
- package/db/dist/mysql/driver.js +107 -0
- package/db/dist/mysql/index.d.ts +11 -0
- package/db/dist/mysql/index.js +11 -0
- package/db/dist/mysql/plugin.d.ts +51 -0
- package/db/dist/mysql/plugin.js +94 -0
- package/db/dist/mysql/types.d.ts +38 -0
- package/db/dist/mysql/types.js +1 -0
- package/db/dist/postgres/index.d.ts +2 -0
- package/db/dist/postgres/index.js +3 -0
- package/db/dist/repository.d.ts +14 -0
- package/db/dist/repository.js +79 -0
- package/db/dist/resolve.d.ts +6 -0
- package/db/dist/resolve.js +81 -0
- package/db/dist/schema-builder/column-builder.d.ts +26 -0
- package/db/dist/schema-builder/column-builder.js +53 -0
- package/db/dist/schema-builder/compile-d1.d.ts +5 -0
- package/db/dist/schema-builder/compile-d1.js +67 -0
- package/db/dist/schema-builder/compile-mysql.d.ts +12 -0
- package/db/dist/schema-builder/compile-mysql.js +78 -0
- package/db/dist/schema-builder/index.d.ts +8 -0
- package/db/dist/schema-builder/index.js +22 -0
- package/db/dist/schema-builder/table-builder.d.ts +16 -0
- package/db/dist/schema-builder/table-builder.js +38 -0
- package/db/dist/schema-builder/types.d.ts +26 -0
- package/db/dist/schema-builder/types.js +1 -0
- package/db/dist/schema-builder/zod-bridge.d.ts +24 -0
- package/db/dist/schema-builder/zod-bridge.js +53 -0
- package/db/dist/sqlite/index.d.ts +4 -0
- package/db/dist/sqlite/index.js +2 -0
- package/db/dist/sqlite/plugin.d.ts +17 -0
- package/db/dist/sqlite/plugin.js +33 -0
- package/db/dist/types.d.ts +42 -0
- package/db/dist/types.js +1 -0
- package/db/node_modules/.bin/esbuild +22 -0
- package/db/node_modules/.bin/jiti +22 -0
- package/db/node_modules/.bin/sass +22 -0
- package/db/node_modules/.bin/tsx +22 -0
- package/db/node_modules/.bin/vite +22 -0
- package/db/node_modules/.bin/vitest +22 -0
- package/db/node_modules/.bin/yaml +22 -0
- package/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/db/package.json +59 -0
- package/db/src/constants.test.ts +8 -0
- package/db/src/constants.ts +1 -0
- package/db/src/d1/index.ts +13 -0
- package/db/src/d1/plugin.ts +135 -0
- package/db/src/db-service.ts +14 -0
- package/db/src/index.test.ts +63 -0
- package/db/src/index.ts +57 -0
- package/db/src/mysql/client.ts +112 -0
- package/db/src/mysql/driver.test.ts +190 -0
- package/db/src/mysql/driver.ts +116 -0
- package/db/src/mysql/index.ts +51 -0
- package/db/src/mysql/plugin.test.ts +228 -0
- package/db/src/mysql/plugin.ts +128 -0
- package/db/src/mysql/types.ts +32 -0
- package/db/src/postgres/index.ts +15 -0
- package/db/src/repository.test.ts +195 -0
- package/db/src/repository.ts +95 -0
- package/db/src/resolve.ts +105 -0
- package/db/src/schema-builder/column-builder.test.ts +55 -0
- package/db/src/schema-builder/column-builder.ts +87 -0
- package/db/src/schema-builder/compile-d1.test.ts +60 -0
- package/db/src/schema-builder/compile-d1.ts +70 -0
- package/db/src/schema-builder/compile-mysql.test.ts +64 -0
- package/db/src/schema-builder/compile-mysql.ts +102 -0
- package/db/src/schema-builder/index.test.ts +36 -0
- package/db/src/schema-builder/index.ts +41 -0
- package/db/src/schema-builder/table-builder.test.ts +55 -0
- package/db/src/schema-builder/table-builder.ts +50 -0
- package/db/src/schema-builder/types.test.ts +68 -0
- package/db/src/schema-builder/types.ts +30 -0
- package/db/src/schema-builder/zod-bridge.ts +89 -0
- package/db/src/sqlite/index.ts +14 -0
- package/db/src/sqlite/plugin.ts +46 -0
- package/db/src/types.ts +45 -0
- package/db/tsconfig.json +21 -0
- package/db/vitest.config.ts +13 -0
- package/mail/.turbo/turbo-build.log +1 -0
- package/mail/.turbo/turbo-test.log +12 -0
- package/mail/.turbo/turbo-typecheck.log +1 -0
- package/mail/CHANGELOG.md +25 -0
- package/mail/README.md +214 -0
- package/mail/dist/index.d.ts +4 -0
- package/mail/dist/index.js +2 -0
- package/mail/dist/plugin.d.ts +64 -0
- package/mail/dist/plugin.js +232 -0
- package/mail/dist/providers/brevo.provider.d.ts +15 -0
- package/mail/dist/providers/brevo.provider.js +75 -0
- package/mail/dist/providers/custom.provider.d.ts +9 -0
- package/mail/dist/providers/custom.provider.js +22 -0
- package/mail/dist/providers/resend.provider.d.ts +16 -0
- package/mail/dist/providers/resend.provider.js +77 -0
- package/mail/dist/providers/smtp.provider.d.ts +21 -0
- package/mail/dist/providers/smtp.provider.js +86 -0
- package/mail/dist/rate-limiter.d.ts +16 -0
- package/mail/dist/rate-limiter.js +49 -0
- package/mail/dist/types.d.ts +68 -0
- package/mail/dist/types.js +6 -0
- package/mail/node_modules/.bin/esbuild +22 -0
- package/mail/node_modules/.bin/jiti +22 -0
- package/mail/node_modules/.bin/sass +22 -0
- package/mail/node_modules/.bin/tsx +22 -0
- package/mail/node_modules/.bin/vite +22 -0
- package/mail/node_modules/.bin/vitest +22 -0
- package/mail/node_modules/.bin/yaml +22 -0
- package/mail/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/mail/package.json +52 -0
- package/mail/src/index.ts +4 -0
- package/mail/src/plugin.test.ts +219 -0
- package/mail/src/plugin.ts +313 -0
- package/mail/src/providers/brevo.provider.ts +78 -0
- package/mail/src/providers/custom.provider.ts +29 -0
- package/mail/src/providers/resend.provider.ts +74 -0
- package/mail/src/providers/smtp.provider.ts +85 -0
- package/mail/src/rate-limiter.test.ts +81 -0
- package/mail/src/rate-limiter.ts +54 -0
- package/mail/src/types.ts +81 -0
- package/mail/tsconfig.json +21 -0
- package/mail/vitest.config.ts +13 -0
- package/package.json +36 -0
- package/s3/.turbo/turbo-build.log +1 -0
- package/s3/.turbo/turbo-test.log +11 -0
- package/s3/CHANGELOG.md +20 -0
- package/s3/README.md +90 -0
- package/s3/dist/index.d.ts +6 -0
- package/s3/dist/index.js +4 -0
- package/s3/dist/s3-service.d.ts +7 -0
- package/s3/dist/s3-service.js +21 -0
- package/s3/dist/s3.driver.d.ts +6 -0
- package/s3/dist/s3.driver.js +221 -0
- package/s3/dist/s3.plugin.d.ts +24 -0
- package/s3/dist/s3.plugin.js +58 -0
- package/s3/dist/types.d.ts +30 -0
- package/s3/dist/types.js +1 -0
- package/s3/node_modules/.bin/esbuild +22 -0
- package/s3/node_modules/.bin/jiti +22 -0
- package/s3/node_modules/.bin/sass +22 -0
- package/s3/node_modules/.bin/tsx +22 -0
- package/s3/node_modules/.bin/vite +22 -0
- package/s3/node_modules/.bin/vitest +22 -0
- package/s3/node_modules/.bin/yaml +22 -0
- package/s3/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/s3/package.json +47 -0
- package/s3/src/index.test.ts +20 -0
- package/s3/src/index.ts +13 -0
- package/s3/src/s3-service.ts +14 -0
- package/s3/src/s3.driver.ts +259 -0
- package/s3/src/s3.plugin.ts +80 -0
- package/s3/src/types.ts +37 -0
- package/s3/tsconfig.json +21 -0
- package/s3/vitest.config.ts +13 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
let awsS3 = null;
|
|
2
|
+
async function getAwsS3() {
|
|
3
|
+
if (!awsS3) {
|
|
4
|
+
const name = '@aws-sdk/client-s3';
|
|
5
|
+
awsS3 = await import(name);
|
|
6
|
+
}
|
|
7
|
+
return awsS3;
|
|
8
|
+
}
|
|
9
|
+
let awsPresigner = null;
|
|
10
|
+
async function getAwsPresigner() {
|
|
11
|
+
if (!awsPresigner) {
|
|
12
|
+
const name = '@aws-sdk/s3-request-presigner';
|
|
13
|
+
awsPresigner = await import(name);
|
|
14
|
+
}
|
|
15
|
+
return awsPresigner;
|
|
16
|
+
}
|
|
17
|
+
export async function createS3Driver(options) {
|
|
18
|
+
const logger = options.logger;
|
|
19
|
+
if (logger) {
|
|
20
|
+
logger.debug({
|
|
21
|
+
bucket: options.bucket,
|
|
22
|
+
endpoint: options.endpoint,
|
|
23
|
+
region: options.region,
|
|
24
|
+
}, 'S3Driver: initializing');
|
|
25
|
+
}
|
|
26
|
+
const s3 = await getAwsS3();
|
|
27
|
+
const client = new s3.S3Client({
|
|
28
|
+
endpoint: options.endpoint,
|
|
29
|
+
region: options.region || 'us-east-1',
|
|
30
|
+
credentials: {
|
|
31
|
+
accessKeyId: options.accessKeyId,
|
|
32
|
+
secretAccessKey: options.secretAccessKey,
|
|
33
|
+
},
|
|
34
|
+
forcePathStyle: options.forcePathStyle,
|
|
35
|
+
});
|
|
36
|
+
const driver = new S3Driver(client, options, logger);
|
|
37
|
+
if (logger) {
|
|
38
|
+
logger.info('S3Driver: initialized');
|
|
39
|
+
}
|
|
40
|
+
return driver;
|
|
41
|
+
}
|
|
42
|
+
class S3Driver {
|
|
43
|
+
client;
|
|
44
|
+
options;
|
|
45
|
+
logger;
|
|
46
|
+
constructor(client, options, logger) {
|
|
47
|
+
this.client = client;
|
|
48
|
+
this.options = options;
|
|
49
|
+
this.logger = logger;
|
|
50
|
+
}
|
|
51
|
+
async upload(key, data, uploadOptions) {
|
|
52
|
+
let body;
|
|
53
|
+
if (data instanceof Uint8Array) {
|
|
54
|
+
body = data;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const chunks = [];
|
|
58
|
+
const reader = data.getReader();
|
|
59
|
+
while (true) {
|
|
60
|
+
const { done, value } = await reader.read();
|
|
61
|
+
if (done)
|
|
62
|
+
break;
|
|
63
|
+
chunks.push(value);
|
|
64
|
+
}
|
|
65
|
+
const totalLength = chunks.reduce((sum, c) => sum + c.byteLength, 0);
|
|
66
|
+
const merged = new Uint8Array(totalLength);
|
|
67
|
+
let offset = 0;
|
|
68
|
+
for (const chunk of chunks) {
|
|
69
|
+
merged.set(chunk, offset);
|
|
70
|
+
offset += chunk.byteLength;
|
|
71
|
+
}
|
|
72
|
+
body = merged;
|
|
73
|
+
}
|
|
74
|
+
const s3 = await getAwsS3();
|
|
75
|
+
const command = new s3.PutObjectCommand({
|
|
76
|
+
Bucket: this.options.bucket,
|
|
77
|
+
Key: key,
|
|
78
|
+
Body: body,
|
|
79
|
+
ContentType: uploadOptions?.contentType,
|
|
80
|
+
Metadata: uploadOptions?.metadata,
|
|
81
|
+
});
|
|
82
|
+
await this.client.send(command);
|
|
83
|
+
const url = this.options.baseUrl
|
|
84
|
+
? `${this.options.baseUrl.replace(/\/$/, '')}/${key}`
|
|
85
|
+
: undefined;
|
|
86
|
+
if (this.logger) {
|
|
87
|
+
this.logger.debug({ key, size: body?.length }, 'S3Driver: uploaded');
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
key,
|
|
91
|
+
size: body?.length || 0,
|
|
92
|
+
contentType: uploadOptions?.contentType || this.guessContentType(key),
|
|
93
|
+
lastModified: new Date(),
|
|
94
|
+
url,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async download(key) {
|
|
98
|
+
const s3 = await getAwsS3();
|
|
99
|
+
const command = new s3.GetObjectCommand({
|
|
100
|
+
Bucket: this.options.bucket,
|
|
101
|
+
Key: key,
|
|
102
|
+
});
|
|
103
|
+
const response = await this.client.send(command);
|
|
104
|
+
if (!response.Body) {
|
|
105
|
+
return new Uint8Array();
|
|
106
|
+
}
|
|
107
|
+
const chunks = [];
|
|
108
|
+
for await (const chunk of response.Body) {
|
|
109
|
+
chunks.push(chunk);
|
|
110
|
+
}
|
|
111
|
+
const totalLength = chunks.reduce((sum, c) => sum + c.byteLength, 0);
|
|
112
|
+
const merged = new Uint8Array(totalLength);
|
|
113
|
+
let offset = 0;
|
|
114
|
+
for (const chunk of chunks) {
|
|
115
|
+
merged.set(chunk, offset);
|
|
116
|
+
offset += chunk.byteLength;
|
|
117
|
+
}
|
|
118
|
+
return merged;
|
|
119
|
+
}
|
|
120
|
+
async getUrl(key, expiresIn) {
|
|
121
|
+
if (this.options.baseUrl) {
|
|
122
|
+
return `${this.options.baseUrl.replace(/\/$/, '')}/${key}`;
|
|
123
|
+
}
|
|
124
|
+
const [s3, presigner] = await Promise.all([getAwsS3(), getAwsPresigner()]);
|
|
125
|
+
const command = new s3.GetObjectCommand({
|
|
126
|
+
Bucket: this.options.bucket,
|
|
127
|
+
Key: key,
|
|
128
|
+
});
|
|
129
|
+
return presigner.getSignedUrl(this.client, command, {
|
|
130
|
+
expiresIn: expiresIn || 3600,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async delete(key) {
|
|
134
|
+
try {
|
|
135
|
+
const s3 = await getAwsS3();
|
|
136
|
+
const command = new s3.DeleteObjectCommand({
|
|
137
|
+
Bucket: this.options.bucket,
|
|
138
|
+
Key: key,
|
|
139
|
+
});
|
|
140
|
+
await this.client.send(command);
|
|
141
|
+
if (this.logger) {
|
|
142
|
+
this.logger.debug({ key }, 'S3Driver: deleted');
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async exists(key) {
|
|
151
|
+
try {
|
|
152
|
+
const s3 = await getAwsS3();
|
|
153
|
+
const command = new s3.HeadObjectCommand({
|
|
154
|
+
Bucket: this.options.bucket,
|
|
155
|
+
Key: key,
|
|
156
|
+
});
|
|
157
|
+
await this.client.send(command);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async list(prefix) {
|
|
165
|
+
const s3 = await getAwsS3();
|
|
166
|
+
const command = new s3.ListObjectsV2Command({
|
|
167
|
+
Bucket: this.options.bucket,
|
|
168
|
+
Prefix: prefix,
|
|
169
|
+
});
|
|
170
|
+
const response = await this.client.send(command);
|
|
171
|
+
const results = [];
|
|
172
|
+
if (response.Contents) {
|
|
173
|
+
for (const item of response.Contents) {
|
|
174
|
+
results.push({
|
|
175
|
+
key: item.Key || '',
|
|
176
|
+
size: item.Size || 0,
|
|
177
|
+
contentType: this.guessContentType(item.Key || ''),
|
|
178
|
+
lastModified: item.LastModified || new Date(),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return results;
|
|
183
|
+
}
|
|
184
|
+
async close() {
|
|
185
|
+
this.client.destroy();
|
|
186
|
+
if (this.logger) {
|
|
187
|
+
this.logger.info('S3Driver: closed');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async healthCheck() {
|
|
191
|
+
try {
|
|
192
|
+
const s3 = await getAwsS3();
|
|
193
|
+
const command = new s3.ListObjectsV2Command({
|
|
194
|
+
Bucket: this.options.bucket,
|
|
195
|
+
MaxKeys: 1,
|
|
196
|
+
});
|
|
197
|
+
await this.client.send(command);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
guessContentType(key) {
|
|
205
|
+
const ext = key.split('.').pop()?.toLowerCase() || '';
|
|
206
|
+
const mimeTypes = {
|
|
207
|
+
html: 'text/html',
|
|
208
|
+
css: 'text/css',
|
|
209
|
+
js: 'application/javascript',
|
|
210
|
+
json: 'application/json',
|
|
211
|
+
png: 'image/png',
|
|
212
|
+
jpg: 'image/jpeg',
|
|
213
|
+
jpeg: 'image/jpeg',
|
|
214
|
+
gif: 'image/gif',
|
|
215
|
+
svg: 'image/svg+xml',
|
|
216
|
+
pdf: 'application/pdf',
|
|
217
|
+
txt: 'text/plain',
|
|
218
|
+
};
|
|
219
|
+
return mimeTypes[ext] || 'application/octet-default';
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { ILogger } from '@rx-ted/packages-core';
|
|
3
|
+
import type { Application, IPlugin } from '@rx-ted/packages-honest';
|
|
4
|
+
import type { FileDriver, S3Options } from './types';
|
|
5
|
+
export declare const S3_CONTEXT_KEY = "honest:s3";
|
|
6
|
+
export declare const S3_GLOBAL_KEY = "s3";
|
|
7
|
+
export interface S3PluginOptions {
|
|
8
|
+
connection: S3Options;
|
|
9
|
+
contextKey?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class S3Plugin implements IPlugin {
|
|
12
|
+
static readonly globalKey = "s3";
|
|
13
|
+
readonly name = "s3-plugin";
|
|
14
|
+
readonly version = "1.0.0";
|
|
15
|
+
logger?: ILogger;
|
|
16
|
+
private driver;
|
|
17
|
+
private readonly connection;
|
|
18
|
+
private readonly contextKey;
|
|
19
|
+
constructor(options: S3PluginOptions);
|
|
20
|
+
getClient(): FileDriver;
|
|
21
|
+
beforeModulesRegistered(app: Application, _hono: Hono): Promise<void>;
|
|
22
|
+
afterModulesRegistered(_app: Application, _hono: Hono): Promise<void>;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ComponentManager, maskSensitive } from '@rx-ted/packages-honest';
|
|
2
|
+
import { createS3Driver } from './s3.driver';
|
|
3
|
+
export const S3_CONTEXT_KEY = 'honest:s3';
|
|
4
|
+
export const S3_GLOBAL_KEY = 's3';
|
|
5
|
+
export class S3Plugin {
|
|
6
|
+
static globalKey = S3_GLOBAL_KEY;
|
|
7
|
+
name = 's3-plugin';
|
|
8
|
+
version = '1.0.0';
|
|
9
|
+
logger;
|
|
10
|
+
driver = null;
|
|
11
|
+
connection;
|
|
12
|
+
contextKey;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.connection = options.connection;
|
|
15
|
+
this.contextKey = options.contextKey ?? S3_CONTEXT_KEY;
|
|
16
|
+
}
|
|
17
|
+
getClient() {
|
|
18
|
+
if (!this.driver) {
|
|
19
|
+
throw new Error('S3 not connected. Ensure beforeModulesRegistered has run.');
|
|
20
|
+
}
|
|
21
|
+
return this.driver;
|
|
22
|
+
}
|
|
23
|
+
async beforeModulesRegistered(app, _hono) {
|
|
24
|
+
this.logger?.info('S3: initializing...');
|
|
25
|
+
const connInfo = {
|
|
26
|
+
category: 'plugins',
|
|
27
|
+
endpoint: this.connection.endpoint,
|
|
28
|
+
region: this.connection.region,
|
|
29
|
+
bucket: this.connection.bucket,
|
|
30
|
+
accessKeyId: maskSensitive(this.connection.accessKeyId),
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
this.driver = await createS3Driver(this.connection);
|
|
34
|
+
app.getContext().set(this.contextKey, this.driver);
|
|
35
|
+
ComponentManager.registerPlugin(S3_GLOBAL_KEY, this.driver);
|
|
36
|
+
const ok = await this.driver.healthCheck();
|
|
37
|
+
if (!ok)
|
|
38
|
+
throw new Error('S3: health check failed');
|
|
39
|
+
this.logger?.info(connInfo, 'success to s3');
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
this.logger?.error({ ...connInfo, error: error instanceof Error ? error.message : String(error) }, 'fail to connect s3');
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async afterModulesRegistered(_app, _hono) {
|
|
47
|
+
if (this.driver) {
|
|
48
|
+
const ok = await this.driver.healthCheck();
|
|
49
|
+
if (ok) {
|
|
50
|
+
this.logger?.info('S3: health check passed');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async close() {
|
|
55
|
+
await this.driver?.close();
|
|
56
|
+
this.driver = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface FileUploadOptions {
|
|
2
|
+
contentType?: string;
|
|
3
|
+
metadata?: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export interface FileMetadata {
|
|
6
|
+
key: string;
|
|
7
|
+
size: number;
|
|
8
|
+
contentType: string;
|
|
9
|
+
lastModified: Date;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface S3Options {
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
accessKeyId: string;
|
|
15
|
+
secretAccessKey: string;
|
|
16
|
+
bucket: string;
|
|
17
|
+
region?: string;
|
|
18
|
+
forcePathStyle?: boolean;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface FileDriver {
|
|
22
|
+
upload(key: string, data: Uint8Array | ReadableStream, options?: FileUploadOptions): Promise<FileMetadata>;
|
|
23
|
+
download(key: string): Promise<Uint8Array>;
|
|
24
|
+
getUrl(key: string, expiresIn?: number): Promise<string>;
|
|
25
|
+
delete(key: string): Promise<boolean>;
|
|
26
|
+
exists(key: string): Promise<boolean>;
|
|
27
|
+
list(prefix?: string): Promise<FileMetadata[]>;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
healthCheck(): Promise<boolean>;
|
|
30
|
+
}
|
package/s3/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/node_modules:/Users/ben/projects/app/node_modules/.pnpm/esbuild@0.28.1/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/node_modules:/Users/ben/projects/app/node_modules/.pnpm/esbuild@0.28.1/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/bin/esbuild" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/bin/esbuild" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/bin/esbuild
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/ben/projects/app/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/ben/projects/app/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/sass@1.100.0/node_modules/sass/node_modules:/Users/ben/projects/app/node_modules/.pnpm/sass@1.100.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/sass@1.100.0/node_modules/sass/node_modules:/Users/ben/projects/app/node_modules/.pnpm/sass@1.100.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/sass@1.100.0/node_modules/sass/sass.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/sass@1.100.0/node_modules/sass/sass.js" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/sass@1.100.0/node_modules/sass/sass.js
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/node_modules:/Users/ben/projects/app/node_modules/.pnpm/tsx@4.23.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/node_modules:/Users/ben/projects/app/node_modules/.pnpm/tsx@4.23.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/dist/cli.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/dist/cli.mjs" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/dist/cli.mjs
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules/vite/node_modules:/Users/ben/projects/app/node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules/vite/node_modules:/Users/ben/projects/app/node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules/vite/bin/vite.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules/vite/bin/vite.js" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/vite@8.0.16_@types+node@25.9.2_esbuild@0.28.1_jiti@2.6.1_sass@1.100.0_tsx@4.23.0_yaml@2.9.0/node_modules/vite/bin/vite.js
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/vitest@4.1.8_@types+node@25.9.2_@vitest+coverage-v8@4.1.7_jsdom@29.1.1_@noble+hashes@1._7bccdcabe1f1ec543f47b71e54a2d105/node_modules/vitest/node_modules:/Users/ben/projects/app/node_modules/.pnpm/vitest@4.1.8_@types+node@25.9.2_@vitest+coverage-v8@4.1.7_jsdom@29.1.1_@noble+hashes@1._7bccdcabe1f1ec543f47b71e54a2d105/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/vitest@4.1.8_@types+node@25.9.2_@vitest+coverage-v8@4.1.7_jsdom@29.1.1_@noble+hashes@1._7bccdcabe1f1ec543f47b71e54a2d105/node_modules/vitest/node_modules:/Users/ben/projects/app/node_modules/.pnpm/vitest@4.1.8_@types+node@25.9.2_@vitest+coverage-v8@4.1.7_jsdom@29.1.1_@noble+hashes@1._7bccdcabe1f1ec543f47b71e54a2d105/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../vitest/vitest.mjs" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/packages/honest-plugins/s3/node_modules/vitest/vitest.mjs
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/node_modules:/Users/ben/projects/app/node_modules/.pnpm/yaml@2.9.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/Users/ben/projects/app/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/node_modules:/Users/ben/projects/app/node_modules/.pnpm/yaml@2.9.0/node_modules:/Users/ben/projects/app/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/bin.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../../../../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/bin.mjs" "$@"
|
|
21
|
+
fi
|
|
22
|
+
# cmd-shim-target=/Users/ben/projects/app/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/bin.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"4.1.8","results":[[":src/index.test.ts",{"duration":1.224082999999979,"failed":false}]]}
|
package/s3/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rx-ted/packages-honest-plugins-s3",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "S3 plugin for @rx-ted/packages-honest",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"vitest": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./dist/index.js"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/rx-ted/honest.git"
|
|
22
|
+
},
|
|
23
|
+
"author": "rx-ted",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"test:coverage": "vitest run --coverage"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@aws-sdk/client-s3": "^3.1056.0",
|
|
36
|
+
"@aws-sdk/s3-request-presigner": "^3.1056.0",
|
|
37
|
+
"@rx-ted/packages-core": "workspace:^"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@rx-ted/packages-honest": "workspace:^",
|
|
41
|
+
"hono": "^4.12.18"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.9.1",
|
|
45
|
+
"vitest": "^4.1.7"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { S3Plugin, S3_CONTEXT_KEY, S3_GLOBAL_KEY, createS3Driver } from './index';
|
|
3
|
+
|
|
4
|
+
describe('S3 plugin exports', () => {
|
|
5
|
+
it('exports S3Plugin', () => {
|
|
6
|
+
expect(S3Plugin).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('exports S3_CONTEXT_KEY', () => {
|
|
10
|
+
expect(S3_CONTEXT_KEY).toBe('honest:s3');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('exports S3_GLOBAL_KEY', () => {
|
|
14
|
+
expect(S3_GLOBAL_KEY).toBe('s3');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('exports createS3Driver', () => {
|
|
18
|
+
expect(createS3Driver).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
});
|
package/s3/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { S3Plugin, S3_CONTEXT_KEY, S3_GLOBAL_KEY } from './s3.plugin';
|
|
2
|
+
export type { S3PluginOptions } from './s3.plugin';
|
|
3
|
+
export { createS3Driver } from './s3.driver';
|
|
4
|
+
export type { S3DriverOptions } from './s3.driver';
|
|
5
|
+
export type {
|
|
6
|
+
FileDriver,
|
|
7
|
+
FileMetadata,
|
|
8
|
+
FileUploadOptions,
|
|
9
|
+
S3Options,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
// DI service
|
|
13
|
+
export { S3Service } from './s3-service';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Service, ComponentManager } from '@rx-ted/packages-honest';
|
|
2
|
+
import type { FileDriver } from './types';
|
|
3
|
+
import { S3_GLOBAL_KEY } from './s3.plugin';
|
|
4
|
+
|
|
5
|
+
@Service()
|
|
6
|
+
class S3Service {
|
|
7
|
+
constructor() {
|
|
8
|
+
return ComponentManager.getPlugin<FileDriver>(S3_GLOBAL_KEY);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface S3Service extends FileDriver {}
|
|
13
|
+
|
|
14
|
+
export { S3Service };
|