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

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 (258) hide show
  1. package/dist/src/components/annotations.d.ts.map +1 -1
  2. package/dist/src/components/annotations.js +24 -3
  3. package/dist/src/components/annotations.js.map +1 -1
  4. package/dist/src/components/entity-container-element.d.ts.map +1 -1
  5. package/dist/src/components/entity-container-element.js +13 -6
  6. package/dist/src/components/entity-container-element.js.map +1 -1
  7. package/dist/src/components/operation-element.d.ts.map +1 -1
  8. package/dist/src/components/operation-element.js +15 -4
  9. package/dist/src/components/operation-element.js.map +1 -1
  10. package/dist/src/components/property-element.js +1 -1
  11. package/dist/src/components/property-element.js.map +1 -1
  12. package/dist/src/components/reference-target-element.d.ts +9 -0
  13. package/dist/src/components/reference-target-element.d.ts.map +1 -0
  14. package/dist/src/components/reference-target-element.js +3 -0
  15. package/dist/src/components/reference-target-element.js.map +1 -0
  16. package/dist/src/components/revisions-annotation.d.ts.map +1 -1
  17. package/dist/src/components/revisions-annotation.js +2 -1
  18. package/dist/src/components/revisions-annotation.js.map +1 -1
  19. package/dist/src/components/schema-element.d.ts.map +1 -1
  20. package/dist/src/components/schema-element.js +5 -3
  21. package/dist/src/components/schema-element.js.map +1 -1
  22. package/dist/src/components/select-supported-annotation.d.ts +5 -0
  23. package/dist/src/components/select-supported-annotation.d.ts.map +1 -0
  24. package/dist/src/components/select-supported-annotation.js +6 -0
  25. package/dist/src/components/select-supported-annotation.js.map +1 -0
  26. package/dist/src/components/term-element.d.ts +9 -0
  27. package/dist/src/components/term-element.d.ts.map +1 -0
  28. package/dist/src/components/term-element.js +8 -0
  29. package/dist/src/components/term-element.js.map +1 -0
  30. package/dist/src/decorators/address-url.d.ts +16 -0
  31. package/dist/src/decorators/address-url.d.ts.map +1 -0
  32. package/dist/src/decorators/address-url.js +19 -0
  33. package/dist/src/decorators/address-url.js.map +1 -0
  34. package/dist/src/decorators/ags-attribute.d.ts +2 -1
  35. package/dist/src/decorators/ags-attribute.d.ts.map +1 -1
  36. package/dist/src/decorators/ags-attribute.js +34 -1
  37. package/dist/src/decorators/ags-attribute.js.map +1 -1
  38. package/dist/src/decorators/global-operation.d.ts +9 -0
  39. package/dist/src/decorators/global-operation.d.ts.map +1 -0
  40. package/dist/src/decorators/global-operation.js +13 -0
  41. package/dist/src/decorators/global-operation.js.map +1 -0
  42. package/dist/src/decorators/graph-deprecated.d.ts +11 -0
  43. package/dist/src/decorators/graph-deprecated.d.ts.map +1 -0
  44. package/dist/src/decorators/graph-deprecated.js +19 -0
  45. package/dist/src/decorators/graph-deprecated.js.map +1 -0
  46. package/dist/src/decorators/index.d.ts +7 -0
  47. package/dist/src/decorators/index.d.ts.map +1 -1
  48. package/dist/src/decorators/index.js +7 -0
  49. package/dist/src/decorators/index.js.map +1 -1
  50. package/dist/src/decorators/is-owner.js +1 -1
  51. package/dist/src/decorators/ownerless.d.ts +8 -0
  52. package/dist/src/decorators/ownerless.d.ts.map +1 -0
  53. package/dist/src/decorators/ownerless.js +12 -0
  54. package/dist/src/decorators/ownerless.js.map +1 -0
  55. package/dist/src/decorators/public-namespace.d.ts.map +1 -1
  56. package/dist/src/decorators/public-namespace.js +4 -1
  57. package/dist/src/decorators/public-namespace.js.map +1 -1
  58. package/dist/src/decorators/reference-target.d.ts +16 -0
  59. package/dist/src/decorators/reference-target.d.ts.map +1 -0
  60. package/dist/src/decorators/reference-target.js +52 -0
  61. package/dist/src/decorators/reference-target.js.map +1 -0
  62. package/dist/src/decorators/select.d.ts +9 -0
  63. package/dist/src/decorators/select.d.ts.map +1 -0
  64. package/dist/src/decorators/select.js +13 -0
  65. package/dist/src/decorators/select.js.map +1 -0
  66. package/dist/src/decorators/term.d.ts +13 -0
  67. package/dist/src/decorators/term.d.ts.map +1 -0
  68. package/dist/src/decorators/term.js +14 -0
  69. package/dist/src/decorators/term.js.map +1 -0
  70. package/dist/src/entities/address-url.d.ts +4 -0
  71. package/dist/src/entities/address-url.d.ts.map +1 -0
  72. package/dist/src/entities/address-url.js +18 -0
  73. package/dist/src/entities/address-url.js.map +1 -0
  74. package/dist/src/entities/annotations.d.ts +6 -0
  75. package/dist/src/entities/annotations.d.ts.map +1 -1
  76. package/dist/src/entities/annotations.js +25 -1
  77. package/dist/src/entities/annotations.js.map +1 -1
  78. package/dist/src/entities/entity-container.d.ts +10 -0
  79. package/dist/src/entities/entity-container.d.ts.map +1 -1
  80. package/dist/src/entities/entity-container.js +3 -0
  81. package/dist/src/entities/entity-container.js.map +1 -1
  82. package/dist/src/entities/enum.js.map +1 -1
  83. package/dist/src/entities/model.d.ts +2 -0
  84. package/dist/src/entities/model.d.ts.map +1 -1
  85. package/dist/src/entities/model.js +66 -5
  86. package/dist/src/entities/model.js.map +1 -1
  87. package/dist/src/entities/ms-graph-route.d.ts +13 -0
  88. package/dist/src/entities/ms-graph-route.d.ts.map +1 -0
  89. package/dist/src/entities/ms-graph-route.js +70 -0
  90. package/dist/src/entities/ms-graph-route.js.map +1 -0
  91. package/dist/src/entities/namespace.d.ts +6 -1
  92. package/dist/src/entities/namespace.d.ts.map +1 -1
  93. package/dist/src/entities/namespace.js +107 -11
  94. package/dist/src/entities/namespace.js.map +1 -1
  95. package/dist/src/entities/operation.d.ts +4 -0
  96. package/dist/src/entities/operation.d.ts.map +1 -1
  97. package/dist/src/entities/operation.js +28 -8
  98. package/dist/src/entities/operation.js.map +1 -1
  99. package/dist/src/entities/revision-definition.d.ts +1 -0
  100. package/dist/src/entities/revision-definition.d.ts.map +1 -1
  101. package/dist/src/entities/revision-definition.js +3 -3
  102. package/dist/src/entities/revision-definition.js.map +1 -1
  103. package/dist/src/entities/term.d.ts +8 -0
  104. package/dist/src/entities/term.d.ts.map +1 -0
  105. package/dist/src/entities/term.js +14 -0
  106. package/dist/src/entities/term.js.map +1 -0
  107. package/dist/src/index.d.ts +1 -1
  108. package/dist/src/index.d.ts.map +1 -1
  109. package/dist/src/index.js +1 -1
  110. package/dist/src/index.js.map +1 -1
  111. package/dist/src/lib.d.ts +69 -146
  112. package/dist/src/lib.d.ts.map +1 -1
  113. package/dist/src/lib.js +24 -10
  114. package/dist/src/lib.js.map +1 -1
  115. package/dist/src/rules/address-url.d.ts +6 -0
  116. package/dist/src/rules/address-url.d.ts.map +1 -0
  117. package/dist/src/rules/address-url.js +40 -0
  118. package/dist/src/rules/address-url.js.map +1 -0
  119. package/dist/src/rules/allowed-values.d.ts +2 -1
  120. package/dist/src/rules/allowed-values.d.ts.map +1 -1
  121. package/dist/src/rules/allowed-values.js +7 -7
  122. package/dist/src/rules/allowed-values.js.map +1 -1
  123. package/dist/src/rules/alternate-key.d.ts +4 -3
  124. package/dist/src/rules/alternate-key.d.ts.map +1 -1
  125. package/dist/src/rules/alternate-key.js +23 -23
  126. package/dist/src/rules/alternate-key.js.map +1 -1
  127. package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -1
  128. package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -1
  129. package/dist/src/rules/collection-navigation-properties-not-nullable.js +9 -9
  130. package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -1
  131. package/dist/src/rules/computed.d.ts +2 -1
  132. package/dist/src/rules/computed.d.ts.map +1 -1
  133. package/dist/src/rules/computed.js +9 -8
  134. package/dist/src/rules/computed.js.map +1 -1
  135. package/dist/src/rules/contains.d.ts +2 -1
  136. package/dist/src/rules/contains.d.ts.map +1 -1
  137. package/dist/src/rules/contains.js +9 -8
  138. package/dist/src/rules/contains.js.map +1 -1
  139. package/dist/src/rules/count.d.ts +2 -1
  140. package/dist/src/rules/count.d.ts.map +1 -1
  141. package/dist/src/rules/count.js +9 -8
  142. package/dist/src/rules/count.js.map +1 -1
  143. package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -1
  144. package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -1
  145. package/dist/src/rules/disallowed-typespec-decorators.js +29 -25
  146. package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -1
  147. package/dist/src/rules/entity.d.ts +5 -2
  148. package/dist/src/rules/entity.d.ts.map +1 -1
  149. package/dist/src/rules/entity.js +102 -19
  150. package/dist/src/rules/entity.js.map +1 -1
  151. package/dist/src/rules/enum.d.ts +3 -1
  152. package/dist/src/rules/enum.d.ts.map +1 -1
  153. package/dist/src/rules/enum.js +9 -6
  154. package/dist/src/rules/enum.js.map +1 -1
  155. package/dist/src/rules/expand.d.ts +3 -2
  156. package/dist/src/rules/expand.d.ts.map +1 -1
  157. package/dist/src/rules/expand.js +16 -16
  158. package/dist/src/rules/expand.js.map +1 -1
  159. package/dist/src/rules/extends-on-same-type.d.ts +2 -1
  160. package/dist/src/rules/extends-on-same-type.d.ts.map +1 -1
  161. package/dist/src/rules/extends-on-same-type.js +9 -8
  162. package/dist/src/rules/extends-on-same-type.js.map +1 -1
  163. package/dist/src/rules/filter.d.ts +4 -3
  164. package/dist/src/rules/filter.d.ts.map +1 -1
  165. package/dist/src/rules/filter.js +23 -23
  166. package/dist/src/rules/filter.js.map +1 -1
  167. package/dist/src/rules/function.d.ts +2 -1
  168. package/dist/src/rules/function.d.ts.map +1 -1
  169. package/dist/src/rules/function.js +9 -9
  170. package/dist/src/rules/function.js.map +1 -1
  171. package/dist/src/rules/global-operation.d.ts +4 -0
  172. package/dist/src/rules/global-operation.d.ts.map +1 -0
  173. package/dist/src/rules/global-operation.js +60 -0
  174. package/dist/src/rules/global-operation.js.map +1 -0
  175. package/dist/src/rules/graph-deprecated.d.ts +8 -0
  176. package/dist/src/rules/graph-deprecated.d.ts.map +1 -0
  177. package/dist/src/rules/graph-deprecated.js +152 -0
  178. package/dist/src/rules/graph-deprecated.js.map +1 -0
  179. package/dist/src/rules/graph-route.d.ts +8 -2
  180. package/dist/src/rules/graph-route.d.ts.map +1 -1
  181. package/dist/src/rules/graph-route.js +80 -16
  182. package/dist/src/rules/graph-route.js.map +1 -1
  183. package/dist/src/rules/has-stream.d.ts +2 -1
  184. package/dist/src/rules/has-stream.d.ts.map +1 -1
  185. package/dist/src/rules/has-stream.js +9 -8
  186. package/dist/src/rules/has-stream.js.map +1 -1
  187. package/dist/src/rules/index.d.ts +5 -0
  188. package/dist/src/rules/index.d.ts.map +1 -1
  189. package/dist/src/rules/index.js +5 -0
  190. package/dist/src/rules/index.js.map +1 -1
  191. package/dist/src/rules/namespace.d.ts +4 -3
  192. package/dist/src/rules/namespace.d.ts.map +1 -1
  193. package/dist/src/rules/namespace.js +58 -73
  194. package/dist/src/rules/namespace.js.map +1 -1
  195. package/dist/src/rules/open.d.ts +2 -1
  196. package/dist/src/rules/open.d.ts.map +1 -1
  197. package/dist/src/rules/open.js +9 -8
  198. package/dist/src/rules/open.js.map +1 -1
  199. package/dist/src/rules/operation-inside-interface.d.ts +2 -1
  200. package/dist/src/rules/operation-inside-interface.d.ts.map +1 -1
  201. package/dist/src/rules/operation-inside-interface.js +9 -8
  202. package/dist/src/rules/operation-inside-interface.js.map +1 -1
  203. package/dist/src/rules/order-by.d.ts +3 -2
  204. package/dist/src/rules/order-by.d.ts.map +1 -1
  205. package/dist/src/rules/order-by.js +16 -16
  206. package/dist/src/rules/order-by.js.map +1 -1
  207. package/dist/src/rules/ownerless.d.ts +10 -0
  208. package/dist/src/rules/ownerless.d.ts.map +1 -0
  209. package/dist/src/rules/ownerless.js +155 -0
  210. package/dist/src/rules/ownerless.js.map +1 -0
  211. package/dist/src/rules/partial.d.ts +2 -1
  212. package/dist/src/rules/partial.d.ts.map +1 -1
  213. package/dist/src/rules/partial.js +9 -8
  214. package/dist/src/rules/partial.js.map +1 -1
  215. package/dist/src/rules/reference-target.d.ts +8 -0
  216. package/dist/src/rules/reference-target.d.ts.map +1 -0
  217. package/dist/src/rules/reference-target.js +119 -0
  218. package/dist/src/rules/reference-target.js.map +1 -0
  219. package/dist/src/rules/references.d.ts +2 -1
  220. package/dist/src/rules/references.d.ts.map +1 -1
  221. package/dist/src/rules/references.js +9 -8
  222. package/dist/src/rules/references.js.map +1 -1
  223. package/dist/src/rules/required-for-create.d.ts +2 -1
  224. package/dist/src/rules/required-for-create.d.ts.map +1 -1
  225. package/dist/src/rules/required-for-create.js +9 -8
  226. package/dist/src/rules/required-for-create.js.map +1 -1
  227. package/dist/src/rules/search.d.ts +2 -1
  228. package/dist/src/rules/search.d.ts.map +1 -1
  229. package/dist/src/rules/search.js +9 -8
  230. package/dist/src/rules/search.js.map +1 -1
  231. package/dist/src/rules/skip.d.ts +2 -1
  232. package/dist/src/rules/skip.d.ts.map +1 -1
  233. package/dist/src/rules/skip.js +9 -8
  234. package/dist/src/rules/skip.js.map +1 -1
  235. package/dist/src/rules/top.d.ts +2 -1
  236. package/dist/src/rules/top.d.ts.map +1 -1
  237. package/dist/src/rules/top.js +9 -8
  238. package/dist/src/rules/top.js.map +1 -1
  239. package/dist/src/testing/index.d.ts +1 -0
  240. package/dist/src/testing/index.d.ts.map +1 -1
  241. package/dist/src/testing/index.js +21 -0
  242. package/dist/src/testing/index.js.map +1 -1
  243. package/dist/src/utils.d.ts +19 -1
  244. package/dist/src/utils.d.ts.map +1 -1
  245. package/dist/src/utils.js +44 -21
  246. package/dist/src/utils.js.map +1 -1
  247. package/dist/src/{linter.d.ts → validate.d.ts} +1 -1
  248. package/dist/src/validate.d.ts.map +1 -0
  249. package/dist/src/validate.js +56 -0
  250. package/dist/src/validate.js.map +1 -0
  251. package/lib/decorators.tsp +114 -17
  252. package/lib/porcelain.tsp +18 -7
  253. package/lib/responses.tsp +32 -7
  254. package/lib/shared-models.tsp +0 -50
  255. package/package.json +5 -7
  256. package/dist/src/linter.d.ts.map +0 -1
  257. package/dist/src/linter.js +0 -44
  258. package/dist/src/linter.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ import { Program } from "@typespec/compiler";
