@auto-engineer/file-upload 1.148.0 → 1.150.0
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +33 -0
- package/README.md +141 -0
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/file-upload@1.
|
|
2
|
+
> @auto-engineer/file-upload@1.150.0 build /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
|
|
3
3
|
> tsc && tsx ../../scripts/fix-esm-imports.ts
|
|
4
4
|
|
|
5
5
|
Fixed ESM imports in dist/
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/file-upload@1.
|
|
2
|
+
> @auto-engineer/file-upload@1.149.0 test /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
|
|
3
3
|
> vitest run --reporter=dot
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m10 passed[39m[22m[90m (10)[39m
|
|
12
|
-
[2m Start at [22m
|
|
13
|
-
[2m Duration [22m 2.
|
|
12
|
+
[2m Start at [22m 12:20:27
|
|
13
|
+
[2m Duration [22m 2.06s[2m (transform 327ms, setup 0ms, collect 320ms, tests 320ms, environment 0ms, prepare 452ms)[22m
|
|
14
14
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @auto-engineer/file-upload
|
|
2
2
|
|
|
3
|
+
## 1.150.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a502d47`](https://github.com/BeOnAuto/auto-engineer/commit/a502d472df528a1c5d53905898220c2a3a49d8a5) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
8
|
+
|
|
9
|
+
- [`c96a70e`](https://github.com/BeOnAuto/auto-engineer/commit/c96a70e49f9f64213450d0b9840bc9a8b2b1d77d) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
10
|
+
|
|
11
|
+
- [`4343bca`](https://github.com/BeOnAuto/auto-engineer/commit/4343bcaa2576703ae578fd9b7f5ec5b9776702a9) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
12
|
+
|
|
13
|
+
- [`28ffce9`](https://github.com/BeOnAuto/auto-engineer/commit/28ffce9c8b95f0c3ca61728bd1f667fa9416d461) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
14
|
+
|
|
15
|
+
- [`3fd5dbf`](https://github.com/BeOnAuto/auto-engineer/commit/3fd5dbfbfb4f7a5fe71ae53105b31a1b0f30f911) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`41f3df3`](https://github.com/BeOnAuto/auto-engineer/commit/41f3df3025445ba92208c2b007b8e29a40489309) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **global**: version packages
|
|
20
|
+
- **global**: major refresh to all the docs
|
|
21
|
+
|
|
22
|
+
## 1.149.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
|
|
27
|
+
- **server-generator-apollo-emmett**: context-aware nonCommandField instructions
|
|
28
|
+
- **server-generator-apollo-emmett**: add state context instruction
|
|
29
|
+
- **server-generator-apollo-emmett**: extract shared template helpers
|
|
30
|
+
- **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
|
|
35
|
+
|
|
3
36
|
## 1.148.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @auto-engineer/file-upload
|
|
2
|
+
|
|
3
|
+
Upload file content to local disk, an HTTP endpoint, or cloud storage via a presigned-URL signer.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Without `@auto-engineer/file-upload`, you would have to implement three separate upload strategies (local filesystem, direct HTTP PUT, presigned-URL signing flow) and wire up the branching logic yourself every time a component needs to persist a file.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @auto-engineer/file-upload
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { uploadFile } from '@auto-engineer/file-upload';
|
|
23
|
+
|
|
24
|
+
// Write to local disk
|
|
25
|
+
await uploadFile('output/report.json', content, {
|
|
26
|
+
uploadUrl: 'file:///tmp/artifacts',
|
|
27
|
+
prefix: 'my-project',
|
|
28
|
+
writeFile: (path, data) => fs.promises.writeFile(path, data),
|
|
29
|
+
mkdir: (path) => fs.promises.mkdir(path, { recursive: true }),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Upload via direct HTTP PUT
|
|
33
|
+
await uploadFile('output/report.json', content, {
|
|
34
|
+
uploadUrl: 'https://storage.example.com/bucket',
|
|
35
|
+
prefix: 'my-project',
|
|
36
|
+
fetch,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Upload via presigned-URL signer
|
|
40
|
+
await uploadFile('output/report.json', content, {
|
|
41
|
+
signerUrl: 'https://signer.example.com/sign',
|
|
42
|
+
signerToken: 'my-token',
|
|
43
|
+
prefix: 'my-project',
|
|
44
|
+
fetch,
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## How-to Guides
|
|
51
|
+
|
|
52
|
+
### Write files to a local directory
|
|
53
|
+
|
|
54
|
+
Set `uploadUrl` to a `file://` URL. Provide `writeFile` and `mkdir` callbacks so the function can create directories and write bytes.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
await uploadFile('data.json', content, {
|
|
58
|
+
uploadUrl: 'file:///var/artifacts',
|
|
59
|
+
writeFile: (p, d) => fs.promises.writeFile(p, d),
|
|
60
|
+
mkdir: (p) => fs.promises.mkdir(p, { recursive: true }),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Upload directly to an HTTP endpoint
|
|
65
|
+
|
|
66
|
+
Set `uploadUrl` to an `http://` or `https://` URL. The file is PUT to `{uploadUrl}/{prefix}/{relativePath}`.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
await uploadFile('data.json', content, {
|
|
70
|
+
uploadUrl: 'https://storage.example.com/bucket',
|
|
71
|
+
prefix: 'proj-1',
|
|
72
|
+
fetch,
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Upload via a presigned-URL signer
|
|
77
|
+
|
|
78
|
+
Omit `uploadUrl` and set `signerUrl` and `signerToken`. The function POSTs `{ key }` to the signer, receives `{ url }` back, then PUTs the content to that presigned URL.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
await uploadFile('data.json', content, {
|
|
82
|
+
signerUrl: 'https://signer.example.com/sign',
|
|
83
|
+
signerToken: process.env.SIGNER_TOKEN,
|
|
84
|
+
fetch,
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Skip uploading entirely
|
|
89
|
+
|
|
90
|
+
If neither `uploadUrl` nor `signerUrl` is provided, `uploadFile` returns immediately with no side effects.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## API Reference
|
|
95
|
+
|
|
96
|
+
### `uploadFile(relativePath, content, deps)`
|
|
97
|
+
|
|
98
|
+
Uploads a file using the strategy determined by `deps`.
|
|
99
|
+
|
|
100
|
+
| Parameter | Type | Description |
|
|
101
|
+
| -------------- | ----------------------- | ------------------------------------ |
|
|
102
|
+
| `relativePath` | `string` | Destination path relative to prefix |
|
|
103
|
+
| `content` | `Uint8Array` | Raw file bytes |
|
|
104
|
+
| `deps` | `UploadDeps` | Configuration and injected functions |
|
|
105
|
+
|
|
106
|
+
Returns `Promise<void>`. Throws on non-OK HTTP responses.
|
|
107
|
+
|
|
108
|
+
### `UploadDeps`
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
interface UploadDeps {
|
|
112
|
+
uploadUrl?: string; // file:// for local, http(s):// for direct PUT
|
|
113
|
+
prefix?: string; // Optional path prefix prepended to the key
|
|
114
|
+
signerUrl?: string; // URL of the presigned-URL signer service
|
|
115
|
+
signerToken?: string; // Bearer token sent to the signer
|
|
116
|
+
fetch?: typeof globalThis.fetch;
|
|
117
|
+
writeFile?: (path: string, data: Uint8Array) => Promise<void>;
|
|
118
|
+
mkdir?: (path: string) => Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Strategy resolution order:**
|
|
123
|
+
|
|
124
|
+
1. `uploadUrl` starts with `file://` -- write to local filesystem using `writeFile` and `mkdir`
|
|
125
|
+
2. `uploadUrl` starts with `http` -- direct PUT to `{uploadUrl}/{key}`
|
|
126
|
+
3. `signerUrl` is set -- POST to signer, then PUT to the returned presigned URL
|
|
127
|
+
4. None of the above -- no-op
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Architecture
|
|
132
|
+
|
|
133
|
+
The package exports a single function with no external dependencies. All I/O is injected through the `UploadDeps` parameter (`fetch`, `writeFile`, `mkdir`), making the function fully testable without mocks at the module level.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
uploadFile(relativePath, content, deps)
|
|
137
|
+
├─ file:// mode → mkdir + writeFile to local path
|
|
138
|
+
├─ http PUT mode → PUT content to {uploadUrl}/{key}
|
|
139
|
+
├─ signer mode → POST to signerUrl → PUT to presigned URL
|
|
140
|
+
└─ no-op → return immediately
|
|
141
|
+
```
|