Граф коммитов

275 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin dec504364c
Bump versions for 0.56.0 release (#3298) 2024-05-08 00:34:05 +00:00
Timothee Guerin 5757fd16e4
Include `type` in generated extern dec (#3250)
This allows us to use `verbatimModuleSyntax: true`
2024-04-29 20:23:34 +00:00
Timothee Guerin 1265330298
Update to Body consistency in http request (#2945)
fix [#2868](https://github.com/microsoft/typespec/issues/2868)

- Change meaning of `@body` to mean this is the body and nothing will be
excluded(show warning on containing metadata)
- Add new `@bodyRoot` which has the same purpose as the old `@body`(
Allows changing where the body is resolved from but allows mixing with
metadata.
- Add new `@bodyIgnore` which allows a property to be ignored from the
body
- Provide a new body resolution common function for request and response

also fix #2075
## Examples from original issue

1. [Inconsitency between request and
response](https://cadlplayground.z22.web.core.windows.net/prs/2945/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwOwoKLyoqCiAqIEJhc2VsaW5lIDE6IEhhdsQqYEBoZWFkZXJgIHByb3BlcnR5IG9ubHkgaW4gcmVxdWVzdMYLc3BvbnNlxAl1bMUTbm8gYm9kecRXUscpxBA6IHZvaWTGFnPFM80WLwpAcm91dGUoIi9i5wCNIikKQGdldCBvcCDIEygg5wCWIGN1c3RvbUjFDTogc3RyaW5nKToge90hIH0g6gD0Q2Fz5QDwQWRkxBtgQHZpc2liaWxpdHlgIHRv9AEBYmVoYXZlIGRpZmZlcmVudGx5IGZvcukBEGFuZOkBES7yAQB7ff8A%2FuUA%2FmNhc2UxIikKb3AgxQso6wCYKCJub%2BQBGOkA5XjuAPvfKsUqIH3vAQMy%2BgEDbm9uIGFubm90YXRlZOoBB%2BoB7GVtcOQBF%2FUB7%2FQA78UU7wDtMuoA7TL1AO3%2FAOXMIuUA3Q%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
2. [Inconsitency between different
ways](https://cadlplayground.z22.web.core.windows.net/prs/2945/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZdmVyc2lvbmluZyI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwO9AVVskyOwoKQHNlcnZpY2UKQMdJZWQoxyFzKQpuYW1lc3BhY2UgTXlTxik7CmVudW0gyCQgewogIHYxLMQGMiwKfQoKQHJvdXRlKCJ0MSIpIG9wIHQxKCk6IHZvaWQ7IC8vIDIwNMUNyigyxygyxCh7fccmMM8mM8cmM8UmQGhlYWRlciBmb286IHN0cmluZ9g5NMc5NMY5dmlzaWJpbGl0eSgiZ2F0ZXdheSIp30jFSDXHSDXcSP8AmMxQNsdQNsVQ1THGFiJhYmMifco5N8c5N8U5QGFkZOsBtC52MvMAzsR6IGluIHYxykc4x0c430fFRyzpANpvdGhlcthe&e=%40typespec%2Fopenapi3&options=%7B%7D)

## Breaking changes 
Azure spec PR showing scale of breaking changes
https://github.com/Azure/azure-rest-api-specs/pull/27897
### `@body` means this is the body
This change makes it that using `@body` will mean exactly this is the
body and everything underneath will be included, including metadata
properties. It will log a warning explaining that.

```tsp
op a1(): {@body _: {@header foo: string, other: string} };
                ^ warning header in a body, it will not be included as a header.
```

Solution use `@bodyRoot` as the goal is only to change where to resolve
the body from.

```tsp
op a1(): {@bodyRoot _: {@header foo: string, other: string} };
```




### Empty model after removing metadata and visibility property result
in void always
This means the following case have changed from returning `{}` to no
body

```tsp
op b1(): {};
op b2(): {@visibility("none") prop: string};
op b3(): {@added(Versions.v2) prop: string};
```

Workaround: Use explicit `@body`

```tsp
op b1(): {@body _: {}};
op b2(): {@body _: {@visibility("none") prop: string}};
op b3(): {@body _: {@added(Versions.v2) prop: string}};
```

### Status code always 200 except if response is explicitly `void`

```tsp
op c1(): {@header foo: string}; // status code 200 (used to be 204)
```

Solution: Add explicit `@statusCode`
```tsp
op c1(): {@header foo: string, @statusCode _: 204};
op c1(): {@header foo: string, ...NoContent}; // or spread common model
```


### Properties are not automatically omitted if everything was removed
from metadata or visibility

```tsp
op d1(): {headers: {@header foo: string}}; // body will be {headers: {}}
```

Solution: use `@bodyIgnore`

```tsp
op d1(): {@bodyIgnore headers: {@header foo: string}}; // body will be {headers: {}}
```

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-04-17 11:20:25 -07:00
Timothee Guerin d290c17b5e
Update dependencies - april 2024 (#3169)
Notable: 
- vitest `1.5.0` which solves some issues with running in the extension
- remove `sinon` from compiler which is not needed anymore as vitest
provide spies built-in
2024-04-15 10:24:38 -07:00
Timothee Guerin 35f5c90343
Migrate to eslint flat config (#3123)
resolve https://github.com/microsoft/typespec/issues/3121
same change in typespec-azure
https://github.com/Azure/typespec-azure/pull/620

## Single top level config
This makes it a little nicer to run as you know get the absolute path
for errors
No need to have the hacky rushstack dependency to allow using the same
shared config.

## Able to lint the projects that are outside of the pnpm workspace
<img width="1054" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/f88691d9-1bf2-4140-ba2b-533207b15f9d">


## Eslint 9 -no yet

eslint 9 was just released firday which makes this config the new
default however it does include breaking changes and not all our plugins
have updated
2024-04-08 09:58:19 -07:00
Timothee Guerin 0c1b96be47
Ci improvements (#3099)
- Use corepack to install pnpm: Faster and respect the pnpm version set
in package.json instead of having another place to keep up to date
- dependency cache
- upgrade to new code coverage task
- Move all consitency check to independent github action workflow(Makes
it easier to see which one failed immediately without having to open
devops and dig into the steps)
2024-04-03 16:19:59 -07:00
Timothee Guerin 2f53533d94
Bump versions for release 0.55.0 - april 2024 (#3096) 2024-04-02 14:55:47 -07:00
Timothee Guerin 0dea649cd7
Update dependencies to resolve vulnerabilities and license issue (#3081)
- Remove unused rollup-plugin-dts dep that had problematic license
- Update dependencies to fix vulnerabilies
2024-03-29 21:22:06 +00:00
Timothee Guerin 077db13c8d
Generate TypeScript decorator signatures from `extern dec` (#2122)
Note this is added to `tspd` which is not published yet so this can be
iterated over without any issues.

Adds a decorator signature generator. Generates 2 files:
- `<namespace>.ts` : Contains the decorator signatures that can be
imported and when declaring the decorators functions
- `<namespace>.ts-test.ts`: Contains some test using typescript type
system to make sure the package does reexport the right `$<name>` for
each decorator

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-03-19 23:08:59 +00:00
Timothee Guerin 4199f83575
Upgrade dependencies march 2024 (#3027)
General update of all dependencies, notable
- typescript 5.4
- vitest 1.4
2024-03-18 10:52:06 -07:00
Timothee Guerin 7312314bcb
Remove old message burried in changelog (#2989) 2024-03-05 16:05:57 -08:00
Timothee Guerin 9881002f1c
Bump versions for release march 2024 (#2988) 2024-03-05 15:31:47 -08:00
Timothee Guerin 02ed01e79b
Improved ref docs for model (#2951)
fix https://github.com/Azure/typespec-azure-pr/issues/3861
fix #2232
Generate docs for model properties and reference models within the same
package
<img width="1213" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ae7eccd0-97d8-401e-b07f-3375c7b41446">
2024-02-29 07:21:13 -08:00
Timothee Guerin 7452fe9a57
Update dependencies - feb 2024 (#2900)
General dependency updates, notable:
- typescript 5.3
- chronus 0.6.0 (BREAKING  THE CHANGELOG FORMAT)
2024-02-08 15:14:01 -08:00
Timothee Guerin 173c0de73c
Merge hotfix back into main (#2899) 2024-02-08 11:37:38 -08:00
Timothee Guerin ad74773b53
Bump version for February release (#2890) 2024-02-06 16:14:38 -08:00
Timothee Guerin be9f6d8145
Rename references from microsoft.github.io/typespec to typespec.io (#2858)
All reference but the README as it is being rewritten here
https://github.com/microsoft/typespec/pull/2855
2024-01-30 12:58:42 -08:00
Mark Cowlishaw 345cd594da
Prepare Publish for January Release (#2816) 2024-01-24 11:14:23 -08:00
Timothee Guerin 55ea44250d
Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791)
Add vitest ui package and `test:ui` command to popup the vitest UI
https://vitest.dev/guide/ui

Import the common vitest config from the workspace so each package
doesn't need to define all of it.
Added `watchExclude: []` to the common config to preven vitest from
excluding dist and node_modules folder which is required so it can auto
rerun the test on when a dependency (monorepo dep) rebuilds

Added debug config to debug the current test. As the vitest extensions
is quite unreliable this should help
2024-01-22 09:56:55 -08:00
Timothee Guerin 324a6b7237
Fix custom path param name with `@autoRoute` (#2792) 2024-01-11 17:02:34 -08:00
Timothee Guerin 9c7bf80187
Migrate test framework to vitest (#2769)
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
2024-01-02 11:40:29 -08:00
Will Temple aae7166f0a
Rename template parameters for clarity and consistency (#2726)
This is in preparation for merging named template argument
instantiation.

---------

Co-authored-by: Will Temple <will@wtemple.net>
2023-12-18 13:44:37 -05:00
Timothee Guerin 9f15ba5502
General dependency upgrades (#2753)
Major:
- Typescript 5.3
- Vite 5
- Rollup 4
2023-12-13 21:01:13 +00:00
Mark Cowlishaw e52a32c76a
Prepare Publish for December release (#2740) 2023-12-06 12:43:01 -08:00
Timothee Guerin c749b1148f
Split libraries from standard library (#2674)
Having the std and other libraries merged together always made it harder

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-21 20:13:40 +00:00
Travis Prescott fbd64fc5f2
Fix `ResourceCreateModel` template (#2663)
Fix #2604.
2023-11-13 22:15:32 +00:00
Mark Cowlishaw 6d69297a05
Prepare typespec publish for November Release (#2646) 2023-11-07 16:56:19 -08:00
Timothee Guerin 3695abb65a
Fix: Default must be last (#2636)
`default` entry must be last in `exports`. Most tools do not care but it
seems like webpack and docusaurus do. This is causing issue when trying
to imoport the playground directly there.
2023-11-06 22:50:49 +00:00
Timothee Guerin 0ca049cf13
Migrate out of typesVersions in package.json and cleanup (#2560)
Re-Reverts microsoft/typespec#2554

Making this pr for next release

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-06 19:55:30 +00:00
Timothee Guerin 533c974a47
Drop support for node 16 (#2605)
fix [#1847](https://github.com/microsoft/typespec/issues/1847)
2023-10-26 11:41:54 -07:00
Alexander Batishchev 2353586552
Added maxDiffSize to Mocha configuration (#2593)
Copying changes from https://github.com/Azure/typespec-azure/pull/3731/

Note: I added the following files as they were missing but the
corresponding `.mocharc.yaml` files already exist:

- packages/protobuf/mocha.reporter.config.json
- packages/samples/mocha.reporter.config.json
- packages/typespec-vscode/mocha.reporter.config.json
2023-10-19 22:37:26 +00:00
Mark Cowlishaw e76223066e
Prepare typespec publish (#2567) 2023-10-11 17:38:29 -07:00
Timothee Guerin 1a18ef2ac4
Revert "Migrate out of typesVersions in package.json and cleanup" (#2554)
Reverts microsoft/typespec#2488

This PR ends up being a breaking change, will move it to next release
after going through process
2023-10-10 18:01:41 +00:00
Timothee Guerin e02b74a876
Migrate out of typesVersions in package.json and cleanup (#2488)
Same pr in typespec-azure
https://github.com/Azure/typespec-azure/pull/3641

Migrate to use the `types` entry under `exports` instead of hte legacy
typesVersions. This was a leftover to when es modules where not
completely supported in typescript and using typesVersions was a
workaround.
2023-10-04 22:16:08 +00:00
Travis Prescott 026c7bd91a
Fix issue with getting keys from base class (#2515)
Required for Azure PR https://github.com/Azure/typespec-azure/pull/3658
2023-09-29 20:48:37 +00:00
Timothee Guerin 61ba17d2d2
General dependencies update september 2023 (#2445)
fix https://github.com/Azure/typespec-azure/issues/3602

Notable change:
- yaml update removes the uncessary escaping of openapi paths
2023-09-21 13:34:11 -07:00
Mark Cowlishaw aa4d05ac5b
Backmerge 2023 09 19 hotfixes (#2444)
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: adam-joffe <58192966+adam-joffe@users.noreply.github.com>
2023-09-19 15:13:38 -07:00
Connor Sullivan f55f570f66
Correct rest → http peer dependency & OpenAPI does not depend on REST (#2410)
### ℹ️ Overview

Includes two commits, one to fix #2391 and a second related to the same
issue.

#### Correct rest → http peer dependency

Fixes #2391

Updates `@typespec/rest` to have a `peerDependency` on `@typespec/http`.
Leftover from the rest/http split.

#### OpenAPI does not depend on REST

Relates to #2391.

Removes `@typespec/rest` as a `peerDependency` for `@typespec/openapi`
and `@typespec/openapi3`. The OpenAPI packages only depend on HTTP
functionality, not the higher-level REST concepts.

The packages still have `@typespec/rest` as a `devDependency` for test
cases (test host).

### 📝 Notes

N/A - Commit message suffices

### 🧪 Testing

Ran rush scripts. Did not attempt an `npm link` and install or
something. (So, no testing really.)
2023-09-19 09:47:41 -07:00
Mark Cowlishaw c9a2751618
Prepare typespec publish for September release (#2409) 2023-09-12 16:38:24 -07:00
Timothee Guerin 6d98cd0afb
Merge `--config` hotfix back into main (#2289)
Co-authored-by: Mingzhe Huang <archerzz@users.noreply.github.com>
2023-08-10 14:29:32 -07:00
Mark Cowlishaw 42d00cef2b
Prepare typespec publish for August release (#2272) 2023-08-08 16:20:33 -07:00
Timothee Guerin 7cce379d3e
Render README from refdoc (#2242)
fix #2130 

Generate the README.md for typespec libraries automatically using the
subset of the content as what gets included in the ref doc

To achieve this I reoganized the markdown rendering to be able to
provide a reusable system that can be cusomized for different markdown
engines.

- The markdown renderer will render a markdown compatible with Github
Flavored Markdown.
- The docusuaurs rendererer extends the markdown renderer and include a
few extra metadata.
2023-08-07 22:24:56 +00:00
Timothee Guerin adbb1559cd
Rename `ref-doc` package to `tspd` and provide a cli that can be used by each package (#2225)
Progress towards providing the ref doc generation as a usable tool by
any typespec library.

Detach the generation from the website, instead each package define
where they want their doc and we generate it.

This adds a new `tspd` package and CLI tool that is meant to be used by
library authors. It will have the following functionalities
- generate docs
- generate TS signatures
- lint library?

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-08-01 22:34:18 +00:00
Mark Cowlishaw 140d6ce464
Prepare typespec publish for July release (#2175) 2023-07-11 16:27:59 -07:00
David Wilson b1eb314d3f
Deprecate `@list` decorator in favor of `rest`'s `@listsResource` (#2093)
This change fixes #1978 by deprecating the virtually-unused `@list`
decorator in favor of the `@listsResource` decorator in
`@typespec/rest`. I'm also deprecating the associated `isListOperation`
and `getListOperationType` functions in `@typespec/compiler` and moving
`isListOperation` to the REST library.

The corresponding `typespec-azure` PR is here:
https://github.com/Azure/typespec-azure/pull/3200

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2023-06-22 11:15:25 -07:00
David Wilson 3578504d85
Make `resourceTypeForKeyParam` decorator private (#2073) 2023-06-20 08:30:28 -07:00
Timothee Guerin 8277fdf25f
Provide a better formatting for properties with comments and decorators (#2089) 2023-06-19 10:38:24 -07:00
Timothee Guerin b87583fbed
Rush pnpm workspaces (#2080) 2023-06-19 09:55:18 -07:00
Timothee Guerin 8988e4328f
Merge back hotfix compiler 0.45.2 (#2074) 2023-06-16 10:08:51 -05:00
Timothee Guerin e3a9d8bbf7
Merge back hotfix release (compiler: 0.45.1) into main (#2065)
* HotFix: Formatter moves all comments in flattened namespace to the top (#2061)

* Bump versions (compiler: 0.45.1) (#2063)
2023-06-14 18:11:51 +00:00