2
+ /***
3
+ * @ownerless can only be applied to interfaces
4
+ */
5
+ export declare function validateOwnerlessMustOnlyBeAppliedToInterfacesWithSingleSegmentGraphRoute(program: Program): void;
6
+ export declare function validateOwnerlessEntityModelReferencedMustOnlyHaveNavigationPropertiesRule(program: Program): void;
7
+ export declare function validateOwnerlessInterfaceMustNotHaveAnyOperations(program: Program): void;
8
+ export declare function validateOwnerlessDecoratorCannotBeUsedWithIsOwner(program: Program): void;
9
+ export declare function validateEntityTypeInOwnerlessExtendsClauseCannotBeUsedInOtherInterfaces(program: Program): void;
10
+ //# sourceMappingURL=ownerless.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownerless.d.ts","sourceRoot":"","sources":["../../../src/rules/ownerless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAiD,MAAM,oBAAoB,CAAC;AAO9G;;GAEG;AAEH,wBAAgB,yEAAyE,CAAC,OAAO,EAAE,OAAO,QAqBzG;AAED,wBAAgB,0EAA0E,CAAC,OAAO,EAAE,OAAO,QA2B1G;AAED,wBAAgB,kDAAkD,CAAC,OAAO,EAAE,OAAO,QAalF;AAED,wBAAgB,iDAAiD,CAAC,OAAO,EAAE,OAAO,QAcjF;AAED,wBAAgB,uEAAuE,CAAC,OAAO,EAAE,OAAO,QAkBvG"}
@@ -0,0 +1,155 @@
1
+ import { getLocationContext, navigateTypesInNamespace, } from "@typespec/compiler";
2
+ import { getGraphRoutePaths, hasIsOwner, isComplex, isContains, isOwnerless, isReferences } from "../index.js";
3
+ import { getInterfaceNavigationSourceType } from "../utils.js";
4
+ import { reportDiagnostic } from "../lib.js";
5
+ import { GetDeclaredNamespaces, getNavigationSources } from "../entities/namespace.js";
6
+ /***
7
+ * @ownerless can only be applied to interfaces
8
+ */
9
+ export function validateOwnerlessMustOnlyBeAppliedToInterfacesWithSingleSegmentGraphRoute(program) {
10
+ for (const namespace of GetDeclaredNamespaces(program)) {
11
+ navigateTypesInNamespace(namespace, {
12
+ interface: (interfaceModel) => {
13
+ if (isLibraryTypeOrNotOwnerless(program, interfaceModel)) {
14
+ return;
15
+ }
16
+ const paths = getGraphRoutePaths(program, interfaceModel);
17
+ if (!paths) {
18
+ reportOwnerlessDiagnostic(program, interfaceModel, 'ownerlessMustBeAppliedToInterfacesWithSingleSegmentGraphRouteRule');
19
+ }
20
+ if (paths) {
21
+ const pathParts = paths[0].split("/");
22
+ if (pathParts.length > 1) {
23
+ reportOwnerlessDiagnostic(program, interfaceModel, 'ownerlessMustBeAppliedToInterfacesWithSingleSegmentGraphRouteRule');
24
+ }
25
+ }
26
+ }
27
+ });
28
+ }
29
+ }
30
+ ;
31
+ export function validateOwnerlessEntityModelReferencedMustOnlyHaveNavigationPropertiesRule(program) {
32
+ for (const namespace of GetDeclaredNamespaces(program)) {
33
+ navigateTypesInNamespace(namespace, {
34
+ interface: (interfaceModel) => {
35
+ if (isLibraryTypeOrNotOwnerless(program, interfaceModel)) {
36
+ return;
37
+ }
38
+ const bindingType = getInterfaceNavigationSourceType(program, interfaceModel);
39
+ if (bindingType) {
40
+ const bindingTypeProperties = [...bindingType.properties];
41
+ bindingTypeProperties.forEach(([_, property]) => {
42
+ if (isContains(program, property)) {
43
+ return;
44
+ }
45
+ if (isReferences(program, property)) {
46
+ return;
47
+ }
48
+ if (property.type.kind === "Model" && isComplex(program, property.type)) {
49
+ reportOwnerlessDiagnostic(program, interfaceModel, 'referencedEntityModelCannotHaveComplexTypeProperties');
50
+ }
51
+ reportOwnerlessDiagnostic(program, interfaceModel, 'referencedEntityModelCanOnlyHaveNavigationProperties');
52
+ });
53
+ }
54
+ }
55
+ });
56
+ }
57
+ }
58
+ ;
59
+ export function validateOwnerlessInterfaceMustNotHaveAnyOperations(program) {
60
+ for (const namespace of GetDeclaredNamespaces(program)) {
61
+ navigateTypesInNamespace(namespace, {
62
+ interface: (interfaceModel) => {
63
+ if (isLibraryTypeOrNotOwnerless(program, interfaceModel)) {
64
+ return;
65
+ }
66
+ if (interfaceModel.operations.size > 0) {
67
+ reportOwnerlessDiagnostic(program, interfaceModel, 'ownerlessInterfaceCannotHaveAnyOperations');
68
+ }
69
+ }
70
+ });
71
+ }
72
+ }
73
+ ;
74
+ export function validateOwnerlessDecoratorCannotBeUsedWithIsOwner(program) {
75
+ for (const namespace of GetDeclaredNamespaces(program)) {
76
+ navigateTypesInNamespace(namespace, {
77
+ interface: (interfaceModel) => {
78
+ if (isLibraryTypeOrNotOwnerless(program, interfaceModel)) {
79
+ return;
80
+ }
81
+ const bindingType = getInterfaceNavigationSourceType(program, interfaceModel);
82
+ if (bindingType && hasIsOwner(program, bindingType)) {
83
+ reportOwnerlessDiagnostic(program, interfaceModel, 'ownerlessDecoratorCannotBeUsedWithIsOwner');
84
+ }
85
+ }
86
+ });
87
+ }
88
+ }
89
+ ;
90
+ export function validateEntityTypeInOwnerlessExtendsClauseCannotBeUsedInOtherInterfaces(program) {
91
+ const interfaces = getInterfaces(program);
92
+ const { bindingType, ownerlessInterface } = getBindingTypeAndOwnerlessInterface(program, interfaces);
93
+ for (const namespace of GetDeclaredNamespaces(program)) {
94
+ navigateTypesInNamespace(namespace, {
95
+ interface: (interfaceModel) => {
96
+ if (getLocationContext(program, interfaceModel).type === 'library') {
97
+ return;
98
+ }
99
+ if (interfaceModel === ownerlessInterface) {
100
+ return;
101
+ }
102
+ const currentInterfaceBindingType = getInterfaceNavigationSourceType(program, interfaceModel);
103
+ if (bindingType && currentInterfaceBindingType && bindingType.name === currentInterfaceBindingType.name) {
104
+ reportOwnerlessDiagnostic(program, interfaceModel, 'entityTypeInOnwerlessCannotBeUsedWithOtherInterfaces');
105
+ }
106
+ }
107
+ });
108
+ }
109
+ }
110
+ ;
111
+ function getBindingTypeAndOwnerlessInterface(program, interfaces) {
112
+ let bindingType = {};
113
+ let ownerlessInterface = {};
114
+ for (const interfaceModel of interfaces) {
115
+ if (isOwnerless(program, interfaceModel)) {
116
+ bindingType = getInterfaceNavigationSourceType(program, interfaceModel);
117
+ ownerlessInterface = interfaceModel;
118
+ break;
119
+ }
120
+ }
121
+ return { bindingType, ownerlessInterface };
122
+ }
123
+ function getInterfaces(program) {
124
+ const interfaces = [];
125
+ GetDeclaredNamespaces(program).forEach(namespace => {
126
+ const sources = getNavigationSources(namespace.interfaces);
127
+ sources.forEach(source => {
128
+ interfaces.push(source);
129
+ });
130
+ });
131
+ return interfaces;
132
+ }
133
+ function isLibraryTypeOrNotOwnerless(program, interfaceModel) {
134
+ return getLocationContext(program, interfaceModel).type === 'library' || !isOwnerless(program, interfaceModel);
135
+ }
136
+ // Note that type checking for messageId has been disabled to avoid the maintainance burden of adding a new union type value
137
+ // to the messageId parameter of the reportDiagnostic function for each new diagnostic message in the lib.ts file.
138
+ function reportOwnerlessDiagnostic(program, interfaceModel, messageId) {
139
+ reportDiagnostic(program, {
140
+ code: 'decorator-invalid-use',
141
+ target: interfaceModel,
142
+ messageId: messageId,
143
+ format: {
144
+ model: "",
145
+ namespace: "",
146
+ decorator: "@ownerless",
147
+ location: "",
148
+ other: "",
149
+ parameters: "",
150
+ properties: "",
151
+ target: ""
152
+ }
153
+ });
154
+ }
155
+ //# sourceMappingURL=ownerless.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownerless.js","sourceRoot":"","sources":["../../../src/rules/ownerless.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,kBAAkB,EAAE,wBAAwB,GAAG,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGvF;;GAEG;AAEH,MAAM,UAAU,yEAAyE,CAAC,OAAgB;IACxG,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,cAAc,EAAE,EA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AAC;AAED,SAAS,aAAa,CAAC,OAAgB;IACrC,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,qBAAqB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QACjD,MAAM,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC3D,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,2BAA2B,CAAC,OAAgB,EAAE,cAAyB;IAC9E,OAAO,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AACjH,CAAC;AAED,6HAA6H;AAC7H,kHAAkH;AAClH,SAAS,yBAAyB,CAAC,OAAgB,EAAE,cAAyB,EAAE,SAAgB;IAC9F,gBAAgB,CAAC,OAAO,EAAE;QACxB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE;YACN,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,YAAY;YACvB,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;SACX;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @partial applies to a model.
3
4
  */
