@auto-engineer/file-upload 1.147.0 → 1.149.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/file-upload@1.147.0 build /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
2
+ > @auto-engineer/file-upload@1.149.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/
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/file-upload@1.146.0 test /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
2
+ > @auto-engineer/file-upload@1.148.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
   Test Files  1 passed (1)
11
11
   Tests  10 passed (10)
12
-  Start at  19:11:22
13
-  Duration  2.37s (transform 451ms, setup 0ms, collect 464ms, tests 220ms, environment 0ms, prepare 516ms)
12
+  Start at  07:22:17
13
+  Duration  2.20s (transform 364ms, setup 0ms, collect 328ms, tests 271ms, environment 0ms, prepare 482ms)
14
14
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @auto-engineer/file-upload@1.146.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
2
+ > @auto-engineer/file-upload@1.148.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/file-upload
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @auto-engineer/file-upload
2
2
 
3
+ ## 1.149.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`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
8
+ - **server-generator-apollo-emmett**: context-aware nonCommandField instructions
9
+ - **server-generator-apollo-emmett**: add state context instruction
10
+ - **server-generator-apollo-emmett**: extract shared template helpers
11
+ - **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
12
+
13
+ ### Patch Changes
14
+
15
+ - [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
16
+
17
+ ## 1.148.0
18
+
19
+ ### Minor Changes
20
+
21
+ - [`d5ba3a0`](https://github.com/BeOnAuto/auto-engineer/commit/d5ba3a0e3fb0f6a9ad7a3a8b1815590ea77a5b42) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added state context instruction to generated decide handlers, preventing unnecessary narrowing when Given steps contain only state references
22
+
23
+ - [`e0cdc4e`](https://github.com/BeOnAuto/auto-engineer/commit/e0cdc4e3363ad84d4bc49996a600ac75c97ccc38) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added context-aware classification of non-command fields in generated decide.ts scaffolds, distinguishing between date-derived, state-derived, and not-yet-tested fields
24
+
25
+ - [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helpers into a dedicated module for cleaner code generation
26
+
27
+ - [`abb6540`](https://github.com/BeOnAuto/auto-engineer/commit/abb6540db7196ed7935c8a8610695828f9035fc3) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added status variant hints from Given state references to the state template, helping implementers create matching discriminated union variants
28
+
29
+ - [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helper functions into a dedicated module for better code reuse across generators
30
+ - Simplified template specs by removing inline duplicate definitions in favor of the shared helpers
31
+
32
+ ### Patch Changes
33
+
34
+ - [`88fb1da`](https://github.com/BeOnAuto/auto-engineer/commit/88fb1da2b222de04dd4959d87657395ee960a6ce) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: skip empty file plans in scaffold output
35
+ - **server-generator-apollo-emmett**: filter state refs from given() in decide.specs.ts.ejs
36
+ - **server-generator-apollo-emmett**: move CS Given states from events to states array
37
+ - **global**: version packages
38
+ - **server-generator-apollo-emmett**: mark G1+G2 ketchup plan complete
39
+
40
+ - [`4255f6d`](https://github.com/BeOnAuto/auto-engineer/commit/4255f6db0d128979e573244a615886482ce799b0) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Updated ketchup plan for state reference fix in decide template generator
41
+ - Marked generator bug fix milestones G1 and G2 as complete
42
+
43
+ - [`62f1ea3`](https://github.com/BeOnAuto/auto-engineer/commit/62f1ea3dd1b4275211574e3df9d9a6571ae9b27a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Fixed scaffold generation to correctly distinguish between event and state references in decision handlers
44
+ - Prevented contradictory instructions from appearing in generated code when Given clauses contain only state references
45
+
46
+ - [`ba4f5c9`](https://github.com/BeOnAuto/auto-engineer/commit/ba4f5c9749fb1c15d444e78ca9a2689817f039cb) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added implementation plan for decide.ts code generation fixes in the Apollo Emmett server generator
47
+
3
48
  ## 1.147.0
4
49
 
5
50
  ### 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
+ ```
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "version": "1.147.0",
16
+ "version": "1.149.0",
17
17
  "scripts": {
18
18
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
19
19
  "test": "vitest run --reporter=dot",