resolve#3046
[Playground](https://cadlplayground.z22.web.core.windows.net/prs/3342/)
Add the following:
- `@multipartBody` decorator
- `File` type
- `HttpPart<Type, Options>` type
Had to do a decent amount of refactoring to be able to reuse the body
parsing, this result in a much cleaner resolution of the body and other
metadata properties across request, response and metadata.
The way it works now is instead of calling `gatherMetadata` that would
just get the properties that are metadata but also ones with `@body` and
`@bodyRoot` we now call a `resolveHtpProperties`, this does the same
resolution in term of filtering properties but it also figure out what
is the kind of property in the concept of http(header, query, body,
etc.) this leaves the error resolution to this function for duplicate
annotations.
What is nice is now we don't need to keep asking oh is this a query or a
header or a body we can just check the kind of `HttpProperty`
also resolve#1311
Remove the opinionated (wrongly so most of the time) middleman that
brings more config pain than value.
Things to check:
- [x] Parallel build performance vs rush
- [ ] Publishing with submodule
- [x] Changesets
Add a new library template with:
- `@alernateName` decorator with some custom diagnostics and tests for
it.
- a linter rule and 2 rulesets(`recommended` and `all`)
Get rid of mocha and upgrade to vitest which is a more modern
alternative providing, watch, direct typescript compilation out of the
box, expect library and more.
Advantage over mocha:
- Much better cli
- watch mode
- better diff
- Better extension:
- tree organization for files too (not everything flattened)
- update in real time the test(no more need to refresh manually to
discover where are the tests)
- just a little buggy
- Compiles typescript directly
- provides more expectation apis(like jest)
Cons over mocha:
- Slower(about 2x) but that means we don't need to build the test as
part of build which would speed up that part(not as much as is lost)
Todo:
- typespec-azure migration
Playground usage was completely broken when used as a package. Local
reference seems to make it work but hwne the package is in node_modules
vite doesn't allow certain things
fix [#3017](https://github.com/Azure/typespec-azure/issues/3017)
Run the samples as test which allows all of them to run without crashing
on the first one, lets us run it in the test explorer.
This also make the sample regeneration much faster(typespec azure repo):
- Before `~90s`
- Now `~12s`
![image](https://github.com/microsoft/typespec/assets/1031227/a3356a90-7847-43cf-a473-4ecda0c53330)
## New `resolveCompilerOptions` utils
This also include the addition of a new util `resolveCompilerOptions`
that resolve the compiler options programtically in the same way that
the cli would have for a given entrypoint.
I can move this into a dedicated PR if people prefer.
---------
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
1. Format *.cadl on save in our repo. This required some extra knobs in
.vscode/settings.json and .prettierrc.json. These are not required when
referencing the prettier plugin via npm, but we need a workaround to consume
the plugin this way from source.
2. Fix a formatter bug with operations that return anonymous models where
the braces around the return model were dropped.
3. Add cadl syntax highlighting to markdown ```cadl blocks