4
- export declare const extendedModelBaseShouldMatchPartialBaseModel: import("@typespec/lint").LintRule;
5
+ export declare function validateExtendedModelBaseShouldMatchPartialBaseModel(program: Program): void;
5
6
  //# sourceMappingURL=partial.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../src/rules/partial.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,eAAO,MAAM,4CAA4C,mCA0BvD,CAAC"}
1
+ {"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../src/rules/partial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAMvE;;GAEG;AAEH,wBAAgB,oDAAoD,CAAC,OAAO,EAAE,OAAO,QAyBpF"}
@@ -1,13 +1,13 @@
1
- import { createRule } from "@typespec/lint";
1
+ import { navigateTypesInNamespace } from "@typespec/compiler";
2
2
  import { getPartialReferenceModel, isPartial } from "../index.js";
3
3
  import { reportDiagnostic } from "../lib.js";
4
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
4
5
  /**
5
6
  * @partial applies to a model.
6
7
  */
7
- export const extendedModelBaseShouldMatchPartialBaseModel = createRule({
8
- name: "extended-model-base-should-match-partial-model-base",
9
- create({ program }) {
10
- return {
8
+ export function validateExtendedModelBaseShouldMatchPartialBaseModel(program) {
9
+ for (const namespace of GetDeclaredNamespaces(program)) {
10
+ navigateTypesInNamespace(namespace, {
11
11
  model: (model) => {
12
12
  var _a, _b;
13
13
  if (!isPartial(program, model)) {
@@ -29,7 +29,8 @@ export const extendedModelBaseShouldMatchPartialBaseModel = createRule({
29
29
  });
30
30
  }
31
31
  },
32
- };
33
- },
34
- });
32
+ });
33
+ }
34
+ }
35
+ ;
35
36
  //# sourceMappingURL=partial.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"partial.js","sourceRoot":"","sources":["../../../src/rules/partial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C;;G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AAI,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,IAAG,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,EAAC;oBACnB,OAAO;iBACR;gBACD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAClE,IAAG,CAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,SAAS,0CAAE,IAAI,OAAK,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,IAAI,CAAA,EAAC;oBAC9D,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,uBAAuB;wBAC7B,MAAM,EAAE,KAAK;wBACb,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE;4BACN,SAAS,EAAE,UAAU;4BACrB,MAAM,EAAE,OAAO;yBAChB;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateReferenceTargetInterfaceHasGraphRoutes(program: Program): void;
