Skip to content

Commit

Permalink
Merge branch 'main' into spread-source
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Apr 23, 2024
2 parents 5ee8c31 + 1987a56 commit 634ce80
Show file tree
Hide file tree
Showing 406 changed files with 19,659 additions and 140 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/actual-std-lib-2024-3-15-15-53-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/compiler"
---

`--nostdlib` flag will now work by only applying to optional standard library types
8 changes: 8 additions & 0 deletions .chronus/changes/actual-std-lib-2024-3-15-15-55-33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/playground"
---

Add support for new intrinsic vs std lib split in the compiler.
8 changes: 8 additions & 0 deletions .chronus/changes/fix-password-flow-2024-3-19-16-22-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/http"
---

Fix password flow defining `authorizationUrl` instead of `tokenUrl`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ docs/**/js-api/

# csharp emitter
!packages/http-client-csharp/package-lock.json
packages/http-client-csharp/generator/artifacts/
3 changes: 2 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"type": "process",
"command": "node",
"args": [
"${workspaceFolder}/packages/compiler/node_modules/typescript/lib/tsc.js",
"${workspaceFolder}/node_modules/typescript/lib/tsc.js",
"--build",
"./tsconfig.ws.json",
"--watch"
],
"isBackground": true,
Expand Down
12 changes: 6 additions & 6 deletions docs/libraries/http/reference/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ model TypeSpec.Http.PasswordFlow

#### Properties

| Name | Type | Description |
| ---------------- | --------------------------------------- | --------------------------------- |
| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow |
| authorizationUrl | `string` | the authorization URL |
| refreshUrl? | `string` | the refresh URL |
| scopes? | `string[]` | list of scopes for the credential |
| Name | Type | Description |
| ----------- | --------------------------------------- | --------------------------------- |
| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow |
| tokenUrl | `string` | the token URL |
| refreshUrl? | `string` | the refresh URL |
| scopes? | `string[]` | list of scopes for the credential |

### `PlainData` {#TypeSpec.Http.PlainData}

