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

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 (208) hide show
  1. package/dist/src/components/annotations.js +21 -3
  2. package/dist/src/components/annotations.js.map +1 -1
  3. package/dist/src/components/operation-element.d.ts.map +1 -1
  4. package/dist/src/components/operation-element.js +15 -4
  5. package/dist/src/components/operation-element.js.map +1 -1
  6. package/dist/src/components/revisions-annotation.d.ts.map +1 -1
  7. package/dist/src/components/revisions-annotation.js +2 -1
  8. package/dist/src/components/revisions-annotation.js.map +1 -1
  9. package/dist/src/components/schema-element.d.ts.map +1 -1
  10. package/dist/src/components/schema-element.js +5 -3
  11. package/dist/src/components/schema-element.js.map +1 -1
  12. package/dist/src/components/term-element.d.ts +9 -0
  13. package/dist/src/components/term-element.d.ts.map +1 -0
  14. package/dist/src/components/term-element.js +8 -0
  15. package/dist/src/components/term-element.js.map +1 -0
  16. package/dist/src/decorators/ags-attribute.d.ts +2 -1
  17. package/dist/src/decorators/ags-attribute.d.ts.map +1 -1
  18. package/dist/src/decorators/ags-attribute.js +34 -1
  19. package/dist/src/decorators/ags-attribute.js.map +1 -1
  20. package/dist/src/decorators/global-operation.d.ts +9 -0
  21. package/dist/src/decorators/global-operation.d.ts.map +1 -0
  22. package/dist/src/decorators/global-operation.js +13 -0
  23. package/dist/src/decorators/global-operation.js.map +1 -0
  24. package/dist/src/decorators/graph-deprecated.d.ts +11 -0
  25. package/dist/src/decorators/graph-deprecated.d.ts.map +1 -0
  26. package/dist/src/decorators/graph-deprecated.js +19 -0
  27. package/dist/src/decorators/graph-deprecated.js.map +1 -0
  28. package/dist/src/decorators/index.d.ts +4 -0
  29. package/dist/src/decorators/index.d.ts.map +1 -1
  30. package/dist/src/decorators/index.js +4 -0
  31. package/dist/src/decorators/index.js.map +1 -1
  32. package/dist/src/decorators/is-owner.js +1 -1
  33. package/dist/src/decorators/ownerless.d.ts +8 -0
  34. package/dist/src/decorators/ownerless.d.ts.map +1 -0
  35. package/dist/src/decorators/ownerless.js +12 -0
  36. package/dist/src/decorators/ownerless.js.map +1 -0
  37. package/dist/src/decorators/public-namespace.d.ts.map +1 -1
  38. package/dist/src/decorators/public-namespace.js +4 -1
  39. package/dist/src/decorators/public-namespace.js.map +1 -1
  40. package/dist/src/decorators/term.d.ts +13 -0
  41. package/dist/src/decorators/term.d.ts.map +1 -0
  42. package/dist/src/decorators/term.js +14 -0
  43. package/dist/src/decorators/term.js.map +1 -0
  44. package/dist/src/entities/annotations.d.ts +4 -0
  45. package/dist/src/entities/annotations.d.ts.map +1 -1
  46. package/dist/src/entities/annotations.js +15 -0
  47. package/dist/src/entities/annotations.js.map +1 -1
  48. package/dist/src/entities/enum.js.map +1 -1
  49. package/dist/src/entities/model.d.ts.map +1 -1
  50. package/dist/src/entities/model.js +53 -4
  51. package/dist/src/entities/model.js.map +1 -1
  52. package/dist/src/entities/namespace.d.ts +6 -1
  53. package/dist/src/entities/namespace.d.ts.map +1 -1
  54. package/dist/src/entities/namespace.js +82 -6
  55. package/dist/src/entities/namespace.js.map +1 -1
  56. package/dist/src/entities/operation.d.ts +4 -0
  57. package/dist/src/entities/operation.d.ts.map +1 -1
  58. package/dist/src/entities/operation.js +16 -7
  59. package/dist/src/entities/operation.js.map +1 -1
  60. package/dist/src/entities/revision-definition.d.ts +1 -0
  61. package/dist/src/entities/revision-definition.d.ts.map +1 -1
  62. package/dist/src/entities/revision-definition.js +3 -3
  63. package/dist/src/entities/revision-definition.js.map +1 -1
  64. package/dist/src/entities/term.d.ts +8 -0
  65. package/dist/src/entities/term.d.ts.map +1 -0
  66. package/dist/src/entities/term.js +14 -0
  67. package/dist/src/entities/term.js.map +1 -0
  68. package/dist/src/index.d.ts +1 -1
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +1 -1
  71. package/dist/src/index.js.map +1 -1
  72. package/dist/src/lib.d.ts +59 -146
  73. package/dist/src/lib.d.ts.map +1 -1
  74. package/dist/src/lib.js +19 -10
  75. package/dist/src/lib.js.map +1 -1
  76. package/dist/src/rules/allowed-values.d.ts +2 -1
  77. package/dist/src/rules/allowed-values.d.ts.map +1 -1
  78. package/dist/src/rules/allowed-values.js +7 -7
  79. package/dist/src/rules/allowed-values.js.map +1 -1
  80. package/dist/src/rules/alternate-key.d.ts +4 -3
  81. package/dist/src/rules/alternate-key.d.ts.map +1 -1
  82. package/dist/src/rules/alternate-key.js +23 -23
  83. package/dist/src/rules/alternate-key.js.map +1 -1
  84. package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -1
  85. package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -1
  86. package/dist/src/rules/collection-navigation-properties-not-nullable.js +9 -9
  87. package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -1
  88. package/dist/src/rules/computed.d.ts +2 -1
  89. package/dist/src/rules/computed.d.ts.map +1 -1
  90. package/dist/src/rules/computed.js +9 -8
  91. package/dist/src/rules/computed.js.map +1 -1
  92. package/dist/src/rules/contains.d.ts +2 -1
  93. package/dist/src/rules/contains.d.ts.map +1 -1
  94. package/dist/src/rules/contains.js +9 -8
  95. package/dist/src/rules/contains.js.map +1 -1
  96. package/dist/src/rules/count.d.ts +2 -1
  97. package/dist/src/rules/count.d.ts.map +1 -1
  98. package/dist/src/rules/count.js +9 -8
  99. package/dist/src/rules/count.js.map +1 -1
  100. package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -1
  101. package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -1
  102. package/dist/src/rules/disallowed-typespec-decorators.js +29 -25
  103. package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -1
  104. package/dist/src/rules/entity.d.ts +5 -2
  105. package/dist/src/rules/entity.d.ts.map +1 -1
  106. package/dist/src/rules/entity.js +102 -19
  107. package/dist/src/rules/entity.js.map +1 -1
  108. package/dist/src/rules/enum.d.ts +3 -1
  109. package/dist/src/rules/enum.d.ts.map +1 -1
  110. package/dist/src/rules/enum.js +9 -6
  111. package/dist/src/rules/enum.js.map +1 -1
  112. package/dist/src/rules/expand.d.ts +3 -2
  113. package/dist/src/rules/expand.d.ts.map +1 -1
  114. package/dist/src/rules/expand.js +16 -16
  115. package/dist/src/rules/expand.js.map +1 -1
  116. package/dist/src/rules/extends-on-same-type.d.ts +2 -1
  117. package/dist/src/rules/extends-on-same-type.d.ts.map +1 -1
  118. package/dist/src/rules/extends-on-same-type.js +9 -8
  119. package/dist/src/rules/extends-on-same-type.js.map +1 -1
  120. package/dist/src/rules/filter.d.ts +4 -3
  121. package/dist/src/rules/filter.d.ts.map +1 -1
  122. package/dist/src/rules/filter.js +23 -23
  123. package/dist/src/rules/filter.js.map +1 -1
  124. package/dist/src/rules/function.d.ts +2 -1
  125. package/dist/src/rules/function.d.ts.map +1 -1
  126. package/dist/src/rules/function.js +9 -9
  127. package/dist/src/rules/function.js.map +1 -1
  128. package/dist/src/rules/global-operation.d.ts +4 -0
  129. package/dist/src/rules/global-operation.d.ts.map +1 -0
  130. package/dist/src/rules/global-operation.js +60 -0
  131. package/dist/src/rules/global-operation.js.map +1 -0
  132. package/dist/src/rules/graph-deprecated.d.ts +8 -0
  133. package/dist/src/rules/graph-deprecated.d.ts.map +1 -0
  134. package/dist/src/rules/graph-deprecated.js +152 -0
  135. package/dist/src/rules/graph-deprecated.js.map +1 -0
  136. package/dist/src/rules/graph-route.d.ts +4 -2
  137. package/dist/src/rules/graph-route.d.ts.map +1 -1
  138. package/dist/src/rules/graph-route.js +55 -15
  139. package/dist/src/rules/graph-route.js.map +1 -1
  140. package/dist/src/rules/has-stream.d.ts +2 -1
  141. package/dist/src/rules/has-stream.d.ts.map +1 -1
  142. package/dist/src/rules/has-stream.js +9 -8
  143. package/dist/src/rules/has-stream.js.map +1 -1
  144. package/dist/src/rules/index.d.ts +3 -0
  145. package/dist/src/rules/index.d.ts.map +1 -1
  146. package/dist/src/rules/index.js +3 -0
  147. package/dist/src/rules/index.js.map +1 -1
  148. package/dist/src/rules/namespace.d.ts +4 -3
  149. package/dist/src/rules/namespace.d.ts.map +1 -1
  150. package/dist/src/rules/namespace.js +58 -73
  151. package/dist/src/rules/namespace.js.map +1 -1
  152. package/dist/src/rules/open.d.ts +2 -1
  153. package/dist/src/rules/open.d.ts.map +1 -1
  154. package/dist/src/rules/open.js +9 -8
  155. package/dist/src/rules/open.js.map +1 -1
  156. package/dist/src/rules/operation-inside-interface.d.ts +2 -1
  157. package/dist/src/rules/operation-inside-interface.d.ts.map +1 -1
  158. package/dist/src/rules/operation-inside-interface.js +9 -8
  159. package/dist/src/rules/operation-inside-interface.js.map +1 -1
  160. package/dist/src/rules/order-by.d.ts +3 -2
  161. package/dist/src/rules/order-by.d.ts.map +1 -1
  162. package/dist/src/rules/order-by.js +16 -16
  163. package/dist/src/rules/order-by.js.map +1 -1
  164. package/dist/src/rules/ownerless.d.ts +10 -0
  165. package/dist/src/rules/ownerless.d.ts.map +1 -0
  166. package/dist/src/rules/ownerless.js +155 -0
  167. package/dist/src/rules/ownerless.js.map +1 -0
  168. package/dist/src/rules/partial.d.ts +2 -1
  169. package/dist/src/rules/partial.d.ts.map +1 -1
  170. package/dist/src/rules/partial.js +9 -8
  171. package/dist/src/rules/partial.js.map +1 -1
  172. package/dist/src/rules/references.d.ts +2 -1
  173. package/dist/src/rules/references.d.ts.map +1 -1
  174. package/dist/src/rules/references.js +9 -8
  175. package/dist/src/rules/references.js.map +1 -1
  176. package/dist/src/rules/required-for-create.d.ts +2 -1
  177. package/dist/src/rules/required-for-create.d.ts.map +1 -1
  178. package/dist/src/rules/required-for-create.js +9 -8
  179. package/dist/src/rules/required-for-create.js.map +1 -1
  180. package/dist/src/rules/search.d.ts +2 -1
  181. package/dist/src/rules/search.d.ts.map +1 -1
  182. package/dist/src/rules/search.js +9 -8
  183. package/dist/src/rules/search.js.map +1 -1
  184. package/dist/src/rules/skip.d.ts +2 -1
  185. package/dist/src/rules/skip.d.ts.map +1 -1
  186. package/dist/src/rules/skip.js +9 -8
  187. package/dist/src/rules/skip.js.map +1 -1
  188. package/dist/src/rules/top.d.ts +2 -1
  189. package/dist/src/rules/top.d.ts.map +1 -1
  190. package/dist/src/rules/top.js +9 -8
  191. package/dist/src/rules/top.js.map +1 -1
  192. package/dist/src/testing/index.d.ts +1 -0
  193. package/dist/src/testing/index.d.ts.map +1 -1
  194. package/dist/src/testing/index.js +21 -0
  195. package/dist/src/testing/index.js.map +1 -1
  196. package/dist/src/utils.d.ts +3 -0
  197. package/dist/src/utils.d.ts.map +1 -1
  198. package/dist/src/utils.js +19 -5
  199. package/dist/src/utils.js.map +1 -1
  200. package/dist/src/{linter.d.ts → validate.d.ts} +1 -1
  201. package/dist/src/validate.d.ts.map +1 -0
  202. package/dist/src/validate.js +51 -0
  203. package/dist/src/validate.js.map +1 -0
  204. package/lib/decorators.tsp +28 -0
  205. package/package.json +5 -7
  206. package/dist/src/linter.d.ts.map +0 -1
  207. package/dist/src/linter.js +0 -44
  208. package/dist/src/linter.js.map +0 -1