3
+ export declare function validateReferenceTargetUsedOnlyOnceOnInterface(program: Program): void;
4
+ export declare function validateTargetPathShouldNotHaveParameters(program: Program): void;
5
+ export declare const singletonOrEntitySetHostingBindingsShouldExist: import("@typespec/compiler").LinterRuleDefinition<"singleton-or-entityset-hosting-bindings-should-exist", {
6
+ readonly default: import("@typespec/compiler").CallableMessage<[string]>;
7
+ }>;
8
+ //# sourceMappingURL=reference-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-target.d.ts","sourceRoot":"","sources":["../../../src/rules/reference-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsD,MAAM,oBAAoB,CAAC;AAMjG,wBAAgB,8CAA8C,CAAC,OAAO,EAAE,OAAO,QAsB9E;AAED,wBAAgB,8CAA8C,CAAC,OAAO,EAAE,OAAO,QAsB9E;AAED,wBAAgB,yCAAyC,CAAC,OAAO,EAAE,OAAO,QA0BzE;AAED,eAAO,MAAM,8CAA8C;;EAyCzD,CAAA"}
@@ -0,0 +1,119 @@
1
+ import { createRule, navigateTypesInNamespace, paramMessage } from "@typespec/compiler";
2
+ import { GetDeclaredNamespaces, GetMsGraphNamespaces } from "../entities/namespace.js";
3
+ import { reportDiagnostic } from "../lib.js";
4
+ import { getGraphRoutePaths, getReferenceTarget, hasReferenceTarget } from "../index.js";
5
+ import { removeRoutePathParams } from "../utils.js";
6
+ export function validateReferenceTargetInterfaceHasGraphRoutes(program) {
7
+ for (const namespace of GetDeclaredNamespaces(program)) {
8
+ navigateTypesInNamespace(namespace, {
9
+ interface: ($interface) => {
10
+ if (!hasReferenceTarget(program, $interface)) {
11
+ return;
12
+ }
13
+ const decorators = $interface.decorators;
14
+ const hasGraphRoute = decorators === null || decorators === void 0 ? void 0 : decorators.some(d => { var _a; return ((_a = d.definition) === null || _a === void 0 ? void 0 : _a.name) === "@graphRoute"; });
15
+ if (!hasGraphRoute) {
16
+ reportDiagnostic(program, {
17
+ code: "decorator-invalid-use",
18
+ target: $interface,
19
+ messageId: "referenceTargetInterfaceMustHaveGraphRoute",
20
+ format: {
21
+ decorator: "@referenceTarget"
22
+ },
23
+ });
24
+ }
25
+ }
26
+ });
27
+ }
28
+ }
29
+ export function validateReferenceTargetUsedOnlyOnceOnInterface(program) {
30
+ for (const namespace of GetDeclaredNamespaces(program)) {
31
+ navigateTypesInNamespace(namespace, {
32
+ interface: ($interface) => {
33
+ if (!hasReferenceTarget(program, $interface)) {
34
+ return;
35
+ }
36
+ const decorators = $interface.decorators;
37
+ const referenceTargetDecorators = decorators === null || decorators === void 0 ? void 0 : decorators.filter(d => { var _a; return ((_a = d.definition) === null || _a === void 0 ? void 0 : _a.name) === "@referenceTarget"; });
38
+ if (referenceTargetDecorators && referenceTargetDecorators.length > 1) {
39
+ reportDiagnostic(program, {
40
+ code: "decorator-invalid-use",
41
+ target: $interface,
42
+ messageId: "referenceTargetMustOnlyBeUsedOnceOnInterface",
43
+ format: {
44
+ decorator: "@referenceTarget"
45
+ },
46
+ });
47
+ }
48
+ }
49
+ });
50
+ }
51
+ }
52
+ export function validateTargetPathShouldNotHaveParameters(program) {
53
+ for (const namespace of GetDeclaredNamespaces(program)) {
54
+ navigateTypesInNamespace(namespace, {
55
+ interface: ($interface) => {
56
+ if (!hasReferenceTarget(program, $interface)) {
57
+ return;
58
+ }
59
+ const target = getReferenceTarget(program, $interface);
60
+ const targetParts = target.split("/");
61
+ const targetWithoutRouteParams = removeRoutePathParams(target);
62
+ const targetWithoutRouteParamsParts = targetWithoutRouteParams.split("/");
63
+ if (targetParts.length !== targetWithoutRouteParamsParts.length) {
64
+ reportDiagnostic(program, {
65
+ code: "decorator-invalid-use",
66
+ target: $interface,
67
+ messageId: "referenceTargetPathShouldNotHaveParameters",
68
+ format: {
69
+ decorator: "@referenceTarget",
70
+ target: target
71
+ },
72
+ });
73
+ }
74
+ }
75
+ });
76
+ }
77
+ }
78
+ export const singletonOrEntitySetHostingBindingsShouldExist = createRule({
79
+ name: "singleton-or-entityset-hosting-bindings-should-exist",
80
+ severity: "warning",
81
+ description: "enforce singleton or entityset hosting bindings should exist",
82
+ messages: {
83
+ default: paramMessage `Singleton or entityset '${"entity"}' should have a hosting binding.`,
84
+ },
85
+ create(context) {
86
+ return {
87
+ interface: ($interface) => {
88
+ if (!hasReferenceTarget(context.program, $interface)) {
89
+ return;
90
+ }
91
+ const graphRoutes = getGraphRoutePaths(context.program, $interface);
92
+ if (graphRoutes) {
93
+ graphRoutes.forEach(graphRoute => {
94
+ const firstSegment = graphRoute.split("/")[0];
95
+ const localNamespace = GetMsGraphNamespaces(context.program).find(namespace => namespace.key !== "library");
96
+ const target = getReferenceTarget(context.program, $interface);
97
+ if (localNamespace) {
98
+ const entitySet = localNamespace.EntitySets.get(firstSegment);
99
+ const singleton = localNamespace.Singletons.get(firstSegment);
100
+ if (!entitySet && !singleton) {
101
+ reportDiagnostic(context.program, {
102
+ code: "decorator-invalid-use",
103
+ target: $interface,
104
+ messageId: "singletonOrEntitySetHostingBindingsShouldExist",
105
+ format: {
106
+ decorator: "@referenceTarget",
107
+ firstSegment: firstSegment,
108
+ target: target
109
+ },
110
+ });
111
+ }
112
+ }
113
+ });
114
+ }
115
+ }
116
+ };
117
+ }
118
+ });
119
+ //# sourceMappingURL=reference-target.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-target.js","sourceRoot":"","sources":["../../../src/rules/reference-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,UAAU,8CAA8C,CAAC,OAAgB;IAC7E,KAAM,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAC;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE;gBACxB,IAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,EAAC;oBAC1C,OAAO;iBACR;gBACD,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;gBACzC,MAAM,aAAa,GAAG,UAAU,aAAV,UAAU,uBAAV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G,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBACpE,IAAG,WAAW,EAAC;oBACb,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;wBAC/B,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC9C,MAAM,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;wBAC5G,MAAM,MAAM,GAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;wBAChE,IAAG,cAAc,EAAC;4BAChB,MAAM,SAAS,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;4BAC9D,MAAM,SAAS,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;4BAC9D,IAAG,CAAC,SAAS,IAAI,CAAC,SAAS,EAAC;gCAC1B,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE;oCAChC,IAAI,EAAE,uBAAuB;oCAC7B,MAAM,EAAE,UAAU;oCAClB,SAAS,EAAE,gDAAgD;oCAC3D,MAAM,EAAE;wCACN,SAAS,EAAE,kBAAkB;wCAC7B,YAAY,EAAE,YAAY;wCAC1B,MAAM,EAAE,MAAM;qCACf;iCACF,CAAC,CAAA;6BACH;yBACF;oBACH,CAAC,CAAC,CAAA;iBACH;YAEH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @references applies to a navigation property.
3
4
  */
4
- export declare const referencesOnlyAppliesToNavigationPropertyRule: import("@typespec/lint").LintRule;
5
+ export declare function validateReferencesOnlyAppliesToNavigationProperty(program: Program): void;
5
6
  //# sourceMappingURL=references.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/rules/references.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,6CAA6C,mCAyBxD,CAAC"}
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/rules/references.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE;;GAEG;AACH,wBAAgB,iDAAiD,CAAC,OAAO,EAAE,OAAO,QAwBjF"}
@@ -1,14 +1,14 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { isReferences } from "../index.js";
3
2
  import { reportDiagnostic } from "../lib.js";
4
3
  import { isNavigationProperty } from "../utils.js";
4
+ import { navigateTypesInNamespace } from "@typespec/compiler";
5
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
5
6
  /**
6
7
  * @references applies to a navigation property.
7
8
  */
8
- export const referencesOnlyAppliesToNavigationPropertyRule = createRule({
9
- name: "references-only-applies-to-navigation-property",
10
- create({ program }) {
11
- return {
9
+ export function validateReferencesOnlyAppliesToNavigationProperty(program) {
10
+ for (const namespace of GetDeclaredNamespaces(program)) {
11
+ navigateTypesInNamespace(namespace, {
12
12
  modelProperty: (property) => {
13
13
  if (!isReferences(program, property)) {
14
14
  return;
@@ -26,7 +26,8 @@ export const referencesOnlyAppliesToNavigationPropertyRule = createRule({
26
26
  },
27
27
  });
28
28
  },
29
- };
30
- },
31
- });
29
+ });
30
+ }
31
+ }
32
+ ;
32
33
  //# sourceMappingURL=references.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"references.js","sourceRoot":"","sources":["../../../src/rules/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,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pC,OAAO;iBACR;gBAED,IAAI,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAC3C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,aAAa;wBACxB,MAAM,EAAE,wCAAwC;qBACjD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare const requiredRequestParametersRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateRequiredRequestParameters(program: Program): void;
