@voltro/serverless 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `@voltro/*` packages are recorded here. The format
4
+ follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## Stability contract — read this before you pin a version
7
+
8
+ Voltro is **`0.x` — pre-1.0, and deliberately so.** Under SemVer, `0.y.z` means
9
+ "anything MAY change." We hold to exactly that, stated out loud:
10
+
11
+ - **Pin exact versions.** Depend on `@voltro/runtime@0.4.2`, never `^0.4.2` or
12
+ `~0.4.2`. There is no compatible-range promise below 1.0.
13
+ - **Every MINOR may break.** Breaking changes land on a minor bump (`0.4.x →
14
+ 0.5.0`); patches (`0.4.1 → 0.4.2`) are additive or fixes only. This is the
15
+ standard `0.x` reading of SemVer — the minor slot carries breaking under `0.x`.
16
+ - **Read this changelog before upgrading.** The `⚠ BREAKING` section of each
17
+ release lists every incompatible change with its migration. It is the only
18
+ migration path we provide — there is no deprecation cycle, no compat shim.
19
+ - **All packages release together (lockstep).** One coordinated version across
20
+ the whole framework; the git tag is the source of truth.
21
+
22
+ This is not a placeholder disclaimer — it is the contract. The framework is
23
+ refactored aggressively while it has no external stability obligations, and that
24
+ velocity is the point. A stable-core tier and per-package `1.0` graduation are
25
+ planned, but not yet; until then, treat the whole surface as movable and pin
26
+ exact.
27
+
28
+ The **public API** of each package is its `publishConfig.exports` entry points,
29
+ minus anything marked `@internal` (those are cross-package internals and are
30
+ stripped from the published `.d.ts`). Importing a deep path that isn't an
31
+ exported entry point is unsupported.
32
+
33
+ ---
34
+
35
+ ## [Unreleased]
36
+
37
+ _Changes staged for the next release accumulate here (rolled up from
38
+ `.changes/*.md` at tag time — see `.changes/README.md`)._
39
+
40
+ ---
41
+
42
+ ## [0.1.0]
43
+
44
+ Initial pre-release baseline. This is the starting point the changelog tracks
45
+ from; it is not an exhaustive history of prior development. The framework ships
46
+ as `@voltro/*` packages spanning the runtime, database/query layer, web client
47
+ and router, durable workflows, the CLI, and the plugin ecosystem
48
+ (auth, storage, mail, billing, observability, and more). Not published to a
49
+ public registry yet.
50
+
51
+ Subsequent releases record their deltas from here under dated headings, with
52
+ `⚠ BREAKING` first.
package/LICENSE ADDED
@@ -0,0 +1,57 @@
1
+ Voltro — Proprietary Software License
2
+
3
+ Copyright (c) 2026 Voltro UG. All rights reserved.
4
+
5
+ This software and all associated source code, documentation, and other
6
+ materials (the "Software") are the proprietary property of Voltro UG
7
+ ("Voltro"). This is NOT open-source software.
8
+
9
+ Your access to and use of the Software is governed exclusively by the Voltro
10
+ Terms of Service at:
11
+
12
+ https://voltro.cloud/legal/terms
13
+
14
+ By downloading, installing, or using the Software you agree to those Terms.
15
+ Subject to and conditioned on your continued compliance with them, Voltro
16
+ grants you a limited, non-exclusive, non-transferable, non-sublicensable,
17
+ revocable license to use the Software. All rights not expressly granted in the
18
+ Terms are reserved by Voltro. If you do not agree to the Terms, you have no
19
+ license and may not use the Software.
20
+
21
+ The Terms of Service — including the scope of permitted use, plan
22
+ entitlements, fees, and pricing — may change from time to time. The version in
23
+ force is the one published at the URL above. Commercial terms and pricing are
24
+ NOT part of this notice and are not fixed by, or granted in perpetuity by, the
25
+ version of the Software in which this file appears.
26
+
27
+ Permitted use — your own software. Voltro is a development framework. You may
28
+ use the Software to build, run, and commercially distribute your own
29
+ applications and services, and to charge your own customers for them, without
30
+ owing Voltro any share of that revenue or any further permission beyond the
31
+ Terms. Applications you build with the Software are yours.
32
+
33
+ Prohibited use — reselling Voltro. You may NOT redistribute, resell,
34
+ sublicense, publish, or otherwise provide the Software itself — in whole or in
35
+ part, in source or compiled form — to third parties as a library, framework,
36
+ SDK, template, starter, or development tool for them to build upon, whether
37
+ standalone or repackaged. Shipping the Software as a non-separable, bundled
38
+ dependency inside an application you deliver (for example, compiled into your
39
+ deployed app) is permitted; extracting or re-exposing it as a reusable
40
+ component for others is not.
41
+
42
+ Except as expressly permitted above or by the Terms, you may not copy, modify,
43
+ merge, publish, sublicense, sell, distribute, or create derivative works of the
44
+ Software, in whole or in part.
45
+
46
+ Third-party open-source components distributed alongside the Software are the
47
+ property of their respective owners and are licensed under their own terms; see
48
+ THIRD-PARTY-NOTICES.md where provided. Nothing in this notice limits your
49
+ rights, or extends Voltro's, in those components.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
54
+ VOLTRO BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM,
55
+ OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR ITS USE.
56
+
57
+ For licensing inquiries, contact Voltro UG.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ <div align="center">
2
+
3
+ # @voltro/serverless
4
+
5
+ **Effect-typed standalone serverless functions (*.serverless.ts) + a deploy abstraction (Cloudflare Workers / Scaleway) and a static-site multi-host deploy abstraction.**
6
+
7
+ [📖 Documentation](https://docs.voltro.dev/docs/deployment/serverless-functions) · [Changelog](./CHANGELOG.md) · [voltro.dev](https://voltro.dev) · [Voltro Cloud](https://voltro.cloud)
8
+
9
+ </div>
10
+
11
+ ---
12
+
13
+ ```sh
14
+ npm install @voltro/serverless
15
+ ```
16
+
17
+ > ### [→ Read the documentation for @voltro/serverless](https://docs.voltro.dev/docs/deployment/serverless-functions)
18
+
19
+ Installation, guides, the full API reference, and examples all live in the
20
+ **[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
21
+ deliberately short so there is nothing here to drift out of date.
22
+
23
+ ## License
24
+
25
+ Proprietary. © 2026 Voltro UG. Your use is governed by the
26
+ [Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
package/SECURITY.md ADDED
@@ -0,0 +1,56 @@
1
+ # Security Policy
2
+
3
+ We take the security of Voltro and the applications built on it seriously. This
4
+ document explains how to report a vulnerability and what to expect in return.
5
+
6
+ ## Reporting a vulnerability
7
+
8
+ **Please do not open public issues or discuss suspected vulnerabilities in
9
+ public channels.** Report them privately by email:
10
+
11
+ **security contact: [support@voltro.dev](mailto:support@voltro.dev)**
12
+ (subject line: `SECURITY`).
13
+
14
+ Include, where you can:
15
+
16
+ - the affected package(s) and version(s) (e.g. `@voltro/runtime@x.y.z`);
17
+ - a description of the issue and its impact;
18
+ - a minimal reproduction or proof of concept;
19
+ - any suggested remediation.
20
+
21
+ If you'd like to encrypt your report, ask in a first plain email and we'll
22
+ arrange a key.
23
+
24
+ ## What to expect
25
+
26
+ - **Acknowledgement** of your report within **3 business days**.
27
+ - An initial assessment (severity, affected surface) and a remediation plan as
28
+ soon as we've reproduced the issue.
29
+ - **Coordinated disclosure:** we'll agree a disclosure timeline with you and
30
+ credit you in the release notes if you wish. Please give us reasonable time to
31
+ ship a fix before any public disclosure.
32
+
33
+ We do not currently run a paid bug-bounty program, but we genuinely appreciate
34
+ responsible disclosure and will credit reporters.
35
+
36
+ ## Software Bill of Materials (SBOM)
37
+
38
+ A CycloneDX SBOM of the third-party runtime dependency graph is generated for the
39
+ published packages (`pnpm gen:sbom` → `sbom.cdx.json`). If your procurement or
40
+ security team needs it, request it at
41
+ [support@voltro.dev](mailto:support@voltro.dev).
42
+
43
+ ## Supported versions
44
+
45
+ Voltro is pre-1.0 and ships in lockstep: **only the latest published minor of
46
+ each `@voltro/*` package receives security fixes.** Please upgrade to the latest
47
+ release before reporting, and pin exact versions in production.
48
+
49
+ ## Scope
50
+
51
+ In scope: the published `@voltro/*` packages and the framework's own code.
52
+
53
+ Out of scope: vulnerabilities in third-party dependencies that are already
54
+ tracked upstream (we monitor these via a production-dependency audit gate in
55
+ CI), and issues that require a non-default, explicitly-unsafe configuration. If
56
+ you're unsure, report it anyway — we'd rather hear about it.
@@ -0,0 +1,393 @@
1
+ # Third-Party Notices — @voltro/serverless
2
+
3
+ This package depends on the open-source software listed below. Each is the
4
+ property of its respective copyright holders and is used under the terms of
5
+ its license. This file is provided for attribution; it grants no rights in
6
+ @voltro/serverless itself, which is proprietary (see LICENSE).
7
+
8
+ Generated from the resolved runtime dependency closure (8 packages).
9
+
10
+ ---
11
+
12
+ ## @effect/platform@0.96.2
13
+
14
+ License: MIT
15
+
16
+ ```
17
+ MIT License
18
+
19
+ Copyright (c) 2023 Effectful Technologies Inc
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ of this software and associated documentation files (the "Software"), to deal
23
+ in the Software without restriction, including without limitation the rights
24
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all
29
+ copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
38
+ ```
39
+
40
+ ## @msgpackr-extract/msgpackr-extract-linux-x64@3.0.3
41
+
42
+ License: MIT
43
+
44
+ _(no bundled license text found in the package; see its npm page.)_
45
+
46
+ ## detect-libc@2.1.2
47
+
48
+ License: Apache-2.0
49
+
50
+ ```
51
+ Apache License
52
+ Version 2.0, January 2004
53
+ http://www.apache.org/licenses/
54
+
55
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
56
+
57
+ 1. Definitions.
58
+
59
+ "License" shall mean the terms and conditions for use, reproduction,
60
+ and distribution as defined by Sections 1 through 9 of this document.
61
+
62
+ "Licensor" shall mean the copyright owner or entity authorized by
63
+ the copyright owner that is granting the License.
64
+
65
+ "Legal Entity" shall mean the union of the acting entity and all
66
+ other entities that control, are controlled by, or are under common
67
+ control with that entity. For the purposes of this definition,
68
+ "control" means (i) the power, direct or indirect, to cause the
69
+ direction or management of such entity, whether by contract or
70
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
71
+ outstanding shares, or (iii) beneficial ownership of such entity.
72
+
73
+ "You" (or "Your") shall mean an individual or Legal Entity
74
+ exercising permissions granted by this License.
75
+
76
+ "Source" form shall mean the preferred form for making modifications,
77
+ including but not limited to software source code, documentation
78
+ source, and configuration files.
79
+
80
+ "Object" form shall mean any form resulting from mechanical
81
+ transformation or translation of a Source form, including but
82
+ not limited to compiled object code, generated documentation,
83
+ and conversions to other media types.
84
+
85
+ "Work" shall mean the work of authorship, whether in Source or
86
+ Object form, made available under the License, as indicated by a
87
+ copyright notice that is included in or attached to the work
88
+ (an example is provided in the Appendix below).
89
+
90
+ "Derivative Works" shall mean any work, whether in Source or Object
91
+ form, that is based on (or derived from) the Work and for which the
92
+ editorial revisions, annotations, elaborations, or other modifications
93
+ represent, as a whole, an original work of authorship. For the purposes
94
+ of this License, Derivative Works shall not include works that remain
95
+ separable from, or merely link (or bind by name) to the interfaces of,
96
+ the Work and Derivative Works thereof.
97
+
98
+ "Contribution" shall mean any work of authorship, including
99
+ the original version of the Work and any modifications or additions
100
+ to that Work or Derivative Works thereof, that is intentionally
101
+ submitted to Licensor for inclusion in the Work by the copyright owner
102
+ or by an individual or Legal Entity authorized to submit on behalf of
103
+ the copyright owner. For the purposes of this definition, "submitted"
104
+ means any form of electronic, verbal, or written communication sent
105
+ to the Licensor or its representatives, including but not limited to
106
+ communication on electronic mailing lists, source code control systems,
107
+ and issue tracking systems that are managed by, or on behalf of, the
108
+ Licensor for the purpose of discussing and improving the Work, but
109
+ excluding communication that is conspicuously marked or otherwise
110
+ designated in writing by the copyright owner as "Not a Contribution."
111
+
112
+ "Contributor" shall mean Licensor and any individual or Legal Entity
113
+ on behalf of whom a Contribution has been received by Licensor and
114
+ subsequently incorporated within the Work.
115
+
116
+ 2. Grant of Copyright License. Subject to the terms and conditions of
117
+ this License, each Contributor hereby grants to You a perpetual,
118
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
119
+ copyright license to reproduce, prepare Derivative Works of,
120
+ publicly display, publicly perform, sublicense, and distribute the
121
+ Work and such Derivative Works in Source or Object form.
122
+
123
+ 3. Grant of Patent License. Subject to the terms and conditions of
124
+ this License, each Contributor hereby grants to You a perpetual,
125
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
126
+ (except as stated in this section) patent license to make, have made,
127
+ use, offer to sell, sell, import, and otherwise transfer the Work,
128
+ where such license applies only to those patent claims licensable
129
+ by such Contributor that are necessarily infringed by their
130
+ Contribution(s) alone or by combination of their Contribution(s)
131
+ with the Work to which such Contribution(s) was submitted. If You
132
+ institute patent litigation against any entity (including a
133
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
134
+ or a Contribution incorporated within the Work constitutes direct
135
+ or contributory patent infringement, then any patent licenses
136
+ granted to You under this License for that Work shall terminate
137
+ as of the date such litigation is filed.
138
+
139
+ 4. Redistribution. You may reproduce and distribute copies of the
140
+ Work or Derivative Works thereof in any medium, with or without
141
+ modifications, and in Source or Object form, provided that You
142
+ meet the following conditions:
143
+
144
+ (a) You must give any other recipients of the Work or
145
+ Derivative Works a copy of this License; and
146
+
147
+ (b) You must cause any modified files to carry prominent notices
148
+ stating that You changed the files; and
149
+
150
+ (c) You must retain, in the Source form of any Derivative Works
151
+ that You distribute, all copyright, patent, trademark, and
152
+ attribution notices from the Source form of the Work,
153
+ excluding those notices that do not pertain to any part of
154
+ the Derivative Works; and
155
+
156
+ (d) If the Work includes a "NOTICE" text file as part of its
157
+ distribution, then any Derivative Works that You distribute must
158
+ include a readable copy of the attribution notices contained
159
+ within such NOTICE file, excluding those notices that do not
160
+ pertain to any part of the Derivative Works, in at least one
161
+ of the following places: within a NOTICE text file distributed
162
+ as part of the Derivative Works; within the Source form or
163
+ documentation, if provided along with the Derivative Works; or,
164
+ within a display generated by the Derivative Works, if and
165
+ wherever such third-party notices normally appear. The contents
166
+ of the NOTICE file are for informational purposes only and
167
+ do not modify the License. You may add Your own attribution
168
+ notices within Derivative Works that You distribute, alongside
169
+ or as an addendum to the NOTICE text from the Work, provided
170
+ that such additional attribution notices cannot be construed
171
+ as modifying the License.
172
+
173
+ You may add Your own copyright statement to Your modifications and
174
+ may provide additional or different license terms and conditions
175
+ for use, reproduction, or distribution of Your modifications, or
176
+ for any such Derivative Works as a whole, provided Your use,
177
+ reproduction, and distribution of the Work otherwise complies with
178
+ the conditions stated in this License.
179
+
180
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
181
+ any Contribution intentionally submitted for inclusion in the Work
182
+ by You to the Licensor shall be under the terms and conditions of
183
+ this License, without any additional terms or conditions.
184
+ Notwithstanding the above, nothing herein shall supersede or modify
185
+ the terms of any separate license agreement you may have executed
186
+ with Licensor regarding such Contributions.
187
+
188
+ 6. Trademarks. This License does not grant permission to use the trade
189
+ names, trademarks, service marks, or product names of the Licensor,
190
+ except as required for reasonable and customary use in describing the
191
+ origin of the Work and reproducing the content of the NOTICE file.
192
+
193
+ 7. Disclaimer of Warranty. Unless required by applicable law or
194
+ agreed to in writing, Licensor provides the Work (and each
195
+ Contributor provides its Contributions) on an "AS IS" BASIS,
196
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
197
+ implied, including, without limitation, any warranties or conditions
198
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
199
+ PARTICULAR PURPOSE. You are solely responsible for determining the
200
+ appropriateness of using or redistributing the Work and assume any
201
+ risks associated with Your exercise of permissions under this License.
202
+
203
+ 8. Limitation of Liability. In no event and under no legal theory,
204
+ whether in tort (including negligence), contract, or otherwise,
205
+ unless required by applicable law (such as deliberate and grossly
206
+ negligent acts) or agreed to in writing, shall any Contributor be
207
+ liable to You for damages, including any direct, indirect, special,
208
+ incidental, or consequential damages of any character arising as a
209
+ result of this License or out of the use or inability to use the
210
+ Work (including but not limited to damages for loss of goodwill,
211
+ work stoppage, computer failure or malfunction, or any and all
212
+ other commercial damages or losses), even if such Contributor
213
+ has been advised of the possibility of such damages.
214
+
215
+ 9. Accepting Warranty or Additional Liability. While redistributing
216
+ the Work or Derivative Works thereof, You may choose to offer,
217
+ and charge a fee for, acceptance of support, warranty, indemnity,
218
+ or other liability obligations and/or rights consistent with this
219
+ License. However, in accepting such obligations, You may act only
220
+ on Your own behalf and on Your sole responsibility, not on behalf
221
+ of any other Contributor, and only if You agree to indemnify,
222
+ defend, and hold each Contributor harmless for any liability
223
+ incurred by, or claims asserted against, such Contributor by reason
224
+ of your accepting any such warranty or additional liability.
225
+
226
+ END OF TERMS AND CONDITIONS
227
+
228
+ APPENDIX: How to apply the Apache License to your work.
229
+
230
+ To apply the Apache License to your work, attach the following
231
+ boilerplate notice, with the fields enclosed by brackets "{}"
232
+ replaced with your own identifying information. (Don't include
233
+ the brackets!) The text should be enclosed in the appropriate
234
+ comment syntax for the file format. We also recommend that a
235
+ file or class name and description of purpose be included on the
236
+ same "printed page" as the copyright notice for easier
237
+ identification within third-party archives.
238
+
239
+ Copyright {yyyy} {name of copyright owner}
240
+
241
+ Licensed under the Apache License, Version 2.0 (the "License");
242
+ you may not use this file except in compliance with the License.
243
+ You may obtain a copy of the License at
244
+
245
+ http://www.apache.org/licenses/LICENSE-2.0
246
+
247
+ Unless required by applicable law or agreed to in writing, software
248
+ distributed under the License is distributed on an "AS IS" BASIS,
249
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
250
+ See the License for the specific language governing permissions and
251
+ limitations under the License.
252
+ ```
253
+
254
+ ## find-my-way-ts@0.1.6
255
+
256
+ License: MIT
257
+
258
+ ```
259
+ MIT License
260
+
261
+ Copyright (c) 2017-2019 Tomas Della Vedova
262
+
263
+ Permission is hereby granted, free of charge, to any person obtaining a copy
264
+ of this software and associated documentation files (the "Software"), to deal
265
+ in the Software without restriction, including without limitation the rights
266
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
267
+ copies of the Software, and to permit persons to whom the Software is
268
+ furnished to do so, subject to the following conditions:
269
+
270
+ The above copyright notice and this permission notice shall be included in all
271
+ copies or substantial portions of the Software.
272
+
273
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
274
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
275
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
276
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
277
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
278
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
279
+ SOFTWARE.
280
+ ```
281
+
282
+ ## msgpackr@1.11.12
283
+
284
+ License: MIT
285
+
286
+ ```
287
+ MIT License
288
+
289
+ Copyright (c) 2020 Kris Zyp
290
+
291
+ Permission is hereby granted, free of charge, to any person obtaining a copy
292
+ of this software and associated documentation files (the "Software"), to deal
293
+ in the Software without restriction, including without limitation the rights
294
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
295
+ copies of the Software, and to permit persons to whom the Software is
296
+ furnished to do so, subject to the following conditions:
297
+
298
+ The above copyright notice and this permission notice shall be included in all
299
+ copies or substantial portions of the Software.
300
+
301
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
302
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
303
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
304
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
305
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
306
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
307
+ SOFTWARE.
308
+ ```
309
+
310
+ ## msgpackr-extract@3.0.3
311
+
312
+ License: MIT
313
+
314
+ ```
315
+ MIT License
316
+
317
+ Copyright (c) 2020 Kris Zyp
318
+
319
+ Permission is hereby granted, free of charge, to any person obtaining a copy
320
+ of this software and associated documentation files (the "Software"), to deal
321
+ in the Software without restriction, including without limitation the rights
322
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
323
+ copies of the Software, and to permit persons to whom the Software is
324
+ furnished to do so, subject to the following conditions:
325
+
326
+ The above copyright notice and this permission notice shall be included in all
327
+ copies or substantial portions of the Software.
328
+
329
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
330
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
331
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
332
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
333
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
334
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
335
+ SOFTWARE.
336
+ ```
337
+
338
+ ## multipasta@0.2.7
339
+
340
+ License: MIT
341
+
342
+ ```
343
+ MIT License
344
+
345
+ Copyright (c) 2023-present The Contributors
346
+
347
+ Permission is hereby granted, free of charge, to any person obtaining a copy
348
+ of this software and associated documentation files (the "Software"), to deal
349
+ in the Software without restriction, including without limitation the rights
350
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
351
+ copies of the Software, and to permit persons to whom the Software is
352
+ furnished to do so, subject to the following conditions:
353
+
354
+ The above copyright notice and this permission notice shall be included in all
355
+ copies or substantial portions of the Software.
356
+
357
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
358
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
359
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
360
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
361
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
362
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
363
+ SOFTWARE.
364
+ ```
365
+
366
+ ## node-gyp-build-optional-packages@5.2.2
367
+
368
+ License: MIT
369
+
370
+ ```
371
+ The MIT License (MIT)
372
+
373
+ Copyright (c) 2017 Mathias Buus
374
+
375
+ Permission is hereby granted, free of charge, to any person obtaining a copy
376
+ of this software and associated documentation files (the "Software"), to deal
377
+ in the Software without restriction, including without limitation the rights
378
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
379
+ copies of the Software, and to permit persons to whom the Software is
380
+ furnished to do so, subject to the following conditions:
381
+
382
+ The above copyright notice and this permission notice shall be included in
383
+ all copies or substantial portions of the Software.
384
+
385
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
386
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
387
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
388
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
389
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
390
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
391
+ THE SOFTWARE.
392
+ ```
393
+
@@ -0,0 +1,264 @@
1
+ import { Effect } from 'effect';
2
+ import { HttpClient } from '@effect/platform';
3
+ import { Schema } from 'effect';
4
+ import { Scope } from 'effect';
5
+
6
+ /** A bundled, ready-to-ship function. */
7
+ export declare interface BuiltFunction {
8
+ readonly name: string;
9
+ /** Absolute path to the bundled entry file. */
10
+ readonly file: string;
11
+ /** Absolute path to the output dir (entry + any sidecar files). */
12
+ readonly dir: string;
13
+ readonly runtime?: ServerlessRuntimeHints;
14
+ }
15
+
16
+ /**
17
+ * Cache policy for a deployed file, keyed off its path RELATIVE to the dist
18
+ * root (POSIX separators). Hashed assets → 1-year immutable; HTML → no-store
19
+ * revalidate; everything else → a short shared TTL.
20
+ */
21
+ export declare const cachePolicyFor: (relPath: string) => FileCachePolicy;
22
+
23
+ /** Cloudflare Workers platform shape (entry + esbuild recipe). */
24
+ export declare const cloudflarePlatform: ServerlessPlatform;
25
+
26
+ /** IANA content-type for a filename (defaults to octet-stream). */
27
+ export declare const contentTypeFor: (path: string) => string;
28
+
29
+ /**
30
+ * Declare a serverless function. Validates the name (kebab-case, DNS-safe — it
31
+ * becomes the deployed function id) and fills defaults (`method: 'POST'`,
32
+ * `path: '/'`). The CLI's discovery picks up the DEFAULT export of a
33
+ * `*.serverless.ts` file.
34
+ */
35
+ export declare const defineServerless: <I, O>(def: ServerlessDefinition<I, O>) => ServerlessDefinition<I, O>;
36
+
37
+ /** esbuild knobs a target needs to bundle the entry for its runtime. */
38
+ export declare interface EsbuildHints {
39
+ /** V8-isolate hosts (Cloudflare) → `browser`; Node hosts (Scaleway) → `node`. */
40
+ readonly platform: 'browser' | 'node' | 'neutral';
41
+ readonly format: 'esm' | 'cjs';
42
+ /** Export conditions (e.g. `['worker', 'browser']` for Workers). */
43
+ readonly conditions?: ReadonlyArray<string>;
44
+ /** Specifiers to keep external (not bundled) — usually empty (bundle all). */
45
+ readonly external?: ReadonlyArray<string>;
46
+ /** Prepended to the bundle (e.g. a Node shim). */
47
+ readonly banner?: string;
48
+ /** Target ES level. */
49
+ readonly targetEs?: string;
50
+ /** Output entry filename. Defaults to `index.mjs` (esm) / `index.js` (cjs).
51
+ * Scaleway overrides it to `handler.js`: its runtime imports the handler by
52
+ * appending `.js` to the handler-string's module part AND ships a
53
+ * `package.json` with `"type":"module"`, so the bundle must be ESM-syntax
54
+ * under a `.js` name — and `handler.js` matches Scaleway's DEFAULT handler
55
+ * `handler.handle`, so a bare `scw function deploy` resolves it with no
56
+ * explicit handler wiring. */
57
+ readonly entryFile?: string;
58
+ }
59
+
60
+ /**
61
+ * Cache policy for a deployed file. The framework derives it once (hashed asset
62
+ * vs HTML) and hands it to every provider, so cache behaviour is identical no
63
+ * matter where you ship.
64
+ */
65
+ export declare interface FileCachePolicy {
66
+ readonly contentType: string;
67
+ readonly cacheControl: string;
68
+ /** True for content-hashed assets (immutable, long TTL). */
69
+ readonly immutable: boolean;
70
+ }
71
+
72
+ /** Self-hosted Node platform shape (entry + esbuild recipe). */
73
+ export declare const nodePlatform: ServerlessPlatform;
74
+
75
+ /** Scaleway Serverless Functions platform shape (entry + esbuild recipe). */
76
+ export declare const scalewayPlatform: ServerlessPlatform;
77
+
78
+ /**
79
+ * Platform-agnostic per-invocation context handed to a handler. The framework
80
+ * fills it from whatever the host passes — Cloudflare's `env` bindings +
81
+ * `ExecutionContext`, Scaleway's `process.env`, etc. — so handler code never
82
+ * branches on the platform.
83
+ */
84
+ export declare interface ServerlessContext {
85
+ /** Env vars / secrets injected by the platform. Cloudflare → the worker `env`
86
+ * bindings; Scaleway / Node → `process.env`. */
87
+ readonly env: Record<string, string | undefined>;
88
+ /** The raw incoming Web `Request` (method, url, headers) for advanced use. */
89
+ readonly request: Request;
90
+ /** Schedule work that outlives the response — Cloudflare
91
+ * `ExecutionContext.waitUntil`; a best-effort fire-and-forget elsewhere. */
92
+ readonly waitUntil: (promise: Promise<unknown>) => void;
93
+ }
94
+
95
+ /**
96
+ * A serverless function definition. The handler is Effect-first and may require
97
+ * `HttpClient` (provided by the framework's base layer); decode/encode of the
98
+ * JSON wire body is driven by the `input`/`output` schemas.
99
+ */
100
+ export declare interface ServerlessDefinition<I = unknown, O = unknown> {
101
+ /** Deployment identifier — kebab-case, DNS-safe (it names the deployed
102
+ * function/worker). */
103
+ readonly name: string;
104
+ /** HTTP method the function answers on (default `POST`). A `GET` reads its
105
+ * input from the query string; everything else from the JSON body. */
106
+ readonly method?: ServerlessMethod;
107
+ /** Path the function answers on within its host (default `/`). */
108
+ readonly path?: string;
109
+ /** Decodes the request body/query into the handler's typed input. */
110
+ readonly input: Schema.Schema<I, any>;
111
+ /** Encodes the handler's result into the JSON response body. */
112
+ readonly output: Schema.Schema<O, any>;
113
+ /** The work. Effect-first; may `yield* HttpClient.HttpClient` and use scoped
114
+ * effects (e.g. `http.get(url)` + reading the body) directly — the framework
115
+ * runs the handler inside a `Scope`, so you never write `Effect.scoped`. */
116
+ readonly handler: (input: I, ctx: ServerlessContext) => Effect.Effect<O, unknown, HttpClient.HttpClient | Scope.Scope>;
117
+ /** Deploy hints (memory / timeout / region / scale). */
118
+ readonly runtime?: ServerlessRuntimeHints;
119
+ }
120
+
121
+ /** Resolved deploy config — env-sourced credentials + per-target options. The
122
+ * CLI assembles it from flags + env; each provider reads the keys it needs. */
123
+ export declare interface ServerlessDeployConfig {
124
+ readonly env: Record<string, string | undefined>;
125
+ /** Free-form per-target options (account id, region, project id, …). */
126
+ readonly options?: Record<string, unknown>;
127
+ /** When true, do everything EXCEPT the final upload (print the plan). */
128
+ readonly dryRun?: boolean;
129
+ }
130
+
131
+ /** Thrown by a target's `deploy` when shipping fails (missing creds, API
132
+ * error, bundle too large, …). */
133
+ export declare class ServerlessDeployError extends ServerlessDeployError_base {
134
+ }
135
+
136
+ declare const ServerlessDeployError_base: Schema.TaggedErrorClass<ServerlessDeployError, "ServerlessDeployError", {
137
+ readonly _tag: Schema.tag<"ServerlessDeployError">;
138
+ } & {
139
+ target: typeof Schema.String;
140
+ message: typeof Schema.String;
141
+ detail: Schema.optional<typeof Schema.Unknown>;
142
+ }>;
143
+
144
+ export declare interface ServerlessDeployResult {
145
+ readonly target: string;
146
+ readonly name: string;
147
+ /** The deployed function's public URL, when the provider returns one. */
148
+ readonly url?: string;
149
+ /** Provider-side id of the function/worker. */
150
+ readonly id?: string;
151
+ }
152
+
153
+ /** Fail a handler with this to control the HTTP status (otherwise → 500). */
154
+ export declare class ServerlessHttpError extends ServerlessHttpError_base {
155
+ }
156
+
157
+ declare const ServerlessHttpError_base: Schema.TaggedErrorClass<ServerlessHttpError, "ServerlessHttpError", {
158
+ readonly _tag: Schema.tag<"ServerlessHttpError">;
159
+ } & {
160
+ status: typeof Schema.Number;
161
+ message: typeof Schema.String;
162
+ detail: Schema.optional<typeof Schema.Unknown>;
163
+ }>;
164
+
165
+ /** HTTP method a function answers on. */
166
+ export declare type ServerlessMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
167
+
168
+ /**
169
+ * The PLATFORM SHAPE of a serverless target — the half that is pure + runtime-
170
+ * agnostic, so it lives in `@voltro/serverless` and is unit-testable without any
171
+ * node/CLI machinery. `entryModule` produces the platform's entrypoint SOURCE:
172
+ * it imports the user's `defineServerless` default export from `defImport` and
173
+ * wraps it with the framework's `serverlessWebHandler` into whatever the host
174
+ * expects (a Workers `export default { fetch }`, a Scaleway `handle(event)`).
175
+ * `esbuild` is the recipe to bundle that entry for the host's runtime.
176
+ */
177
+ export declare interface ServerlessPlatform {
178
+ /** `'cloudflare'` | `'scaleway'` | … */
179
+ readonly id: string;
180
+ /** Human label for logs. */
181
+ readonly label: string;
182
+ /** The platform entrypoint source. `defImport` is the import specifier the
183
+ * generated entry uses to load the user's function (an absolute path). */
184
+ readonly entryModule: (defImport: string) => string;
185
+ readonly esbuild: EsbuildHints;
186
+ }
187
+
188
+ /** Platform deploy hints — best-effort; a host ignores what it can't honour. */
189
+ export declare interface ServerlessRuntimeHints {
190
+ readonly memoryMb?: number;
191
+ readonly timeoutSeconds?: number;
192
+ /** Provider region (e.g. `fr-par` for Scaleway). Cloudflare is global. */
193
+ readonly region?: string;
194
+ /** Warm/cap instance counts (provider best-effort). */
195
+ readonly minScale?: number;
196
+ readonly maxScale?: number;
197
+ }
198
+
199
+ /**
200
+ * A full deploy target = the platform shape PLUS a `deploy` that ships a bundled
201
+ * function. `deploy` lives CLI-side (it shells out to the host's official tool —
202
+ * `wrangler` / `scw` — behind a mockable runner) and is composed onto a
203
+ * `ServerlessPlatform` there; the framework never reimplements a host's upload
204
+ * wire protocol.
205
+ */
206
+ export declare interface ServerlessTarget extends ServerlessPlatform {
207
+ /** Ship the bundle. `config` is the resolved per-target deploy config
208
+ * (tokens, account ids, region) — providers validate what they need. */
209
+ readonly deploy: (fn: BuiltFunction, config: ServerlessDeployConfig) => Effect.Effect<ServerlessDeployResult, ServerlessDeployError>;
210
+ }
211
+
212
+ /**
213
+ * Build the Web handler for a single serverless definition. The returned
214
+ * function is a standard `(Request) => Promise<Response>` runnable on any
215
+ * fetch-based runtime; the platform adapters wrap it.
216
+ */
217
+ export declare const serverlessWebHandler: <I, O>(def: ServerlessDefinition<I, O>, options?: WebHandlerOptions) => ((request: Request) => Promise<Response>);
218
+
219
+ export declare interface StaticDeployConfig {
220
+ readonly env: Record<string, string | undefined>;
221
+ /** Per-host options (bucket, account id, project name, region, …). */
222
+ readonly options?: Record<string, unknown>;
223
+ /** SPA fallback: serve `index.html` for unknown routes (off for pure SSG with
224
+ * per-route `dist/<route>/index.html`, on for a single-page app). */
225
+ readonly spaFallback?: boolean;
226
+ readonly dryRun?: boolean;
227
+ }
228
+
229
+ export declare class StaticDeployError extends StaticDeployError_base {
230
+ }
231
+
232
+ declare const StaticDeployError_base: Schema.TaggedErrorClass<StaticDeployError, "StaticDeployError", {
233
+ readonly _tag: Schema.tag<"StaticDeployError">;
234
+ } & {
235
+ host: typeof Schema.String;
236
+ message: typeof Schema.String;
237
+ detail: Schema.optional<typeof Schema.Unknown>;
238
+ }>;
239
+
240
+ export declare interface StaticDeployResult {
241
+ readonly host: string;
242
+ /** Public URL of the deployment, when the provider returns one. */
243
+ readonly url?: string;
244
+ readonly filesUploaded: number;
245
+ /** Files skipped because the host already had identical bytes (diff upload). */
246
+ readonly filesSkipped: number;
247
+ }
248
+
249
+ /** A static-hosting provider — ships a built `dist/` directory. */
250
+ export declare interface StaticHost {
251
+ /** `'cloudflare-pages'` | `'scaleway-object-storage'` | `'s3'` | `'netlify'` */
252
+ readonly id: string;
253
+ readonly label: string;
254
+ readonly deploy: (distDir: string, config: StaticDeployConfig) => Effect.Effect<StaticDeployResult, StaticDeployError>;
255
+ }
256
+
257
+ export declare interface WebHandlerOptions {
258
+ /** Env / secrets exposed to the handler via `ctx.env`. */
259
+ readonly env?: Record<string, string | undefined>;
260
+ /** Background-work scheduler (Cloudflare `ctx.waitUntil`); default no-op. */
261
+ readonly waitUntil?: (promise: Promise<unknown>) => void;
262
+ }
263
+
264
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,152 @@
1
+ import { n as e, t } from "./webHandler-ss_jy07c.js";
2
+ import { Schema as n } from "effect";
3
+ //#region src/define.ts
4
+ var r = /^[a-z][a-z0-9-]*$/, i = (e) => {
5
+ if (typeof e.name != "string" || !r.test(e.name)) throw Error(`defineServerless: \`name\` must be kebab-case + DNS-safe (^[a-z][a-z0-9-]*$), got ${JSON.stringify(e.name)} — it becomes the deployed function/worker id.`);
6
+ return {
7
+ method: "POST",
8
+ path: "/",
9
+ ...e
10
+ };
11
+ }, a = class extends n.TaggedError()("ServerlessDeployError", {
12
+ target: n.String,
13
+ message: n.String,
14
+ detail: n.optional(n.Unknown)
15
+ }) {}, o = {
16
+ id: "cloudflare",
17
+ label: "Cloudflare Workers",
18
+ entryModule: (e) => `// AUTO-GENERATED by @voltro/serverless — Cloudflare Workers entry. Do not edit.
19
+ import def from ${JSON.stringify(e)}
20
+ import { serverlessWebHandler } from '@voltro/serverless'
21
+
22
+ export default {
23
+ fetch(request, env, ctx) {
24
+ const handler = serverlessWebHandler(def, {
25
+ env,
26
+ waitUntil: (p) => ctx.waitUntil(p),
27
+ })
28
+ return handler(request)
29
+ },
30
+ }
31
+ `,
32
+ esbuild: {
33
+ platform: "browser",
34
+ format: "esm",
35
+ conditions: ["worker", "browser"],
36
+ external: [],
37
+ targetEs: "es2022"
38
+ }
39
+ }, s = {
40
+ id: "scaleway",
41
+ label: "Scaleway Serverless Functions",
42
+ entryModule: (e) => `// AUTO-GENERATED by @voltro/serverless — Scaleway Functions entry. Do not edit.
43
+ import def from ${JSON.stringify(e)}
44
+ import { serverlessWebHandler } from '@voltro/serverless'
45
+
46
+ const handler = serverlessWebHandler(def, {
47
+ env: process.env,
48
+ waitUntil: (p) => { Promise.resolve(p).catch(() => {}) },
49
+ })
50
+
51
+ export async function handle(event, context) {
52
+ const method = String(event.httpMethod || event.method || 'GET').toUpperCase()
53
+ const query = event.queryStringParameters || {}
54
+ const qs = new URLSearchParams(query).toString()
55
+ const path = event.path || '/'
56
+ const url = 'https://serverless.local' + path + (qs ? '?' + qs : '')
57
+ const headers = event.headers || {}
58
+ const hasBody = method !== 'GET' && method !== 'HEAD' && event.body != null
59
+ const body = hasBody
60
+ ? (event.isBase64Encoded ? Buffer.from(event.body, 'base64') : event.body)
61
+ : undefined
62
+ const res = await handler(new Request(url, { method, headers, body }))
63
+ const outHeaders = {}
64
+ res.headers.forEach((v, k) => { outHeaders[k] = v })
65
+ return { statusCode: res.status, headers: outHeaders, body: await res.text() }
66
+ }
67
+ `,
68
+ esbuild: {
69
+ platform: "node",
70
+ format: "esm",
71
+ entryFile: "handler.js",
72
+ external: [],
73
+ targetEs: "node20"
74
+ }
75
+ }, c = {
76
+ id: "node",
77
+ label: "Self-hosted Node server",
78
+ entryModule: (e) => `// AUTO-GENERATED by @voltro/serverless — self-hosted Node server entry. Do not edit.
79
+ import def from ${JSON.stringify(e)}
80
+ import { serveServerless } from '@voltro/serverless/node'
81
+
82
+ serveServerless([def])
83
+ .then((s) => {
84
+ console.log(\`serverless "\${def.name}" listening on http://\${s.host}:\${s.port}\`)
85
+ for (const r of s.routes) console.log(\` \${r.method} \${r.path}\`)
86
+ })
87
+ .catch((err) => {
88
+ console.error('failed to start serverless server:', err)
89
+ process.exit(1)
90
+ })
91
+ `,
92
+ esbuild: {
93
+ platform: "node",
94
+ format: "esm",
95
+ external: [],
96
+ targetEs: "node20"
97
+ }
98
+ }, l = class extends n.TaggedError()("StaticDeployError", {
99
+ host: n.String,
100
+ message: n.String,
101
+ detail: n.optional(n.Unknown)
102
+ }) {}, u = {
103
+ html: "text/html; charset=utf-8",
104
+ htm: "text/html; charset=utf-8",
105
+ css: "text/css; charset=utf-8",
106
+ js: "text/javascript; charset=utf-8",
107
+ mjs: "text/javascript; charset=utf-8",
108
+ json: "application/json; charset=utf-8",
109
+ map: "application/json; charset=utf-8",
110
+ txt: "text/plain; charset=utf-8",
111
+ xml: "application/xml; charset=utf-8",
112
+ svg: "image/svg+xml",
113
+ png: "image/png",
114
+ jpg: "image/jpeg",
115
+ jpeg: "image/jpeg",
116
+ gif: "image/gif",
117
+ webp: "image/webp",
118
+ avif: "image/avif",
119
+ ico: "image/x-icon",
120
+ woff: "font/woff",
121
+ woff2: "font/woff2",
122
+ ttf: "font/ttf",
123
+ otf: "font/otf",
124
+ eot: "application/vnd.ms-fontobject",
125
+ wasm: "application/wasm",
126
+ pdf: "application/pdf",
127
+ webmanifest: "application/manifest+json",
128
+ csv: "text/csv; charset=utf-8",
129
+ mp4: "video/mp4",
130
+ webm: "video/webm",
131
+ mp3: "audio/mpeg"
132
+ }, d = (e) => {
133
+ let t = e.lastIndexOf(".");
134
+ return t < 0 ? "" : e.slice(t + 1).toLowerCase();
135
+ }, f = (e) => u[d(e)] ?? "application/octet-stream", p = /[.-][0-9a-zA-Z_]{8,}\.[a-z0-9]+$/, m = (e) => {
136
+ let t = f(e);
137
+ return e.endsWith(".html") ? {
138
+ contentType: t,
139
+ cacheControl: "public, max-age=0, must-revalidate",
140
+ immutable: !1
141
+ } : e.startsWith("assets/") || e.includes("/assets/") || p.test(e) ? {
142
+ contentType: t,
143
+ cacheControl: "public, max-age=31536000, immutable",
144
+ immutable: !0
145
+ } : {
146
+ contentType: t,
147
+ cacheControl: "public, max-age=3600",
148
+ immutable: !1
149
+ };
150
+ };
151
+ //#endregion
152
+ export { a as ServerlessDeployError, t as ServerlessHttpError, l as StaticDeployError, m as cachePolicyFor, o as cloudflarePlatform, f as contentTypeFor, i as defineServerless, c as nodePlatform, s as scalewayPlatform, e as serverlessWebHandler };
package/dist/node.d.ts ADDED
@@ -0,0 +1,100 @@
1
+ import { Effect } from 'effect';
2
+ import { HttpClient } from '@effect/platform';
3
+ import { Schema } from 'effect';
4
+ import { Scope } from 'effect';
5
+ import { Server } from 'node:http';
6
+
7
+ export declare interface RunningServer {
8
+ readonly server: Server;
9
+ readonly port: number;
10
+ readonly host: string;
11
+ readonly routes: ReadonlyArray<ServeRoute>;
12
+ readonly close: () => Promise<void>;
13
+ }
14
+
15
+ export declare interface ServeOptions {
16
+ readonly port?: number;
17
+ readonly host?: string;
18
+ /** Env exposed to every handler via `ctx.env` (defaults to `process.env`). */
19
+ readonly env?: Record<string, string | undefined>;
20
+ /**
21
+ * CORS allow-origin for responses + OPTIONS preflight. A serverless function
22
+ * is almost always called cross-origin (the static site that fetches it lives
23
+ * on a different host) — Cloudflare/Scaleway add these headers at the edge, so
24
+ * the local runner matches by default. `'*'` (default) allows any origin;
25
+ * pass a concrete origin to lock it down, or `false` to send no CORS headers.
26
+ */
27
+ readonly cors?: string | false;
28
+ }
29
+
30
+ /**
31
+ * Platform-agnostic per-invocation context handed to a handler. The framework
32
+ * fills it from whatever the host passes — Cloudflare's `env` bindings +
33
+ * `ExecutionContext`, Scaleway's `process.env`, etc. — so handler code never
34
+ * branches on the platform.
35
+ */
36
+ declare interface ServerlessContext {
37
+ /** Env vars / secrets injected by the platform. Cloudflare → the worker `env`
38
+ * bindings; Scaleway / Node → `process.env`. */
39
+ readonly env: Record<string, string | undefined>;
40
+ /** The raw incoming Web `Request` (method, url, headers) for advanced use. */
41
+ readonly request: Request;
42
+ /** Schedule work that outlives the response — Cloudflare
43
+ * `ExecutionContext.waitUntil`; a best-effort fire-and-forget elsewhere. */
44
+ readonly waitUntil: (promise: Promise<unknown>) => void;
45
+ }
46
+
47
+ /**
48
+ * A serverless function definition. The handler is Effect-first and may require
49
+ * `HttpClient` (provided by the framework's base layer); decode/encode of the
50
+ * JSON wire body is driven by the `input`/`output` schemas.
51
+ */
52
+ declare interface ServerlessDefinition<I = unknown, O = unknown> {
53
+ /** Deployment identifier — kebab-case, DNS-safe (it names the deployed
54
+ * function/worker). */
55
+ readonly name: string;
56
+ /** HTTP method the function answers on (default `POST`). A `GET` reads its
57
+ * input from the query string; everything else from the JSON body. */
58
+ readonly method?: ServerlessMethod;
59
+ /** Path the function answers on within its host (default `/`). */
60
+ readonly path?: string;
61
+ /** Decodes the request body/query into the handler's typed input. */
62
+ readonly input: Schema.Schema<I, any>;
63
+ /** Encodes the handler's result into the JSON response body. */
64
+ readonly output: Schema.Schema<O, any>;
65
+ /** The work. Effect-first; may `yield* HttpClient.HttpClient` and use scoped
66
+ * effects (e.g. `http.get(url)` + reading the body) directly — the framework
67
+ * runs the handler inside a `Scope`, so you never write `Effect.scoped`. */
68
+ readonly handler: (input: I, ctx: ServerlessContext) => Effect.Effect<O, unknown, HttpClient.HttpClient | Scope.Scope>;
69
+ /** Deploy hints (memory / timeout / region / scale). */
70
+ readonly runtime?: ServerlessRuntimeHints;
71
+ }
72
+
73
+ /** HTTP method a function answers on. */
74
+ declare type ServerlessMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
75
+
76
+ /** Platform deploy hints — best-effort; a host ignores what it can't honour. */
77
+ declare interface ServerlessRuntimeHints {
78
+ readonly memoryMb?: number;
79
+ readonly timeoutSeconds?: number;
80
+ /** Provider region (e.g. `fr-par` for Scaleway). Cloudflare is global. */
81
+ readonly region?: string;
82
+ /** Warm/cap instance counts (provider best-effort). */
83
+ readonly minScale?: number;
84
+ readonly maxScale?: number;
85
+ }
86
+
87
+ export declare interface ServeRoute {
88
+ readonly name: string;
89
+ readonly method: string;
90
+ readonly path: string;
91
+ }
92
+
93
+ /**
94
+ * Start an http server for the given functions. Resolves once listening; the
95
+ * returned handle exposes the effective route table and a `close()`. Rejects
96
+ * only if the port can't be bound.
97
+ */
98
+ export declare const serveServerless: (defs: ReadonlyArray<ServerlessDefinition<unknown, unknown>>, opts?: ServeOptions) => Promise<RunningServer>;
99
+
100
+ export { }
package/dist/node.js ADDED
@@ -0,0 +1,85 @@
1
+ import { n as e } from "./webHandler-ss_jy07c.js";
2
+ import { createServer as t } from "node:http";
3
+ //#region src/node.ts
4
+ var n = async (e, t) => {
5
+ let n = t + (e.url ?? "/"), r = (e.method ?? "GET").toUpperCase(), i = new Headers();
6
+ for (let [t, n] of Object.entries(e.headers)) typeof n == "string" ? i.set(t, n) : Array.isArray(n) && i.set(t, n.join(", "));
7
+ if (r === "GET" || r === "HEAD") return new Request(n, {
8
+ method: r,
9
+ headers: i
10
+ });
11
+ let a = [];
12
+ for await (let t of e) a.push(t);
13
+ let o = a.length > 0 ? Buffer.concat(a) : void 0;
14
+ return new Request(n, {
15
+ method: r,
16
+ headers: i,
17
+ ...o ? { body: o } : {}
18
+ });
19
+ }, r = async (e, t) => {
20
+ t.statusCode = e.status, e.headers.forEach((e, n) => t.setHeader(n, e)), t.end(Buffer.from(await e.arrayBuffer()));
21
+ }, i = (e, t) => {
22
+ let n = e.path ?? "/";
23
+ return n === "/" ? t > 1 ? `/${e.name}` : "/" : n;
24
+ }, a = (e, t, n) => {
25
+ e.statusCode = t, e.setHeader("content-type", "application/json; charset=utf-8"), e.end(JSON.stringify(n));
26
+ }, o = (o, s = {}) => {
27
+ let c = s.port ?? Number(s.env?.PORT ?? process.env.PORT ?? 8910), l = s.host ?? "0.0.0.0", u = s.env ?? process.env, d = s.cors ?? "*", f = [], p = /* @__PURE__ */ new Map();
28
+ for (let t of o) {
29
+ let n = (t.method ?? "POST").toUpperCase(), r = i(t, o.length), a = p.get(r) ?? /* @__PURE__ */ new Map();
30
+ a.set(n, e(t, { env: u })), p.set(r, a), f.push({
31
+ name: t.name,
32
+ method: n,
33
+ path: r
34
+ });
35
+ }
36
+ let m = t((e, t) => {
37
+ let i = `http://localhost:${c}`, o = (e.method ?? "GET").toUpperCase(), s = new URL(e.url ?? "/", i).pathname;
38
+ if (d !== !1 && (t.setHeader("access-control-allow-origin", d), t.setHeader("vary", "origin"), o === "OPTIONS")) {
39
+ let n = e.headers["access-control-request-headers"];
40
+ t.setHeader("access-control-allow-methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS"), t.setHeader("access-control-allow-headers", typeof n == "string" && n.length > 0 ? n : "content-type, authorization"), t.setHeader("access-control-max-age", "86400"), t.statusCode = 204, t.end();
41
+ return;
42
+ }
43
+ if (o === "GET" && s === "/internal/liveness") {
44
+ t.statusCode = 200, t.end("ok");
45
+ return;
46
+ }
47
+ if (o === "GET" && s === "/internal/readiness") {
48
+ t.statusCode = 200, t.end("ready");
49
+ return;
50
+ }
51
+ let l = p.get(s);
52
+ if (!l) {
53
+ a(t, 404, {
54
+ error: "not-found",
55
+ path: s
56
+ });
57
+ return;
58
+ }
59
+ let u = l.get(o);
60
+ if (!u) {
61
+ t.setHeader("allow", [...l.keys()].join(", ")), a(t, 405, {
62
+ error: "method-not-allowed",
63
+ expected: [...l.keys()]
64
+ });
65
+ return;
66
+ }
67
+ n(e, i).then((e) => u(e)).then((e) => r(e, t)).catch((e) => a(t, 500, {
68
+ error: "handler-failed",
69
+ detail: String(e)
70
+ }));
71
+ });
72
+ return new Promise((e, t) => {
73
+ m.on("error", t), m.listen(c, l, () => {
74
+ e({
75
+ server: m,
76
+ port: c,
77
+ host: l,
78
+ routes: f,
79
+ close: () => new Promise((e) => m.close(() => e()))
80
+ });
81
+ });
82
+ });
83
+ };
84
+ //#endregion
85
+ export { o as serveServerless };
@@ -0,0 +1,50 @@
1
+ import { Cause as e, Effect as t, Exit as n, Schema as r } from "effect";
2
+ import { FetchHttpClient as i } from "@effect/platform";
3
+ //#region src/webHandler.ts
4
+ var a = class extends r.TaggedError()("ServerlessHttpError", {
5
+ status: r.Number,
6
+ message: r.String,
7
+ detail: r.optional(r.Unknown)
8
+ }) {}, o = (e) => typeof e == "object" && !!e && e._tag === "ServerlessHttpError" && typeof e.status == "number" && typeof e.message == "string", s = (e, t) => new Response(JSON.stringify(t), {
9
+ status: e,
10
+ headers: { "content-type": "application/json; charset=utf-8" }
11
+ }), c = async (e, t) => t === "GET" || t === "DELETE" ? Object.fromEntries(new URL(e.url).searchParams.entries()) : e.json().catch(() => ({})), l = (l, u = {}) => {
12
+ let d = l.method ?? "POST";
13
+ return async (f) => {
14
+ if (f.method.toUpperCase() !== d) return s(405, {
15
+ error: "method-not-allowed",
16
+ expected: d
17
+ });
18
+ let p = {
19
+ env: u.env ?? {},
20
+ request: f,
21
+ waitUntil: u.waitUntil ?? (() => {})
22
+ }, m = await c(f, d), h = t.gen(function* () {
23
+ let e = yield* r.decodeUnknown(l.input)(m).pipe(t.mapError((e) => new a({
24
+ status: 400,
25
+ message: "invalid-input",
26
+ detail: String(e)
27
+ }))), n = yield* l.handler(e, p);
28
+ return yield* r.encode(l.output)(n).pipe(t.mapError((e) => new a({
29
+ status: 500,
30
+ message: "invalid-output",
31
+ detail: String(e)
32
+ })));
33
+ }).pipe(t.scoped, t.provide(i.layer)), g = await t.runPromiseExit(h);
34
+ if (n.isSuccess(g)) return s(200, g.value);
35
+ let _ = e.failureOption(g.cause);
36
+ if (_._tag === "Some" && o(_.value)) {
37
+ let e = _.value;
38
+ return s(e.status, {
39
+ error: e.message,
40
+ ...e.detail === void 0 ? {} : { detail: e.detail }
41
+ });
42
+ }
43
+ return s(500, {
44
+ error: "handler-failed",
45
+ detail: e.pretty(g.cause)
46
+ });
47
+ };
48
+ };
49
+ //#endregion
50
+ export { l as n, a as t };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@voltro/serverless",
3
+ "version": "0.1.0",
4
+ "description": "Effect-typed standalone serverless functions (*.serverless.ts) + a deploy abstraction (Cloudflare Workers / Scaleway) and a static-site multi-host deploy abstraction.",
5
+ "keywords": [
6
+ "voltro",
7
+ "typescript",
8
+ "framework"
9
+ ],
10
+ "license": "SEE LICENSE IN LICENSE",
11
+ "homepage": "https://voltro.dev",
12
+ "bugs": {
13
+ "email": "support@voltro.dev"
14
+ },
15
+ "author": {
16
+ "name": "Voltro UG",
17
+ "url": "https://voltro.dev"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./node": {
27
+ "types": "./dist/node.d.ts",
28
+ "import": "./dist/node.js",
29
+ "default": "./dist/node.js"
30
+ }
31
+ },
32
+ "main": "./dist/index.js",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "sideEffects": false,
36
+ "engines": {
37
+ "node": ">=24.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@effect/platform": "^0.96.2"
41
+ },
42
+ "peerDependencies": {
43
+ "effect": "^3.21.4"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }