@toa.io/extensions.storages 1.0.0-alpha.274 → 1.0.0-alpha.277
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 +7 -0
- package/package.json +8 -11
- package/source/Annotation.ts +3 -3
- package/source/Aspect.ts +1 -1
- package/source/Factory.ts +9 -9
- package/source/Provider.ts +2 -2
- package/source/Storage.test.ts +64 -64
- package/source/Storage.ts +4 -4
- package/source/deployment.ts +3 -3
- package/source/index.ts +6 -6
- package/source/providers/Cloudinary.ts +4 -4
- package/source/providers/Declaration.ts +5 -5
- package/source/providers/FileSystem.ts +3 -3
- package/source/providers/S3.ts +4 -4
- package/source/providers/Spaces.ts +2 -2
- package/source/providers/Temporary.ts +1 -1
- package/source/providers/Test.ts +2 -2
- package/source/providers/index.test.ts +40 -36
- package/source/providers/index.ts +13 -13
- package/source/schemas.test.ts +8 -4
- package/source/schemas.ts +3 -3
- package/source/test/util.ts +3 -3
- package/transpiled/Annotation.d.ts +1 -1
- package/transpiled/Annotation.js +8 -38
- package/transpiled/Annotation.js.map +1 -1
- package/transpiled/Aspect.d.ts +1 -1
- package/transpiled/Aspect.js +4 -11
- package/transpiled/Aspect.js.map +1 -1
- package/transpiled/Entry.d.ts +0 -1
- package/transpiled/Entry.js +1 -2
- package/transpiled/Factory.d.ts +1 -1
- package/transpiled/Factory.js +17 -24
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Provider.d.ts +2 -3
- package/transpiled/Provider.js +2 -29
- package/transpiled/Provider.js.map +1 -1
- package/transpiled/Scanner.d.ts +0 -3
- package/transpiled/Scanner.js +6 -13
- package/transpiled/Scanner.js.map +1 -1
- package/transpiled/Secrets.js +1 -2
- package/transpiled/Storage.d.ts +3 -4
- package/transpiled/Storage.js +13 -17
- package/transpiled/Storage.js.map +1 -1
- package/transpiled/deployment.js +9 -36
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/errors.d.ts +1 -1
- package/transpiled/errors.js +1 -4
- package/transpiled/errors.js.map +1 -1
- package/transpiled/index.d.ts +6 -6
- package/transpiled/index.js +3 -9
- package/transpiled/index.js.map +1 -1
- package/transpiled/manifest.js +1 -5
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/providers/Cloudinary.d.ts +3 -4
- package/transpiled/providers/Cloudinary.js +28 -32
- package/transpiled/providers/Cloudinary.js.map +1 -1
- package/transpiled/providers/Declaration.d.ts +5 -5
- package/transpiled/providers/Declaration.js +1 -2
- package/transpiled/providers/FileSystem.d.ts +2 -3
- package/transpiled/providers/FileSystem.js +19 -26
- package/transpiled/providers/FileSystem.js.map +1 -1
- package/transpiled/providers/S3.d.ts +3 -4
- package/transpiled/providers/S3.js +20 -50
- package/transpiled/providers/S3.js.map +1 -1
- package/transpiled/providers/Spaces.d.ts +2 -2
- package/transpiled/providers/Spaces.js +2 -6
- package/transpiled/providers/Spaces.js.map +1 -1
- package/transpiled/providers/Temporary.d.ts +1 -1
- package/transpiled/providers/Temporary.js +5 -9
- package/transpiled/providers/Temporary.js.map +1 -1
- package/transpiled/providers/Test.d.ts +2 -2
- package/transpiled/providers/Test.js +2 -6
- package/transpiled/providers/Test.js.map +1 -1
- package/transpiled/providers/index.d.ts +12 -12
- package/transpiled/providers/index.js +13 -16
- package/transpiled/providers/index.js.map +1 -1
- package/transpiled/schemas.d.ts +2 -2
- package/transpiled/schemas.js +11 -14
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/test/util.d.ts +19 -19
- package/transpiled/test/util.js +4 -10
- package/transpiled/test/util.js.map +1 -1
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/transpiled/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.277](https://github.com/toa-io/toa/compare/v1.0.0-alpha.276...v1.0.0-alpha.277) (2026-09-03)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* drop the build output that landed beside the sources ([a724f69](https://github.com/toa-io/toa/commit/a724f6921190e5c9d945e33c6035bb12d832e5c8))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
# [1.0.0-alpha.274](https://github.com/toa-io/toa/compare/v1.0.0-alpha.273...v1.0.0-alpha.274) (2026-09-02)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @toa.io/extensions.storages
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.storages",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.277",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Toa Storages",
|
|
5
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
7
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -16,24 +17,20 @@
|
|
|
16
17
|
"publishConfig": {
|
|
17
18
|
"access": "public"
|
|
18
19
|
},
|
|
19
|
-
"jest": {
|
|
20
|
-
"preset": "ts-jest",
|
|
21
|
-
"testEnvironment": "node"
|
|
22
|
-
},
|
|
23
20
|
"scripts": {
|
|
24
|
-
"test": "
|
|
21
|
+
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
25
22
|
"transpile": "npx tsc"
|
|
26
23
|
},
|
|
27
24
|
"devDependencies": {
|
|
28
25
|
"dotenv": "17.4.2"
|
|
29
26
|
},
|
|
30
27
|
"dependencies": {
|
|
31
|
-
"@aws-sdk/client-s3": "3.
|
|
32
|
-
"@aws-sdk/lib-storage": "3.
|
|
33
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
28
|
+
"@aws-sdk/client-s3": "3.1125.0",
|
|
29
|
+
"@aws-sdk/lib-storage": "3.1125.0",
|
|
30
|
+
"@toa.io/schemas": "1.0.0-alpha.277",
|
|
34
31
|
"cloudinary": "2.11.0",
|
|
35
32
|
"negotiator": "1.1.0",
|
|
36
|
-
"openspan": "1.0.0-alpha.
|
|
33
|
+
"openspan": "1.0.0-alpha.277"
|
|
37
34
|
},
|
|
38
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0c0071418c2c56a44e621ba5ced5cdd23dff1738"
|
|
39
36
|
}
|
package/source/Annotation.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
|
-
import { providers } from './providers'
|
|
3
|
-
import * as schemas from './schemas'
|
|
4
|
-
import type { Declaration } from './providers'
|
|
2
|
+
import { providers } from './providers/index.js'
|
|
3
|
+
import * as schemas from './schemas.js'
|
|
4
|
+
import type { Declaration } from './providers/index.js'
|
|
5
5
|
import type { Schema } from '@toa.io/schemas'
|
|
6
6
|
|
|
7
7
|
export type Annotation = Record<string, Declaration>
|
package/source/Aspect.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { Connector, type extensions } from '@toa.io/core'
|
|
3
|
-
import { type Storage, type Storages } from './Storage'
|
|
3
|
+
import { type Storage, type Storages } from './Storage.js'
|
|
4
4
|
|
|
5
5
|
export class Aspect extends Connector implements extensions.Aspect {
|
|
6
6
|
public readonly name = 'storages'
|
package/source/Factory.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { console } from 'openspan'
|
|
3
|
-
import { providers } from './providers'
|
|
4
|
-
import { Storage, type Storages } from './Storage'
|
|
5
|
-
import { Aspect } from './Aspect'
|
|
6
|
-
import { ENV_PREFIX } from './deployment'
|
|
7
|
-
import { validateAnnotation } from './Annotation'
|
|
8
|
-
import type { Constructor } from './Provider'
|
|
9
|
-
import type { Declaration } from './providers'
|
|
10
|
-
import type { Annotation } from './Annotation'
|
|
11
|
-
import type { Secrets } from './Secrets'
|
|
3
|
+
import { providers } from './providers/index.js'
|
|
4
|
+
import { Storage, type Storages } from './Storage.js'
|
|
5
|
+
import { Aspect } from './Aspect.js'
|
|
6
|
+
import { ENV_PREFIX } from './deployment.js'
|
|
7
|
+
import { validateAnnotation } from './Annotation.js'
|
|
8
|
+
import type { Constructor } from './Provider.js'
|
|
9
|
+
import type { Declaration } from './providers/index.js'
|
|
10
|
+
import type { Annotation } from './Annotation.js'
|
|
11
|
+
import type { Secrets } from './Secrets.js'
|
|
12
12
|
|
|
13
13
|
export class Factory {
|
|
14
14
|
private readonly annotation: Annotation
|
package/source/Provider.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as assert from 'node:assert'
|
|
2
|
-
import type { Metadata, Stream } from './Entry'
|
|
2
|
+
import type { Metadata, Stream } from './Entry.js'
|
|
3
3
|
import type { Readable } from 'node:stream'
|
|
4
4
|
import type { Maybe } from '@toa.io/types'
|
|
5
|
-
import type { Secret, Secrets } from './Secrets'
|
|
5
|
+
import type { Secret, Secrets } from './Secrets.js'
|
|
6
6
|
|
|
7
7
|
export abstract class Provider<Options = unknown> {
|
|
8
8
|
public static readonly SECRETS?: readonly Secret[]
|
package/source/Storage.test.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { describe, it, before, beforeEach } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
1
4
|
import { randomUUID } from 'node:crypto'
|
|
2
5
|
import { buffer } from 'node:stream/consumers'
|
|
3
6
|
import { createReadStream } from 'node:fs'
|
|
4
7
|
import path from 'node:path'
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
-
import type { Constructor } from './Provider'
|
|
11
|
-
|
|
12
|
-
jest.setTimeout(15_000)
|
|
8
|
+
import { Storage } from './Storage.js'
|
|
9
|
+
import { suites } from './test/util.js'
|
|
10
|
+
import { providers } from './providers/index.js'
|
|
11
|
+
import type { Entry, Stream } from './Entry.js'
|
|
12
|
+
import type { Constructor } from './Provider.js'
|
|
13
13
|
|
|
14
14
|
const suite = suites[0]
|
|
15
15
|
const Provider: Constructor = providers[suite.provider]
|
|
@@ -17,19 +17,19 @@ const provider = new Provider(suite.options, suite.secrets)
|
|
|
17
17
|
const storage = new Storage(provider)
|
|
18
18
|
const dir = '/' + randomUUID()
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
process.chdir(path.join(
|
|
20
|
+
before(async () => {
|
|
21
|
+
process.chdir(path.join(import.meta.dirname, 'test'))
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it('should be', async () => {
|
|
25
|
-
|
|
25
|
+
assert.ok(storage instanceof Storage)
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
it('should return error if entry is not found', async () => {
|
|
29
29
|
const result = await storage.get('not-found')
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
assert.ok(result instanceof Error)
|
|
32
|
+
assert.deepStrictEqual(result.code, 'NOT_FOUND')
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
describe('put', () => {
|
|
@@ -48,43 +48,43 @@ describe('put', () => {
|
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
it('should not return error', async () => {
|
|
51
|
-
|
|
51
|
+
assert.ok(!(lenna instanceof Error))
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
it('should return entry id', async () => {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
assert.notStrictEqual(lenna.id, undefined)
|
|
56
|
+
assert.strictEqual(lenna.id.length, 32)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
it('should detect file type', async () => {
|
|
60
|
-
|
|
60
|
+
assert.deepStrictEqual(lenna['type'], 'image/png')
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
it('should count size', async () => {
|
|
64
|
-
|
|
64
|
+
assert.deepStrictEqual(lenna['size'], 473831)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('should return entry', async () => {
|
|
68
|
-
|
|
68
|
+
assert.partialDeepStrictEqual(lenna, {
|
|
69
69
|
id: lenna.id,
|
|
70
70
|
type: 'image/png',
|
|
71
71
|
size: 473831,
|
|
72
72
|
checksum: lenna.checksum,
|
|
73
|
-
created: expect.any(String),
|
|
74
73
|
attributes: {}
|
|
75
|
-
}
|
|
74
|
+
})
|
|
75
|
+
assert.strictEqual(typeof lenna.created, 'string')
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
it('should create metadata', async () => {
|
|
79
79
|
const entry = await storage.head(path) as Entry
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
assert.partialDeepStrictEqual(entry, {
|
|
82
82
|
type: 'image/png',
|
|
83
83
|
size: 473831,
|
|
84
84
|
checksum: lenna.checksum,
|
|
85
|
-
created: expect.any(String),
|
|
86
85
|
attributes: {}
|
|
87
|
-
}
|
|
86
|
+
})
|
|
87
|
+
assert.strictEqual(typeof entry.created, 'string')
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
it('should set timestamp', async () => {
|
|
@@ -92,8 +92,8 @@ describe('put', () => {
|
|
|
92
92
|
const entry = await storage.get(path) as Stream
|
|
93
93
|
const created = new Date(entry.created).getTime()
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
assert.ok(created <= now)
|
|
96
|
+
assert.ok(created >= startCreation)
|
|
97
97
|
})
|
|
98
98
|
|
|
99
99
|
it('should store with given id', async () => {
|
|
@@ -102,14 +102,14 @@ describe('put', () => {
|
|
|
102
102
|
|
|
103
103
|
const entry = await storage.put(dir, stream, { id }) as Entry
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert.strictEqual(entry.id, id)
|
|
106
106
|
|
|
107
107
|
const check = await storage.head(`${dir}/${id}`)
|
|
108
108
|
|
|
109
109
|
if (check instanceof Error)
|
|
110
110
|
throw check
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
assert.strictEqual(check.id, id)
|
|
113
113
|
})
|
|
114
114
|
})
|
|
115
115
|
|
|
@@ -130,32 +130,32 @@ describe('get, head', () => {
|
|
|
130
130
|
const stored = await buffer(entry.stream)
|
|
131
131
|
const buf = await buffer(createReadStream('lenna.png'))
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
assert.strictEqual(stored.compare(new Uint8Array(buf.buffer)), 0)
|
|
134
134
|
})
|
|
135
135
|
|
|
136
136
|
it('should get entry', async () => {
|
|
137
137
|
const entry = await storage.head(path) as Entry
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
assert.strictEqual(entry.id, lenna.id)
|
|
140
140
|
})
|
|
141
141
|
|
|
142
142
|
if (suite.provider === 'cloudinary') {
|
|
143
143
|
it('should return cloudinary url', async () => {
|
|
144
144
|
const entry = await storage.head(`${path}.jpeg`) as Entry
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
assert.match(entry.attributes.url, /^https:\/\//)
|
|
147
147
|
})
|
|
148
148
|
|
|
149
149
|
it('should support conditions', async () => {
|
|
150
150
|
const entry = await storage.head(`${path}.vertical.jpeg`) as Entry
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
assert.strictEqual(entry.attributes.url.includes('/if_w_gt_h/a_90/if_end/'), true)
|
|
153
153
|
})
|
|
154
154
|
|
|
155
155
|
it('should return entry id when requested with extensions', async () => {
|
|
156
156
|
const entry = await storage.head(`${path}.jpeg`) as Entry
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
assert.strictEqual(entry.id, lenna.id)
|
|
159
159
|
})
|
|
160
160
|
}
|
|
161
161
|
})
|
|
@@ -178,47 +178,47 @@ describe('delete', () => {
|
|
|
178
178
|
|
|
179
179
|
const result = await storage.get(`${dir}/${lenna.id}`)
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
assert.ok(result instanceof Error)
|
|
182
|
+
assert.deepStrictEqual(result['code'], 'NOT_FOUND')
|
|
183
183
|
})
|
|
184
184
|
|
|
185
185
|
it('should not return error', async () => {
|
|
186
186
|
const result = await storage.delete(dir)
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
assert.strictEqual(result, undefined)
|
|
189
189
|
})
|
|
190
190
|
})
|
|
191
191
|
|
|
192
192
|
describe('signatures', () => {
|
|
193
|
-
|
|
194
|
-
async (
|
|
193
|
+
for (const type of ['jpeg', 'gif', 'webp', 'heic', 'jxl', 'avif'])
|
|
194
|
+
it(`should detect image/${type}`, async () => {
|
|
195
195
|
const stream = createReadStream('sample.' + type)
|
|
196
196
|
const entry = await storage.put(dir, stream) as Entry
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
assert.deepStrictEqual(entry['type'], 'image/' + type)
|
|
199
199
|
})
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
for (const type of ['avi'])
|
|
202
|
+
it(`should detect video/${type}`, async () => {
|
|
203
203
|
const stream = createReadStream('sample.' + type)
|
|
204
204
|
const entry = await storage.put(dir, stream) as Entry
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
assert.deepStrictEqual(entry['type'], 'video/' + type)
|
|
207
207
|
})
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
for (const type of ['wav'])
|
|
210
|
+
it(`should detect audio/${type}`, async () => {
|
|
211
211
|
const stream = createReadStream('sample.' + type)
|
|
212
212
|
const entry = (await storage.put(dir, stream)) as Entry
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
assert.deepStrictEqual(entry['type'], 'audio/' + type)
|
|
215
215
|
})
|
|
216
216
|
|
|
217
217
|
it('should be ok with Arny', async () => {
|
|
218
218
|
const stream = createReadStream('arny.jpg')
|
|
219
219
|
const entry = (await storage.put(dir, stream)) as Entry
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
assert.deepStrictEqual(entry['type'], 'image/jpeg')
|
|
222
222
|
})
|
|
223
223
|
})
|
|
224
224
|
|
|
@@ -227,8 +227,8 @@ it('should return error if type doesn\'t match', async () => {
|
|
|
227
227
|
|
|
228
228
|
const result = await storage.put(dir, stream, { claim: 'image/png' })
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
assert.ok(result instanceof Error)
|
|
231
|
+
assert.deepStrictEqual(result['code'], 'TYPE_MISMATCH')
|
|
232
232
|
})
|
|
233
233
|
|
|
234
234
|
it('should trust unknown types', async () => {
|
|
@@ -236,8 +236,8 @@ it('should trust unknown types', async () => {
|
|
|
236
236
|
|
|
237
237
|
const result = await storage.put(dir, stream, { claim: 'text/plain' })
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
assert.ok(!(result instanceof Error))
|
|
240
|
+
assert.deepStrictEqual(result['type'], 'text/plain')
|
|
241
241
|
})
|
|
242
242
|
|
|
243
243
|
it('should return error if type is identifiable', async () => {
|
|
@@ -245,8 +245,8 @@ it('should return error if type is identifiable', async () => {
|
|
|
245
245
|
|
|
246
246
|
const result = await storage.put(dir, stream, { claim: 'image/jpeg' })
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
assert.ok(result instanceof Error)
|
|
249
|
+
assert.deepStrictEqual(result['code'], 'TYPE_MISMATCH')
|
|
250
250
|
})
|
|
251
251
|
|
|
252
252
|
it('should not return error if type application/octet-stream', async () => {
|
|
@@ -254,8 +254,8 @@ it('should not return error if type application/octet-stream', async () => {
|
|
|
254
254
|
|
|
255
255
|
const result = await storage.put(dir, stream, { claim: 'application/octet-stream' })
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
assert.ok(!(result instanceof Error))
|
|
258
|
+
assert.deepStrictEqual(result['type'], 'image/jpeg')
|
|
259
259
|
})
|
|
260
260
|
|
|
261
261
|
it('should return error if type is not acceptable', async () => {
|
|
@@ -263,8 +263,8 @@ it('should return error if type is not acceptable', async () => {
|
|
|
263
263
|
|
|
264
264
|
const result = await storage.put(dir, stream, { accept: 'image/png' })
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
assert.ok(result instanceof Error)
|
|
267
|
+
assert.deepStrictEqual(result['code'], 'NOT_ACCEPTABLE')
|
|
268
268
|
})
|
|
269
269
|
|
|
270
270
|
it('should accept wildcard types', async () => {
|
|
@@ -272,27 +272,27 @@ it('should accept wildcard types', async () => {
|
|
|
272
272
|
|
|
273
273
|
const result = await storage.put(dir, stream, { accept: 'image/*' })
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
assert.ok(!(result instanceof Error))
|
|
276
|
+
assert.deepStrictEqual(result['type'], 'image/jpeg')
|
|
277
277
|
})
|
|
278
278
|
|
|
279
279
|
it('should handle root entries', async () => {
|
|
280
280
|
const stream = createReadStream('sample.jpeg')
|
|
281
281
|
const result = await storage.put('/', stream) as Entry
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
assert.ok(!(result instanceof Error))
|
|
284
284
|
|
|
285
285
|
const stored = await storage.get(result.id)
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
assert.ok(!(stored instanceof Error))
|
|
288
288
|
})
|
|
289
289
|
|
|
290
290
|
it('should return error of stream size limit exceeded', async () => {
|
|
291
291
|
const stream = createReadStream('sample.jpeg')
|
|
292
292
|
const result = await storage.put(dir, stream, { limit: 1024 })
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
assert.ok(result instanceof Error)
|
|
295
|
+
assert.deepStrictEqual(result['code'], 'LIMIT_EXCEEDED')
|
|
296
296
|
})
|
|
297
297
|
|
|
298
298
|
if (suite.provider !== 'cloudinary')
|
|
@@ -307,11 +307,11 @@ if (suite.provider !== 'cloudinary')
|
|
|
307
307
|
|
|
308
308
|
assert.ok(!(entry instanceof Error))
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
assert.strictEqual(entry.attributes.origin, origin)
|
|
311
311
|
})
|
|
312
312
|
|
|
313
313
|
it('should expose path', () => {
|
|
314
314
|
const path = storage.path()
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
assert.ok(typeof path === 'string' || path === null)
|
|
317
317
|
})
|
package/source/Storage.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { basename, dirname, join } from 'node:path'
|
|
2
2
|
import { randomUUID } from 'node:crypto'
|
|
3
3
|
import { console, type SpanOptions } from 'openspan'
|
|
4
|
-
import { Scanner } from './Scanner'
|
|
4
|
+
import { Scanner } from './Scanner.js'
|
|
5
5
|
import type { Readable } from 'node:stream'
|
|
6
|
-
import type { Attributes, Entry, Stream } from './Entry'
|
|
7
|
-
import type { ScanOptions } from './Scanner'
|
|
8
|
-
import type { Provider } from './Provider'
|
|
6
|
+
import type { Attributes, Entry, Stream } from './Entry.js'
|
|
7
|
+
import type { ScanOptions } from './Scanner.js'
|
|
8
|
+
import type { Provider } from './Provider.js'
|
|
9
9
|
|
|
10
10
|
export class Storage<T extends Provider = Provider> {
|
|
11
11
|
private readonly provider: T
|
package/source/deployment.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as assert from 'node:assert'
|
|
2
|
-
import { providers } from './providers'
|
|
3
|
-
import { validateAnnotation } from './Annotation'
|
|
4
|
-
import type { Annotation } from './Annotation'
|
|
2
|
+
import { providers } from './providers/index.js'
|
|
3
|
+
import { validateAnnotation } from './Annotation.js'
|
|
4
|
+
import type { Annotation } from './Annotation.js'
|
|
5
5
|
import type { Dependency, Variable, Mounts } from '@toa.io/operations'
|
|
6
6
|
import type { context } from '@toa.io/norm'
|
|
7
7
|
|
package/source/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { Factory } from './Factory'
|
|
2
|
-
export { deployment } from './deployment'
|
|
3
|
-
export { manifest } from './manifest'
|
|
1
|
+
export { Factory } from './Factory.js'
|
|
2
|
+
export { deployment } from './deployment.js'
|
|
3
|
+
export { manifest } from './manifest.js'
|
|
4
4
|
|
|
5
|
-
export type { Entry, Stream } from './Entry'
|
|
6
|
-
export type { Storage } from './Storage'
|
|
7
|
-
export type * from './providers'
|
|
5
|
+
export type { Entry, Stream } from './Entry.js'
|
|
6
|
+
export type { Storage } from './Storage.js'
|
|
7
|
+
export type * from './providers/index.js'
|
|
@@ -2,11 +2,11 @@ import { basename, dirname, join } from 'node:path'
|
|
|
2
2
|
import { Readable } from 'node:stream'
|
|
3
3
|
import { v2 as cloudinary } from 'cloudinary'
|
|
4
4
|
import { console } from 'openspan'
|
|
5
|
-
import { Provider } from '../Provider'
|
|
6
|
-
import { ERR_NOT_FOUND } from '../errors'
|
|
5
|
+
import { Provider } from '../Provider.js'
|
|
6
|
+
import { ERR_NOT_FOUND } from '../errors.js'
|
|
7
7
|
import type { Maybe } from '@toa.io/types'
|
|
8
|
-
import type { Metadata, Stream } from '../Entry'
|
|
9
|
-
import type { Secret, Secrets } from '../Secrets'
|
|
8
|
+
import type { Metadata, Stream } from '../Entry.js'
|
|
9
|
+
import type { Secret, Secrets } from '../Secrets.js'
|
|
10
10
|
import type { ReadableStream } from 'node:stream/web'
|
|
11
11
|
import type {
|
|
12
12
|
ConfigOptions,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { S3Options } from './S3'
|
|
2
|
-
import type { SpacesOptions } from './Spaces'
|
|
3
|
-
import type { CloudinaryOptions } from './Cloudinary'
|
|
4
|
-
import type { FileSystemOptions } from './FileSystem'
|
|
5
|
-
import type { TemporaryOptions } from './Temporary'
|
|
1
|
+
import type { S3Options } from './S3.js'
|
|
2
|
+
import type { SpacesOptions } from './Spaces.js'
|
|
3
|
+
import type { CloudinaryOptions } from './Cloudinary.js'
|
|
4
|
+
import type { FileSystemOptions } from './FileSystem.js'
|
|
5
|
+
import type { TemporaryOptions } from './Temporary.js'
|
|
6
6
|
|
|
7
7
|
export type Declaration =
|
|
8
8
|
({ provider: 's3' } & S3Options)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import { createReadStream } from 'node:fs'
|
|
3
3
|
import { dirname, join } from 'node:path'
|
|
4
|
-
import { Provider } from '../Provider'
|
|
5
|
-
import { ERR_NOT_FOUND } from '../errors'
|
|
4
|
+
import { Provider } from '../Provider.js'
|
|
5
|
+
import { ERR_NOT_FOUND } from '../errors.js'
|
|
6
6
|
import type { Readable } from 'node:stream'
|
|
7
7
|
import type { Maybe } from '@toa.io/types'
|
|
8
|
-
import type { Metadata, Stream } from '../Entry'
|
|
8
|
+
import type { Metadata, Stream } from '../Entry.js'
|
|
9
9
|
|
|
10
10
|
export interface FileSystemOptions {
|
|
11
11
|
path: string
|
package/source/providers/S3.ts
CHANGED
|
@@ -5,12 +5,12 @@ import assert from 'node:assert'
|
|
|
5
5
|
import { Upload } from '@aws-sdk/lib-storage'
|
|
6
6
|
import * as s3 from '@aws-sdk/client-s3'
|
|
7
7
|
import { console } from 'openspan'
|
|
8
|
-
import { Provider } from '../Provider'
|
|
9
|
-
import { ERR_NOT_FOUND } from '../errors'
|
|
8
|
+
import { Provider } from '../Provider.js'
|
|
9
|
+
import { ERR_NOT_FOUND } from '../errors.js'
|
|
10
10
|
import type { ReadableStream } from 'node:stream/web'
|
|
11
11
|
import type { Maybe } from '@toa.io/types'
|
|
12
|
-
import type { Metadata, Stream } from '../Entry'
|
|
13
|
-
import type { Secret, Secrets } from '../Secrets'
|
|
12
|
+
import type { Metadata, Stream } from '../Entry.js'
|
|
13
|
+
import type { Secret, Secrets } from '../Secrets.js'
|
|
14
14
|
|
|
15
15
|
export interface S3Options {
|
|
16
16
|
bucket: string
|
package/source/providers/Test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Temporary, type TemporaryOptions } from './Temporary'
|
|
2
|
-
import type { Secret } from '../Secrets'
|
|
1
|
+
import { Temporary, type TemporaryOptions } from './Temporary.js'
|
|
2
|
+
import type { Secret } from '../Secrets.js'
|
|
3
3
|
|
|
4
4
|
export class Test extends Temporary {
|
|
5
5
|
public static override readonly SECRETS: readonly Secret[] = [
|