@typespec/http 0.61.0-dev.3 → 0.61.0

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/src/lib.d.ts CHANGED
@@ -80,7 +80,7 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
80
80
  "header-format-required": {
81
81
  readonly default: "A format must be specified for @header when type is an array. e.g. @header({format: \"csv\"})";
82
82
  };
83
- }, Record<string, any>, "path" | "file" | "query" | "authentication" | "header" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart">;
83
+ }, Record<string, any>, "file" | "path" | "query" | "authentication" | "header" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart">;
84
84
  export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "write-visibility-not-supported" | "multipart-invalid-content-type" | "multipart-model" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "formdata-no-part-name" | "header-format-required", M extends keyof {
85
85
  "http-verb-duplicate": {
86
86
  readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
@@ -409,5 +409,5 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
409
409
  "header-format-required": {
410
410
  readonly default: "A format must be specified for @header when type is an array. e.g. @header({format: \"csv\"})";
411
411
  };
412
- }, C, M>) => import("@typespec/compiler").Diagnostic, HttpStateKeys: Record<"path" | "file" | "query" | "authentication" | "header" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart", symbol>;
412
+ }, C, M>) => import("@typespec/compiler").Diagnostic, HttpStateKeys: Record<"file" | "path" | "query" | "authentication" | "header" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart", symbol>;
413
413
  //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/streams/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/streams/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import "@typespec/streams";
2
+ import "../http.tsp";
3
+
4
+ using TypeSpec.Streams;
5
+
6
+ namespace TypeSpec.Http.Streams;
7
+
8
+ /**
9
+ * Defines a model that represents a stream protocol type whose data is described
10
+ * by `Type`.
11
+ *
12
+ * The `ContentType` and `BodyType` describe how the stream is encoded over the wire,
13
+ * while `Type` describes the data that the stream contains.
14
+ *
15
+ * @template Type The type of the stream's data.
16
+ * @template ContentType The content type of the stream.
17
+ * @template BodyType The underlying wire type of the stream.
18
+ */
19
+ @doc("")
20
+ model HttpStream<Type, ContentType extends valueof string, BodyType extends bytes | string = string>
21
+ is Stream<Type> {
22
+ @header contentType: typeof ContentType;
23
+ @body body: BodyType;
24
+ }
25
+
26
+ /**
27
+ * Describes a stream of JSON data with one JSON object per line and sets
28
+ * the content type to `application/jsonl`.
29
+ *
30
+ * The JSON data is described by `Type`.
31
+ *
32
+ * @template Type The set of models describing the JSON data in the stream.
33
+ *
34
+ * @example
35
+ *
36
+ * ```typespec
37
+ * model Message {
38
+ * id: string;
39
+ * text: string;
40
+ * }
41
+ *
42
+ * @TypeSpec.Events.events
43
+ * union Events {
44
+ * Message,
45
+ * }
46
+ *
47
+ * op subscribe(): JsonlStream<Events>;
48
+ * ```
49
+ */
50
+ @doc("")
51
+ model JsonlStream<Type> is HttpStream<Type, "application/jsonl">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http",
3
- "version": "0.61.0-dev.3",
3
+ "version": "0.61.0",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec HTTP protocol binding",
6
6
  "homepage": "https://github.com/microsoft/typespec",
@@ -28,32 +28,43 @@
28
28
  "./testing": {
29
29
  "types": "./dist/src/testing/index.d.ts",
30
30
  "default": "./dist/src/testing/index.js"
31
+ },
32
+ "./streams": {
33
+ "typespec": "./lib/streams/main.tsp",
34
+ "types": "./dist/src/streams/index.d.ts",
35
+ "default": "./dist/src/streams/index.js"
31
36
  }
32
37
  },
33
38
  "engines": {
34
39
  "node": ">=18.0.0"
35
40
  },
36
41
  "files": [
37
- "lib/*.tsp",
42
+ "lib/**/*.tsp",
38
43
  "dist/**",
39
44
  "!dist/test/**"
40
45
  ],
41
46
  "peerDependencies": {
42
- "@typespec/compiler": "~0.60.1 || >=0.61.0-dev <0.61.0"
47
+ "@typespec/compiler": "~0.61.0",
48
+ "@typespec/streams": "~0.61.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "@typespec/streams": {
52
+ "optional": true
53
+ }
43
54
  },
44
55
  "devDependencies": {
45
56
  "@types/node": "~22.7.1",
46
- "@typespec/compiler": "~0.60.1 || >=0.61.0-dev <0.61.0",
47
- "@typespec/library-linter": "~0.60.0 || >=0.61.0-dev <0.61.0",
48
57
  "@vitest/coverage-v8": "^2.1.1",
49
58
  "@vitest/ui": "^2.1.1",
50
59
  "c8": "^10.1.2",
51
60
  "rimraf": "~6.0.1",
52
61
  "typescript": "~5.6.2",
53
62
  "vitest": "^2.1.1",
63
+ "@typespec/compiler": "~0.61.0",
64
+ "@typespec/streams": "~0.61.0",
65
+ "@typespec/library-linter": "~0.61.0",
54
66
  "@typespec/tspd": "~0.46.0"
55
67
  },
56
- "dependencies": {},
57
68
  "scripts": {
58
69
  "clean": "rimraf ./dist ./temp",
59
70
  "build": "npm run gen-extern-signature && tsc -p . && npm run lint-typespec-library",