@c9up/archive 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -3
- package/dist/ArchiveProvider.d.ts +6 -1
- package/dist/ArchiveProvider.d.ts.map +1 -1
- package/dist/ArchiveProvider.js +73 -1
- package/dist/ArchiveProvider.js.map +1 -1
- package/dist/DriveManager.d.ts +10 -3
- package/dist/DriveManager.d.ts.map +1 -1
- package/dist/DriveManager.js +23 -6
- package/dist/DriveManager.js.map +1 -1
- package/dist/GcsDriver.d.ts +14 -9
- package/dist/GcsDriver.d.ts.map +1 -1
- package/dist/GcsDriver.js +202 -98
- package/dist/GcsDriver.js.map +1 -1
- package/dist/S3Driver.d.ts +11 -7
- package/dist/S3Driver.d.ts.map +1 -1
- package/dist/S3Driver.js +73 -110
- package/dist/S3Driver.js.map +1 -1
- package/dist/StaticMiddleware.d.ts +5 -1
- package/dist/StaticMiddleware.d.ts.map +1 -1
- package/dist/StaticMiddleware.js +114 -13
- package/dist/StaticMiddleware.js.map +1 -1
- package/dist/StorageManager.d.ts +28 -3
- package/dist/StorageManager.d.ts.map +1 -1
- package/dist/StorageManager.js +333 -132
- package/dist/StorageManager.js.map +1 -1
- package/dist/augmentations.d.ts +17 -0
- package/dist/augmentations.d.ts.map +1 -1
- package/dist/errno.d.ts +6 -0
- package/dist/errno.d.ts.map +1 -0
- package/dist/errno.js +11 -0
- package/dist/errno.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +34 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +88 -0
- package/dist/keys.js.map +1 -0
- package/dist/local-signature.d.ts +32 -0
- package/dist/local-signature.d.ts.map +1 -0
- package/dist/local-signature.js +58 -0
- package/dist/local-signature.js.map +1 -0
- package/dist/move-to-disk.d.ts +24 -0
- package/dist/move-to-disk.d.ts.map +1 -0
- package/dist/move-to-disk.js +167 -0
- package/dist/move-to-disk.js.map +1 -0
- package/dist/objects.d.ts.map +1 -1
- package/dist/objects.js +5 -2
- package/dist/objects.js.map +1 -1
- package/dist/provider-fetch.d.ts +36 -0
- package/dist/provider-fetch.d.ts.map +1 -0
- package/dist/provider-fetch.js +158 -0
- package/dist/provider-fetch.js.map +1 -0
- package/dist/services/main.d.ts +1 -1
- package/dist/services/main.d.ts.map +1 -1
- package/dist/services/main.js +14 -1
- package/dist/services/main.js.map +1 -1
- package/dist/signed-route.d.ts +18 -6
- package/dist/signed-route.d.ts.map +1 -1
- package/dist/signed-route.js +186 -31
- package/dist/signed-route.js.map +1 -1
- package/dist/streams.d.ts +36 -0
- package/dist/streams.d.ts.map +1 -0
- package/dist/streams.js +108 -0
- package/dist/streams.js.map +1 -0
- package/dist/testing/FakeStorage.d.ts.map +1 -1
- package/dist/testing/FakeStorage.js +2 -1
- package/dist/testing/FakeStorage.js.map +1 -1
- package/package.json +7 -3
- package/src/ArchiveProvider.ts +105 -4
- package/src/DriveManager.ts +32 -6
- package/src/GcsDriver.ts +256 -139
- package/src/S3Driver.ts +87 -130
- package/src/StaticMiddleware.ts +124 -13
- package/src/StorageManager.ts +398 -141
- package/src/augmentations.ts +24 -1
- package/src/errno.ts +10 -0
- package/src/index.ts +1 -0
- package/src/keys.ts +104 -0
- package/src/local-signature.ts +76 -0
- package/src/move-to-disk.ts +234 -0
- package/src/objects.ts +5 -2
- package/src/provider-fetch.ts +171 -0
- package/src/services/main.ts +15 -2
- package/src/signed-route.ts +216 -36
- package/src/streams.ts +118 -0
- package/src/testing/FakeStorage.ts +2 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @c9up/archive
|
|
2
2
|
|
|
3
|
-
> File storage abstraction for the Ream framework —
|
|
3
|
+
> File storage abstraction for the Ream framework — local, S3-compatible and GCS drivers, signed URLs, expiry.
|
|
4
4
|
|
|
5
|
-
Part of **[Ream](https://github.com/C9up/ream)** — a Rust-powered
|
|
5
|
+
Part of **[Ream](https://github.com/C9up/ream)** — a Rust-powered Node.js framework. Independent, publishable package.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -25,12 +25,105 @@ providers: [
|
|
|
25
25
|
]
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Visibility and signed URLs
|
|
29
|
+
|
|
30
|
+
Every stored object is `public` or `private`. Pass `visibility` when writing,
|
|
31
|
+
or change it afterwards:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
await disk.put('invoices/42.pdf', bytes, { visibility: 'private' })
|
|
35
|
+
await disk.setVisibility('avatars/1.png', 'public')
|
|
36
|
+
const visibility = await disk.getVisibility('invoices/42.pdf') // 'private'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
On the local disk a file with no visibility marker is `public`; a file made
|
|
40
|
+
private carries a marker beside it. On S3 the visibility is the object's ACL
|
|
41
|
+
(`public-read` or `private`), and an object whose ACL cannot be read counts as
|
|
42
|
+
private.
|
|
43
|
+
|
|
44
|
+
`url(path)` follows the visibility: a public file gets its plain URL, a
|
|
45
|
+
private one a signed URL. `getSignedUrl(path, { expiresIn })` signs
|
|
46
|
+
explicitly; `expiresIn` is a number of seconds or a duration string (`'30m'`,
|
|
47
|
+
`'7 days'`), 5 minutes by default, between 1 second and 7 days:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const link = await disk.getSignedUrl('invoices/42.pdf', { expiresIn: '30m' })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The local disk signs with its `signingSecret` (HMAC-SHA256). Without one,
|
|
54
|
+
`getSignedUrl` throws `E_ARCHIVE_SIGNING_DISABLED`; the other methods still
|
|
55
|
+
work.
|
|
56
|
+
|
|
57
|
+
## Serving the local disk
|
|
58
|
+
|
|
59
|
+
A local disk builds its URLs under its `routeBasePath`: `/storage` unless
|
|
60
|
+
`services.fs({ routeBasePath })` says otherwise. Nothing serves that path until
|
|
61
|
+
you mount the signed route from `@c9up/archive/signed-route`. It reads the
|
|
62
|
+
prefix from the driver, serves public files, refuses a private file unless the
|
|
63
|
+
URL carries a valid signature, and streams the file with an ETag, so a client
|
|
64
|
+
revalidating its copy gets a 304:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
// start/storage.ts
|
|
68
|
+
import { LocalDriver, StorageManager } from '@c9up/archive'
|
|
69
|
+
import { createSignedRouteHandler } from '@c9up/archive/signed-route'
|
|
70
|
+
import env from '#start/env'
|
|
71
|
+
|
|
72
|
+
export const driver = new LocalDriver('storage/uploads', {
|
|
73
|
+
signingSecret: env.get('APP_KEY'),
|
|
74
|
+
})
|
|
75
|
+
export const uploads = new StorageManager(driver)
|
|
76
|
+
export const serveUploads = createSignedRouteHandler({ storage: uploads, driver })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// start/kernel.ts
|
|
81
|
+
import { serveUploads } from '#start/storage'
|
|
82
|
+
|
|
83
|
+
server.use([serveUploads])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`createSignedRouteHandler` throws at construction when the driver has no
|
|
87
|
+
`signingSecret`, and throws `E_ARCHIVE_PREFIX_MISMATCH` when a `prefix` option
|
|
88
|
+
disagrees with the driver's `routeBasePath`: configure the path on the driver
|
|
89
|
+
and leave `prefix` out. A refused request gets a JSON body
|
|
90
|
+
`{ error: { code, message } }`:
|
|
91
|
+
|
|
92
|
+
| Status | Code | When |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| 403 | `E_ARCHIVE_INVALID_SIGNATURE` | The signature, its expiry or a signed header override is malformed or does not match |
|
|
95
|
+
| 403 | `E_ARCHIVE_EXPIRED_SIGNATURE` | The signature is valid but its `exp` has passed |
|
|
96
|
+
| 403 | `E_ARCHIVE_ACCESS_DENIED` | An unsigned request for a private file |
|
|
97
|
+
| 403 | `E_ARCHIVE_INVALID_KEY` | The path names no key the disk will address |
|
|
98
|
+
| 404 | `E_ARCHIVE_NOT_FOUND` | A valid signature for a file that is not stored |
|
|
99
|
+
|
|
100
|
+
An unsigned request for a name that is not stored falls through to the next
|
|
101
|
+
middleware.
|
|
102
|
+
|
|
103
|
+
## Static files
|
|
104
|
+
|
|
105
|
+
`StaticMiddleware` serves a directory of assets (`root`), under `prefix`
|
|
106
|
+
(default `/static`), with `max-age` set by `maxAge` (default 0: the browser
|
|
107
|
+
keeps the bytes and revalidates them through the ETag):
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { StaticMiddleware } from '@c9up/archive'
|
|
111
|
+
|
|
112
|
+
const assets = new StaticMiddleware({ root: 'public', prefix: '/assets' })
|
|
113
|
+
server.use([assets.handle.bind(assets)])
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Point it at public assets only, never at a local disk's directory. It has no
|
|
117
|
+
signature check: it refuses a file whose visibility marker says private and
|
|
118
|
+
never serves the markers themselves, but everything else under `root` is
|
|
119
|
+
served to anyone who asks. Private files are served through the signed route.
|
|
120
|
+
|
|
28
121
|
## Entry points
|
|
29
122
|
|
|
30
123
|
- `@c9up/archive` — main API
|
|
31
124
|
- `@c9up/archive/provider` — Ream IoC provider
|
|
32
125
|
- `@c9up/archive/services/main` — container service accessor
|
|
33
|
-
- `@c9up/archive/signed-route` —
|
|
126
|
+
- `@c9up/archive/signed-route` — the route that serves a local disk (see above)
|
|
34
127
|
- `@c9up/archive/testing` — test fakes & helpers
|
|
35
128
|
|
|
36
129
|
## License
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* `archive` config key.
|
|
6
6
|
*
|
|
7
7
|
* Duck-typed against `ArchiveAppContext` so archive does NOT import
|
|
8
|
-
* `@c9up/ream` — keeps the package publishable standalone.
|
|
8
|
+
* `@c9up/ream` statically — keeps the package publishable standalone. At
|
|
9
|
+
* boot it gives ream's uploads `moveToDisk(key, disk?, options?)` when ream
|
|
10
|
+
* is installed (see `move-to-disk.ts`).
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* // reamrc.ts
|
|
@@ -35,6 +37,8 @@ interface ArchiveConfigStore {
|
|
|
35
37
|
export interface ArchiveAppContext {
|
|
36
38
|
container: ArchiveContainer;
|
|
37
39
|
config: ArchiveConfigStore;
|
|
40
|
+
/** Set by inker's provider when the app renders views with it. */
|
|
41
|
+
usingInker?: boolean;
|
|
38
42
|
}
|
|
39
43
|
/**
|
|
40
44
|
* Legacy single-disk config shape (pre-parity). Still accepted: the
|
|
@@ -47,6 +51,7 @@ export interface ArchiveConfig {
|
|
|
47
51
|
local?: {
|
|
48
52
|
root: string;
|
|
49
53
|
signingSecret?: string | ReleasableSecret;
|
|
54
|
+
routeBasePath?: string;
|
|
50
55
|
};
|
|
51
56
|
s3?: S3Config;
|
|
52
57
|
gcs?: GcsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArchiveProvider.d.ts","sourceRoot":"","sources":["../src/ArchiveProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ArchiveProvider.d.ts","sourceRoot":"","sources":["../src/ArchiveProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,oBAAoB,CAAC;AAI5B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,eAAe,CAAC;AACxD,OAAO,EAEN,KAAK,gBAAgB,EAIrB,MAAM,qBAAqB,CAAC;AAQ7B,UAAU,gBAAgB;IACzB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjD;AACD,UAAU,kBAAkB;IAC3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7C;AACD,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC;IAC/B,KAAK,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;QAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd,GAAG,CAAC,EAAE,SAAS,CAAC;CAChB;AAOD,MAAM,CAAC,OAAO,OAAO,eAAe;;IAavB,SAAS,CAAC,GAAG,EAAE,iBAAiB;gBAAtB,GAAG,EAAE,iBAAiB;IAE5C,QAAQ,IAAI,IAAI;IA4CV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkGrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAS/B"}
|
package/dist/ArchiveProvider.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* `archive` config key.
|
|
6
6
|
*
|
|
7
7
|
* Duck-typed against `ArchiveAppContext` so archive does NOT import
|
|
8
|
-
* `@c9up/ream` — keeps the package publishable standalone.
|
|
8
|
+
* `@c9up/ream` statically — keeps the package publishable standalone. At
|
|
9
|
+
* boot it gives ream's uploads `moveToDisk(key, disk?, options?)` when ream
|
|
10
|
+
* is installed (see `move-to-disk.ts`).
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* // reamrc.ts
|
|
@@ -25,6 +27,7 @@ import "./augmentations.js";
|
|
|
25
27
|
import { DriveManager } from "./DriveManager.js";
|
|
26
28
|
import { ArchiveError } from "./errors.js";
|
|
27
29
|
import { GcsDriver } from "./GcsDriver.js";
|
|
30
|
+
import { extendMultipartFile } from "./move-to-disk.js";
|
|
28
31
|
import { S3Driver } from "./S3Driver.js";
|
|
29
32
|
import { LocalDriver, StorageManager, } from "./StorageManager.js";
|
|
30
33
|
import { clearStorage, getStorage, setStorage, setStorageResolver, } from "./services/main.js";
|
|
@@ -41,6 +44,8 @@ export default class ArchiveProvider {
|
|
|
41
44
|
* {@link register}, which always runs before {@link boot}.
|
|
42
45
|
*/
|
|
43
46
|
#storage;
|
|
47
|
+
/** The lazily-built disk manager behind it, likewise set by register(). */
|
|
48
|
+
#drive;
|
|
44
49
|
constructor(app) {
|
|
45
50
|
this.app = app;
|
|
46
51
|
}
|
|
@@ -67,6 +72,7 @@ export default class ArchiveProvider {
|
|
|
67
72
|
return manager;
|
|
68
73
|
};
|
|
69
74
|
this.#storage = storageManager;
|
|
75
|
+
this.#drive = driveManager;
|
|
70
76
|
this.app.container.singleton(DriveManager, () => driveManager());
|
|
71
77
|
// Backward-compatible bindings — the default disk is what apps
|
|
72
78
|
// previously resolved via `StorageManager` / the `storage` token.
|
|
@@ -91,6 +97,12 @@ export default class ArchiveProvider {
|
|
|
91
97
|
// The accessor reads the same cell the container's bindings read, so
|
|
92
98
|
// however storage is reached there is one manager behind it.
|
|
93
99
|
setStorageResolver(storage);
|
|
100
|
+
await this.#registerViewHelpers();
|
|
101
|
+
// Lazy like the helpers: the macro resolves the disk when an upload is
|
|
102
|
+
// moved, so an unconfigured app builds nothing here.
|
|
103
|
+
const drive = this.#drive;
|
|
104
|
+
if (drive !== undefined)
|
|
105
|
+
await extendMultipartFile(drive);
|
|
94
106
|
// No eager construction when archive is unconfigured: an app that
|
|
95
107
|
// registers this provider and never uses storage should not trigger
|
|
96
108
|
// LocalDriver's mkdir of './storage' at boot, which fails on a
|
|
@@ -109,6 +121,51 @@ export default class ArchiveProvider {
|
|
|
109
121
|
this.#owned = manager;
|
|
110
122
|
setStorage(manager);
|
|
111
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Publish `driveUrl` and `driveSignedUrl` to templates, as upstream's
|
|
126
|
+
* provider does for its view engine:
|
|
127
|
+
*
|
|
128
|
+
* {{ await driveUrl(user.avatar) }}
|
|
129
|
+
* {{ await driveSignedUrl(invoice.pdf, 'invoices', { expiresIn: '1h' }) }}
|
|
130
|
+
*
|
|
131
|
+
* Only when the app renders with inker (its provider sets `usingInker`),
|
|
132
|
+
* through inker's module singleton — the same way the i18n package
|
|
133
|
+
* publishes its globals, for the same reason: the engine's container
|
|
134
|
+
* binding is not resolvable during boot, while the singleton's `use()`
|
|
135
|
+
* queues the plugin until the first render. Nothing is built here: each
|
|
136
|
+
* helper resolves the disk when a template calls it.
|
|
137
|
+
*/
|
|
138
|
+
async #registerViewHelpers() {
|
|
139
|
+
const drive = this.#drive;
|
|
140
|
+
if (this.app.usingInker !== true || drive === undefined)
|
|
141
|
+
return;
|
|
142
|
+
// Computed: inker is an optional peer, so a bundler must not try to
|
|
143
|
+
// resolve it for an application that does not install it.
|
|
144
|
+
const specifier = "@c9up/inker";
|
|
145
|
+
const loaded = await import(/* @vite-ignore */ specifier);
|
|
146
|
+
const engine = typeof loaded === "object" && loaded !== null
|
|
147
|
+
? Reflect.get(loaded, "default")
|
|
148
|
+
: undefined;
|
|
149
|
+
const plugin = (target) => {
|
|
150
|
+
if (!publishesGlobals(target))
|
|
151
|
+
return;
|
|
152
|
+
target.global("driveUrl", (key, disk) => drive().use(disk).getUrl(key));
|
|
153
|
+
target.global("driveSignedUrl", (key, diskOrOptions, options) => typeof diskOrOptions === "string"
|
|
154
|
+
? drive().use(diskOrOptions).getSignedUrl(key, options)
|
|
155
|
+
: drive()
|
|
156
|
+
.use()
|
|
157
|
+
.getSignedUrl(key, diskOrOptions ?? options));
|
|
158
|
+
};
|
|
159
|
+
if (isPluggable(engine))
|
|
160
|
+
engine.use(plugin);
|
|
161
|
+
else if (publishesGlobals(engine))
|
|
162
|
+
plugin(engine);
|
|
163
|
+
else {
|
|
164
|
+
throw new ArchiveError("E_ARCHIVE_TEMPLATE_ENGINE", "The app renders with inker, but its module exposes neither use() nor global(): the drive template helpers cannot be published.", {
|
|
165
|
+
hint: "Install a @c9up/inker version whose default export has use(plugin) or global(name, value).",
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
112
169
|
async start() { }
|
|
113
170
|
async ready() { }
|
|
114
171
|
async shutdown() {
|
|
@@ -121,6 +178,20 @@ export default class ArchiveProvider {
|
|
|
121
178
|
this.#owned = undefined;
|
|
122
179
|
}
|
|
123
180
|
}
|
|
181
|
+
/** An engine that queues plugins until it renders: inker's module singleton. */
|
|
182
|
+
function isPluggable(value) {
|
|
183
|
+
return (typeof value === "object" &&
|
|
184
|
+
value !== null &&
|
|
185
|
+
"use" in value &&
|
|
186
|
+
typeof value.use === "function");
|
|
187
|
+
}
|
|
188
|
+
/** An engine that publishes template globals. */
|
|
189
|
+
function publishesGlobals(value) {
|
|
190
|
+
return (typeof value === "object" &&
|
|
191
|
+
value !== null &&
|
|
192
|
+
"global" in value &&
|
|
193
|
+
typeof value.global === "function");
|
|
194
|
+
}
|
|
124
195
|
/** Narrow an unknown config value to the multi-disk {@link DriveConfig} shape. */
|
|
125
196
|
function isDriveConfig(config) {
|
|
126
197
|
return (typeof config === "object" &&
|
|
@@ -165,6 +236,7 @@ function buildDriver(config) {
|
|
|
165
236
|
const root = config.local?.root ?? "./storage";
|
|
166
237
|
return new LocalDriver(root, {
|
|
167
238
|
signingSecret: config.local?.signingSecret,
|
|
239
|
+
routeBasePath: config.local?.routeBasePath,
|
|
168
240
|
});
|
|
169
241
|
}
|
|
170
242
|
// Reject unknown driver values explicitly so a typo like
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArchiveProvider.js","sourceRoot":"","sources":["../src/ArchiveProvider.ts"],"names":[],"mappings":"AAAA
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+FAA+F;aACrG,CACD,CAAC;QACH,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YACjB,MAAM,IAAI,YAAY,CACrB,0BAA0B,EAC1B,0DAA0D,EAC1D;gBACC,IAAI,EAAE,6FAA6F;aACnG,CACD,CAAC;QACH,CAAC;QACD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,IAAI,WAAW,CAAC;QAC/C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;YAC5B,aAAa,EAAE,MAAM,CAAC,KAAK,EAAE,aAAa;YAC1C,aAAa,EAAE,MAAM,CAAC,KAAK,EAAE,aAAa;SAC1C,CAAC,CAAC;IACJ,CAAC;IACD,yDAAyD;IACzD,8DAA8D;IAC9D,0DAA0D;IAC1D,MAAM,IAAI,YAAY,CACrB,0BAA0B,EAC1B,+DAA+D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EACvF,EAAE,IAAI,EAAE,uDAAuD,EAAE,CACjE,CAAC;AACH,CAAC"}
|
package/dist/DriveManager.d.ts
CHANGED
|
@@ -48,14 +48,21 @@ export interface FsServiceOptions {
|
|
|
48
48
|
* `Secret`, kept wrapped here and released by the driver.
|
|
49
49
|
*/
|
|
50
50
|
signingSecret?: string | ReleasableSecret;
|
|
51
|
+
/**
|
|
52
|
+
* URL path the disk's files are served under (default `/storage`): the
|
|
53
|
+
* driver's URLs and the signed route both derive from it.
|
|
54
|
+
*/
|
|
55
|
+
routeBasePath?: string;
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
53
58
|
* Config helpers mirroring AdonisJS Drive's `services.fs/s3/gcs`. Each
|
|
54
59
|
* returns a factory consumed by {@link DriveConfig.services}.
|
|
55
60
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
61
|
+
* NAMED DEVIATION: the ream `services.fs` builds URLs in-package via the
|
|
62
|
+
* LocalDriver + signed-route handler — it does NOT couple to the router,
|
|
63
|
+
* so there is no `serveFiles` that registers the route for you. Its
|
|
64
|
+
* `routeBasePath` plays the upstream role all the same: the driver's URLs
|
|
65
|
+
* and the signed route's prefix both derive from it.
|
|
59
66
|
*/
|
|
60
67
|
export declare const services: {
|
|
61
68
|
fs(options?: FsServiceOptions): DriveServiceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DriveManager.d.ts","sourceRoot":"","sources":["../src/DriveManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,cAAc,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAAG,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,yFAAyF;IACzF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC9C,qFAAqF;IACrF,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9B;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAChC,wEAAwE;IACxE,QAAQ,CAAC,EAA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E,QAAQ,GAAG,mBAAmB,CAAC;IAC1C,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAAC;CAgB5C,CAAC;AAkBF,qBAAa,YAAY;;gBAKZ,MAAM,EAAE,WAAW;IAa/B;;;;OAIG;IACH,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc;IAqBrC;;;;OAIG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,kBAAkB;IAQ1C,6EAA6E;IAC7E,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CAQ/B"}
|
package/dist/DriveManager.js
CHANGED
|
@@ -26,14 +26,19 @@ import { FakeStorageManager } from "./testing/FakeStorage.js";
|
|
|
26
26
|
* Config helpers mirroring AdonisJS Drive's `services.fs/s3/gcs`. Each
|
|
27
27
|
* returns a factory consumed by {@link DriveConfig.services}.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* NAMED DEVIATION: the ream `services.fs` builds URLs in-package via the
|
|
30
|
+
* LocalDriver + signed-route handler — it does NOT couple to the router,
|
|
31
|
+
* so there is no `serveFiles` that registers the route for you. Its
|
|
32
|
+
* `routeBasePath` plays the upstream role all the same: the driver's URLs
|
|
33
|
+
* and the signed route's prefix both derive from it.
|
|
32
34
|
*/
|
|
33
35
|
export const services = {
|
|
34
36
|
fs(options) {
|
|
35
37
|
const root = options?.location ?? options?.root ?? "./storage";
|
|
36
|
-
return () => new LocalDriver(root, {
|
|
38
|
+
return () => new LocalDriver(root, {
|
|
39
|
+
signingSecret: options?.signingSecret,
|
|
40
|
+
routeBasePath: options?.routeBasePath,
|
|
41
|
+
});
|
|
37
42
|
},
|
|
38
43
|
s3(config) {
|
|
39
44
|
return () => new S3Driver(config);
|
|
@@ -42,12 +47,24 @@ export const services = {
|
|
|
42
47
|
return () => new GcsDriver(config);
|
|
43
48
|
},
|
|
44
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* The factory configured for a disk, or `undefined` when there is none. Only
|
|
52
|
+
* OWN entries of `services` are disks: a plain lookup would answer
|
|
53
|
+
* `constructor`, `toString` or `hasOwnProperty` with the function inherited
|
|
54
|
+
* from `Object.prototype` and build a broken disk out of it.
|
|
55
|
+
*
|
|
56
|
+
* NAMED DEVIATION (stricter than flydrive's `DriveManager.use`, which reads
|
|
57
|
+
* `services[name]` directly): an inherited name is an unknown disk.
|
|
58
|
+
*/
|
|
59
|
+
function serviceFactory(services, name) {
|
|
60
|
+
return Object.hasOwn(services, name) ? services[name] : undefined;
|
|
61
|
+
}
|
|
45
62
|
export class DriveManager {
|
|
46
63
|
#config;
|
|
47
64
|
#cache = new Map();
|
|
48
65
|
#fakes = new Map();
|
|
49
66
|
constructor(config) {
|
|
50
|
-
if (config.services
|
|
67
|
+
if (serviceFactory(config.services, config.default) === undefined) {
|
|
51
68
|
throw new ArchiveError("E_ARCHIVE_UNKNOWN_DISK", `Archive default disk '${config.default}' is not present in config.services`, {
|
|
52
69
|
hint: `Add a '${config.default}' entry to config.services, or point config.default at an existing disk.`,
|
|
53
70
|
});
|
|
@@ -67,7 +84,7 @@ export class DriveManager {
|
|
|
67
84
|
const cached = this.#cache.get(name);
|
|
68
85
|
if (cached)
|
|
69
86
|
return cached;
|
|
70
|
-
const factory = this.#config.services
|
|
87
|
+
const factory = serviceFactory(this.#config.services, name);
|
|
71
88
|
if (factory === undefined) {
|
|
72
89
|
throw new ArchiveError("E_ARCHIVE_UNKNOWN_DISK", `Archive disk '${name}' is not configured`, {
|
|
73
90
|
hint: `Known disks: ${Object.keys(this.#config.services).join(", ") || "(none)"}.`,
|
package/dist/DriveManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DriveManager.js","sourceRoot":"","sources":["../src/DriveManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;A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AAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG;aAClF,CACD,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,OAAgB;QACpB,MAAM,IAAI,GAAG,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,IAAI,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6EAA6E;IAC7E,OAAO,CAAC,OAAgB;QACvB,MAAM,IAAI,GAAG,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;CACD"}
|
package/dist/GcsDriver.d.ts
CHANGED
|
@@ -18,13 +18,18 @@ export interface GcsConfig {
|
|
|
18
18
|
bucket: string;
|
|
19
19
|
serviceAccount: GcsServiceAccount;
|
|
20
20
|
/** Optional CDN prefix for public URLs (e.g. `https://cdn.example.com`). */
|
|
21
|
-
publicUrl?: string
|
|
22
|
-
|
|
21
|
+
publicUrl?: string;
|
|
22
|
+
/**
|
|
23
|
+
* How long the provider may stay silent during one request, in ms.
|
|
24
|
+
* Default 30 000.
|
|
23
25
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
26
|
+
* An idle bound, not a deadline: it runs while the provider is awaited
|
|
27
|
+
* (taking the request body, sending headers, sending the next chunk), so a
|
|
28
|
+
* long transfer that keeps moving is never cut. Without a bound a hung
|
|
29
|
+
* connection never settles: the handler awaiting it waits forever, and
|
|
30
|
+
* enough of them stop the server from serving. Set 0 to disable, which
|
|
31
|
+
* only makes sense behind an outer timeout.
|
|
32
|
+
*/
|
|
28
33
|
requestTimeoutMs?: number;
|
|
29
34
|
}
|
|
30
35
|
export declare class GcsDriver implements StorageDriver {
|
|
@@ -44,9 +49,9 @@ export declare class GcsDriver implements StorageDriver {
|
|
|
44
49
|
setVisibility(filePath: string, visibility: Visibility): Promise<void>;
|
|
45
50
|
copy(from: string, to: string, options?: WriteOptions): Promise<void>;
|
|
46
51
|
move(from: string, to: string, options?: WriteOptions): Promise<void>;
|
|
47
|
-
deleteAll(
|
|
48
|
-
listAll(
|
|
49
|
-
list(
|
|
52
|
+
deleteAll(given: string): Promise<void>;
|
|
53
|
+
listAll(given: string, options?: ListAllOptions): Promise<ListAllResult>;
|
|
54
|
+
list(given: string): AsyncIterable<StorageEntry>;
|
|
50
55
|
getSignedUrl(filePath: string, options?: SignedUrlOptions): string;
|
|
51
56
|
/**
|
|
52
57
|
* Presigned PUT URL for direct-to-GCS uploads. AdonisJS Drive parity.
|
package/dist/GcsDriver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GcsDriver.d.ts","sourceRoot":"","sources":["../src/GcsDriver.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"GcsDriver.d.ts","sourceRoot":"","sources":["../src/GcsDriver.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAcH,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,aA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