@@ -1,11 +1,11 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { hasStream } from "../decorators/has-stream.js";
3
2
  import { isEntity } from "../index.js";
4
3
  import { reportDiagnostic } from "../lib.js";
5
- export const hasStreamOnlyOnEntity = createRule({
6
- name: "has-stream-on-entity",
7
- create({ program }) {
8
- return {
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
9
  model: (model) => {
10
10
  if (!hasStream(program, model)) {
11
11
  return;
@@ -23,7 +23,8 @@ export const hasStreamOnlyOnEntity = createRule({
23
23
  },
24
24
  });
25
25
  },
26
- };
27
- },
28
- });
26
+ });
27
+ }
28
+ }
29
+ ;
29
30
  //# sourceMappingURL=has-stream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"has-stream.js","sourceRoot":"","sources":["../../../src/rules/has-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,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;IACJ,CAAC;CACF,CAAC,CAAC"}
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"}
@@ -25,4 +25,7 @@ export * from "./top.js";
25
25
  export * from "./allowed-values.js";
26
26
  export * from "./graph-route.js";
27
27
  export * from "./partial.js";
28
+ export * from "./graph-deprecated.js";
29
+ export * from "./ownerless.js";
30
+ export * from "./global-operation.js";
28
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
@@ -25,4 +25,7 @@ export * from "./top.js";
25
25
  export * from "./allowed-values.js";
