@microsoft/typespec-msgraph 0.0.1-Preview.14 → 0.0.1-Preview.16

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.
Files changed (146) hide show
  1. package/dist/src/components/annotations.js +2 -2
  2. package/dist/src/components/annotations.js.map +1 -1
  3. package/dist/src/components/entity-container-element.js +2 -6
  4. package/dist/src/components/entity-container-element.js.map +1 -1
  5. package/dist/src/components/open-property-type-constraint-annotation-element.d.ts +5 -0
  6. package/dist/src/components/open-property-type-constraint-annotation-element.d.ts.map +1 -0
  7. package/dist/src/components/open-property-type-constraint-annotation-element.js +7 -0
  8. package/dist/src/components/open-property-type-constraint-annotation-element.js.map +1 -0
  9. package/dist/src/components/operation-element.js +2 -2
  10. package/dist/src/components/operation-element.js.map +1 -1
  11. package/dist/src/components/property-element.js +1 -1
  12. package/dist/src/components/property-element.js.map +1 -1
  13. package/dist/src/components/structured-type-element.d.ts.map +1 -1
  14. package/dist/src/components/structured-type-element.js +7 -5
  15. package/dist/src/components/structured-type-element.js.map +1 -1
  16. package/dist/src/components/update-restrictions-annotation.d.ts +2 -1
  17. package/dist/src/components/update-restrictions-annotation.d.ts.map +1 -1
  18. package/dist/src/components/update-restrictions-annotation.js +6 -4
  19. package/dist/src/components/update-restrictions-annotation.js.map +1 -1
  20. package/dist/src/decorators/address-url-msa.d.ts +12 -0
  21. package/dist/src/decorators/address-url-msa.d.ts.map +1 -0
  22. package/dist/src/decorators/address-url-msa.js +19 -0
  23. package/dist/src/decorators/address-url-msa.js.map +1 -0
  24. package/dist/src/decorators/address-url.d.ts.map +1 -1
  25. package/dist/src/decorators/function.d.ts +7 -2
  26. package/dist/src/decorators/function.d.ts.map +1 -1
  27. package/dist/src/decorators/function.js +2 -2
  28. package/dist/src/decorators/function.js.map +1 -1
  29. package/dist/src/decorators/graph-route.d.ts +1 -0
  30. package/dist/src/decorators/graph-route.d.ts.map +1 -1
  31. package/dist/src/decorators/graph-route.js +17 -0
  32. package/dist/src/decorators/graph-route.js.map +1 -1
  33. package/dist/src/decorators/index.d.ts +13 -10
  34. package/dist/src/decorators/index.d.ts.map +1 -1
  35. package/dist/src/decorators/index.js +13 -10
  36. package/dist/src/decorators/index.js.map +1 -1
  37. package/dist/src/decorators/media.d.ts +10 -0
  38. package/dist/src/decorators/media.d.ts.map +1 -0
  39. package/dist/src/decorators/media.js +16 -0
  40. package/dist/src/decorators/media.js.map +1 -0
  41. package/dist/src/decorators/passthrough-address-url-msa.d.ts +11 -0
  42. package/dist/src/decorators/passthrough-address-url-msa.d.ts.map +1 -0
  43. package/dist/src/decorators/passthrough-address-url-msa.js +17 -0
  44. package/dist/src/decorators/passthrough-address-url-msa.js.map +1 -0
  45. package/dist/src/decorators/passthrough-address-url.d.ts +11 -0
  46. package/dist/src/decorators/passthrough-address-url.d.ts.map +1 -0
  47. package/dist/src/decorators/passthrough-address-url.js +17 -0
  48. package/dist/src/decorators/passthrough-address-url.js.map +1 -0
  49. package/dist/src/dom/error-interceptor.d.ts +2 -0
  50. package/dist/src/dom/error-interceptor.d.ts.map +1 -0
  51. package/dist/src/dom/error-interceptor.js +13 -0
  52. package/dist/src/dom/error-interceptor.js.map +1 -0
  53. package/dist/src/dom/renderer.d.ts +1 -0
  54. package/dist/src/dom/renderer.d.ts.map +1 -1
  55. package/dist/src/dom/renderer.js +1 -0
  56. package/dist/src/dom/renderer.js.map +1 -1
  57. package/dist/src/entities/address-url.d.ts +4 -0
  58. package/dist/src/entities/address-url.d.ts.map +1 -1
  59. package/dist/src/entities/address-url.js +40 -11
  60. package/dist/src/entities/address-url.js.map +1 -1
  61. package/dist/src/entities/annotations.d.ts +9 -2
  62. package/dist/src/entities/annotations.d.ts.map +1 -1
  63. package/dist/src/entities/annotations.js +34 -3
  64. package/dist/src/entities/annotations.js.map +1 -1
  65. package/dist/src/entities/entity-container.d.ts +6 -0
  66. package/dist/src/entities/entity-container.d.ts.map +1 -1
  67. package/dist/src/entities/entity-container.js +7 -1
  68. package/dist/src/entities/entity-container.js.map +1 -1
  69. package/dist/src/entities/model.d.ts +8 -4
  70. package/dist/src/entities/model.d.ts.map +1 -1
  71. package/dist/src/entities/model.js +54 -8
  72. package/dist/src/entities/model.js.map +1 -1
  73. package/dist/src/entities/ms-graph-route.d.ts.map +1 -1
  74. package/dist/src/entities/ms-graph-route.js +15 -15
  75. package/dist/src/entities/ms-graph-route.js.map +1 -1
  76. package/dist/src/entities/operation.d.ts +1 -0
  77. package/dist/src/entities/operation.d.ts.map +1 -1
  78. package/dist/src/entities/operation.js +11 -5
  79. package/dist/src/entities/operation.js.map +1 -1
  80. package/dist/src/index.d.ts +1 -0
  81. package/dist/src/index.d.ts.map +1 -1
  82. package/dist/src/index.js +1 -0
  83. package/dist/src/index.js.map +1 -1
  84. package/dist/src/lib.d.ts +17 -3
  85. package/dist/src/lib.d.ts.map +1 -1
  86. package/dist/src/lib.js +11 -5
  87. package/dist/src/lib.js.map +1 -1
  88. package/dist/src/linter.d.ts +2 -0
  89. package/dist/src/linter.d.ts.map +1 -0
  90. package/dist/src/linter.js +17 -0
  91. package/dist/src/linter.js.map +1 -0
  92. package/dist/src/rules/address-url.d.ts +13 -0
  93. package/dist/src/rules/address-url.d.ts.map +1 -1
  94. package/dist/src/rules/address-url.js +128 -7
  95. package/dist/src/rules/address-url.js.map +1 -1
  96. package/dist/src/rules/contains.d.ts +1 -1
  97. package/dist/src/rules/contains.js +1 -1
  98. package/dist/src/rules/expand.d.ts.map +1 -1
  99. package/dist/src/rules/expand.js +3 -1
  100. package/dist/src/rules/expand.js.map +1 -1
  101. package/dist/src/rules/graph-route.d.ts +2 -0
  102. package/dist/src/rules/graph-route.d.ts.map +1 -1
  103. package/dist/src/rules/graph-route.js +65 -1
  104. package/dist/src/rules/graph-route.js.map +1 -1
  105. package/dist/src/rules/index.d.ts +3 -1
  106. package/dist/src/rules/index.d.ts.map +1 -1
  107. package/dist/src/rules/index.js +3 -1
  108. package/dist/src/rules/index.js.map +1 -1
  109. package/dist/src/rules/media.d.ts +10 -0
  110. package/dist/src/rules/media.d.ts.map +1 -0
  111. package/dist/src/rules/media.js +122 -0
  112. package/dist/src/rules/media.js.map +1 -0
  113. package/dist/src/rules/model.d.ts +4 -0
  114. package/dist/src/rules/model.d.ts.map +1 -0
  115. package/dist/src/rules/model.js +36 -0
  116. package/dist/src/rules/model.js.map +1 -0
  117. package/dist/src/rules/record-t.d.ts +5 -0
  118. package/dist/src/rules/record-t.d.ts.map +1 -0
  119. package/dist/src/rules/record-t.js +78 -0
  120. package/dist/src/rules/record-t.js.map +1 -0
  121. package/dist/src/rules/reference-target.d.ts +1 -1
  122. package/dist/src/rules/reference-target.d.ts.map +1 -1
  123. package/dist/src/rules/reference-target.js +11 -12
  124. package/dist/src/rules/reference-target.js.map +1 -1
  125. package/dist/src/utils.d.ts +3 -0
  126. package/dist/src/utils.d.ts.map +1 -1
  127. package/dist/src/utils.js +24 -5
  128. package/dist/src/utils.js.map +1 -1
  129. package/dist/src/validate.d.ts.map +1 -1
  130. package/dist/src/validate.js +12 -3
  131. package/dist/src/validate.js.map +1 -1
  132. package/lib/bodies.tsp +71 -0
  133. package/lib/decorators.tsp +39 -4
  134. package/lib/msgraph.tsp +1 -0
  135. package/lib/porcelain.tsp +43 -18
  136. package/lib/responses.tsp +4 -52
  137. package/lib/shared-models.tsp +2 -2
  138. package/package.json +4 -4
  139. package/dist/src/decorators/has-stream.d.ts +0 -10
  140. package/dist/src/decorators/has-stream.d.ts.map +0 -1
  141. package/dist/src/decorators/has-stream.js +0 -17
  142. package/dist/src/decorators/has-stream.js.map +0 -1
  143. package/dist/src/rules/has-stream.d.ts +0 -3
  144. package/dist/src/rules/has-stream.d.ts.map +0 -1
  145. package/dist/src/rules/has-stream.js +0 -30
  146. package/dist/src/rules/has-stream.js.map +0 -1
package/lib/porcelain.tsp CHANGED
@@ -23,14 +23,14 @@ namespace MsGraph;
23
23
  ): TResponse | TErrorResponse;
24
24
 
25
25
  op ResourceOperation<
26
- TResource extends {},
26
+ TResource,
27
27
  TParams,
28
28
  TResponse,
29
29
  TErrorResponse = ResourceErrorResponse
30
30
  > is GraphFoundations.Operation<TParams, TResponse, TErrorResponse>;
31
31
 
32
32
  op CollectionOperation<
33
- TResource extends {},
33
+ TResource,
34
34
  TParams,
35
35
  TResponse,
36
36
  TErrorResponse = CollectionErrorResponse
@@ -42,7 +42,7 @@ namespace MsGraph;
42
42
  interface GraphOps {
43
43
 
44
44
  @get op GetCollection<
45
- TResource extends {} = Automatic.CalculatedResourceType,
45
+ TResource = Automatic.CalculatedResourceType,
46
46
  TParams = {... Automatic.GraphRouteParams},
47
47
  TResponse = CollectionResponse<TResource>,
48
48
  TErrorResponse = CollectionErrorResponse
@@ -50,7 +50,7 @@ namespace MsGraph;
50
50
  TResource, TParams, TResponse, TErrorResponse>;
51
51
 
52
52
  @get op GetPagedCollection<
53
- TResource extends {} = Automatic.CalculatedResourceType,
53
+ TResource = Automatic.CalculatedResourceType,
54
54
  TParams = {... Automatic.GraphRouteParams},
55
55
  TResponse = PagedCollectionResponse<TResource>,
56
56
  TErrorResponse = CollectionErrorResponse
@@ -60,23 +60,39 @@ namespace MsGraph;
60
60
  // TODO: GetDelta? FUnction etc.?
61
61
 
62
62
  @post op Post<
63
- TResource extends {} = Automatic.CalculatedResourceType,
63
+ TResource = Automatic.CalculatedResourceType,
64
64
  TParams = { ... Automatic.GraphRouteParams, @body body: TResource },
65
65
  TResponse = ResourceCreatedResponse<TResource>,
66
66
  TErrorResponse = CollectionErrorResponse
67
67
  > is Foundations.GraphFoundations.CollectionOperation<
68
68
  TResource, TParams, TResponse, TErrorResponse>;
69
69
 
70
+ @post op PostMediaValue<
71
+ TResource,
72
+ TParams = { ... Automatic.GraphRouteParams, ...TResource },
73
+ TResponse = ResourceCreatedResponse<TResource>,
74
+ TErrorResponse = CollectionErrorResponse
75
+ > is Foundations.GraphFoundations.CollectionOperation<
76
+ TResource, TParams, TResponse, TErrorResponse>;
77
+
70
78
  @get op GetResource<
71
- TResource extends {} = Automatic.CalculatedResourceType,
79
+ TResource = Automatic.CalculatedResourceType,
72
80
  TParams = {... Automatic.GraphRouteParams},
73
81
  TResponse = ResourceResponse<TResource>,
74
82
  TErrorResponse = ResourceErrorResponse
75
83
  > is Foundations.GraphFoundations.ResourceOperation<
76
84
  TResource, TParams, TResponse, TErrorResponse>;
77
85
 
86
+ @get op GetMediaValue<
87
+ TResource,
88
+ TParams = {... Automatic.GraphRouteParams, @path value:"$value"},
89
+ TResponse = ResourceResponse<TResource>,
90
+ TErrorResponse = ResourceErrorResponse
91
+ > is Foundations.GraphFoundations.ResourceOperation<
92
+ TResource, TParams, TResponse, TErrorResponse>;
93
+
78
94
  @delete op Delete<
79
- TResource extends {} = Automatic.CalculatedResourceType,
95
+ TResource = Automatic.CalculatedResourceType,
80
96
  TParams = {... Automatic.GraphRouteParams},
81
97
  TResponse = EmptyResponse,
82
98
  TErrorResponse = ResourceErrorResponse
@@ -84,41 +100,50 @@ namespace MsGraph;
84
100
  TResource, TParams, TResponse, TErrorResponse>;
85
101
 
86
102
  @patch op PatchNoResponse<
87
- TResource extends {} = Automatic.CalculatedResourceType,
88
- TParams = {... Automatic.GraphRouteParams},
103
+ TResource = Automatic.CalculatedResourceType,
104
+ TParams = {... Automatic.GraphRouteParams, @body body: TResource},
89
105
  TResponse = EmptyResponse,
90
106
  TErrorResponse = ResourceErrorResponse
91
107
  > is Foundations.GraphFoundations.ResourceOperation<
92
108
  TResource, TParams, TResponse, TErrorResponse>;
93
109
 
94
110
  @patch op PatchWithResponse<
95
- TResource extends {} = Automatic.CalculatedResourceType,
96
- TParams = {... Automatic.GraphRouteParams},
111
+ TResource = Automatic.CalculatedResourceType,
112
+ TParams = {... Automatic.GraphRouteParams, @body body: TResource},
97
113
  TResponse = ResourceResponse<TResource>,
98
114
  TErrorResponse = ResourceErrorResponse
99
115
  > is Foundations.GraphFoundations.ResourceOperation<
100
116
  TResource, TParams, TResponse, TErrorResponse>;
101
117
 
102
118
  @put op PutNoResponse<
103
- TResource extends {} = Automatic.CalculatedResourceType,
104
- TParams = {... Automatic.GraphRouteParams},
119
+ TResource = Automatic.CalculatedResourceType,
120
+ TParams = {... Automatic.GraphRouteParams, @body body: TResource},
105
121
  TResponse = EmptyResponse,
106
122
  TErrorResponse = ResourceErrorResponse
107
123
  > is Foundations.GraphFoundations.ResourceOperation<
108
124
  TResource, TParams, TResponse, TErrorResponse>;
109
125
 
110
126
  @put op PutWithResponse<
111
- TResource extends {} = Automatic.CalculatedResourceType,
112
- TParams = {... Automatic.GraphRouteParams},
127
+ TResource = Automatic.CalculatedResourceType,
128
+ TParams = {... Automatic.GraphRouteParams, @body body: TResource},
113
129
  TResponse = ResourceResponse<TResource>,
114
130
  TErrorResponse = ResourceErrorResponse
115
131
  > is Foundations.GraphFoundations.ResourceOperation<
116
132
  TResource, TParams, TResponse, TErrorResponse>;
117
133
 
134
+ @put op PutMediaValueNoResponse<
135
+ TResource,
136
+ TParams = {... Automatic.GraphRouteParams, @path value:"$value", ...TResource},
137
+ TResponse = EmptyResponse,
138
+ TErrorResponse = ResourceErrorResponse
139
+ > is Foundations.GraphFoundations.ResourceOperation<
140
+ TResource, TParams, TResponse, TErrorResponse>;
141
+
142
+
118
143
  @action op Action<
119
144
  TReturnType = void,
120
145
  TActionParams extends {} = {},
121
- TResource extends {} = Automatic.CalculatedResourceType,
146
+ TResource = Automatic.CalculatedResourceType,
122
147
  TParams = {... Automatic.GraphRouteParams, ... TActionParams},
123
148
  TResponse = TReturnType,
124
149
  TErrorResponse = MsGraph.Responses.OperationErrorResponse
@@ -127,7 +152,7 @@ namespace MsGraph;
127
152
  @function op Function<
128
153
  TReturnType,
129
154
  TFunctionParams extends {} = {},
130
- TResource extends {} = Automatic.CalculatedResourceType,
155
+ TResource = Automatic.CalculatedResourceType,
131
156
  TParams = {... Automatic.GraphRouteParams, ... TFunctionParams},
132
157
  TResponse = TReturnType,
133
158
  TErrorResponse = MsGraph.Responses.OperationErrorResponse
@@ -137,7 +162,7 @@ namespace MsGraph;
137
162
 
138
163
  namespace Automatic {
139
164
  @doc("Marker type to allow injection of parameters from @route decorator.")
140
- model GraphRouteParams { graphRouteParams: string }
165
+ model GraphRouteParams { @path graphRouteParams: string }
141
166
 
142
167
  // TODO: Needs direct support in the graphRoute decorator code to be able to make use of this.
143
168
  @doc("Marker type to indicate to emitter that it should calculate resource from the Resource type of the containing interface's extended interface.")
package/lib/responses.tsp CHANGED
@@ -5,60 +5,12 @@
5
5
  import "@typespec/http";
6
6
  import "@microsoft/typespec-msgraph";
7
7
  import "./shared-models.tsp";
8
+ import "./bodies.tsp";
8
9
 
9
10
  using TypeSpec.Http;
10
11
  using MsGraph;
11
12
  using MsGraph.SharedModels;
12
-
13
- // Raw body models represent the content of the response body, without any additional metadata.
14
- // Note that these are primarily marker types. CSDL has no notion of what actual body content is returned in such types,
15
- // but by passing markers through, HIDI can translate to OpenAPI.
16
- // The content of the types exists for other future emitters that run directly off TypeSpec.
17
- namespace MsGraph.Responses.Bodies {
18
-
19
- /** Complex type to represent a nested error that potentially has other recursive nested errors. */
20
- @error
21
- model InnerError {
22
- code: string;
23
- innererror: InnerError | null; // Small e for error NOT a typo.
24
- }
25
-
26
- /** Complex type to represent a standard Microsoft Graph error. */
27
- @error
28
- model GraphError {
29
- code: string;
30
- message: string;
31
- localizedMessage: string;
32
- target: string | null;
33
- innererror: InnerError | null; // Small e for error NOT a typo.
34
- details: GraphError[];
35
- }
36
-
37
- @error
38
- model ErrorBody {
39
- error: GraphError;
40
- }
41
-
42
- model ResourceBody<TResource> {
43
- ...TResource;
44
- }
45
-
46
- model CollectionBody<TResource> {
47
- value: TResource[];
48
- `@odata.count`?: int64;
49
- }
50
-
51
- @pagedCollection
52
- model PagedCollectionBody<TResource> is CollectionBody<TResource> {
53
- `@odata.nextLink`?: MsGraph.SharedModels.url;
54
- }
55
-
56
- @pagedCollection
57
- @deltaCollection
58
- model DeltaCollectionBody<TResource> is PagedCollectionBody<TResource> {
59
- `@odata.deltaLink`?: MsGraph.SharedModels.url;
60
- }
61
- }
13
+ using MsGraph.Bodies;
62
14
 
63
15
  // Response models represent the response as a whole, including the status code, headers, and body.
64
16
  namespace MsGraph.Responses {
@@ -73,7 +25,7 @@ namespace MsGraph.Responses {
73
25
  is CollectionResponse<TResource, TStatus, TBody>;
74
26
 
75
27
  /** Response to represent a Microsoft Graph individual resource response payload. */
76
- model ResourceResponse<TResource, TStatus = 200, TBody = Bodies.ResourceBody<TResource>>
28
+ model ResourceResponse<TResource, TStatus = 200, TBody = TResource>
77
29
  is Http.Response<TStatus> {
78
30
  ...Http.Body<TBody>;
79
31
  }
@@ -85,7 +37,7 @@ namespace MsGraph.Responses {
85
37
  }
86
38
 
87
39
  /** Response to represent a Microsoft Graph resource creation response payload. */
88
- model ResourceCreatedResponse<TResource, TStatus = 201, TBody = Bodies.ResourceBody<TResource>>
40
+ model ResourceCreatedResponse<TResource, TStatus = 201, TBody = TResource>
89
41
  is ResourceResponse<TResource, TStatus, TBody> {
90
42
  ...Http.LocationHeader
91
43
  }
@@ -18,8 +18,8 @@ namespace MsGraph.SharedModels;
18
18
 
19
19
 
20
20
  @doc("Scalar type for URLs that would be expected to work in the browser address bar.")
21
- scalar webUrl extends string;
21
+ scalar webUrl extends url;
22
22
 
23
23
  @doc("Scalar type for URLs that represent Graph APIs.")
24
- scalar url extends string;
24
+ scalar graphUrl extends url;
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/typespec-msgraph",
3
- "version": "0.0.1-Preview.14",
3
+ "version": "0.0.1-Preview.16",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec for Microsoft Graph provides a description of the Microsoft Graph APIs. It is used for generating API description languages, client and service code, documentation, and other assets.",
6
6
  "homepage": "https://github.com/microsoftgraph/typespec-msgraph",
@@ -53,8 +53,8 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@xmldom/xmldom": "~0.8.4",
56
- "@typespec/compiler": "~0.52.0",
57
- "@typespec/http": "~0.52.0",
56
+ "@typespec/compiler": "~0.53.1",
57
+ "@typespec/http": "~0.53.0",
58
58
  "prettier": "~3.1.1",
59
59
  "react-dom": "~18.2.0",
60
60
  "react": "~18.2.0",
@@ -65,7 +65,7 @@
65
65
  "@types/node": "~18.11.9",
66
66
  "@types/react": "~18.0.5",
67
67
  "@types/react-reconciler": "~0.28.0",
68
- "@typespec/eslint-config-typespec": "~0.52.0",
68
+ "@typespec/eslint-config-typespec": "~0.53.0",
69
69
  "c8": "~8.0.1",
70
70
  "eslint": "^8.49.0",
71
71
  "mocha": "~10.2.0",
@@ -1,10 +0,0 @@
1
- import { DecoratorContext, Model, Program } from "@typespec/compiler";
2
- /**
3
- * `@hasStream` - indicates that an `@entity` model has a stream.
4
- *
5
- * `mediaTypes` - list of media types supported by the stream. If not specified, the stream supports any media type.
6
- */
7
- export declare function $hasStream(context: DecoratorContext, target: Model, args?: string, ...mediaTypes: string[]): void;
8
- export declare function hasStream(program: Program, target: Model): boolean;
9
- export declare function getStreamTypes(program: Program, target: Model): string[];
10
- //# sourceMappingURL=has-stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-stream.d.ts","sourceRoot":"","sources":["../../../src/decorators/has-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAItE;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,KAAK,EACb,IAAI,CAAC,EAAE,MAAM,EACb,GAAG,UAAU,EAAE,MAAM,EAAE,QAOxB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAElE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,CAExE"}
@@ -1,17 +0,0 @@
1
- const hasStreamKey = Symbol("hasStream");
2
- /**
3
- * `@hasStream` - indicates that an `@entity` model has a stream.
4
- *
5
- * `mediaTypes` - list of media types supported by the stream. If not specified, the stream supports any media type.
6
- */
7
- export function $hasStream(context, target, args, ...mediaTypes) {
8
- const types = args ? [args, ...mediaTypes] : [];
9
- context.program.stateMap(hasStreamKey).set(target, types.filter((t) => t.trim()));
10
- }
11
- export function hasStream(program, target) {
12
- return program.stateMap(hasStreamKey).has(target);
13
- }
14
- export function getStreamTypes(program, target) {
15
- return program.stateMap(hasStreamKey).get(target) || [];
16
- }
17
- //# sourceMappingURL=has-stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-stream.js","sourceRoot":"","sources":["../../../src/decorators/has-stream.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,OAAyB,EACzB,MAAa,EACb,IAAa,EACb,GAAG,UAAoB;IAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,GAAG,CACxC,MAAM,EACN,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAgB,EAAE,MAAa;IACvD,OAAO,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAgB,EAAE,MAAa;IAC5D,OAAO,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAC1D,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Program } from "@typespec/compiler";
2
- export declare function validateHasStreamOnlyOnEntity(program: Program): void;
3
- //# sourceMappingURL=has-stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-stream.d.ts","sourceRoot":"","sources":["../../../src/rules/has-stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,QAsB7D"}
@@ -1,30 +0,0 @@
1
- import { hasStream } from "../decorators/has-stream.js";
2
- import { isEntity } from "../index.js";
3
- import { reportDiagnostic } from "../lib.js";
4
- import { navigateTypesInNamespace } from "@typespec/compiler";
5
- import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
- export function validateHasStreamOnlyOnEntity(program) {
7
- for (const namespace of GetDeclaredNamespaces(program)) {
8
- navigateTypesInNamespace(namespace, {
9
- model: (model) => {
10
- if (!hasStream(program, model)) {
11
- return;
12
- }
13
- if (isEntity(program, model)) {
14
- return;
15
- }
16
- reportDiagnostic(program, {
17
- code: "decorator-invalid-use",
18
- target: model,
19
- messageId: "wrongType",
20
- format: {
21
- decorator: "@hasStream",
22
- target: "@entity model",
23
- },
24
- });
25
- },
26
- });
27
- }
28
- }
29
- ;
30
- //# sourceMappingURL=has-stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-stream.js","sourceRoot":"","sources":["../../../src/rules/has-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC5D,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC9B,OAAO;iBACR;gBACD,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC5B,OAAO;iBACR;gBACD,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,KAAK;oBACb,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,YAAY;wBACvB,MAAM,EAAE,eAAe;qBACxB;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}