2
3
  //# sourceMappingURL=required-for-create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"required-for-create.d.ts","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,6BAA6B,mCAsCxC,CAAC"}
1
+ {"version":3,"file":"required-for-create.d.ts","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAI9E,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,OAAO,QAqCjE"}
@@ -1,12 +1,12 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { isComputed, isRequiredForCreate } from "../index.js";
3
2
  import { getIdForType, isTypeNullable } from "../utils.js";
4
3
  import { getOperationVerb } from "@typespec/http";
4
+ import { navigateTypesInNamespace } from "@typespec/compiler";
5
5
  import { reportDiagnostic } from "../lib.js";
6
- export const requiredRequestParametersRule = createRule({
7
- name: "required-request-parameters",
8
- create({ program }) {
9
- return {
6
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
7
+ export function validateRequiredRequestParameters(program) {
8
+ for (const namespace of GetDeclaredNamespaces(program)) {
9
+ navigateTypesInNamespace(namespace, {
10
10
  interface: (theInterface) => {
11
11
  const postOperations = [...theInterface.operations]
12
12
  .map(([_, operation]) => operation)
@@ -34,7 +34,8 @@ export const requiredRequestParametersRule = createRule({
34
34
  }
35
35
  });
36
36
  },
37
- };
38
- },
39
- });
37
+ });
38
+ }
39
+ }
40
+ ;
40
41
  //# sourceMappingURL=required-for-create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"required-for-create.js","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;IACtD,IAAI,EAAE,6BAA6B;IACnC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,YAAY,EAAE,EAAE;gBAC1B,MAAM,cAAc,GAAG,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC;qBAChD,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC;qBAClC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,MAAM,CAAC,CAAC;gBAE1E,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;oBACnC,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;wBAC/C,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,UAAU,CAA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qCAC9C;iCACF,CAAC,CAAC;6BACJ;wBACH,CAAC,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @search applies to get operations that return collections.
