Перейти к файлу
dependabot[bot] 72e5c09a30
Bump happy-dom from 15.7.4 to 15.10.2 (#4992)
Bumps [happy-dom](https://github.com/capricorn86/happy-dom) from 15.7.4
to 15.10.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/capricorn86/happy-dom/releases">happy-dom's
releases</a>.</em></p>
<blockquote>
<h2>v15.10.2</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Fixes a security vulnerability that allowed for server side code to
be executed by a <code>&lt;script&gt;</code> tag - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1585">#1585</a>
<ul>
<li>There was a case that was missed with the first patch</li>
</ul>
</li>
</ul>
<h2>v15.10.1</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Fixes a security vulnerability that allowed for server side code to
be executed by a <code>&lt;script&gt;</code> tag - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1585">#1585</a></li>
</ul>
<h2>v15.10.0</h2>
<h3>🎨 Features</h3>
<ul>
<li>Adds a new setting called <code>disableSameOriginPolicy</code> that
makes it possible to bypass the same-origin policy in fetch requests -
By <strong><a
href="https://github.com/OlaviSau"><code>@​OlaviSau</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1553">#1553</a></li>
</ul>
<h2>v15.9.0</h2>
<h3>🎨 Features</h3>
<ul>
<li>Adds support for &quot;aspect-ratio&quot; to
<code>CSSStyleDeclaration</code> - By <strong><a
href="https://github.com/yinm"><code>@​yinm</code></a></strong> in task
<a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1147">#1147</a></li>
</ul>
<h2>v15.8.5</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Fixes bug where <code>Node.getRootNode()</code> returned null when
it was within a <code>ShadowRoot</code> that previously been
disconnected from the <code>Document</code> - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1581">#1581</a></li>
</ul>
<h2>v15.8.4</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Fixes bug where child nodes of <code>HTMLSelectElement</code> and
<code>HTMLFormElement</code> had the wrong reference to the parent - By
<strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1578">#1578</a></li>
</ul>
<h2>v15.8.3</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Toggle &quot;open&quot; attribute on <code>HTMLDetailsElement</code>
when dispatching a click event on a summary element which is a child of
the details element - By <strong><a
href="https://github.com/mikedidomizio"><code>@​mikedidomizio</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1534">#1534</a></li>
</ul>
<h2>v15.8.2</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Use <code>globalThis</code> instead of <code>global</code> to make
Happy DOM work in other runtimes such as Cloudflare workers - By
<strong><a
href="https://github.com/mattallty"><code>@​mattallty</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1546">#1546</a></li>
</ul>
<h2>v15.8.1</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Always return <code>Promise&lt;Blob&gt;</code> from
<code>ClipboardItem.getType()</code> - By <strong><a
href="https://github.com/ezzatron"><code>@​ezzatron</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1538">#1538</a></li>
</ul>
<h2>v15.8.0</h2>
<h3>👷‍♂️ Patch fixes</h3>
<ul>
<li>Adds support for using non-ASCII characters in custom elements when
parsing HTML - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1079">#1079</a></li>
<li>Fixes an issue where <code>getHTML()</code> and
<code>getInnerHTML()</code> would return the slotted content of a shadow
root before the template, but the template should be the first child -
By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1079">#1079</a></li>
<li>Fixes a bug where SVG elements would not be found by
<code>getElementsByTagName()</code> - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1079">#1079</a></li>
<li>Improves performance when creating elements (e.g. during parsing of
HTML) - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1550">#1550</a>
<ul>
<li>Binding all methods to the target scope in Proxies caused a
performance hit, so this is now done when calling a method the first
time</li>
</ul>
</li>
</ul>
<h3>🎨 Features</h3>
<ul>
<li>Adds support for all remaining SVG elements:
<code>SVGAnimateElement</code>, <code>SVGAnimateMotionElement</code>,
<code>SVGAnimateTransformElement</code>, <code>SVGCircleElement</code>,
<code>SVGClipPathElement</code>, <code>SVGDefsElement</code>,
<code>SVGDescElement</code>, <code>SVGEllipseElement</code>,
<code>SVGFEBlendElement</code>, <code>SVGFEColorMatrixElement</code>,
<code>SVGFEComponentTransferElement</code>,
<code>SVGFECompositeElement</code>,
<code>SVGFEConvolveMatrixElement</code>,
<code>SVGFEDiffuseLightingElement</code>,
<code>SVGFEDisplacementMapElement</code>,
<code>SVGFEDistantLightElement</code>,
<code>SVGFEDropShadowElement</code>, <code>SVGFEFloodElement</code>,
<code>SVGFEFuncAElement</code>, <code>SVGFEFuncBElement</code>,
<code>SVGFEFuncGElement</code>, <code>SVGFEFuncRElement</code>,
<code>SVGFEGaussianBlurElement</code>, <code>SVGFEImageElement</code>,
<code>SVGFEMergeElement</code>, <code>SVGFEMergeNodeElement</code>,
<code>SVGFEMorphologyElement</code>, <code>SVGFEOffsetElement</code>,
<code>SVGFEPointLightElement</code>,
<code>SVGFESpecularLightingElement</code>,
<code>SVGFESpotLightElement</code>, <code>SVGFETileElement</code>,
<code>SVGFETurbulenceElement</code>, <code>SVGFilterElement</code>,
<code>SVGForeignObjectElement</code>, <code>SVGGElement</code>,
<code>SVGImageElement</code>, <code>SVGLineElement</code>,
<code>SVGLinearGradientElement</code>, <code>SVGMarkerElement</code>,
<code>SVGMaskElement</code>, <code>SVGMetadataElement</code>,
<code>SVGMPathElement</code>, <code>SVGPathElement</code>,
<code>SVGPatternElement</code>, <code>SVGPolygonElement</code>,
<code>SVGPolylineElement</code>, <code>SVGRadialGradientElement</code>,
<code>SVGRectElement</code>, <code>SVGScriptElement</code>,
<code>SVGSetElement</code>, <code>SVGStopElement</code>,
<code>SVGStyleElement</code>, <code>SVGSwitchElement</code>,
<code>SVGSymbolElement</code>, <code>SVGTextElement</code>,
<code>SVGTextPathElement</code>, <code>SVGTitleElement</code>,
<code>SVGTSpanElement</code>, <code>SVGUseElement</code> and
<code>SVGViewElement</code> - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1079">#1079</a></li>
<li>Adds support for <code>DOMMatrix</code>,
<code>DOMMatrixReadOnly</code>, <code>DOMPoint</code> and
<code>DOMPointReadOnly</code> - By <strong><a
href="https://github.com/capricorn86"><code>@​capricorn86</code></a></strong>
in task <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1079">#1079</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d23834c232"><code>d23834c</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1585">#1585</a>
Fixes a security vulnerability that allowed for server side code...</li>
<li><a
href="5ee0b1676d"><code>5ee0b16</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1585">#1585</a>
Fixes security vulnerability that allowed for server side code t...</li>
<li><a
href="a20dba9440"><code>a20dba9</code></a>
chore: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1542">#1542</a>
Adds SECURITY.md file (<a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1584">#1584</a>)</li>
<li><a
href="1625d40803"><code>1625d40</code></a>
feat: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1553">#1553</a>
Adds setting disableSameOriginPolicy, to make it possible to by...</li>
<li><a
href="a78cd8f28d"><code>a78cd8f</code></a>
feat: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1147">#1147</a>
Adds support for aspect-ratio to CSSStyleDeclaration (<a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1537">#1537</a>)</li>
<li><a
href="e6f8b13b57"><code>e6f8b13</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1581">#1581</a>
Fixes bug where Node.getRootNode() returned null when it was wi...</li>
<li><a
href="38ab960d0e"><code>38ab960</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1578">#1578</a>
Fixes bug where child nodes of HTMLSelectElement and HTMLFormEle...</li>
<li><a
href="8f74989abe"><code>8f74989</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1534">#1534</a>
Toggle open attribute on HTMLDetailsElement when dispatching a c...</li>
<li><a
href="7f57469f2e"><code>7f57469</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1546">#1546</a>
Use <code>globalThis</code> instead of <code>global</code> to make Happy
DOM work in o...</li>
<li><a
href="759b4fb60e"><code>759b4fb</code></a>
fix: <a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1538">#1538</a>
Always return Promise&lt;Blob&gt; from ClipboardItem.getType() (<a
href="https://redirect.github.com/capricorn86/happy-dom/issues/1539">#1539</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/capricorn86/happy-dom/compare/v15.7.4...v15.10.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=happy-dom&package-manager=npm_and_yarn&previous-version=15.7.4&new-version=15.10.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/microsoft/typespec/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-06 21:07:06 +00:00
.chronus Propagate Namespace mutation to its types (#4937) 2024-11-06 02:17:17 +00:00
.devcontainer Add dev container configuration for repo (#3440) 2024-05-24 00:20:36 +00:00
.github Java server label (#4961) 2024-11-04 19:48:51 +00:00
.vscode Make use of starlight file tree in our docs (#4917) 2024-10-30 23:17:30 +00:00
docker Add dev container configuration for repo (#3440) 2024-05-24 00:20:36 +00:00
docs Move docs under astro (#4928) 2024-10-31 20:10:29 +00:00
e2e Update prettier config to format trailing commas to `all` (Default) (#4457) 2024-09-16 20:20:57 +00:00
eng Java server label (#4961) 2024-11-04 19:48:51 +00:00
grammars Fix type argument tmlanguage (#4089) 2024-08-08 21:42:27 +00:00
icons/raw Website & Docs Cleanup (#3002) 2024-03-11 18:56:35 -07:00
packages Bump happy-dom from 15.7.4 to 15.10.2 (#4992) 2024-11-06 21:07:06 +00:00
website fix incorrect config schema in Docs (`TypeSpecProjectSchema.output-dir`) (#4965) 2024-11-06 19:12:12 +00:00
.dockerignore Feature: docker image (#57) 2021-11-12 11:17:46 -08:00
.editorconfig Format CSharp files: add `dotnet format` to `rush format` (#490) 2022-04-29 09:46:23 -07:00
.gitattributes Add release notes for 0.56.0 (#3294) 2024-05-07 21:02:14 +00:00
.gitignore Move docs under astro (#4928) 2024-10-31 20:10:29 +00:00
.npmrc Add dev container configuration for repo (#3440) 2024-05-24 00:20:36 +00:00
.prettierignore Move docs under astro (#4928) 2024-10-31 20:10:29 +00:00
.prettierrc.json Astro format (#4811) 2024-10-22 16:06:08 +00:00
CODE_OF_CONDUCT.md Add LICENSE, CODE_OF_CONDUCT.md, and SECURITY.md 2021-10-19 14:53:13 -05:00
CONTRIBUTING.md Java server label (#4961) 2024-11-04 19:48:51 +00:00
LICENSE Add LICENSE, CODE_OF_CONDUCT.md, and SECURITY.md 2021-10-19 14:53:13 -05:00
README.md Simplify Readme (#2864) 2024-01-30 16:18:37 -08:00
SECURITY.md Add LICENSE, CODE_OF_CONDUCT.md, and SECURITY.md 2021-10-19 14:53:13 -05:00
api-extractor.base.json Bump dependencies - Sep 2024 (#4424) 2024-09-13 15:50:22 +00:00
cspell.yaml Symbol refactor (#4849) 2024-11-04 23:50:10 +00:00
eslint.config.js Moving astro website to the root (#4846) 2024-10-23 22:04:21 +00:00
package.json Astro format (#4811) 2024-10-22 16:06:08 +00:00
pnpm-lock.yaml Bump happy-dom from 15.7.4 to 15.10.2 (#4992) 2024-11-06 21:07:06 +00:00
pnpm-workspace.yaml Moving astro website to the root (#4846) 2024-10-23 22:04:21 +00:00
troubleshooting.md 1/3 TypeSpec: Find/Replace Content 2023-02-16 13:07:22 -08:00
tsconfig.base.json Add numeric data structure (#3115) 2024-04-09 16:38:16 +00:00
tsconfig.eng.json Analyze change ts (#3415) 2024-07-26 18:38:09 +00:00
tsconfig.json Add storybook for playground library (#3412) 2024-05-24 02:37:11 +00:00
tsconfig.ws.json Add astro utils common private package to reuse for typespec-azure (#4944) 2024-11-01 16:43:29 +00:00
vitest.config.ts Fix vitest not reloading JS files (#3395) 2024-05-17 21:53:01 +00:00
vitest.workspace.ts Fix anonymous union variant in tree viewer (#4353) 2024-09-05 17:45:19 +00:00

README.md

TypeSpec

Official Docs | Try TypeSpec Online | Getting Started | Language Overview

TypeSpec is a language for defining cloud service APIs and shapes. TypeSpec is a highly extensible language with primitives that can describe API shapes common among REST, OpenAPI, gRPC, and other protocols.

TypeSpec is excellent for generating many different API description formats, client and service code, documentation, and many other assets. All this while keeping your TypeSpec definition as a single source of truth.

Using TypeSpec, you can create reusable patterns for all aspects of an API and package those reusable patterns into libraries. These patterns establish "guardrails" for API designers and makes it easier to follow best practices than to deviate from them. TypeSpec also has a rich linter framework with the ability to flag anti-patterns as well as an emitter framework that lets you control of the output to ensure it follows the patterns you want.

Installation

npm install -g @typespec/compiler

Tools

The TypeSpec VS Code extension can be installed from the VS Code marketplace or directly on the command line:

tsp code install

The TypeSpec VS Extension can be installed from the VS Marketplace or directly on the command line:

tsp vs install

Usage

TypeSpec to OpenAPI 3.0 Example

This example uses the @typespec/http, @typespec/rest, and @typespec/openapi3 libraries to define a basic REST service and generate an OpenAPI 3.0 document from it.

Run the following command and select "Generic REST API":

tsp init

Hit enter a few times to confirm the defaults.

Copy the contents below into your main.tsp:

import "@typespec/http";
import "@typespec/rest";
import "@typespec/openapi3";

using TypeSpec.Http;
using TypeSpec.Rest;

/** This is a pet store service. */
@service({
  title: "Pet Store Service",
})
@server("https://example.com", "The service endpoint")
namespace PetStore;

@route("/pets")
interface Pets {
  list(): Pet[];
}

model Pet {
  @minLength(100)
  name: string;

  @minValue(0)
  @maxValue(100)
  age: int32;

  kind: "dog" | "cat" | "fish";
}

Install the dependencies of main.tsp:

tsp install

Compile it to OpenAPI 3.0:

tsp compile main.tsp --emit @typespec/openapi3

You can find the emitted OpenAPI output in ./tsp-output/openapi.json.

Advanced Scenarios

Installing nightly version

On every commit to the main branch, packages with changes are automatically published to npm with the @next tag. The packages section shows which version corresponds to the next tag for each package.

To use a nightly version of the packages, go over each one of the packages in the package.json file and update it to either the latest published @next version or @latest, whichever is the newest. You can also use the tag latest or next instead of an explicit version.

After updating the package.json file you can run npm update --force. Force is required as there might be some incompatible version requirement.

Example

// Stable setup
"dependencies": {
  "@typespec/compiler": "~0.30.0",
  "@typespec/http": "~0.14.0",
  "@typespec/rest": "~0.14.0",
  "@typespec/openapi": "~0.9.0",
}

// Consume next version
// In this example: compiler and openapi have changes but rest library has none
"dependencies": {
  "@typespec/compiler": "~0.31.0-dev.5",
  "@typespec/http": "~0.14.0",
  "@typespec/rest": "~0.14.0", // No changes to @typespec/rest library so need to stay the latest.
  "@typespec/openapi": "~0.10.0-dev.2",
}

Packages

Name Changelog Latest Next
Core functionality
@typespec/compiler Changelog
TypeSpec Libraries
@typespec/http Changelog
@typespec/rest Changelog
@typespec/openapi Changelog
@typespec/openapi3 Changelog
@typespec/versioning Changelog
TypeSpec Tools
@typespec/prettier-plugin-typespec Changelog
typespec-vs Changelog
typespec-vscode Changelog
tmlanguage-generator Changelog

@next version of the package are the latest versions available on the main branch.