26
26
  export * from "./graph-route.js";
27
27
  export * from "./partial.js";
28
+ export * from "./graph-deprecated.js";
29
+ export * from "./ownerless.js";
30
+ export * from "./global-operation.js";
28
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
@@ -1,4 +1,5 @@
1
- export declare const namespaceIsRequiredRule: import("@typespec/lint").LintRule;
2
- export declare const invalidPublicNamespaceNameRule: import("@typespec/lint").LintRule;
3
- export declare const topLevelNamespaceMustHavePublicNamespaceRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateNamespaceIsRequired(program: Program): void;
3
+ export declare function validatePublicNamespaceName(program: Program): void;
4
+ export declare function validateTopLevelNamespaceMustHavePublicNamespace(program: Program): void;
4
5
  //# sourceMappingURL=namespace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/rules/namespace.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,mCA2BlC,CAAC;AAEH,eAAO,MAAM,8BAA8B,mCA0BzC,CAAC;AAEH,eAAO,MAAM,4CAA4C,mCAwCvD,CAAC"}
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/rules/namespace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkD,MAAM,oBAAoB,CAAC;AAI7F,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QA0B3D;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QAqB3D;AAED,wBAAgB,gDAAgD,CAAC,OAAO,EAAE,OAAO,QAkChF"}
@@ -1,12 +1,11 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { reportDiagnostic } from "../lib.js";
3
2
  import { getPublicNamespaceName, hasPublicNamespace } from "../index.js";
