@typespec/compiler 0.67.0-dev.26 → 0.67.0-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated-defs/TypeSpec.d.ts +27 -0
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/ast/index.d.ts +14 -0
- package/dist/src/ast/index.d.ts.map +1 -0
- package/dist/src/ast/index.js +13 -0
- package/dist/src/ast/index.js.map +1 -0
- package/dist/src/core/checker.d.ts +5 -16
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +6 -0
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +8 -0
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/program.d.ts +5 -7
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/types.d.ts +0 -24
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/index.d.ts +9 -11
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -10
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/decorators.d.ts +13 -1
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +70 -0
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/tsp-index.d.ts.map +1 -1
- package/dist/src/lib/tsp-index.js +2 -1
- package/dist/src/lib/tsp-index.js.map +1 -1
- package/dist/src/testing/code-fix-testing.js +1 -1
- package/dist/src/testing/code-fix-testing.js.map +1 -1
- package/dist/src/testing/expect.d.ts +1 -7
- package/dist/src/testing/expect.d.ts.map +1 -1
- package/dist/src/testing/expect.js +0 -12
- package/dist/src/testing/expect.js.map +1 -1
- package/dist/src/testing/index.d.ts +6 -6
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +5 -6
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/testing/source-utils.d.ts +20 -0
- package/dist/src/testing/source-utils.d.ts.map +1 -0
- package/dist/src/testing/source-utils.js +23 -0
- package/dist/src/testing/source-utils.js.map +1 -0
- package/dist/src/testing/test-server-host.d.ts +0 -19
- package/dist/src/testing/test-server-host.d.ts.map +1 -1
- package/dist/src/testing/test-server-host.js +0 -22
- package/dist/src/testing/test-server-host.js.map +1 -1
- package/lib/std/decorators.tsp +35 -0
- package/package.json +4 -1
|
@@ -16,25 +16,6 @@ export interface TestServerHost extends ServerHost, TestFileSystem {
|
|
|
16
16
|
export declare function createTestServerHost(options?: TestHostOptions & {
|
|
17
17
|
workspaceDir?: string;
|
|
18
18
|
}): Promise<TestServerHost>;
|
|
19
|
-
/**
|
|
20
|
-
* Takes source code with a cursor position indicated by the given marker
|
|
21
|
-
* ("┆" by default), and returns the source without the marker along with
|
|
22
|
-
* the cursor position.
|
|
23
|
-
*/
|
|
24
|
-
export declare function extractCursor(sourceWithCursor: string, marker?: string): {
|
|
25
|
-
source: string;
|
|
26
|
-
pos: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Takes source code with start and end positions indicated by given marker
|
|
30
|
-
* ("~~~" by default) and returns the source without the markers along with
|
|
31
|
-
* the start and end positions.
|
|
32
|
-
*/
|
|
33
|
-
export declare function extractSquiggles(sourceWithSquiggles: string, marker?: string): {
|
|
34
|
-
source: string;
|
|
35
|
-
pos: number;
|
|
36
|
-
end: number;
|
|
37
|
-
};
|
|
38
19
|
/**
|
|
39
20
|
* Extracts all identifiers marked with trailing empty comments from source
|
|
40
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-server-host.d.ts","sourceRoot":"","sources":["../../../src/testing/test-server-host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-server-host.d.ts","sourceRoot":"","sources":["../../../src/testing/test-server-host.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAgB,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAuB,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,cAAe,SAAQ,UAAU,EAAE,cAAc;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IACxD,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IACjE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IACzC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,UAAU,EAAE,CAAC;IACpD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,2BA0E/F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAanE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ok } from "assert";
|
|
2
1
|
import { pathToFileURL } from "url";
|
|
3
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
4
3
|
import { parse, visitChildren } from "../core/parser.js";
|
|
@@ -78,27 +77,6 @@ export async function createTestServerHost(options) {
|
|
|
78
77
|
serverHost.server = server;
|
|
79
78
|
return serverHost;
|
|
80
79
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Takes source code with a cursor position indicated by the given marker
|
|
83
|
-
* ("┆" by default), and returns the source without the marker along with
|
|
84
|
-
* the cursor position.
|
|
85
|
-
*/
|
|
86
|
-
export function extractCursor(sourceWithCursor, marker = "┆") {
|
|
87
|
-
const pos = sourceWithCursor.indexOf(marker);
|
|
88
|
-
ok(pos >= 0, "marker not found");
|
|
89
|
-
const source = sourceWithCursor.replace(marker, "");
|
|
90
|
-
return { source, pos };
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Takes source code with start and end positions indicated by given marker
|
|
94
|
-
* ("~~~" by default) and returns the source without the markers along with
|
|
95
|
-
* the start and end positions.
|
|
96
|
-
*/
|
|
97
|
-
export function extractSquiggles(sourceWithSquiggles, marker = "~~~") {
|
|
98
|
-
const { source: sourceWithoutFistSquiggle, pos } = extractCursor(sourceWithSquiggles, marker);
|
|
99
|
-
const { source, pos: end } = extractCursor(sourceWithoutFistSquiggle, marker);
|
|
100
|
-
return { source, pos, end };
|
|
101
|
-
}
|
|
102
80
|
/**
|
|
103
81
|
* Extracts all identifiers marked with trailing empty comments from source
|
|
104
82
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-server-host.js","sourceRoot":"","sources":["../../../src/testing/test-server-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"test-server-host.js","sourceRoot":"","sources":["../../../src/testing/test-server-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,eAAe,EA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CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/lib/std/decorators.tsp
CHANGED
|
@@ -108,6 +108,41 @@ extern dec service(target: Namespace, options?: valueof ServiceOptions);
|
|
|
108
108
|
*/
|
|
109
109
|
extern dec error(target: Model);
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Applies a media type hint to a TypeSpec type. Emitters and libraries may choose to use this hint to determine how a
|
|
113
|
+
* type should be serialized. For example, the `@typespec/http` library will use the media type hint of the response
|
|
114
|
+
* body type as a default `Content-Type` if one is not explicitly specified in the operation.
|
|
115
|
+
*
|
|
116
|
+
* Media types (also known as MIME types) are defined by RFC 6838. The media type hint should be a valid media type
|
|
117
|
+
* string as defined by the RFC, but the decorator does not enforce or validate this constraint.
|
|
118
|
+
*
|
|
119
|
+
* Notes: the applied media type is _only_ a hint. It may be overridden or not used at all. Media type hints are
|
|
120
|
+
* inherited by subtypes. If a media type hint is applied to a model, it will be inherited by all other models that
|
|
121
|
+
* `extend` it unless they delcare their own media type hint.
|
|
122
|
+
*
|
|
123
|
+
* @param mediaType The media type hint to apply to the target type.
|
|
124
|
+
*
|
|
125
|
+
* @example create a model that serializes as XML by default
|
|
126
|
+
*
|
|
127
|
+
* ```tsp
|
|
128
|
+
* @mediaTypeHint("application/xml")
|
|
129
|
+
* model Example {
|
|
130
|
+
* @visibility(Lifecycle.Read)
|
|
131
|
+
* id: string;
|
|
132
|
+
*
|
|
133
|
+
* name: string;
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
extern dec mediaTypeHint(target: Model | Scalar | Enum | Union, mediaType: valueof string);
|
|
138
|
+
|
|
139
|
+
// Cannot apply this to the scalar itself. Needs to be applied here so that we don't crash nostdlib scenarios
|
|
140
|
+
@@mediaTypeHint(TypeSpec.bytes, "application/octet-stream");
|
|
141
|
+
|
|
142
|
+
// @@mediaTypeHint(TypeSpec.string "text/plain") -- This is hardcoded in the compiler to avoid circularity
|
|
143
|
+
// between the initialization of the string scalar and the `valueof string` required to call the
|
|
144
|
+
// `mediaTypeHint` decorator.
|
|
145
|
+
|
|
111
146
|
/**
|
|
112
147
|
* Specify a known data format hint for this string type. For example `uuid`, `uri`, etc.
|
|
113
148
|
* This differs from the `@pattern` decorator which is meant to specify a regular expression while `@format` accepts a known format name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/compiler",
|
|
3
|
-
"version": "0.67.0-dev.
|
|
3
|
+
"version": "0.67.0-dev.30",
|
|
4
4
|
"description": "TypeSpec Compiler Preview",
|
|
5
5
|
"author": "Microsoft Corporation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"types": "./dist/module-resolver/module-resolver.d.ts",
|
|
39
39
|
"default": "./dist/src/module-resolver/module-resolver.js"
|
|
40
40
|
},
|
|
41
|
+
"./ast": {
|
|
42
|
+
"import": "./dist/src/ast/index.js"
|
|
43
|
+
},
|
|
41
44
|
"./emitter-framework": {
|
|
42
45
|
"types": "./dist/src/emitter-framework/index.d.ts",
|
|
43
46
|
"default": "./dist/src/emitter-framework/index.js"
|