Expand Down
11 changes: 9 additions & 2 deletions eng/common/pipelines/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
trigger: none
trigger:
branches:
include:
- gh-readonly-queue/*

pr:
branches:
include:
Expand All @@ -18,14 +22,17 @@ extends:
- job: InitJob
displayName: Initialize
steps:
- script: node $(Build.SourcesDirectory)/eng/common/scripts/resolve-target-branch.js
displayName: Resolve target branch

- task: PowerShell@2
displayName: "Analyze PR changes"
name: InitStep
inputs:
pwsh: true
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Analyze-Changes.ps1
arguments: >
-TargetBranch $(System.PullRequest.TargetBranch)
-TargetBranch $(TARGET_BRANCH)
workingDirectory: $(Build.SourcesDirectory)

# Run csharp stages if RunCSharp == true
Expand Down
36 changes: 30 additions & 6 deletions eng/common/scripts/Analyze-Changes.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,51 @@ Describe 'Analyze-Changes' {
}

It 'Should return package variables if package specific changes are detected' {
$variables = Get-ActiveVariables @(
$actual = Get-ActiveVariables @(
"packages/http-client-csharp/src/constants.ts"
)

$variables | Should -Be 'RunCSharp'
$expected = @('RunCSharp')

$actual | ForEach-Object {
$_ | Should -BeIn $expected
}
}

It 'Should return RunCore if common files are changed' {
$variables = Get-ActiveVariables @(
$actual = Get-ActiveVariables @(
"packages/compiler/package.json"
)

$variables | Should -Be 'RunCore'
$expected = @('RunCore')

$actual | ForEach-Object {
$_ | Should -BeIn $expected
}
}

It 'Should return a combination of core and isolated packages' {
$variables = Get-ActiveVariables @(
$actual = Get-ActiveVariables @(
"packages/http-client-csharp/src/constants.ts",
"packages/compiler/package.json"
)

$variables | Should -Be 'RunCore', 'RunCSharp'
$expected = @('RunCore', 'RunCSharp')

$actual | ForEach-Object {
$_ | Should -BeIn $expected
}
}

It 'Should return RunCSharp and RunCore if .editorconfig is changed' {
$actual = Get-ActiveVariables @(
".editorconfig"
)

$expected = @('RunCore', 'RunCSharp')

$actual | ForEach-Object {
$_ | Should -BeIn $expected
}
}
}
21 changes: 13 additions & 8 deletions eng/common/scripts/Analyze-Changes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ param(

# Represents an isolated package which has its own stages in typespec - ci pipeline
class IsolatedPackage {
[string] $Path
[string[]] $Paths
[string] $RunVariable
[bool] $RunValue

IsolatedPackage([string]$path, [string]$runVariable, [bool]$runValue) {
$this.Path = $path
IsolatedPackage([string[]]$paths, [string]$runVariable, [bool]$runValue) {
$this.Paths = $paths
$this.RunVariable = $runVariable
$this.RunValue = $runValue
}
}

# Emitter packages in the repo
$isolatedPackages = @{
"http-client-csharp" = [IsolatedPackage]::new("packages/http-client-csharp", "RunCSharp", $false)
"http-client-java" = [IsolatedPackage]::new("packages/http-client-java", "RunJava", $false)
"http-client-typescript" = [IsolatedPackage]::new("packages/http-client-typescript", "RunTypeScript", $false)
"http-client-python" = [IsolatedPackage]::new("packages/http-client-python", "RunPython", $false)
"http-client-csharp" = [IsolatedPackage]::new(@("packages/http-client-csharp", ".editorconfig"), "RunCSharp", $false)
"http-client-java" = [IsolatedPackage]::new(@("packages/http-client-java"), "RunJava", $false)
"http-client-typescript" = [IsolatedPackage]::new(@("packages/http-client-typescript"), "RunTypeScript", $false)
"http-client-python" = [IsolatedPackage]::new(@("packages/http-client-python"), "RunPython", $false)
}

# A tree representation of a set of files
Expand Down Expand Up @@ -125,7 +125,12 @@ function Get-ActiveVariables($changes) {
if (-not $runIsolated) {
# set each isolated package flag
foreach ($package in $isolatedPackages.Values) {
$package.RunValue = $root.PathExists($package.Path)
foreach ($path in $package.Paths) {
$package.RunValue = $package.RunValue -or $root.PathExists($path)
if ($package.RunValue) {
break
}
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions eng/common/scripts/resolve-target-branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-check
const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"];
const currentBranch = process.env["BUILD_SOURCEBRANCH"];

console.log("Branches:", {
prTargetBranch,
currentBranch,
});

if (prTargetBranch !== undefined) {
console.log("Target branch is", prTargetBranch);
console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`);
} else if (currentBranch) {
const match = currentBranch.match(/refs\/heads\/gh-readonly-queue\/(.*)\/pr-.*/);
if (match !== null) {
const targetBranch = match[1];
console.log("Target branch is", targetBranch);
console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`);
}
} else {
console.log("Failed to resolve target branch.");
process.exit(1);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "../dist/src/lib/intrinsic-decorators.js";

// This file contains all the intrinsic types of typespec. Everything here will always be loaded
namespace TypeSpec;

/**
Expand Down Expand Up @@ -122,20 +125,6 @@ scalar duration;
*/
scalar boolean;

/**
* Represent a 32-bit unix timestamp datetime with 1s of granularity.
* It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.
*/
@encode("unixTimestamp", int32)
scalar unixTimestamp32 extends utcDateTime;

/**
* Represent a model
*/
// Deprecated June 2023 sprint
#deprecated "object is deprecated. Please use {} for an empty model, `Record<unknown>` for a record with unknown property types, `unknown[]` for an array."
model object {}

/**
* @dev Array model type, equivalent to `Element[]`
* @template Element The type of the array elements
Expand All @@ -149,64 +138,3 @@ model Array<Element> {}
*/
@indexer(string, Element)
model Record<Element> {}

/**
* Represent a URL string as described by https://url.spec.whatwg.org/
*/
scalar url extends string;

/**
* Represents a collection of optional properties.
*
* @template Source An object whose spread properties are all optional.
*/
@doc("The template for adding optional properties.")
@withOptionalProperties
model OptionalProperties<Source> {
...Source;
}

/**
* Represents a collection of updateable properties.
*
* @template Source An object whose spread properties are all updateable.
*/
@doc("The template for adding updateable properties.")
@withUpdateableProperties
model UpdateableProperties<Source> {
...Source;
}

/**
* Represents a collection of omitted properties.
*
* @template Source An object whose properties are spread.
* @template Keys The property keys to omit.
*/
@doc("The template for omitting properties.")
@withoutOmittedProperties(Keys)
model OmitProperties<Source, Keys extends string> {
...Source;
}

/**
* Represents a collection of properties with default values omitted.
*
* @template Source An object whose spread property defaults are all omitted.
*/
@withoutDefaultValues
model OmitDefaults<Source> {
...Source;
}

/**
* Applies a visibility setting to a collection of properties.
*
* @template Source An object whose properties are spread.
* @template Visibility The visibility to apply to all properties.
*/
@doc("The template for setting the default visibility of key properties.")
@withDefaultKeyVisibility(Visibility)
model DefaultKeyVisibility<Source, Visibility extends valueof string> {
...Source;
}
4 changes: 0 additions & 4 deletions packages/compiler/lib/main.tsp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../dist/src/lib/decorators.js";
import "../../dist/src/lib/decorators.js";

using TypeSpec.Reflection;

Expand Down
5 changes: 5 additions & 0 deletions packages/compiler/lib/std/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// TypeSpec standard library. Everything in here can be omitted by using `--nostdlib` cli flag or `nostdlib` in the config.
import "./types.tsp";
import "./decorators.tsp";
import "./reflection.tsp";
import "./projected-names.tsp";
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 634ce80

Please sign in to comment.