@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
@@ -1,12 +1,11 @@
1
- import { isKey, walkPropertiesInherited } from "@typespec/compiler";
2
- import { createRule } from "@typespec/lint";
1
+ import { isKey, navigateTypesInNamespace, walkPropertiesInherited } from "@typespec/compiler";
3
2
  import { isAlternateKey } from "../index.js";
4
3
  import { reportDiagnostic } from "../lib.js";
5
4
  import { isTypeNullable } from "../utils.js";
6
- export const alternateKeyOnPrimitivePropertyRule = createRule({
7
- name: "alternate-key-on-primitive-property",
8
- create({ program }) {
9
- return {
5
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
+ export function validateAlternateKeyOnPrimitiveProperty(program) {
7
+ for (const namespace of GetDeclaredNamespaces(program)) {
8
+ navigateTypesInNamespace(namespace, {
10
9
  modelProperty: (property) => {
11
10
  if (!property.model || !isAlternateKey(program, property)) {
12
11
  return;
@@ -23,13 +22,13 @@ export const alternateKeyOnPrimitivePropertyRule = createRule({
23
22
  return;
24
23
  }
25
24
  },
26
- };
27
- },
28
- });
29
- export const alternateKeyOnKeyRule = createRule({
30
- name: "alternate-key-on-key",
31
- create({ program }) {
32
- return {
25
+ });
26
+ }
27
+ }
28
+ ;
29
+ export function validateAlternateKeyOnKey(program) {
30
+ for (const namespace of GetDeclaredNamespaces(program)) {
31
+ navigateTypesInNamespace(namespace, {
33
32
  modelProperty: (property) => {
34
33
  if (!property.model || !isAlternateKey(program, property)) {
35
34
  return;
@@ -49,13 +48,13 @@ export const alternateKeyOnKeyRule = createRule({
49
48
  });
50
49
  return;
51
50
  },
52
- };
53
- },
54
- });
55
- export const alternateKeyRequiresKeyRule = createRule({
56
- name: "alternate-key-requires-key",
57
- create({ program }) {
58
- return {
51
+ });
52
+ }
53
+ }
54
+ ;
55
+ export function validateAlternateKeyRequiresKey(program) {
56
+ for (const namespace of GetDeclaredNamespaces(program)) {
57
+ navigateTypesInNamespace(namespace, {
59
58
  modelProperty: (property) => {
60
59
  if (!property.model || !isAlternateKey(program, property)) {
61
60
  return;
@@ -75,7 +74,8 @@ export const alternateKeyRequiresKeyRule = createRule({
75
74
  },
76
75
  });
77
76
  },
78
- };
79
- },
80
- });
77
+ });
78
+ }
79
+ }
80
+ ;
81
81
  //# sourceMappingURL=alternate-key.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alternate-key.js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,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAC7B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,SAAS;oBACpB,MAAM,EAAE;wBACN,SAAS,EAAE,eAAe;wBAC1B,KAAK,EAAE,MAAM;wBACb,QAAQ,EAAE,UAAU;qBACrB;iBACF,CAAC,CAAC;gBAEH,OAAO;YACT,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAAC,OAAgB;IAC9D,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBACzD,OAAO;iBACR;gBAED,KAAK,MAAM,aAAa,IAAI,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;oBACnE,IAAI,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE;wBACjC,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,SAAS,EAAE,eAAe;wBAC1B,QAAQ,EAAE,MAAM;wBAChB,QAAQ,EAAE,cAAc;qBACzB;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare const collectionValuedNavigationPropertiesCannotBeNullableRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateCollectionValuedNavigationPropertiesCannotBeNullable(program: Program): void;
2
3
  //# sourceMappingURL=collection-navigation-properties-not-nullable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-navigation-properties-not-nullable.d.ts","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,wDAAwD,mCA2BjE,CAAC"}
1
+ {"version":3,"file":"collection-navigation-properties-not-nullable.d.ts","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE,wBAAgB,4DAA4D,CAAC,OAAO,EAAE,OAAO,QAyB5F"}
@@ -1,10 +1,10 @@
1
- import { createRule } from "@typespec/lint";
2
- import { isTypeCollection, isNavigationProperty, isTypeNullable, } from "../utils.js";
1
+ import { isTypeCollection, isNavigationProperty, isTypeNullable } from "../utils.js";
3
2
  import { reportDiagnostic } from "../lib.js";
4
- export const collectionValuedNavigationPropertiesCannotBeNullableRule = createRule({
5
- name: "collection-valued-navigation-properties-cannot-be-nullable",
6
- create({ program }) {
7
- return {
3
+ import { navigateTypesInNamespace } from "@typespec/compiler";
4
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
5
+ export function validateCollectionValuedNavigationPropertiesCannotBeNullable(program) {
6
+ for (const namespace of GetDeclaredNamespaces(program)) {
7
+ navigateTypesInNamespace(namespace, {
8
8
  modelProperty: (property) => {
9
9
  if (!isNavigationProperty(program, property)) {
10
10
  return;
@@ -22,7 +22,7 @@ export const collectionValuedNavigationPropertiesCannotBeNullableRule = createRu
22
22
  format: {},
23
23
  });
24
24
  },
25
- };
26
- },
27
- });
25
+ });
26
+ }
27
+ }
28
28
  //# sourceMappingURL=collection-navigation-properties-not-nullable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-navigation-properties-not-nullable.js","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,wDAAwD,GACnE,UAAU,CAAC;IACT,IAAI,EAAE,4DAA4D;IAClE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAC5C,OAAO;iBACR;gBAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC7C,OAAO;iBACR;gBAED,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC3C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,2CAA2C;oBACtD,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"collection-navigation-properties-not-nullable.js","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrF,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,4DAA4D,CAAC,OAAgB;IAC3F,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAC5C,OAAO;iBACR;gBAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC7C,OAAO;iBACR;gBAED,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC3C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,2CAA2C;oBACtD,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC"}
@@ -1,7 +1,8 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @computed cannot be combined with nullable
3
4
  * @computed cannot be combined with @required
4
5
  * @computed cannot be combined with @writeOnly
5
6
  */
6
- export declare const computedCannotBeCombinedWithRule: import("@typespec/lint").LintRule;
7
+ export declare function validateComputedCannotBeCombined(program: Program): void;
7
8
  //# sourceMappingURL=computed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../../src/rules/computed.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,mCAqC3C,CAAC"}
1
+ {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../../src/rules/computed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAOvE;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,OAAO,QAoChE"}
@@ -1,17 +1,17 @@
1
- import { createRule } from "@typespec/lint";
1
+ import { navigateTypesInNamespace } from "@typespec/compiler";
2
2
  import { isComputed } from "../decorators/computed.js";
3
3
  import { isWriteOnly } from "../index.js";
4
4
  import { reportDiagnostic } from "../lib.js";
5
5
  import { isTypeNullable } from "../utils.js";
6
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
7
  /**
7
8
  * @computed cannot be combined with nullable
8
9
  * @computed cannot be combined with @required
9
10
  * @computed cannot be combined with @writeOnly
10
11
  */
11
- export const computedCannotBeCombinedWithRule = createRule({
12
- name: "computed-cannot-be-combined-with",
13
- create({ program }) {
14
- return {
12
+ export function validateComputedCannotBeCombined(program) {
13
+ for (const namespace of GetDeclaredNamespaces(program)) {
14
+ navigateTypesInNamespace(namespace, {
15
15
  modelProperty: (property) => {
16
16
  if (!isComputed(program, property)) {
17
17
  return;
@@ -41,7 +41,8 @@ export const computedCannotBeCombinedWithRule = createRule({
41
41
  });
42
42
  }
43
43
  },
44
- };
45
- },
46
- });
44
+ });
45
+ }
46
+ }
47
+ ;
47
48
  //# sourceMappingURL=computed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed.js","sourceRoot":"","sources":["../../../src/rules/computed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAAC;IACzD,IAAI,EAAE,kCAAkC;IACxC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,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CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAClC,OAAO;iBACR;gBAED,IAAI,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC1C,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,uBAAuB;wBAC7B,MAAM,EAAE,QAAQ;wBAChB,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE;4BACN,SAAS,EAAE,WAAW;4BACtB,KAAK,EAAE,UAAU;4BACjB,QAAQ,EAAE,UAAU;yBACrB;qBACF,CAAC,CAAC;iBACJ;gBAED,IAAI,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAClC,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,uBAAuB;wBAC7B,MAAM,EAAE,QAAQ;wBAChB,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE;4BACN,SAAS,EAAE,WAAW;4BACtB,KAAK,EAAE,YAAY;4BACnB,QAAQ,EAAE,UAAU;yBACrB;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Program } from "@typespec/compiler";
1
2
  /**
2
3
  * @contains applies to a navigation property.
3
4
  */
4
- export declare const containsOnlyAppliesToNavigationPropertyRule: import("@typespec/lint").LintRule;
5
+ export declare function validatecontainsOnlyAppliesToNavigationProperty(program: Program): void;
5
6
  //# sourceMappingURL=contains.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contains.d.ts","sourceRoot":"","sources":["../../../src/rules/contains.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,2CAA2C,mCAyBtD,CAAC"}
1
+ {"version":3,"file":"contains.d.ts","sourceRoot":"","sources":["../../../src/rules/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAMvE;;GAEG;AACH,wBAAgB,+CAA+C,CAAC,OAAO,EAAE,OAAO,QAwB/E"}
@@ -1,14 +1,14 @@
1
- import { createRule } from "@typespec/lint";
1
+ import { navigateTypesInNamespace } from "@typespec/compiler";
2
2
  import { isContains } from "../index.js";
3
3
  import { reportDiagnostic } from "../lib.js";
4
4
  import { isNavigationProperty } from "../utils.js";
5
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
5
6
  /**
6
7
  * @contains applies to a navigation property.
7
8
  */
8
- export const containsOnlyAppliesToNavigationPropertyRule = createRule({
9
- name: "contains-only-applies-to-navigation-property",
10
- create({ program }) {
11
- return {
9
+ export function validatecontainsOnlyAppliesToNavigationProperty(program) {
10
+ for (const namespace of GetDeclaredNamespaces(program)) {
11
+ navigateTypesInNamespace(namespace, {
12
12
  modelProperty: (property) => {
13
13
  if (!isContains(program, property)) {
14
14
  return;
@@ -26,7 +26,8 @@ export const containsOnlyAppliesToNavigationPropertyRule = createRule({
26
26
  },
27
27
  });
28
28
  },
29
- };
30
- },
31
- });
29
+ });
30
+ }
31
+ }
32
+ ;
32
33
  //# sourceMappingURL=contains.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../src/rules/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG,UAAU,CAAC;IACpE,IAAI,EAAE,8CAA8C;IACpD,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,UAAU,CA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BACtB,MAAM,EAAE,wCAAwC;qBACjD;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
  * @count applies to get operations that return collections.
3
4
  */
4
- export declare const countAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
5
+ export declare function validateCountAppliesToGetOperationsThatReturnCollections(program: Program): void;
5
6
  //# sourceMappingURL=count.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,oDAAoD,mCA6B/D,CAAC"}
1
+ {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAOvE;;GAEG;AACH,wBAAgB,wDAAwD,CAAC,OAAO,EAAE,OAAO,QA4BxF"}
@@ -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 { isCount } 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
  * @count applies to get operations that return collections.
8
9
  */
9
- export const countAppliesToGetOperationsThatReturnCollectionsRule = createRule({
10
- name: "count-applies-to-get-operations-that-return-collections",
11
- create({ program }) {
12
- return {
10
+ export function validateCountAppliesToGetOperationsThatReturnCollections(program) {
11
+ for (const namespace of GetDeclaredNamespaces(program)) {
12
+ navigateTypesInNamespace(namespace, {
13
13
  operation: (operation) => {
14
14
  if (!isCount(program, operation)) {
15
15
  return;
@@ -31,7 +31,8 @@ export const countAppliesToGetOperationsThatReturnCollectionsRule = createRule({
31
31
  },
32
32
  });
33
33
  },
34
- };
35
- },
36
- });
34
+ });
35
+ }
36
+ }
37
+ ;
37
38
  //# sourceMappingURL=count.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"count.js","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,oDAAoD,GAAG,UAAU,CAAC;IAC7E,IAAI,EAAE,yDAAyD;IAC/D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAChC,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,QAAQ;wBACnB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"count.js","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,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,wDAAwD,CAAC,OAAgB;IACvF,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAChC,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,QAAQ;wBACnB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare const disallowedTypeSpecDecoratorsRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateDisallowedTypeSpecDecorators(program: Program): void;
2
3
  //# sourceMappingURL=disallowed-typespec-decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"disallowed-typespec-decorators.d.ts","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gCAAgC,mCA+B3C,CAAC"}
1
+ {"version":3,"file":"disallowed-typespec-decorators.d.ts","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,OAAO,EAER,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,OAAO,QAkCpE"}
@@ -1,33 +1,37 @@
1
- import { createRule } from "@typespec/lint";
1
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
2
2
  import { reportDiagnostic } from "../lib.js";
3
- export const disallowedTypeSpecDecoratorsRule = createRule({
4
- name: "disallowed-typespec-decorators",
5
- create({ program }) {
6
- return {
7
- decorator: (decorator) => {
8
- const denyList = [
9
- "@friendlyName",
10
- "@secret",
11
- "@summary",
12
- "@tag",
13
- "@visibility",
14
- "@withVisibility",
15
- "@withUpdateableProperties",
16
- "@withDefaultKeyVisibility",
17
- ];
18
- if (denyList.indexOf(decorator.name) < 0) {
19
- return;
20
- }
3
+ import { navigateTypesInNamespace, } from "@typespec/compiler";
4
+ export function validateDisallowedTypeSpecDecorators(program) {
5
+ const denyList = [
6
+ "$friendlyName",
7
+ "$secret",
8
+ "$summary",
9
+ "$tag",
10
+ "$visibility",
11
+ "$withVisibility",
12
+ "$withUpdateableProperties",
13
+ "$withDefaultKeyVisibility",
14
+ ];
15
+ function validate(x) {
16
+ x.decorators.forEach((d) => {
17
+ if (denyList.indexOf(d.decorator.name) >= 0) {
21
18
  reportDiagnostic(program, {
22
19
  code: "decorator-invalid-use",
23
- target: decorator.target,
20
+ target: x,
24
21
  messageId: "disallowedTypeSpecDecorators",
25
22
  format: {
26
- decorator: decorator.name,
23
+ decorator: d.decorator.name,
27
24
  },
28
25
  });
29
- },
30
- };
31
- },
32
- });
26
+ }
27
+ });
28
+ }
29
+ for (const namespace of GetDeclaredNamespaces(program)) {
30
+ navigateTypesInNamespace(namespace, {
31
+ model: validate,
32
+ modelProperty: validate,
33
+ interface: validate,
34
+ });
35
+ }
36
+ }
33
37
  //# sourceMappingURL=disallowed-typespec-decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"disallowed-typespec-decorators.js","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAAC;IACzD,IAAI,EAAE,gCAAgC;IACtC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,QAAQ,GAAG;oBACf,eAAe;oBACf,SAAS;oBACT,UAAU;oBACV,MAAM;oBACN,aAAa;oBACb,iBAAiB;oBACjB,2BAA2B;oBAC3B,2BAA2B;iBAC5B,CAAC;gBAEF,IAAI,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;oBACxC,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,SAAS,EAAE,8BAA8B;oBACzC,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS,CAAC,IAAI;qBAC1B;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"disallowed-typespec-decorators.js","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAKL,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,UAAU,oCAAoC,CAAC,OAAgB;IACnE,MAAM,QAAQ,GAAG;QACf,eAAe;QACf,SAAS;QACT,UAAU;QACV,MAAM;QACN,aAAa;QACb,iBAAiB;QACjB,2BAA2B;QAC3B,2BAA2B;KAC5B,CAAC;IAEF,SAAS,QAAQ,CAAC,CAAoC;QACpD,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACzB,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC3C,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,CAAC;oBACT,SAAS,EAAE,8BAA8B;oBACzC,MAAM,EAAE;wBACN,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI;qBAC5B;iBACF,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,KAAK,EAAE,QAAQ;YACf,aAAa,EAAE,QAAQ;YACvB,SAAS,EAAE,QAAQ;SACpB,CAAC,CAAC;KACJ;AACH,CAAC"}
@@ -1,3 +1,6 @@
1
- export declare const entityMustHaveKeyRule: import("@typespec/lint").LintRule;
2
- export declare const keyOnlyOnEntityNonNullablePrimitivePropertyRule: import("@typespec/lint").LintRule;
1
+ import { Program } from "@typespec/compiler";
2
+ export declare function validateEntityMustHaveKey(program: Program): void;
3
+ export declare function validateKeyOnlyOnEntityNonNullablePrimitiveProperty(program: Program): void;
4
+ export declare function validateExtendOnlyAppliesOnDifferentNamespaces(program: Program): void;
5
+ export declare function validatePropertyTypeOfEntityTypeMustHaveContainsOrReferences(program: Program): void;
3
6
  //# sourceMappingURL=entity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,mCA+BhC,CAAC;AAEH,eAAO,MAAM,+CAA+C,mCA4C1D,CAAC"}
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EACoD,MAAM,oBAAoB,CAAC;AAM/F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAgCzD;AAED,wBAAgB,mDAAmD,CAAC,OAAO,EAAE,OAAO,QA2CnF;AAGD,wBAAgB,8CAA8C,CAAC,OAAO,EAAE,OAAO,QA8B9E;AAED,wBAAgB,4DAA4D,CAAE,OAAO,EAAE,OAAO,QA0B7F"}
@@ -1,17 +1,18 @@
1
- import { isKey, walkPropertiesInherited } from "@typespec/compiler";
2
- import { createRule } from "@typespec/lint";
3
- import { isEntity, isPartial } from "../index.js";
1
+ import { getLocationContext, isKey, navigateTypesInNamespace, walkPropertiesInherited, isArrayModelType } from "@typespec/compiler";
2
+ import { isContains, isEntity, isPartial, isReferences } from "../index.js";
4
3
  import { reportDiagnostic } from "../lib.js";
5
- import { isTypeNullable, isExcludedLibraryType } from "../utils.js";
6
- export const entityMustHaveKeyRule = createRule({
7
- name: "entity-must-have-key",
8
- create({ program }) {
9
- return {
4
+ import { isTypeNullable, isExcludedLibraryType, isSameNamespace, extractTypesFromUnion } from "../utils.js";
5
+ import { GetDeclaredNamespaces } from "../entities/namespace.js";
6
+ export function validateEntityMustHaveKey(program) {
7
+ for (const namespace of GetDeclaredNamespaces(program)) {
8
+ navigateTypesInNamespace(namespace, {
10
9
  model: (model) => {
11
10
  if (!isEntity(program, model)) {
12
11
  return;
13
12
  }
14
- for (const property of walkPropertiesInherited(model)) {
13
+ // for (const property of walkPropertiesInherited(model)) {
14
+ const properties = walkPropertiesInherited(model);
15
+ for (const property of properties) {
15
16
  if (isKey(program, property)) {
16
17
  return;
17
18
  }
@@ -29,13 +30,13 @@ export const entityMustHaveKeyRule = createRule({
29
30
  },
30
31
  });
31
32
  },
32
- };
33
- },
34
- });
35
- export const keyOnlyOnEntityNonNullablePrimitivePropertyRule = createRule({
36
- name: "key-only-on-entity-non-nullable-primitive-property",
37
- create({ program }) {
38
- return {
33
+ });
34
+ }
35
+ }
36
+ ;
37
+ export function validateKeyOnlyOnEntityNonNullablePrimitiveProperty(program) {
38
+ for (const namespace of GetDeclaredNamespaces(program)) {
39
+ navigateTypesInNamespace(namespace, {
39
40
  modelProperty: (property) => {
40
41
  if (!property.model || !isKey(program, property)) {
41
42
  return;
@@ -67,7 +68,89 @@ export const keyOnlyOnEntityNonNullablePrimitivePropertyRule = createRule({
67
68
  return;
68
69
  }
69
70
  },
70
- };
71
- },
72
- });
71
+ });
72
+ }
73
+ }
74
+ ;
75
+ // TODO: Add unit tests for this function
76
+ export function validateExtendOnlyAppliesOnDifferentNamespaces(program) {
77
+ for (const namespace of GetDeclaredNamespaces(program)) {
78
+ navigateTypesInNamespace(namespace, {
79
+ model: (model) => {
80
+ if (!model.baseModel) {
81
+ return;
82
+ }
83
+ const baseModelLocationContextType = getLocationContext(program, model.baseModel).type;
84
+ const modelLocationContextType = getLocationContext(program, model).type;
85
+ if (baseModelLocationContextType === "library" && modelLocationContextType === "library") {
86
+ return;
87
+ }
88
+ if (baseModelLocationContextType === "project" && modelLocationContextType === "project") {
89
+ return;
90
+ }
91
+ if (isSameNamespace(program, model, model.baseModel)) {
92
+ reportDiagnostic(program, {
93
+ code: "extends-invalid-use",
94
+ target: model,
95
+ messageId: "namespaces",
96
+ format: {},
97
+ });
98
+ }
99
+ },
100
+ });
101
+ }
102
+ }
103
+ ;
104
+ export function validatePropertyTypeOfEntityTypeMustHaveContainsOrReferences(program) {
105
+ for (const namespace of GetDeclaredNamespaces(program)) {
106
+ navigateTypesInNamespace(namespace, {
107
+ modelProperty: (property) => {
108
+ if (property.type.kind === "Model" && isPropertyParentModelAndPropertyTypeEntity(program, property)) {
109
+ if (!isContains(program, property) && !isReferences(program, property)) {
110
+ reportModelPropertyDiagnostics(program, property);
111
+ return;
112
+ }
113
+ }
114
+ if (property.type.kind === "Union" && getLocationContext(program, property).type !== "library") {
115
+ const unionTypes = extractTypesFromUnion(property.type);
116
+ for (const unionType of unionTypes) {
117
+ if (unionType.kind === "Model" && isEntity(program, unionType)) {
118
+ if (!isContains(program, property) && !isReferences(program, property)) {
119
+ reportModelPropertyDiagnostics(program, property, unionType.name);
120
+ return;
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ });
127
+ }
128
+ }
129
+ function isPropertyParentModelAndPropertyTypeEntity(program, property) {
130
+ const propertyType = getPropertyType(program, property);
131
+ return getLocationContext(program, property).type !== "library" &&
132
+ property.model &&
133
+ propertyType.kind === "Model" &&
134
+ isEntity(program, property.model) &&
135
+ isEntity(program, propertyType);
136
+ }
137
+ function reportModelPropertyDiagnostics(program, property, propertyTypeName) {
138
+ const propertyType = getPropertyType(program, property);
139
+ reportDiagnostic(program, {
140
+ code: "element-missing-dependencies",
141
+ target: property,
142
+ messageId: "propertyMissingContainsOrReferences",
143
+ format: {
144
+ property: property.name,
145
+ entity: propertyTypeName !== null && propertyTypeName !== void 0 ? propertyTypeName : propertyType.name,
146
+ }
147
+ });
148
+ }
149
+ function getPropertyType(program, property) {
150
+ let propertyType = property.type;
151
+ if (propertyType.kind === "Model" && isArrayModelType(program, propertyType)) {
152
+ propertyType = propertyType.indexer.value;
153
+ }
154
+ return propertyType;
155
+ }
73
156
  //# sourceMappingURL=entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AA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AG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;KAC3C;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -1,2 +1,4 @@
1
- export declare const useEvolvableEnumRule: import("@typespec/lint").LintRule;
1
+ export declare const useEvolvableEnumRule: import("@typespec/compiler").LinterRuleDefinition<"use-evolvable-enum", {
2
+ readonly default: import("@typespec/compiler").CallableMessage<[string]>;
3
+ }>;
2
4
  //# sourceMappingURL=enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,mCAuB/B,CAAC"}
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;EA2B/B,CAAC"}
@@ -1,19 +1,22 @@
1
- import { createRule } from "@typespec/lint";
2
- import { reportDiagnostic } from "../lib.js";
1
+ import { createRule, paramMessage } from "@typespec/compiler";
3
2
  import { isExcludedCoreType } from "../utils.js";
4
3
  export const useEvolvableEnumRule = createRule({
5
4
  name: "use-evolvable-enum",
6
- create({ program }) {
5
+ severity: "warning",
6
+ description: "Enforce evolvable enums",
7
+ messages: {
8
+ default: paramMessage `Enumeration '${"enum"}' should have a member named unknownFutureValue for future extensibility.`,
9
+ },
10
+ create(context) {
7
11
  return {
8
12
  enum: (enumType) => {
9
- if (isExcludedCoreType(program, enumType)) {
13
+ if (isExcludedCoreType(context.program, enumType)) {
10
14
  return;
11
15
  }
12
16
  if (enumType.members.has("unknownFutureValue")) {
13
17
  return;
14
18
  }
15
- reportDiagnostic(program, {
16
- code: "use-evolvable-enum",
19
+ context.reportDiagnostic({
17
20
  target: enumType,
18
21
  format: {
19
22
  enum: enumType.name,