@microsoft/typespec-msgraph 0.0.1-Preview.5 → 0.0.1-Preview.7
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.d.ts +5 -5
- package/dist/src/components/annotations.d.ts.map +1 -1
- package/dist/src/components/annotations.js +18 -23
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +2 -2
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/entity-container-element.d.ts +2 -2
- package/dist/src/components/entity-container-element.d.ts.map +1 -1
- package/dist/src/components/entity-container-element.js.map +1 -1
- package/dist/src/components/enum-type-element.js +1 -1
- package/dist/src/components/enum-type-element.js.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +3 -3
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/property-element.js +1 -1
- package/dist/src/components/property-element.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/search-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +2 -2
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +1 -1
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +3 -3
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/structured-type-element.js +2 -2
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts +1 -1
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +2 -2
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/components/update-restrictions-annotation.d.ts +5 -0
- package/dist/src/components/update-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/update-restrictions-annotation.js +8 -0
- package/dist/src/components/update-restrictions-annotation.js.map +1 -0
- package/dist/src/decorators/flags.d.ts +9 -0
- package/dist/src/decorators/flags.d.ts.map +1 -0
- package/dist/src/decorators/flags.js +13 -0
- package/dist/src/decorators/flags.js.map +1 -0
- package/dist/src/decorators/index.d.ts +1 -0
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +1 -0
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/entities/annotations.d.ts +19 -18
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +55 -54
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.d.ts +4 -3
- package/dist/src/entities/entity-container.d.ts.map +1 -1
- package/dist/src/entities/entity-container.js +14 -10
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/enum.d.ts +1 -0
- package/dist/src/entities/enum.d.ts.map +1 -1
- package/dist/src/entities/enum.js +2 -0
- package/dist/src/entities/enum.js.map +1 -1
- package/dist/src/entities/model.d.ts +4 -4
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +7 -7
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +8 -6
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +25 -8
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/revision-definition.d.ts +1 -1
- package/dist/src/entities/revision-definition.js +3 -3
- package/dist/src/lib.d.ts +4 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +1 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +28 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -0
- package/dist/src/rules/count.js +2 -2
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -0
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -0
- package/dist/src/rules/disallowed-typespec-decorators.js +33 -0
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -0
- package/dist/src/rules/extends-on-same-type.d.ts +2 -0
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -0
- package/dist/src/rules/extends-on-same-type.js +38 -0
- package/dist/src/rules/extends-on-same-type.js.map +1 -0
- package/dist/src/rules/index.d.ts +4 -3
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +4 -89
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/operation-inside-interface.d.ts +2 -0
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -0
- package/dist/src/rules/operation-inside-interface.js +25 -0
- package/dist/src/rules/operation-inside-interface.js.map +1 -0
- package/dist/src/rules/order-by.js +2 -2
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/search.js +2 -2
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.js +2 -2
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.js +2 -2
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/utils.d.ts +4 -5
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +41 -25
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +7 -0
- package/lib/porcelain.tsp +1 -1
- package/package.json +1 -1
package/dist/src/lib.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const libDef: {
|
|
|
14
14
|
readonly messages: {
|
|
15
15
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
16
16
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
17
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
readonly "decorator-invalid-use": {
|
|
@@ -57,6 +58,7 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
57
58
|
"element-missing-dependencies": {
|
|
58
59
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
59
60
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
61
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
60
62
|
};
|
|
61
63
|
"decorator-invalid-use": {
|
|
62
64
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
|
@@ -86,6 +88,7 @@ export declare const reportDiagnostic: <C extends "decorator-missing-dependencie
|
|
|
86
88
|
"element-missing-dependencies": {
|
|
87
89
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
88
90
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
91
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
89
92
|
};
|
|
90
93
|
"decorator-invalid-use": {
|
|
91
94
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
|
@@ -114,6 +117,7 @@ export declare const reportDiagnostic: <C extends "decorator-missing-dependencie
|
|
|
114
117
|
"element-missing-dependencies": {
|
|
115
118
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
116
119
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
120
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
117
121
|
};
|
|
118
122
|
"decorator-invalid-use": {
|
|
119
123
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
package/dist/src/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAE5C,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAE5C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDT,CAAC;AAEX,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAAgC,CAAC;AAClD,eAAO,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAS,CAAC"}
|
package/dist/src/lib.js
CHANGED
|
@@ -15,6 +15,7 @@ export const libDef = {
|
|
|
15
15
|
messages: {
|
|
16
16
|
default: paramMessage `The ${"element"} must be used together with ${"other"} on a ${"location"}.`,
|
|
17
17
|
operation: paramMessage `Operations must be used inside interfaces.`,
|
|
18
|
+
collectionNavigationPropertiesNotNullable: `Collection-valued navigation properties cannot be nullable.`,
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
"decorator-invalid-use": {
|
package/dist/src/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAA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B,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,OAAO,WAAW,2CAA2C,OAAO,SAAS,UAAU,GAAG;gBAC/G,YAAY,EAAE,YAAY,CAAA,8FAA8F;gBACxH,4BAA4B,EAAE,YAAY,CAAA,iBAAiB,WAAW,uCAAuC;gBAC7G,gBAAgB,EAAE,YAAY,CAAA,mBAAmB,YAAY,6GAA6G,OAAO,iCAAiC;gBAClN,GAAG,EAAE,YAAY,CAAA,2EAA2E;gBAC5F,iBAAiB,EAAE,YAAY,CAAA,mBAAmB,YAAY,kHAAkH,OAAO,iCAAiC;gBACxN,QAAQ,EAAE,YAAY,CAAA,OAAO,WAAW,mCAAmC,YAAY,GAAG;gBAC1F,SAAS,EAAE,YAAY,CAAA,OAAO,WAAW,uCAAuC,QAAQ,GAAG;aAC5F;SACF;QACD,wBAAwB,EAAE;YACxB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,wCAAwC,OAAO,uEAAuE;aAC5I;SACF;QACD,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,KAAK,MAAM,4BAA4B,MAAM,YAAY;aAC/E;SACF;QACD,oBAAoB,EAAE;YACpB,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,gBAAgB,MAAM,2EAA2E;aACvH;SACF;KACF;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { isTypeCollection, isNavigationProperty, isTypeNullable, } from "../utils.js";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
export const collectionValuedNavigationPropertiesCannotBeNullableRule = createRule({
|
|
5
|
+
name: "collection-valued-navigation-properties-cannot-be-nullable",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
modelProperty: (property) => {
|
|
9
|
+
if (!isNavigationProperty(program, property)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!isTypeCollection(program, property.type)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!isTypeNullable(program, property.type)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
reportDiagnostic(program, {
|
|
19
|
+
code: "element-missing-dependencies",
|
|
20
|
+
target: property,
|
|
21
|
+
messageId: "collectionNavigationPropertiesNotNullable",
|
|
22
|
+
format: {},
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=collection-navigation-properties-not-nullable.js.map
|
|
@@ -0,0 +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"}
|
package/dist/src/rules/count.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isCount } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @count applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const countAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -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,OA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|
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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
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
|
+
}
|
|
21
|
+
reportDiagnostic(program, {
|
|
22
|
+
code: "decorator-invalid-use",
|
|
23
|
+
target: decorator.target,
|
|
24
|
+
messageId: "disallowedTypeSpecDecorators",
|
|
25
|
+
format: {
|
|
26
|
+
decorator: decorator.name,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=disallowed-typespec-decorators.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-on-same-type.d.ts","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,mCAmChC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isComplex, isEntity } from "../index.js";
|
|
4
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
5
|
+
export const extendsOnSameTypeRule = createRule({
|
|
6
|
+
name: "extends-on-same-type",
|
|
7
|
+
create({ program }) {
|
|
8
|
+
return {
|
|
9
|
+
model: (model) => {
|
|
10
|
+
if (!model.baseModel) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (isExcludedCoreType(program, model)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (isEntity(program, model) && !isEntity(program, model.baseModel)) {
|
|
17
|
+
reportDiagnostic(program, {
|
|
18
|
+
code: "extends-invalid-use",
|
|
19
|
+
target: model,
|
|
20
|
+
format: {
|
|
21
|
+
type: "@entity",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (isComplex(program, model) && !isComplex(program, model.baseModel)) {
|
|
26
|
+
reportDiagnostic(program, {
|
|
27
|
+
code: "extends-invalid-use",
|
|
28
|
+
target: model,
|
|
29
|
+
format: {
|
|
30
|
+
type: "@complex",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=extends-on-same-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-on-same-type.js","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,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,KAAK,CAAC,SAAS,EAAE;oBACpB,OAAO;iBACR;gBAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACtC,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE;oBACnE,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,qBAAqB;wBAC3B,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE;4BACN,IAAI,EAAE,SAAS;yBAChB;qBACF,CAAC,CAAC;iBACJ;gBAED,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE;oBACrE,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,qBAAqB;wBAC3B,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE;4BACN,IAAI,EAAE,UAAU;yBACjB;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export * from "./abstract.js";
|
|
2
2
|
export * from "./alternate-key.js";
|
|
3
|
+
export * from "./collection-navigation-properties-not-nullable.js";
|
|
3
4
|
export * from "./computed.js";
|
|
4
5
|
export * from "./contains.js";
|
|
5
6
|
export * from "./count.js";
|
|
7
|
+
export * from "./disallowed-typespec-decorators.js";
|
|
6
8
|
export * from "./entity.js";
|
|
7
9
|
export * from "./enum.js";
|
|
8
10
|
export * from "./expand.js";
|
|
11
|
+
export * from "./extends-on-same-type.js";
|
|
9
12
|
export * from "./function.js";
|
|
10
13
|
export * from "./has-stream.js";
|
|
11
14
|
export * from "./open.js";
|
|
15
|
+
export * from "./operation-inside-interface.js";
|
|
12
16
|
export * from "./order-by.js";
|
|
13
17
|
export * from "./references.js";
|
|
14
18
|
export * from "./search.js";
|
|
15
19
|
export * from "./skip.js";
|
|
16
20
|
export * from "./top.js";
|
|
17
|
-
export declare const disallowedTypeSpecDecoratorsRule: import("@typespec/lint").LintRule;
|
|
18
|
-
export declare const extendsOnSameTypeRule: import("@typespec/lint").LintRule;
|
|
19
|
-
export declare const operationInsideInterfaceRule: import("@typespec/lint").LintRule;
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"
|
|
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,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/dist/src/rules/index.js
CHANGED
|
@@ -1,106 +1,21 @@
|
|
|
1
|
-
import { createRule } from "@typespec/lint";
|
|
2
|
-
import { isComplex, isEntity } from "../index.js";
|
|
3
|
-
import { reportDiagnostic } from "../lib.js";
|
|
4
|
-
import { isExcludedCoreType } from "../utils.js";
|
|
5
1
|
export * from "./abstract.js";
|
|
6
2
|
export * from "./alternate-key.js";
|
|
3
|
+
export * from "./collection-navigation-properties-not-nullable.js";
|
|
7
4
|
export * from "./computed.js";
|
|
8
5
|
export * from "./contains.js";
|
|
9
6
|
export * from "./count.js";
|
|
7
|
+
export * from "./disallowed-typespec-decorators.js";
|
|
10
8
|
export * from "./entity.js";
|
|
11
9
|
export * from "./enum.js";
|
|
12
10
|
export * from "./expand.js";
|
|
11
|
+
export * from "./extends-on-same-type.js";
|
|
13
12
|
export * from "./function.js";
|
|
14
13
|
export * from "./has-stream.js";
|
|
15
14
|
export * from "./open.js";
|
|
15
|
+
export * from "./operation-inside-interface.js";
|
|
16
16
|
export * from "./order-by.js";
|
|
17
17
|
export * from "./references.js";
|
|
18
18
|
export * from "./search.js";
|
|
19
19
|
export * from "./skip.js";
|
|
20
20
|
export * from "./top.js";
|
|
21
|
-
export const disallowedTypeSpecDecoratorsRule = createRule({
|
|
22
|
-
name: "disallowed-typespec-decorators",
|
|
23
|
-
create({ program }) {
|
|
24
|
-
return {
|
|
25
|
-
decorator: (decorator) => {
|
|
26
|
-
const denyList = [
|
|
27
|
-
"@friendlyName",
|
|
28
|
-
"@secret",
|
|
29
|
-
"@summary",
|
|
30
|
-
"@tag",
|
|
31
|
-
"@visibility",
|
|
32
|
-
"@withVisibility",
|
|
33
|
-
"@withUpdateableProperties",
|
|
34
|
-
"@withDefaultKeyVisibility",
|
|
35
|
-
];
|
|
36
|
-
if (denyList.indexOf(decorator.name) < 0) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
reportDiagnostic(program, {
|
|
40
|
-
code: "decorator-invalid-use",
|
|
41
|
-
target: decorator.target,
|
|
42
|
-
messageId: "disallowedTypeSpecDecorators",
|
|
43
|
-
format: {
|
|
44
|
-
decorator: decorator.name,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
export const extendsOnSameTypeRule = createRule({
|
|
52
|
-
name: "extends-on-same-type",
|
|
53
|
-
create({ program }) {
|
|
54
|
-
return {
|
|
55
|
-
model: (model) => {
|
|
56
|
-
if (!model.baseModel) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (isExcludedCoreType(program, model)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (isEntity(program, model) && !isEntity(program, model.baseModel)) {
|
|
63
|
-
reportDiagnostic(program, {
|
|
64
|
-
code: "extends-invalid-use",
|
|
65
|
-
target: model,
|
|
66
|
-
format: {
|
|
67
|
-
type: "@entity",
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (isComplex(program, model) && !isComplex(program, model.baseModel)) {
|
|
72
|
-
reportDiagnostic(program, {
|
|
73
|
-
code: "extends-invalid-use",
|
|
74
|
-
target: model,
|
|
75
|
-
format: {
|
|
76
|
-
type: "@complex",
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
export const operationInsideInterfaceRule = createRule({
|
|
85
|
-
name: "operation-inside-interface",
|
|
86
|
-
create({ program }) {
|
|
87
|
-
return {
|
|
88
|
-
operation: (operation) => {
|
|
89
|
-
if (operation.interface) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (isExcludedCoreType(program, operation)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
return; // TODO: Work out the compiler bug and get it fixed. See #138
|
|
96
|
-
reportDiagnostic(program, {
|
|
97
|
-
code: "element-missing-dependencies",
|
|
98
|
-
target: operation,
|
|
99
|
-
messageId: "operation",
|
|
100
|
-
format: {},
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,
|
|
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,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
4
|
+
export const operationInsideInterfaceRule = createRule({
|
|
5
|
+
name: "operation-inside-interface",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
operation: (operation) => {
|
|
9
|
+
if (operation.interface) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (isExcludedCoreType(program, operation)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
reportDiagnostic(program, {
|
|
16
|
+
code: "element-missing-dependencies",
|
|
17
|
+
target: operation,
|
|
18
|
+
messageId: "operation",
|
|
19
|
+
format: {},
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=operation-inside-interface.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -2,7 +2,7 @@ import { walkPropertiesInherited } from "@typespec/compiler";
|
|
|
2
2
|
import { createRule } from "@typespec/lint";
|
|
3
3
|
import { getOperationVerb } from "@typespec/http";
|
|
4
4
|
import { getOrderBy, isContains, isOrderBy, isReferences } from "../index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isTypeCollection } from "../utils.js";
|
|
6
6
|
import { reportDiagnostic } from "../lib.js";
|
|
7
7
|
import { getNavigationSourceType } from "../utils.js";
|
|
8
8
|
export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
@@ -15,7 +15,7 @@ export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule
|
|
|
15
15
|
}
|
|
16
16
|
if (getOperationVerb(program, operation) === "get") {
|
|
17
17
|
const returnType = operation.returnType;
|
|
18
|
-
const isCollection =
|
|
18
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
19
19
|
if (isCollection) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
@@ -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,
|
|
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,UAA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AAC,IAAI,CAAC,CAAC;gBAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CACpC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,uBAAuB,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;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/rules/search.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isSearch } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @search applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const searchAppliesToGetOperationsThatReturnCollectionsRule = createRule(
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,qDAAqD,GAAG,UAAU,CAAC;IAC9E,IAAI,EAAE,0DAA0D;IAChE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBACjC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/rules/skip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isSkip } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @skip applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const skipAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,mDAAmD,GAAG,UAAU,CAAC;IAC5E,IAAI,EAAE,wDAAwD;IAC9D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC/B,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/rules/top.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isTop } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @top applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const topAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"top.js","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"top.js","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kDAAkD,GAAG,UAAU,CAAC;IAC3E,IAAI,EAAE,uDAAuD;IAC7D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC9B,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,MAAM;wBACjB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -7,17 +7,17 @@ export declare function getNameForType(program: Program, type: Type): string;
|
|
|
7
7
|
export declare function getNameForModelType(program: Program, type: Model | Scalar): string;
|
|
8
8
|
export declare function getIdForType(program: Program, type: Type): string;
|
|
9
9
|
export declare function getNavigationTypeId(program: Program, getOperation: Operation): string;
|
|
10
|
-
export declare function getInterfacesOfKinds(program: Program, navigationSources:
|
|
10
|
+
export declare function getInterfacesOfKinds(program: Program, navigationSources: Map<string, Interface>, kinds: string[]): Map<string, MsGraphInterface>;
|
|
11
11
|
export declare function getPropertyTypeName(program: Program, type: Type): string;
|
|
12
12
|
export declare function isTypeNullable(program: Program, type: Type): boolean;
|
|
13
13
|
export declare function extractTypesFromUnion(type: Union): Type[];
|
|
14
14
|
export declare function getSingletonTypeId(program: Program, singletonType: string | null, getOperation: Operation | undefined): string | undefined;
|
|
15
15
|
/**
|
|
16
|
-
* Returns whether a type
|
|
16
|
+
* Returns whether a type matches Graph's definition of a collection
|
|
17
17
|
* @param program
|
|
18
|
-
* @param
|
|
18
|
+
* @param type
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function isTypeCollection(Program: Program, type: Type): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Imported from typespec-azure
|
|
23
23
|
* Returns the full namespace name for the given type, if available.
|
|
@@ -36,7 +36,6 @@ export declare function getNamespaceName(program: Program, type: Model | Scalar
|
|
|
36
36
|
export declare function isExcludedCoreType(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum): boolean;
|
|
37
37
|
export declare function isExcludedLibraryType(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum): boolean;
|
|
38
38
|
export declare function isNavigationProperty(program: Program, property: ModelProperty): boolean;
|
|
39
|
-
export declare function getNavigationSources(program: Program, namespace: Namespace): Interface[];
|
|
40
39
|
export declare function isNavigationSource(theInterface: Interface): boolean;
|
|
41
40
|
export declare function getInterfaceNavigationSourceType(program: Program, theInterface: Interface): Model | undefined;
|
|
42
41
|
export declare function getNavigationSourceType(program: Program, operation: Operation): Model | undefined;
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACN,MAAM,oBAAoB,CAAC;AAI5B,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,SAAS,CAAC;IACxB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAqBnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,UAuCzE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAkBjE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,GAAG,MAAM,CAOrF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACN,MAAM,oBAAoB,CAAC;AAI5B,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,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