3
4
  */
4
- export declare const searchAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
5
+ export declare function validateSearchAppliesToGetOperationsThatReturnCollections(program: Program): void;
5
6
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,qDAAqD,mCA6BhE,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE;;GAEG;AACH,wBAAgB,yDAAyD,CAAC,OAAO,EAAE,OAAO,QA4BzF"}
@@ -1,15 +1,15 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { getOperationVerb } from "@typespec/http";
3
2
  import { isSearch } from "../index.js";
4
3
  import { isTypeCollection } from "../utils.js";
5
4
  import { reportDiagnostic } from "../lib.js";
5
+ import { navigateTypesInNamespace } from "@typespec/compiler";
6
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
7
  /**
7
8
  * @search applies to get operations that return collections.
8
9
  */
9
- export const searchAppliesToGetOperationsThatReturnCollectionsRule = createRule({
10
- name: "search-applies-to-get-operations-that-return-collections",
11
- create({ program }) {
12
- return {
10
+ export function validateSearchAppliesToGetOperationsThatReturnCollections(program) {
11
+ for (const namespace of GetDeclaredNamespaces(program)) {
12
+ navigateTypesInNamespace(namespace, {
13
13
  operation: (operation) => {
14
14
  if (!isSearch(program, operation)) {
15
15
  return;
@@ -31,7 +31,8 @@ export const searchAppliesToGetOperationsThatReturnCollectionsRule = createRule(
31
31
  },
32
32
  });
33
33
  },
34
- };
35
- },
36
- });
34
+ });
35
+ }
36
+ }
37
+ ;
37
38
  //# sourceMappingURL=search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,qDAAqD,GAAG,UAAU,CAAC;IAC9E,IAAI,EAAE,0DAA0D;IAChE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBACjC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,yDAAyD,CAAC,OAAgB;IACxF,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBACjC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @skip applies to get operations that return collections.
