feat: external inflight typescript files
Note: I'm looking for feedback in the documentation regarding the general direction and API rather than the code itself. https://github.com/winglang/wing/blob/mark/intrinsic-inflight/docs/docs/07-examples/10-using-javascript.md While the implementation here works it still needs changes.
Fixes #6045
This PR introduces a new utility function importInflight. This allows you to create an inflight closure from an external file with specific lifts:
// main.w
bring cloud;
let bucket = new cloud.Bucket();
let queue = new cloud.Queue();
bucket.onCreate(importInflight("./bucket_create.ts", lifts: {
myQueue: { lift: queue, ops: ["push"] }
//^ name, does not need to match the variable being lifted
// ^ object to lift, can be any preflight expression
// ^ methods to lift, if not provided then all methods will be granted
}));
// bucket_create.ts
import inflight from "./bucket_create.inflight";
export default inflight(async ({ myQueue }, file) => {
// ^ inflight interface to your preflight queue
await myQueue.push(file);
});
TODOS before leaving draft
- [ ] Get approval for the overall design
- [ ] Document use of non-default export
- [ ] Several tests
- [ ] Fix lifting bug when not providing
ops - [ ] Refactor handling of args to use actual types rather than loose json parsing
- [ ] Some lsp integration
By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.
Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Discord.
| Topic | Owner |
|---|---|
| Wing SDK and utility APIs | @chriscbr |
| Wing Console | @ainvoner, @skyrpex, @polamoros |
| JSON, structs, primitives and collections | @hasanaburayyan |
| Platforms and plugins | @hasanaburayyan |
| Frontend resources (website, react, etc) | @tsuf239 |
| Language design | @chriscbr |
| VSCode extension and language server | @markmcculloh |
| Compiler architecture, inflights, lifting | @yoav-steinberg |
| Wing Testing Framework | @tsuf239 |
| Wing CLI | @markmcculloh |
| Build system, dev environment, releases | @markmcculloh |
| Library Ecosystem | @chriscbr |
| Documentation | @hasanaburayyan |
| SDK test suite | @tsuf239 |
| Examples | @hasanaburayyan |
| Wing Playground | @eladcon |
Console preview environment is available at https://wing-console-pr-6305.fly.dev :rocket:
Last Updated (UTC) 2024-05-27 01:19
Benchmarks
Comparison to Baseline 🟥⬜⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜
| Benchmark | Before | After | Change |
|---|---|---|---|
| version | 56ms±0.58 | 58ms±0.66 | +3ms (+4.65%)🟥 |
| functions_10.test.w -t sim | 495ms±7.74 | 510ms±8.05 | +15ms (+2.94%)⬜ |
| functions_10.test.w -t tf-aws | 2025ms±25.31 | 2079ms±18.42 | +54ms (+2.68%)⬜ |
| hello_world.test.w -t sim | 399ms±3.7 | 411ms±5.69 | +12ms (+3.01%)🟥 |
| hello_world.test.w -t tf-aws | 1441ms±9.86 | 1445ms±9.28 | +3ms (+0.24%)⬜ |
| functions_1.test.w -t sim | 395ms±6.09 | 399ms±3.17 | +3ms (+0.78%)⬜ |
| functions_1.test.w -t tf-aws | 817ms±4.91 | 829ms±8.33 | +12ms (+1.5%)⬜ |
| jsii_big.test.w -t sim | 2793ms±16.04 | 2801ms±9.01 | +8ms (+0.29%)⬜ |
| jsii_big.test.w -t tf-aws | 2996ms±12.38 | 2995ms±13.44 | -1ms (-0.04%)⬜ |
| empty.test.w -t sim | 360ms±5.07 | 364ms±4.48 | +4ms (+1.15%)⬜ |
| empty.test.w -t tf-aws | 593ms±4.03 | 594ms±3.85 | +1ms (+0.23%)⬜ |
| jsii_small.test.w -t sim | 373ms±2.63 | 372ms±5.13 | -1ms (-0.17%)⬜ |
| jsii_small.test.w -t tf-aws | 612ms±4.93 | 607ms±5.1 | -5ms (-0.85%)⬜ |
⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations
Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.
Results
| name | mean | min | max | moe | sd |
|---|---|---|---|---|---|
| version | 58ms | 57ms | 60ms | 1ms | 1ms |
| functions_10.test.w -t sim | 510ms | 488ms | 521ms | 8ms | 11ms |
| functions_10.test.w -t tf-aws | 2079ms | 2035ms | 2121ms | 18ms | 26ms |
| hello_world.test.w -t sim | 411ms | 404ms | 426ms | 6ms | 8ms |
| hello_world.test.w -t tf-aws | 1445ms | 1426ms | 1477ms | 9ms | 13ms |
| functions_1.test.w -t sim | 399ms | 395ms | 409ms | 3ms | 4ms |
| functions_1.test.w -t tf-aws | 829ms | 811ms | 849ms | 8ms | 12ms |
| jsii_big.test.w -t sim | 2801ms | 2783ms | 2824ms | 9ms | 13ms |
| jsii_big.test.w -t tf-aws | 2995ms | 2966ms | 3025ms | 13ms | 19ms |
| empty.test.w -t sim | 364ms | 354ms | 374ms | 4ms | 6ms |
| empty.test.w -t tf-aws | 594ms | 585ms | 602ms | 4ms | 5ms |
| jsii_small.test.w -t sim | 372ms | 363ms | 384ms | 5ms | 7ms |
| jsii_small.test.w -t tf-aws | 607ms | 596ms | 618ms | 5ms | 7ms |
Last Updated (UTC) 2024-05-26 22:47
Thanks for contributing, @MarkMcCulloh! This PR will now be added to the merge queue, or immediately merged if mark/intrinsic-inflight is up-to-date with main and the queue is empty.
Congrats! :rocket: This was released in Wing 0.74.17.