@toa.io/extensions.storages 1.0.0-alpha.31 → 1.0.0-alpha.310
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/package.json +38 -18
- package/readme.md +115 -47
- package/transpiled/Aspect.d.ts +8 -4
- package/transpiled/Aspect.js +12 -14
- package/transpiled/Aspect.js.map +1 -1
- package/transpiled/Entry.d.ts +14 -11
- package/transpiled/Entry.js +1 -2
- package/transpiled/Factory.d.ts +1 -1
- package/transpiled/Factory.js +29 -30
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Provider.d.ts +17 -19
- package/transpiled/Provider.js +10 -33
- package/transpiled/Provider.js.map +1 -1
- package/transpiled/Scanner.d.ts +5 -4
- package/transpiled/Scanner.js +33 -26
- package/transpiled/Scanner.js.map +1 -1
- package/transpiled/Secrets.d.ts +5 -0
- package/transpiled/Secrets.js +2 -0
- package/transpiled/Secrets.js.map +1 -0
- package/transpiled/Storage.d.ts +23 -22
- package/transpiled/Storage.js +79 -142
- package/transpiled/Storage.js.map +1 -1
- package/transpiled/errors.d.ts +7 -0
- package/transpiled/errors.js +4 -0
- package/transpiled/errors.js.map +1 -0
- package/transpiled/index.d.ts +4 -4
- package/transpiled/index.js +1 -9
- package/transpiled/index.js.map +1 -1
- package/transpiled/measurements.d.ts +3 -0
- package/transpiled/measurements.js +23 -0
- package/transpiled/measurements.js.map +1 -0
- package/transpiled/providers/Cloudinary.d.ts +50 -0
- package/transpiled/providers/Cloudinary.js +223 -0
- package/transpiled/providers/Cloudinary.js.map +1 -0
- package/transpiled/providers/Declaration.d.ts +9 -5
- package/transpiled/providers/Declaration.js +1 -2
- package/transpiled/providers/FileSystem.d.ts +16 -11
- package/transpiled/providers/FileSystem.js +64 -43
- package/transpiled/providers/FileSystem.js.map +1 -1
- package/transpiled/providers/S3.d.ts +14 -19
- package/transpiled/providers/S3.js +72 -123
- package/transpiled/providers/S3.js.map +1 -1
- package/transpiled/providers/Spaces.d.ts +12 -0
- package/transpiled/providers/Spaces.js +13 -0
- package/transpiled/providers/Spaces.js.map +1 -0
- package/transpiled/providers/Temporary.d.ts +2 -3
- package/transpiled/providers/Temporary.js +7 -11
- package/transpiled/providers/Temporary.js.map +1 -1
- package/transpiled/providers/Test.d.ts +4 -4
- package/transpiled/providers/Test.js +6 -12
- package/transpiled/providers/Test.js.map +1 -1
- package/transpiled/providers/index.d.ts +23 -11
- package/transpiled/providers/index.js +30 -14
- package/transpiled/providers/index.js.map +1 -1
- package/transpiled/providers/index.types.d.ts +5 -0
- package/transpiled/providers/index.types.js +2 -0
- package/transpiled/providers/index.types.js.map +1 -0
- package/transpiled/test/util.d.ts +113 -6
- package/transpiled/test/util.js +68 -15
- package/transpiled/test/util.js.map +1 -1
- package/schemas/annotation.cos.yaml +0 -10
- package/schemas/fs.cos.yaml +0 -9
- package/schemas/mem.cos.yaml +0 -6
- package/schemas/s3.cos.yaml +0 -16
- package/schemas/test.cos.yaml +0 -8
- package/schemas/tmp.cos.yaml +0 -9
- package/source/Annotation.ts +0 -39
- package/source/Aspect.ts +0 -25
- package/source/Entry.ts +0 -14
- package/source/Factory.ts +0 -68
- package/source/Provider.ts +0 -37
- package/source/Scanner.ts +0 -153
- package/source/Storage.test.ts +0 -472
- package/source/Storage.ts +0 -235
- package/source/deployment.ts +0 -57
- package/source/index.ts +0 -5
- package/source/manifest.ts +0 -8
- package/source/providers/Declaration.ts +0 -10
- package/source/providers/FileSystem.test.ts +0 -5
- package/source/providers/FileSystem.ts +0 -63
- package/source/providers/Memory.ts +0 -55
- package/source/providers/S3.test.ts +0 -134
- package/source/providers/S3.ts +0 -196
- package/source/providers/Temporary.ts +0 -16
- package/source/providers/Test.ts +0 -13
- package/source/providers/index.test.ts +0 -136
- package/source/providers/index.ts +0 -16
- package/source/providers/readme.md +0 -25
- package/source/schemas.test.ts +0 -58
- package/source/schemas.ts +0 -15
- package/source/test/.env.example +0 -1
- package/source/test/albert.jpg +0 -0
- package/source/test/empty.txt +0 -0
- package/source/test/lenna.ascii +0 -64
- package/source/test/lenna.png +0 -0
- package/source/test/sample.avi +0 -0
- package/source/test/sample.avif +0 -0
- package/source/test/sample.gif +0 -0
- package/source/test/sample.heic +0 -0
- package/source/test/sample.jpeg +0 -0
- package/source/test/sample.jxl +0 -0
- package/source/test/sample.svg +0 -4
- package/source/test/sample.wav +0 -0
- package/source/test/sample.webp +0 -0
- package/source/test/util.ts +0 -45
- package/transpiled/Annotation.d.ts +0 -3
- package/transpiled/Annotation.js +0 -57
- package/transpiled/Annotation.js.map +0 -1
- package/transpiled/deployment.d.ts +0 -5
- package/transpiled/deployment.js +0 -68
- package/transpiled/deployment.js.map +0 -1
- package/transpiled/manifest.d.ts +0 -1
- package/transpiled/manifest.js +0 -9
- package/transpiled/manifest.js.map +0 -1
- package/transpiled/providers/Memory.d.ts +0 -15
- package/transpiled/providers/Memory.js +0 -72
- package/transpiled/providers/Memory.js.map +0 -1
- package/transpiled/schemas.d.ts +0 -9
- package/transpiled/schemas.js +0 -14
- package/transpiled/schemas.js.map +0 -1
- package/transpiled/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.json +0 -12
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { type Readable } from 'node:stream'
|
|
2
|
-
import { buffer } from 'node:stream/consumers'
|
|
3
|
-
import { readFile } from 'node:fs/promises'
|
|
4
|
-
import { createReadStream } from 'node:fs'
|
|
5
|
-
import path from 'node:path'
|
|
6
|
-
import { randomUUID } from 'node:crypto'
|
|
7
|
-
import { suites } from '../test/util'
|
|
8
|
-
import { providers } from './index'
|
|
9
|
-
import type { ProviderConstructor } from '../Provider'
|
|
10
|
-
|
|
11
|
-
describe.each(suites)('$provider', (suite) => {
|
|
12
|
-
const it = suite.run ? global.it : global.it.skip
|
|
13
|
-
const Provider: ProviderConstructor = providers[suite.provider]
|
|
14
|
-
const provider = new Provider(suite.options, suite.secrets)
|
|
15
|
-
|
|
16
|
-
let dir: string
|
|
17
|
-
|
|
18
|
-
beforeAll(async () => {
|
|
19
|
-
process.chdir(path.resolve(__dirname, '../test/'))
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
dir = '/' + randomUUID()
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should be', async () => {
|
|
27
|
-
expect(provider).toBeInstanceOf(Provider)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('should return null if file not found', async () => {
|
|
31
|
-
const result = await provider.get(randomUUID())
|
|
32
|
-
|
|
33
|
-
expect(result).toBeNull()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should create entry', async () => {
|
|
37
|
-
const stream = createReadStream('lenna.png')
|
|
38
|
-
|
|
39
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
40
|
-
|
|
41
|
-
const readable = await provider.get(dir + '/lenna.png') as Readable
|
|
42
|
-
const output = await buffer(readable)
|
|
43
|
-
const lenna = await readFile('lenna.png')
|
|
44
|
-
|
|
45
|
-
expect(output.compare(lenna)).toBe(0)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('should overwrite existing entry', async () => {
|
|
49
|
-
const stream0 = createReadStream('lenna.png')
|
|
50
|
-
const stream1 = createReadStream('albert.jpg')
|
|
51
|
-
|
|
52
|
-
await provider.put(dir, 'lenna.png', stream0)
|
|
53
|
-
await provider.put(dir, 'lenna.png', stream1)
|
|
54
|
-
|
|
55
|
-
const readable = await provider.get(dir + '/lenna.png') as Readable
|
|
56
|
-
const output = await buffer(readable)
|
|
57
|
-
const albert = await readFile('albert.jpg')
|
|
58
|
-
|
|
59
|
-
expect(output.compare(albert)).toBe(0)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('should get by path', async () => {
|
|
63
|
-
const stream = createReadStream('lenna.png')
|
|
64
|
-
|
|
65
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
66
|
-
|
|
67
|
-
const result = await provider.get('/bar/lenna.png')
|
|
68
|
-
|
|
69
|
-
expect(result).toBeNull()
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('should list files', async () => {
|
|
73
|
-
const stream = createReadStream('lenna.png')
|
|
74
|
-
|
|
75
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
76
|
-
|
|
77
|
-
const result = await provider.list(dir)
|
|
78
|
-
|
|
79
|
-
expect(result).toContain('lenna.png')
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
describe('danger', () => {
|
|
83
|
-
/*
|
|
84
|
-
|
|
85
|
-
WHEN MAKING CHANGES TO DELETION,
|
|
86
|
-
ALWAYS RUN TESTS IN STEP-BY-STEP DEBUGGING MODE
|
|
87
|
-
|
|
88
|
-
YOU MAY EVENTUALLY DELETE YOUR ENTIRE FILE SYSTEM
|
|
89
|
-
|
|
90
|
-
Sincerely yours, Murphy
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
it('should delete entry', async () => {
|
|
95
|
-
const stream = createReadStream('lenna.png')
|
|
96
|
-
|
|
97
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
98
|
-
await provider.delete(dir + '/lenna.png')
|
|
99
|
-
|
|
100
|
-
const result = await provider.get(dir + '/lenna.png')
|
|
101
|
-
|
|
102
|
-
expect(result).toBeNull()
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
it('should not throw if path does not exists', async () => {
|
|
106
|
-
await expect(provider.delete(dir + '/whatever')).resolves.not.toThrow()
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('should delete directory', async () => {
|
|
110
|
-
const stream = createReadStream('lenna.png')
|
|
111
|
-
|
|
112
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
113
|
-
await provider.delete(dir)
|
|
114
|
-
|
|
115
|
-
const result = await provider.get(dir + '/lenna.png')
|
|
116
|
-
|
|
117
|
-
expect(result).toBeNull()
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it('should move an entry', async () => {
|
|
121
|
-
const stream = createReadStream('lenna.png')
|
|
122
|
-
const dir2 = '/' + randomUUID()
|
|
123
|
-
|
|
124
|
-
await provider.put(dir, 'lenna.png', stream)
|
|
125
|
-
await provider.move(dir + '/lenna.png', dir2 + '/lenna2.png')
|
|
126
|
-
|
|
127
|
-
const result = await provider.get(dir2 + '/lenna2.png') as Readable
|
|
128
|
-
|
|
129
|
-
expect(result).not.toBeNull()
|
|
130
|
-
|
|
131
|
-
const nope = await provider.get(dir + '/lenna.png')
|
|
132
|
-
|
|
133
|
-
expect(nope).toBeNull()
|
|
134
|
-
})
|
|
135
|
-
})
|
|
136
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from './FileSystem'
|
|
2
|
-
import { S3 } from './S3'
|
|
3
|
-
import { Temporary } from './Temporary'
|
|
4
|
-
import { Test } from './Test'
|
|
5
|
-
import { InMemory } from './Memory'
|
|
6
|
-
import type { ProviderConstructor } from '../Provider'
|
|
7
|
-
|
|
8
|
-
export const providers = {
|
|
9
|
-
s3: S3,
|
|
10
|
-
fs: FileSystem,
|
|
11
|
-
tmp: Temporary,
|
|
12
|
-
mem: InMemory,
|
|
13
|
-
test: Test
|
|
14
|
-
} as const satisfies Record<string, ProviderConstructor>
|
|
15
|
-
|
|
16
|
-
export type { Declaration } from './Declaration'
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Developing a provider
|
|
2
|
-
|
|
3
|
-
1. Add an implementation of the [Provider](../Provider.ts) interface under this directory.
|
|
4
|
-
2. Add an entry to the provider map in [`index.ts`](./index.ts).
|
|
5
|
-
3. Add a suite to the `suites` object in [`util.ts`](../.test/util.ts).
|
|
6
|
-
4. Run `$ npm test` in the [`storages` directory](../..).
|
|
7
|
-
5. (optional) To test S3 provider, add `.env` file into [`.test'](../.test) folder.
|
|
8
|
-
6. (optional) To test S3 provider with localstack, run `docker compose up localstack` in [`root`](../../../../)
|
|
9
|
-
|
|
10
|
-
Provider's constructor must have the following signature:
|
|
11
|
-
`constructor(url: URL)`
|
|
12
|
-
|
|
13
|
-
## Secrets
|
|
14
|
-
|
|
15
|
-
Provider class may have static `SECRETS` property of type `string[]` that lists the names of the secrets that it
|
|
16
|
-
requires.
|
|
17
|
-
The secrets are passed to the constructor as the second argument.
|
|
18
|
-
|
|
19
|
-
`constructor(url: URL, secrets: Record<string, string>)`
|
|
20
|
-
|
|
21
|
-
See [`Test` provider](./Test.ts) for an example.
|
|
22
|
-
|
|
23
|
-
## Testing S3 provider
|
|
24
|
-
|
|
25
|
-
Copy [`.env.example`](../test/.env.example) to `.env`.
|
package/source/schemas.test.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as schemas from './schemas'
|
|
2
|
-
|
|
3
|
-
const ok = {
|
|
4
|
-
a: {
|
|
5
|
-
provider: 'tmp',
|
|
6
|
-
directory: 'ok'
|
|
7
|
-
},
|
|
8
|
-
b: {
|
|
9
|
-
provider: 'fs',
|
|
10
|
-
path: 'ok'
|
|
11
|
-
},
|
|
12
|
-
c: {
|
|
13
|
-
provider: 's3',
|
|
14
|
-
bucket: 'my-bucket'
|
|
15
|
-
},
|
|
16
|
-
d: {
|
|
17
|
-
provider: 'mem'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const oh = [
|
|
22
|
-
{
|
|
23
|
-
whatever: {
|
|
24
|
-
provider: 'non-existent'
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
whatever: {
|
|
29
|
-
provider: 'fs'
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
whatever: {
|
|
34
|
-
provider: 'tmp',
|
|
35
|
-
extra: true
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
whatever: {
|
|
40
|
-
|
|
41
|
-
provider: 's3'
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
whatever: {
|
|
46
|
-
provider: 'mem',
|
|
47
|
-
extra: true
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
it('should pass', () => {
|
|
53
|
-
expect(() => schemas.annotation.validate(ok)).not.toThrow()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it.each(oh)('should fail', (value) => {
|
|
57
|
-
expect(() => schemas.annotation.validate(value)).toThrow()
|
|
58
|
-
})
|
package/source/schemas.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path'
|
|
2
|
-
import { namespace } from '@toa.io/schemas'
|
|
3
|
-
import type { Declaration } from './providers'
|
|
4
|
-
import type { Schema } from '@toa.io/schemas'
|
|
5
|
-
import type { Annotation } from './Annotation'
|
|
6
|
-
|
|
7
|
-
const path = resolve(__dirname, '../schemas')
|
|
8
|
-
const ns = namespace(path)
|
|
9
|
-
|
|
10
|
-
export const annotation: Schema<Annotation> = ns.schema<Annotation>('annotation')
|
|
11
|
-
export const s3: Schema<Declaration> = ns.schema<Declaration>('s3')
|
|
12
|
-
export const fs: Schema<Declaration> = ns.schema<Declaration>('fs')
|
|
13
|
-
export const mem: Schema<Declaration> = ns.schema<Declaration>('mem')
|
|
14
|
-
export const tmp: Schema<Declaration> = ns.schema<Declaration>('tmp')
|
|
15
|
-
export const test: Schema<Declaration> = ns.schema<Declaration>('test')
|
package/source/test/.env.example
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
RUN_S3=1
|
package/source/test/albert.jpg
DELETED
|
Binary file
|
package/source/test/empty.txt
DELETED
|
File without changes
|
package/source/test/lenna.ascii
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
***************...............******.*********************************.***.*.....********************@@@@*....................**
|
|
2
|
-
***************..................**********************************.****.*.*......********************@@@@*................**.
|
|
3
|
-
***************..................**************************************.****.......********************@@@@*..........****..
|
|
4
|
-
***************.................*.***********.****.....*...*..****.**..............**********************@@@@.........**.
|
|
5
|
-
***************..................*.**..**.**.****.......*....********...............**********************@@@@*.....**.
|
|
6
|
-
***************......................***..*******..*...........*..**.*.***..........***********************@@@@*.....
|
|
7
|
-
***************.....................*****..***.******************....**.*...........************************@@@@*..
|
|
8
|
-
*****..********..........................***...*****************@@@*................*************************@@@@*
|
|
9
|
-
****...********........................*.......*.****************@@@@@*.............**************************@@.
|
|
10
|
-
***....********.......................*........*****************@@@@@**@@*..........*******..*****************. . *
|
|
11
|
-
**.....********.....................*...........*************@****@@@@@@@@@.........*******...*************** . .**
|
|
12
|
-
*......********...............................*.**************@@@@@@@@@@@@@@@.......*******. ..***********. ...****
|
|
13
|
-
.......********..............................***************@@@@@@@@@@@@@@@@@@@.....*******. ..*********. .******
|
|
14
|
-
.......********.................**..........*********..***@@@*@**@@@@@@@@@@@@@@@*...*******. .******* .*******
|
|
15
|
-
.......********.................@.........********...*****@***@@@@@@@@@@@@@@@@@@@*..*******.. .@@@@@@ .*********
|
|
16
|
-
.......********................@*........**..**...************@@@@**@@@@@@@@@@@@@@*.*******. @@*@@@@@@* .**********
|
|
17
|
-
.......********................@*...........***.****************@@*@@@@@@@**@@@@@@@@******..*@*@@@@@@@@@* ************
|
|
18
|
-
.......********...............***.............***********************@@@***@@@@@@@**@****@@**@@@@@@@@@@@. .*************
|
|
19
|
-
.......********...............@**...........****.*************************************@@@@@@@@@@@@@@@@@@ .**************
|
|
20
|
-
.......********...............@****.......****.***********************************@**@@@@@@@@@@@@@****@ .***************
|
|
21
|
-
.......********...............@*****....****.**********************************@**@@@@@@@@@@@@@@******* ..****************
|
|
22
|
-
.......********...............@@*****.****..***********...****.*************@**@@***@@@@@@@@@@@***..*@ .*****************
|
|
23
|
-
.......********...............@@@****.....***.***.*****.....***..... @**@@@@@@@@@@@@@@@@@*....*@* .******************
|
|
24
|
-
.......********...............@@@*.**...***..**.**..*.... .*... .. .**@**@*@****@@@@@@*.....**@* .*******************
|
|
25
|
-
.......********................@*****..**...*....*..... .. ... ***@*********@@@@* ..******** .********************
|
|
26
|
-
.......********.................@@**.**..*...*....... . . . .. *.*@@*************....*.***@. .*********************
|
|
27
|
-
.......********..................@@**...*..*.*...... ... ...*************@@@@@*....***. .**********************
|
|
28
|
-
.......********..................@@......**.. .. . *. *.****@********@@@@@@@*.. ..** .**********************
|
|
29
|
-
.......********............*.....*@.....*.. . . . .. *.***************@@@@@@@@*. .** . .***********************
|
|
30
|
-
.......********...................*..***. . . . ...****************@@@@@@@@@*.. .*. . .************************
|
|
31
|
-
.......********.................*..*.*.... . .. . .. *******@*..*********@@@@@@@@@* .*. . .*************************
|
|
32
|
-
........*******...............*** ...... .. . . .. ..*****@*.*****...*******@**..... ** ... .*************************
|
|
33
|
-
........********...........******.. ..... ... . ****@***. . .******@@*. .*. .**************************
|
|
34
|
-
........*******............****.. . . ..* . ****@@*.. ... @@....***@@.....*. ..*... ***************************
|
|
35
|
-
........********......* .***@ .... .....*. .***@*..***...*******.***@@*****. . ..*.. .***************************
|
|
36
|
-
...... .********.......**.... ..... ....... .**@@...******************@@*****... . *.. .***********************@@***
|
|
37
|
-
...... .********.....****.. ..... ...... ..*@@.....****************.*@@******.. . ** *********************@@@@**@@
|
|
38
|
-
..... .********............. .. . .*. ..*@@ ...********************@@*****.. ** .*****************.**@@@@@@@@@
|
|
39
|
-
..... .********..*.*.. ... ..*** . ...**.. .*@* ...****************..**@@*****.. .. **. *******************@@@@@@@@@@@
|
|
40
|
-
.... .********........ .... .*.. ..*... ..**. .....************..**.**@@*****. . .** .******************@@@@@@@@@@@@
|
|
41
|
-
..... .********.......... *. ..*. . ... **** .....************.*. ...******. ** ******************@@@@@@@@@@@@@
|
|
42
|
-
.......*********.....* .. . ....... .* . ..**.** ......*****************@@****. .. *...******************@@@@@@@@@@@@@
|
|
43
|
-
.......*********......... . ... **.. ..**..* . .....****************@*@@**** ... ...******************@@@@@@@@@@@@@@
|
|
44
|
-
. . ..*********..*... .... ..........@@*..* . . .....*******..*****..**.*.** ... . .*.****************.*@@@@@@@@@@@@@@
|
|
45
|
-
. ..*********........ .. *.... ..**@*.*. . ........******...****@@**** .. . .******************.*@@@@@@@@@@@@@@
|
|
46
|
-
..*********..*.. . . ...*....*.*.*** . ........*********...*.***. ..... ******************.*@@@@@@@@@@@@@@
|
|
47
|
-
...*********....... . *..*...*..*@ .......**************.. .. ..... *****************..@@@@@@@@@@@@@@@
|
|
48
|
-
...*********.... . . *. ....**.. . . . ....************. . ...... *****************.*@@@@@@@@@@@@@@*
|
|
49
|
-
...********.*.* . .. .*...*..****. .. . .......*.**********. . ........**...***********..*@@@@@@@@@*.
|
|
50
|
-
.. ...*******@.... . . ..*.**.....** .. . ......************@@@@*. .......****..............@@@@@@@@** ...
|
|
51
|
-
**.... .********.. .. .. .........*. ... . . .. .....*.************@@@@@@@. ......*********.........*@@@@@*. ......
|
|
52
|
-
.****. .*********. . . * .....**..*.. . . ... ....****************@@@@@@@.. .. *************...*.*@@@@@*. ........
|
|
53
|
-
.***. .*********. . . . .......*** *@ . . .... ..*******************@@@@@@@* ******************@@@@@*...........
|
|
54
|
-
**** ********.. . . .......**...* .. . ... ..********************@@@@@@@* *************..*@@@@@@@............
|
|
55
|
-
.*** ********* .. . . * .**..**. . .... ..********************@@@@@@@@. .************..*@@@@@@@*............
|
|
56
|
-
.***. .********. .. . .**. ...*.... ........*********************@@@@@@@@ .***********..*@@@@@@@*.............
|
|
57
|
-
.***. .*******. .. . . ......*.. . ..... ..**********************@@@@@@@@*.***************@@@@@*..............
|
|
58
|
-
***. .********. . .. ....* ........************************@@@@@@@@*.....************@@*...............
|
|
59
|
-
**** .*******.. . . . . ..* ... ...... .**************************@@@@@@@@...........*****@@@*..............
|
|
60
|
-
...****..*******.. . .*... ..... ..***************************@@@@@@@@........ *@**@@.. ............
|
|
61
|
-
...****..******... . .. . . .... ..... ....****************************@@@@@@@@...........*@@**. ............. .
|
|
62
|
-
...***..*******. . ... . . ... ......********************************@@@@@@*..........**.................. .
|
|
63
|
-
.*@**.******. . . .* .. .. .. ........**********************************@@@@@@@.........................*...
|
|
64
|
-
.@@@*.******. . . ...* .. . ... ...........**********************************@@@@@@*......*....*..........*... ..
|
package/source/test/lenna.png
DELETED
|
Binary file
|
package/source/test/sample.avi
DELETED
|
Binary file
|
package/source/test/sample.avif
DELETED
|
Binary file
|
package/source/test/sample.gif
DELETED
|
Binary file
|
package/source/test/sample.heic
DELETED
|
Binary file
|
package/source/test/sample.jpeg
DELETED
|
Binary file
|
package/source/test/sample.jxl
DELETED
|
Binary file
|
package/source/test/sample.svg
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg width="160" height="160" viewBox="0 0 160 160" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<rect width="160" height="160" rx="6" fill="white"/>
|
|
3
|
-
<path d="M83.8172 117.311H77.1506V75.6034C76.519 64.0461 71.2424 54.9753 62.4955 50.5487C55.8003 47.163 48.1655 47.3486 43.0436 51.0295C40.1688 53.0962 38.5807 55.5676 38.1898 58.5867C37.3617 64.9771 42.1922 72.4486 44.1231 74.7915L38.9812 79.0344C38.6222 78.5963 30.2131 68.2629 31.5783 57.7295C32.2107 52.8533 34.7593 48.7772 39.1526 45.6153C46.3817 40.42 56.4798 40.0343 65.5055 44.601C72.2494 48.0136 77.4112 53.7335 80.5225 60.9231C83.6337 53.7335 88.7954 48.0137 95.539 44.601C104.566 40.0343 114.664 40.42 121.892 45.6153C126.286 48.7772 128.834 52.8533 129.467 57.7295C130.832 68.2629 122.423 78.5963 122.064 79.0344L116.918 74.7963C116.988 74.7106 123.858 66.2201 122.853 58.5677C122.457 55.5582 120.87 53.0914 118.001 51.0295C112.879 47.3486 105.244 47.1582 98.5495 50.5487C89.5949 55.0803 84.2775 64.4793 83.8573 76.4304C83.8678 76.7653 83.8748 77.1016 83.8783 77.4392L83.8335 77.4396C83.8333 77.4617 83.833 77.4837 83.8328 77.5058L83.8172 77.5056V117.311Z" fill="#323232"/>
|
|
4
|
-
</svg>
|
package/source/test/sample.wav
DELETED
|
Binary file
|
package/source/test/sample.webp
DELETED
|
Binary file
|
package/source/test/util.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
|
-
import dotenv from 'dotenv'
|
|
3
|
-
import type { ProviderSecrets } from '../Provider'
|
|
4
|
-
import type { providers } from '../providers'
|
|
5
|
-
import type { FileSystemOptions } from '../providers/FileSystem'
|
|
6
|
-
import type { S3Options } from '../providers/S3'
|
|
7
|
-
import type { TemporaryOptions } from '../providers/Temporary'
|
|
8
|
-
|
|
9
|
-
dotenv.config({ path: join(__dirname, '.env') })
|
|
10
|
-
|
|
11
|
-
export const suites = [
|
|
12
|
-
{
|
|
13
|
-
run: true,
|
|
14
|
-
provider: 'tmp',
|
|
15
|
-
options: {
|
|
16
|
-
directory: 'toa-storages-temp'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
run: true,
|
|
21
|
-
provider: 'mem'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
run: process.env.RUN_S3 === '1',
|
|
25
|
-
provider: 's3',
|
|
26
|
-
options: {
|
|
27
|
-
endpoint: 'http://localhost:4566',
|
|
28
|
-
region: 'us-west-1',
|
|
29
|
-
bucket: 'test-bucket'
|
|
30
|
-
},
|
|
31
|
-
secrets: {
|
|
32
|
-
ACCESS_KEY_ID: 'developer',
|
|
33
|
-
SECRET_ACCESS_KEY: 'secret'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// add more providers here, use `run` as a condition to run the test
|
|
37
|
-
// e.g.: `run: process.env.ACCESS_KEY_ID !== undefined`
|
|
38
|
-
] satisfies Suite[]
|
|
39
|
-
|
|
40
|
-
interface Suite {
|
|
41
|
-
run: boolean
|
|
42
|
-
provider: keyof typeof providers
|
|
43
|
-
options?: FileSystemOptions | S3Options | TemporaryOptions
|
|
44
|
-
secrets?: ProviderSecrets
|
|
45
|
-
}
|
package/transpiled/Annotation.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.validateAnnotation = void 0;
|
|
30
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
31
|
-
const providers_1 = require("./providers");
|
|
32
|
-
const schemas = __importStar(require("./schemas"));
|
|
33
|
-
function validateAnnotation(annotation) {
|
|
34
|
-
try {
|
|
35
|
-
schemas.annotation.validate(annotation);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
explain(annotation);
|
|
39
|
-
// if all declarations are valid, re-throw the error
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.validateAnnotation = validateAnnotation;
|
|
44
|
-
/*
|
|
45
|
-
It is required because `oneOf` schema is used for the annotation validation.
|
|
46
|
-
*/
|
|
47
|
-
function explain(annotation) {
|
|
48
|
-
node_assert_1.default.ok(typeof annotation === 'object' && annotation !== null, 'TOA_STORAGES is not an object');
|
|
49
|
-
for (const declaration of Object.values(annotation)) {
|
|
50
|
-
node_assert_1.default.ok(typeof declaration === 'object' && declaration !== null &&
|
|
51
|
-
declaration.provider in providers_1.providers, `Unknown provider '${declaration.provider}'`);
|
|
52
|
-
node_assert_1.default.ok(declaration.provider in schemas, `No schema for provider '${declaration.provider}'`);
|
|
53
|
-
const schema = schemas[declaration.provider];
|
|
54
|
-
schema.validate(declaration, `Storage '${declaration.provider}' annotation`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=Annotation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Annotation.js","sourceRoot":"","sources":["../source/Annotation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,2CAAuC;AACvC,mDAAoC;AAMpC,SAAgB,kBAAkB,CAAE,UAAmB;IACrD,IAAI,CAAC;QACH,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,UAAU,CAAC,CAAA;QAEnB,oDAAoD;QACpD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AATD,gDASC;AAED;;GAEG;AACH,SAAS,OAAO,CAAE,UAAmB;IACnC,qBAAM,CAAC,EAAE,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAC7D,+BAA+B,CAAC,CAAA;IAElC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,qBAAM,CAAC,EAAE,CAAC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI;YAC/D,WAAW,CAAC,QAAQ,IAAI,qBAAS,EACjC,qBAAqB,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAA;QAE/C,qBAAM,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,IAAI,OAAO,EACvC,2BAA2B,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAA;QAErD,MAAM,MAAM,GAAwB,OAAO,CAAC,WAAW,CAAC,QAAkC,CAAC,CAAA;QAE3F,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,WAAW,CAAC,QAAQ,cAAc,CAAC,CAAA;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Dependency } from '@toa.io/operations';
|
|
2
|
-
import type { context } from '@toa.io/norm';
|
|
3
|
-
export declare const SERIALIZATION_PREFIX = "TOA_STORAGES";
|
|
4
|
-
export declare function deployment(instances: Instance[], annotation: unknown): Dependency;
|
|
5
|
-
export type Instance = context.Dependency<string[]>;
|
package/transpiled/deployment.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.deployment = exports.SERIALIZATION_PREFIX = void 0;
|
|
27
|
-
const assert = __importStar(require("node:assert"));
|
|
28
|
-
const generic_1 = require("@toa.io/generic");
|
|
29
|
-
const providers_1 = require("./providers");
|
|
30
|
-
const Annotation_1 = require("./Annotation");
|
|
31
|
-
exports.SERIALIZATION_PREFIX = 'TOA_STORAGES';
|
|
32
|
-
function deployment(instances, annotation) {
|
|
33
|
-
validate(instances, annotation);
|
|
34
|
-
const value = (0, generic_1.encode)(annotation);
|
|
35
|
-
const pointer = { name: exports.SERIALIZATION_PREFIX, value };
|
|
36
|
-
const secrets = getSecrets(annotation);
|
|
37
|
-
return {
|
|
38
|
-
variables: { global: [pointer, ...secrets] }
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
exports.deployment = deployment;
|
|
42
|
-
function validate(instances, annotation) {
|
|
43
|
-
(0, Annotation_1.validateAnnotation)(annotation);
|
|
44
|
-
for (const instance of instances)
|
|
45
|
-
contains(instance, annotation);
|
|
46
|
-
}
|
|
47
|
-
function contains(instance, annotation) {
|
|
48
|
-
for (const name of instance.manifest)
|
|
49
|
-
assert.ok(name in annotation, `Missing '${name}' storage annotation ` +
|
|
50
|
-
`declared in '${instance.component.locator.id}'`);
|
|
51
|
-
}
|
|
52
|
-
function getSecrets(annotation) {
|
|
53
|
-
const secrets = [];
|
|
54
|
-
for (const [name, declaration] of Object.entries(annotation)) {
|
|
55
|
-
const Provider = providers_1.providers[declaration.provider];
|
|
56
|
-
for (const secret of Provider.SECRETS)
|
|
57
|
-
secrets.push({
|
|
58
|
-
name: `${exports.SERIALIZATION_PREFIX}_${name}_${secret.name}`.toUpperCase(),
|
|
59
|
-
secret: {
|
|
60
|
-
name: `toa-storages-${name}`,
|
|
61
|
-
key: secret.name,
|
|
62
|
-
optional: secret.optional
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return secrets;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=deployment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,6CAAwC;AACxC,2CAAuC;AACvC,6CAAiD;AAKpC,QAAA,oBAAoB,GAAG,cAAc,CAAA;AAElD,SAAgB,UAAU,CAAE,SAAqB,EAAE,UAAmB;IACpE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAE/B,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAA;IAChC,MAAM,OAAO,GAAa,EAAE,IAAI,EAAE,4BAAoB,EAAE,KAAK,EAAE,CAAA;IAC/D,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IAEtC,OAAO;QACL,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,EAAE;KAC7C,CAAA;AACH,CAAC;AAVD,gCAUC;AAED,SAAS,QAAQ,CAAE,SAAqB,EAAE,UAAmB;IAC3D,IAAA,+BAAkB,EAAC,UAAU,CAAC,CAAA;IAE9B,KAAK,MAAM,QAAQ,IAAI,SAAS;QAC9B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AAClC,CAAC;AAED,SAAS,QAAQ,CAAE,QAAkB,EAAE,UAAsB;IAC3D,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,QAAQ;QAClC,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,UAAU,EAC1B,YAAY,IAAI,uBAAuB;YACvC,gBAAgB,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,SAAS,UAAU,CAAE,UAAsB;IACzC,MAAM,OAAO,GAAe,EAAE,CAAA;IAE9B,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,MAAM,QAAQ,GAAG,qBAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAEhD,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO;YACnC,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,GAAG,4BAAoB,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpE,MAAM,EAAE;oBACN,IAAI,EAAE,gBAAgB,IAAI,EAAE;oBAC5B,GAAG,EAAE,MAAM,CAAC,IAAI;oBAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B;aACF,CAAC,CAAA;IACN,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/transpiled/manifest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function manifest(manifest: string | string[] | null): string[];
|
package/transpiled/manifest.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.manifest = void 0;
|
|
4
|
-
const matchacho_1 = require("matchacho");
|
|
5
|
-
function manifest(manifest) {
|
|
6
|
-
return (0, matchacho_1.match)(manifest, String, (name) => [name], Array, manifest, null, []);
|
|
7
|
-
}
|
|
8
|
-
exports.manifest = manifest;
|
|
9
|
-
//# sourceMappingURL=manifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,SAAgB,QAAQ,CAAE,QAAkC;IAC1D,OAAO,IAAA,iBAAK,EAAC,QAAQ,EACnB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAChC,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,EAAE,CAAC,CAAA;AACb,CAAC;AALD,4BAKC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
import { Provider } from '../Provider';
|
|
4
|
-
/**
|
|
5
|
-
* In-memory provider
|
|
6
|
-
*/
|
|
7
|
-
export declare class InMemory extends Provider {
|
|
8
|
-
private readonly storage;
|
|
9
|
-
get(path: string): Promise<Readable | null>;
|
|
10
|
-
list(path: string): Promise<string[]>;
|
|
11
|
-
put(path: string, filename: string, stream: Readable): Promise<void>;
|
|
12
|
-
delete(path: string): Promise<void>;
|
|
13
|
-
move(from: string, to: string): Promise<void>;
|
|
14
|
-
moveDir(from: string, to: string): Promise<void>;
|
|
15
|
-
}
|