3
4
  */
4
- export declare const skipAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
5
+ export declare function validateSkipAppliesToGetOperationsThatReturnCollections(program: Program): void;
5
6
  //# sourceMappingURL=skip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,mDAAmD,mCA6B9D,CAAC"}
1
+ {"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAOvE;;GAEG;AACH,wBAAgB,uDAAuD,CAAC,OAAO,EAAE,OAAO,QA4BvF"}
@@ -1,15 +1,15 @@
1
- import { createRule } from "@typespec/lint";
1
+ import { navigateTypesInNamespace } from "@typespec/compiler";
2
2
  import { getOperationVerb } from "@typespec/http";
3
3
  import { isSkip } from "../index.js";
4
4
  import { isTypeCollection } from "../utils.js";
5
5
  import { reportDiagnostic } from "../lib.js";
6
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
7
  /**
7
8
  * @skip applies to get operations that return collections.
8
9
  */
9
- export const skipAppliesToGetOperationsThatReturnCollectionsRule = createRule({
10
- name: "skip-applies-to-get-operations-that-return-collections",
11
- create({ program }) {
12
- return {
10
+ export function validateSkipAppliesToGetOperationsThatReturnCollections(program) {
11
+ for (const namespace of GetDeclaredNamespaces(program)) {
12
+ navigateTypesInNamespace(namespace, {
13
13
  operation: (operation) => {
14
14
  if (!isSkip(program, operation)) {
15
15
  return;
@@ -31,7 +31,8 @@ export const skipAppliesToGetOperationsThatReturnCollectionsRule = createRule({
31
31
  },
32
32
  });
33
33
  },
34
- };
35
- },
36
- });
34
+ });
35
+ }
36
+ }
37
+ ;
37
38
  //# sourceMappingURL=skip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"skip.js","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,mDAAmD,GAAG,UAAU,CAAC;IAC5E,IAAI,EAAE,wDAAwD;IAC9D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC/B,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"skip.js","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,uDAAuD,CAAC,OAAgB;IACtF,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC/B,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @top applies to get operations that return collections.
3
4
  */
4
- export declare const topAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
5
+ export declare function validateTopAppliesToGetOperationsThatReturnCollections(program: Program): void;
5
6
  //# sourceMappingURL=top.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"top.d.ts","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,kDAAkD,mCA6B7D,CAAC"}
1
+ {"version":3,"file":"top.d.ts","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAOvE;;GAEG;AACH,wBAAgB,sDAAsD,CAAC,OAAO,EAAE,OAAO,QA4BtF"}