@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.
- package/dist/src/components/annotations.js +21 -3
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/operation-element.d.ts.map +1 -1
- package/dist/src/components/operation-element.js +15 -4
- package/dist/src/components/operation-element.js.map +1 -1
- package/dist/src/components/revisions-annotation.d.ts.map +1 -1
- package/dist/src/components/revisions-annotation.js +2 -1
- package/dist/src/components/revisions-annotation.js.map +1 -1
- package/dist/src/components/schema-element.d.ts.map +1 -1
- package/dist/src/components/schema-element.js +5 -3
- package/dist/src/components/schema-element.js.map +1 -1
- package/dist/src/components/term-element.d.ts +9 -0
- package/dist/src/components/term-element.d.ts.map +1 -0
- package/dist/src/components/term-element.js +8 -0
- package/dist/src/components/term-element.js.map +1 -0
- package/dist/src/decorators/ags-attribute.d.ts +2 -1
- package/dist/src/decorators/ags-attribute.d.ts.map +1 -1
- package/dist/src/decorators/ags-attribute.js +34 -1
- package/dist/src/decorators/ags-attribute.js.map +1 -1
- package/dist/src/decorators/global-operation.d.ts +9 -0
- package/dist/src/decorators/global-operation.d.ts.map +1 -0
- package/dist/src/decorators/global-operation.js +13 -0
- package/dist/src/decorators/global-operation.js.map +1 -0
- package/dist/src/decorators/graph-deprecated.d.ts +11 -0
- package/dist/src/decorators/graph-deprecated.d.ts.map +1 -0
- package/dist/src/decorators/graph-deprecated.js +19 -0
- package/dist/src/decorators/graph-deprecated.js.map +1 -0
- package/dist/src/decorators/index.d.ts +4 -0
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +4 -0
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/is-owner.js +1 -1
- package/dist/src/decorators/ownerless.d.ts +8 -0
- package/dist/src/decorators/ownerless.d.ts.map +1 -0
- package/dist/src/decorators/ownerless.js +12 -0
- package/dist/src/decorators/ownerless.js.map +1 -0
- package/dist/src/decorators/public-namespace.d.ts.map +1 -1
- package/dist/src/decorators/public-namespace.js +4 -1
- package/dist/src/decorators/public-namespace.js.map +1 -1
- package/dist/src/decorators/term.d.ts +13 -0
- package/dist/src/decorators/term.d.ts.map +1 -0
- package/dist/src/decorators/term.js +14 -0
- package/dist/src/decorators/term.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +4 -0
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +15 -0
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/enum.js.map +1 -1
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +53 -4
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +6 -1
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +82 -6
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts +4 -0
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +16 -7
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/entities/revision-definition.d.ts +1 -0
- package/dist/src/entities/revision-definition.d.ts.map +1 -1
- package/dist/src/entities/revision-definition.js +3 -3
- package/dist/src/entities/revision-definition.js.map +1 -1
- package/dist/src/entities/term.d.ts +8 -0
- package/dist/src/entities/term.d.ts.map +1 -0
- package/dist/src/entities/term.js +14 -0
- package/dist/src/entities/term.js.map +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +59 -146
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +19 -10
- package/dist/src/lib.js.map +1 -1
- package/dist/src/rules/allowed-values.d.ts +2 -1
- package/dist/src/rules/allowed-values.d.ts.map +1 -1
- package/dist/src/rules/allowed-values.js +7 -7
- package/dist/src/rules/allowed-values.js.map +1 -1
- package/dist/src/rules/alternate-key.d.ts +4 -3
- package/dist/src/rules/alternate-key.d.ts.map +1 -1
- package/dist/src/rules/alternate-key.js +23 -23
- package/dist/src/rules/alternate-key.js.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +9 -9
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -1
- package/dist/src/rules/computed.d.ts +2 -1
- package/dist/src/rules/computed.d.ts.map +1 -1
- package/dist/src/rules/computed.js +9 -8
- package/dist/src/rules/computed.js.map +1 -1
- package/dist/src/rules/contains.d.ts +2 -1
- package/dist/src/rules/contains.d.ts.map +1 -1
- package/dist/src/rules/contains.js +9 -8
- package/dist/src/rules/contains.js.map +1 -1
- package/dist/src/rules/count.d.ts +2 -1
- package/dist/src/rules/count.d.ts.map +1 -1
- package/dist/src/rules/count.js +9 -8
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.js +29 -25
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -1
- package/dist/src/rules/entity.d.ts +5 -2
- package/dist/src/rules/entity.d.ts.map +1 -1
- package/dist/src/rules/entity.js +102 -19
- package/dist/src/rules/entity.js.map +1 -1
- package/dist/src/rules/enum.d.ts +3 -1
- package/dist/src/rules/enum.d.ts.map +1 -1
- package/dist/src/rules/enum.js +9 -6
- package/dist/src/rules/enum.js.map +1 -1
- package/dist/src/rules/expand.d.ts +3 -2
- package/dist/src/rules/expand.d.ts.map +1 -1
- package/dist/src/rules/expand.js +16 -16
- package/dist/src/rules/expand.js.map +1 -1
- package/dist/src/rules/extends-on-same-type.d.ts +2 -1
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -1
- package/dist/src/rules/extends-on-same-type.js +9 -8
- package/dist/src/rules/extends-on-same-type.js.map +1 -1
- package/dist/src/rules/filter.d.ts +4 -3
- package/dist/src/rules/filter.d.ts.map +1 -1
- package/dist/src/rules/filter.js +23 -23
- package/dist/src/rules/filter.js.map +1 -1
- package/dist/src/rules/function.d.ts +2 -1
- package/dist/src/rules/function.d.ts.map +1 -1
- package/dist/src/rules/function.js +9 -9
- package/dist/src/rules/function.js.map +1 -1
- package/dist/src/rules/global-operation.d.ts +4 -0
- package/dist/src/rules/global-operation.d.ts.map +1 -0
- package/dist/src/rules/global-operation.js +60 -0
- package/dist/src/rules/global-operation.js.map +1 -0
- package/dist/src/rules/graph-deprecated.d.ts +8 -0
- package/dist/src/rules/graph-deprecated.d.ts.map +1 -0
- package/dist/src/rules/graph-deprecated.js +152 -0
- package/dist/src/rules/graph-deprecated.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +4 -2
- package/dist/src/rules/graph-route.d.ts.map +1 -1
- package/dist/src/rules/graph-route.js +55 -15
- package/dist/src/rules/graph-route.js.map +1 -1
- package/dist/src/rules/has-stream.d.ts +2 -1
- package/dist/src/rules/has-stream.d.ts.map +1 -1
- package/dist/src/rules/has-stream.js +9 -8
- package/dist/src/rules/has-stream.js.map +1 -1
- package/dist/src/rules/index.d.ts +3 -0
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +3 -0
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/namespace.d.ts +4 -3
- package/dist/src/rules/namespace.d.ts.map +1 -1
- package/dist/src/rules/namespace.js +58 -73
- package/dist/src/rules/namespace.js.map +1 -1
- package/dist/src/rules/open.d.ts +2 -1
- package/dist/src/rules/open.d.ts.map +1 -1
- package/dist/src/rules/open.js +9 -8
- package/dist/src/rules/open.js.map +1 -1
- package/dist/src/rules/operation-inside-interface.d.ts +2 -1
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -1
- package/dist/src/rules/operation-inside-interface.js +9 -8
- package/dist/src/rules/operation-inside-interface.js.map +1 -1
- package/dist/src/rules/order-by.d.ts +3 -2
- package/dist/src/rules/order-by.d.ts.map +1 -1
- package/dist/src/rules/order-by.js +16 -16
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/ownerless.d.ts +10 -0
- package/dist/src/rules/ownerless.d.ts.map +1 -0
- package/dist/src/rules/ownerless.js +155 -0
- package/dist/src/rules/ownerless.js.map +1 -0
- package/dist/src/rules/partial.d.ts +2 -1
- package/dist/src/rules/partial.d.ts.map +1 -1
- package/dist/src/rules/partial.js +9 -8
- package/dist/src/rules/partial.js.map +1 -1
- package/dist/src/rules/references.d.ts +2 -1
- package/dist/src/rules/references.d.ts.map +1 -1
- package/dist/src/rules/references.js +9 -8
- package/dist/src/rules/references.js.map +1 -1
- package/dist/src/rules/required-for-create.d.ts +2 -1
- package/dist/src/rules/required-for-create.d.ts.map +1 -1
- package/dist/src/rules/required-for-create.js +9 -8
- package/dist/src/rules/required-for-create.js.map +1 -1
- package/dist/src/rules/search.d.ts +2 -1
- package/dist/src/rules/search.d.ts.map +1 -1
- package/dist/src/rules/search.js +9 -8
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.d.ts +2 -1
- package/dist/src/rules/skip.d.ts.map +1 -1
- package/dist/src/rules/skip.js +9 -8
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.d.ts +2 -1
- package/dist/src/rules/top.d.ts.map +1 -1
- package/dist/src/rules/top.js +9 -8
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -0
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +21 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +19 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/src/{linter.d.ts → validate.d.ts} +1 -1
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +51 -0
- package/dist/src/validate.js.map +1 -0
- package/lib/decorators.tsp +28 -0
- package/package.json +5 -7
- package/dist/src/linter.d.ts.map +0 -1
- package/dist/src/linter.js +0 -44
- package/dist/src/linter.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isTypeCollection, isNavigationProperty, isTypeNullable, } from "../utils.js";
|
|
1
|
+
import { isTypeCollection, isNavigationProperty, isTypeNullable } from "../utils.js";
|
|
3
2
|
import { reportDiagnostic } from "../lib.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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,
|
|
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
|
|
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":"
|
|
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 {
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../../src/rules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AAC,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
|
|
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":"
|
|
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 {
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../src/rules/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,+CAA+C,CAAC,OAAgB;IAC9E,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAClC,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,WAAW;wBACtB,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
|
|
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":"
|
|
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"}
|
package/dist/src/rules/count.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
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,
|
|
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
|
-
|
|
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":"
|
|
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 {
|
|
1
|
+
import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
2
2
|
import { reportDiagnostic } from "../lib.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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:
|
|
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,
|
|
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
|
-
|
|
2
|
-
export declare
|
|
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":"
|
|
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"}
|
package/dist/src/rules/entity.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { isKey, walkPropertiesInherited } from "@typespec/compiler";
|
|
2
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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":"AAAA,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,kBAAkB,EAAE,KAAK,EAAE,wBAAwB,EAClE,uBAAuB,EAAwB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC5G,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,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AAC,CAAA;KACH;AACH,CAAC;AAED,SAAS,0CAA0C,CAAC,OAAgB,EAAE,QAAuB;IAC3F,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAExD,OAAO,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,IAAI,KAAK,SAAS;QAC7D,QAAQ,CAAC,KAAK;QACd,YAAY,CAAC,IAAI,KAAK,OAAO;QAC7B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;QACjC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,8BAA8B,CAAC,OAAgB,EAAE,QAAuB,EAAE,gBAAyB;IAC1G,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxD,gBAAgB,CAAC,OAAO,EAAE;QACxB,IAAI,EAAE,8BAA8B;QACpC,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,qCAAqC;QAChD,MAAM,EAAE;YACN,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAK,YAAsB,CAAC,IAAI;SACzD;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB,EAAE,QAAuB;IAChE,IAAI,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;IACjC,IAAI,YAAY,CAAC,IAAI,KAAK,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE;QAC5E,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;KAC3C;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/src/rules/enum.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare const useEvolvableEnumRule: import("@typespec/
|
|
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":"
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;EA2B/B,CAAC"}
|
package/dist/src/rules/enum.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { createRule } from "@typespec/
|
|
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
|
-
|
|
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(
|
|
16
|
-
code: "use-evolvable-enum",
|
|
19
|
+
context.reportDiagnostic({
|
|
17
20
|
target: enumType,
|
|
18
21
|
format: {
|
|
19
22
|
enum: enumType.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,yBAAyB;IACtC,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,gBAAgB,MAAM,2EAA2E;KACvH;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACjB,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBACjD,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE;oBAC9C,OAAO;iBACR;gBAED,OAAO,CAAC,gBAAgB,CAAC;oBACvB,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ,CAAC,IAAI;qBACpB;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
import { Program } from "@typespec/compiler";
|
|
2
|
+
export declare function validateExpandOnlyOnGetNavigationSource(program: Program): void;
|
|
3
|
+
export declare function validateExpandOnlyNavigationProperties(program: Program): void;
|
|
3
4
|
//# sourceMappingURL=expand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAqD,MAAM,oBAAoB,CAAC;AAOvG,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,OAAO,QA0BvE;AAED,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,OAAO,QAuCtE"}
|
package/dist/src/rules/expand.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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 { getExpand, isContains, isExpand, isReferences } from "../index.js";
|
|
5
4
|
import { reportDiagnostic } from "../lib.js";
|
|
6
5
|
import { getNavigationSourceType } from "../utils.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
7
|
+
export function validateExpandOnlyOnGetNavigationSource(program) {
|
|
8
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
9
|
+
navigateTypesInNamespace(namespace, {
|
|
11
10
|
operation: (operation) => {
|
|
12
11
|
if (!isExpand(program, operation)) {
|
|
13
12
|
return;
|
|
@@ -27,13 +26,13 @@ export const expandOnlyOnGetNavigationSourceRule = createRule({
|
|
|
27
26
|
},
|
|
28
27
|
});
|
|
29
28
|
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
export function validateExpandOnlyNavigationProperties(program) {
|
|
34
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
35
|
+
navigateTypesInNamespace(namespace, {
|
|
37
36
|
operation: (operation) => {
|
|
38
37
|
const expanded = getExpand(program, operation);
|
|
39
38
|
if (!expanded.length) {
|
|
@@ -61,7 +60,8 @@ export const expandOnlyNavigationPropertiesRule = createRule({
|
|
|
61
60
|
},
|
|
62
61
|
});
|
|
63
62
|
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
;
|
|
67
67
|
//# sourceMappingURL=expand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.js","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"expand.js","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,uCAAuC,CAAC,OAAgB;IACtE,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,IAAG,uBAAuB,CAAC,OAA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Q,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACvD,CAAC;gBAEF,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;oBAC7B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,kBAAkB;oBAC7B,MAAM,EAAE;wBACN,KAAK,EAAE,SAAS,CAAC,IAAI;wBACrB,UAAU,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;qBACzC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAAA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extends-on-same-type.d.ts","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extends-on-same-type.d.ts","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAA4B,MAAM,oBAAoB,CAAC;AAGvE,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,QAkCzD"}
|