4
- import { getNamespaceFullName } from "@typespec/compiler";
5
- import { getIdForType, getNamespaceName, isExcludedCoreType } from "../utils.js";
6
- export const namespaceIsRequiredRule = createRule({
7
- name: "namespace-is-required",
8
- create({ program }) {
9
- return {
3
+ import { getNamespaceFullName, navigateTypesInNamespace } from "@typespec/compiler";
4
+ import { getIdForType, isExcludedCoreType, isTypeDefinedInExternalLibrary } from "../utils.js";
5
+ import { GetDeclaredNamespaces, expandNamespaces } from "../entities/namespace.js";
6
+ export function validateNamespaceIsRequired(program) {
7
+ for (const namespace of GetDeclaredNamespaces(program)) {
8
+ navigateTypesInNamespace(namespace, {
10
9
  model: (model) => {
11
10
  if (model.namespace && model.namespace.name) {
12
11
  return;
@@ -26,75 +25,61 @@ export const namespaceIsRequiredRule = createRule({
26
25
  },
27
26
  });
28
27
  },
29
- };
30
- },
31
- });
32
- export const invalidPublicNamespaceNameRule = createRule({
33
- name: "invalid-public-namespace-name",
34
- create({ program }) {
35
- return {
36
- namespace: (namespace) => {
37
- if (!hasPublicNamespace(program, namespace)) {
38
- return;
39
- }
40
- const publicNamespaceName = getPublicNamespaceName(program, namespace);
41
- if (isValidPublicNamespaceName(publicNamespaceName)) {
42
- return;
43
- }
44
- reportDiagnostic(program, {
45
- code: "decorator-invalid-use",
46
- target: namespace,
47
- messageId: "invalidPublicNamespaceName",
48
- format: {
49
- namespace: getNamespaceFullName(namespace),
50
- },
51
- });
28
+ });
29
+ }
30
+ }
31
+ ;
32
+ export function validatePublicNamespaceName(program) {
33
+ for (const namespace of GetDeclaredNamespaces(program)) {
34
+ if (!hasPublicNamespace(program, namespace)) {
35
+ return;
36
+ }
37
+ const publicNamespaceName = getPublicNamespaceName(program, namespace);
38
+ if (isValidPublicNamespaceName(publicNamespaceName)) {
39
+ return;
40
+ }
41
+ reportDiagnostic(program, {
42
+ code: "decorator-invalid-use",
43
+ target: namespace,
44
+ messageId: "invalidPublicNamespaceName",
45
+ format: {
46
+ namespace: getNamespaceFullName(namespace),
52
47
  },
53
- };
54
- },
55
- });
56
- export const topLevelNamespaceMustHavePublicNamespaceRule = createRule({
57
- name: "top-level-namespace-must-have-public-namespace",
58
- create({ program }) {
59
- return {
60
- namespace: (namespace) => {
61
- if (isExcludedCoreType(program, namespace)) {
62
- return;
63
- }
64
- if (!isTopLevelNamespace(program, namespace)) {
65
- return;
66
- }
67
- if (hasPublicNamespace(program, namespace)) {
68
- return;
69
- }
70
- // Special case for microsoft root namespace.
71
- // i.e. microsoft.graph is actually interpreted as two namespaces:
72
- // a) microsoft, and b) graph.
73
- // We don't want to emit an error for the root microsoft namespace.
74
- if (getIdForType(program, namespace) === "microsoft") {
75
- return;
76
- }
77
- const namespaceName = getIdForType(program, namespace);
78
- if (isValidPublicNamespaceName(namespaceName)) {
79
- return;
80
- }
81
- reportDiagnostic(program, {
82
- code: "element-missing-dependencies",
83
- target: namespace,
84
- messageId: "topLevelNamespaceMissingPublicNamespace",
85
- format: {
86
- namespace: getNamespaceFullName(namespace),
87
- },
88
- });
48
+ });
49
+ }
50
+ }
51
+ ;
52
+ export function validateTopLevelNamespaceMustHavePublicNamespace(program) {
53
+ const rootNamespace = program.checker.getGlobalNamespaceType();
54
+ for (const namespace of expandNamespaces(rootNamespace)) {
55
+ if (isTypeDefinedInExternalLibrary(program, namespace)) {
56
+ continue;
57
+ }
58
+ if (isExcludedCoreType(program, namespace)) {
59
+ continue;
60
+ }
61
+ // The nested namespaces will cause validation of the parent namespace.
62
+ if (namespace.namespaces.size > 0) {
63
+ continue;
64
+ }
65
+ if (getPublicNamespaceName(program, namespace)) {
66
+ continue;
67
+ }
68
+ const namespaceName = getIdForType(program, namespace);
69
+ if (isValidPublicNamespaceName(namespaceName)) {
70
+ continue;
71
+ }
72
+ reportDiagnostic(program, {
73
+ code: "element-missing-dependencies",
74
+ target: namespace,
75
+ messageId: "topLevelNamespaceMissingPublicNamespace",
76
+ format: {
77
+ namespace: getNamespaceFullName(namespace),
89
78
  },
90
- };
91
- },
92
- });
93
- function isTopLevelNamespace(program, namespace) {
94
- const topLevelNamespaceNames = ["TypeSpec", ""];
95
- return (namespace.namespace &&
96
- topLevelNamespaceNames.includes(getNamespaceName(program, namespace.namespace)));
79
+ });
80
+ }
97
81
  }
82
+ ;
98
83
  function isValidPublicNamespaceName(namespace) {
99
84
  // publicNamespace name should either be "microsoft.graph"
100
85
  // or match the pattern "microsoft.graph.<string_token>"
@@ -1 +1 @@
1
- {"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/rules/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAsB,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;IAChD,IAAI,EAAE,uBAAuB;IAC7B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE;oBAC3C,OAAO;iBACR;gBAED,OAAO,KAAK,CAAC,SAAS,EAAE;oBACtB,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;oBACxB,IAAI,KAAK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,GAAG,yBAAyB,CAAC;IACjD,OAAO,SAAS,KAAK,iBAAiB,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3E,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @open applies to either an entity or a complex type.
3
4
  */
4
- export declare const openOnlyAppliesToStructuredType: import("@typespec/lint").LintRule;
5
+ export declare function validateOpenOnlyAppliesToStructuredType(program: Program): void;
5
6
  //# sourceMappingURL=open.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/rules/open.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,+BAA+B,mCAyB1C,CAAC"}
1
+ {"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/rules/open.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE;;GAEG;AACH,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,OAAO,QAwBvE"}
@@ -1,13 +1,13 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { isComplex, isEntity, isOpen } from "../index.js";
3
2
  import { reportDiagnostic } from "../lib.js";
3
+ import { navigateTypesInNamespace } from "@typespec/compiler";
4
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
4
5
  /**
5
6
  * @open applies to either an entity or a complex type.
6
7
  */
7
- export const openOnlyAppliesToStructuredType = createRule({
8
- name: "open-only-applies-to-structured-type",
9
- create({ program }) {
10
- return {
8
+ export function validateOpenOnlyAppliesToStructuredType(program) {
9
+ for (const namespace of GetDeclaredNamespaces(program)) {
10
+ navigateTypesInNamespace(namespace, {
11
11
  model: (model) => {
12
12
  if (!isOpen(program, model)) {
13
13
  return;
@@ -25,7 +25,8 @@ export const openOnlyAppliesToStructuredType = createRule({
25
25
  },
26
26
  });
27
27
  },
28
- };
29
- },
30
- });
28
+ });
29
+ }
30
+ }
31
+ ;
31
32
  //# sourceMappingURL=open.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/rules/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,UAAU,CAAC;IACxD,IAAI,EAAE,sCAAsC;IAC5C,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC3B,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACzD,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,KAAK;oBACb,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,gCAAgC;qBACzC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/rules/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,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,uCAAuC,CAAC,OAAgB;IACtE,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC3B,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACzD,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,KAAK;oBACb,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,gCAAgC;qBACzC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare const operationInsideInterfaceRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateOperationInsideInterface(program: Program): void;
2
3
  //# sourceMappingURL=operation-inside-interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation-inside-interface.d.ts","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,mCAsBvC,CAAC"}
1
+ {"version":3,"file":"operation-inside-interface.d.ts","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,OAAO,QAqBhE"}
@@ -1,10 +1,10 @@
1
- import { createRule } from "@typespec/lint";
2
1
  import { reportDiagnostic } from "../lib.js";
3
2
  import { isExcludedCoreType } from "../utils.js";
4
- export const operationInsideInterfaceRule = createRule({
5
- name: "operation-inside-interface",
6
- create({ program }) {
7
- return {
3
+ import { navigateTypesInNamespace } from "@typespec/compiler";
4
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
5
+ export function validateOperationInsideInterface(program) {
6
+ for (const namespace of GetDeclaredNamespaces(program)) {
7
+ navigateTypesInNamespace(namespace, {
8
8
  operation: (operation) => {
9
9
  if (operation.interface) {
10
10
  return;
@@ -19,7 +19,8 @@ export const operationInsideInterfaceRule = createRule({
19
19
  format: {},
20
20
  });
21
21
  },
22
- };
23
- },
24
- });
22
+ });
23
+ }
24
+ }
25
+ ;
25
26
  //# sourceMappingURL=operation-inside-interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation-inside-interface.js","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC;IACrD,IAAI,EAAE,4BAA4B;IAClC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,SAAS,CAAC,SAAS,EAAE;oBACvB,OAAO;iBACR;gBAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC1C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"operation-inside-interface.js","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,gCAAgC,CAAC,OAAgB;IAC/D,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,SAAS,CAAC,SAAS,EAAE;oBACvB,OAAO;iBACR;gBAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC1C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,3 +1,4 @@
1
- export declare const orderByAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
2
- export declare const orderByOnlyNonNavigationPropertiesRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateOrderByAppliesToGetOperationsThatReturnCollections(program: Program): void;
3
+ export declare function validateOrderByOnlyNonNavigationProperties(program: Program): void;
3
4
  //# sourceMappingURL=order-by.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-by.d.ts","sourceRoot":"","sources":["../../../src/rules/order-by.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,sDAAsD,mCA6BjE,CAAC;AAEH,eAAO,MAAM,sCAAsC,mCAwCjD,CAAC"}
1
+ {"version":3,"file":"order-by.d.ts","sourceRoot":"","sources":["../../../src/rules/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAqD,MAAM,oBAAoB,CAAC;AAQvG,wBAAgB,0DAA0D,CAAC,OAAO,EAAE,OAAO,QA4B1F;AAED,wBAAgB,0CAA0C,CAAC,OAAO,EAAE,OAAO,QAuC1E"}
@@ -1,14 +1,13 @@
1
- import { walkPropertiesInherited } from "@typespec/compiler";
2
- import { createRule } from "@typespec/lint";
1
+ import { navigateTypesInNamespace, walkPropertiesInherited } from "@typespec/compiler";
3
2
  import { getOperationVerb } from "@typespec/http";
4
3
  import { getOrderBy, isContains, isOrderBy, isReferences } from "../index.js";
5
4
  import { isTypeCollection } from "../utils.js";
6
5
  import { reportDiagnostic } from "../lib.js";
7
6
  import { getNavigationSourceType } from "../utils.js";
8
- export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule({
9
- name: "order-by-applies-to-get-operations-that-return-collections",
10
- create({ program }) {
11
- return {
7
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
8
+ export function validateOrderByAppliesToGetOperationsThatReturnCollections(program) {
9
+ for (const namespace of GetDeclaredNamespaces(program)) {
10
+ navigateTypesInNamespace(namespace, {
12
11
  operation: (operation) => {
13
12
  if (!isOrderBy(program, operation)) {
14
13
  return;
@@ -30,13 +29,13 @@ export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule
30
29
  },
31
30
  });
32
31
  },
33
- };
34
- },
35
- });
36
- export const orderByOnlyNonNavigationPropertiesRule = createRule({
37
- name: "order-by-only-non-navigation-properties",
38
- create({ program }) {
39
- return {
32
+ });
33
+ }
34
+ }
35
+ ;
36
+ export function validateOrderByOnlyNonNavigationProperties(program) {
37
+ for (const namespace of GetDeclaredNamespaces(program)) {
38
+ navigateTypesInNamespace(namespace, {
40
39
  operation: (operation) => {
41
40
  const ordered = getOrderBy(program, operation);
42
41
  if (!ordered.length) {
@@ -64,7 +63,8 @@ export const orderByOnlyNonNavigationPropertiesRule = createRule({
64
63
  },
65
64
  });
66
65
  },
67
- };
68
- },
69
- });
66
+ });
67
+ }
68
+ }
69
+ ;
70
70
  //# sourceMappingURL=order-by.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-by.js","sourceRoot":"","sources":["../../../src/rules/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,sDAAsD,GAAG,UAAU,CAAC;IAC/E,IAAI,EAAE,4DAA4D;IAClE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAClC,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,EAA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BAAuB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC1D,CAAC;gBAEF,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;oBAC3B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,mBAAmB;oBAC9B,MAAM,EAAE;wBACN,KAAK,EAAE,SAAS,CAAC,IAAI;wBACrB,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;qBACvC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -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","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