@microsoft/typespec-msgraph 0.0.1-Preview.6 → 0.0.1-Preview.8
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 +21 -20
- 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/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/filter-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/filter-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/filter-restrictions-annotation.js +10 -0
- package/dist/src/components/filter-restrictions-annotation.js.map +1 -0
- package/dist/src/components/immutable-annotation.d.ts +5 -0
- package/dist/src/components/immutable-annotation.d.ts.map +1 -0
- package/dist/src/components/immutable-annotation.js +6 -0
- package/dist/src/components/immutable-annotation.js.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.js +10 -0
- package/dist/src/components/insert-restrictions-annotation.js.map +1 -0
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +4 -2
- 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 +6 -6
- 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/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/decorators/action.d.ts +10 -0
- package/dist/src/decorators/action.d.ts.map +1 -0
- package/dist/src/decorators/action.js +16 -0
- package/dist/src/decorators/action.js.map +1 -0
- package/dist/src/decorators/filter.d.ts +11 -0
- package/dist/src/decorators/filter.d.ts.map +1 -0
- package/dist/src/decorators/filter.js +27 -0
- package/dist/src/decorators/filter.js.map +1 -0
- package/dist/src/decorators/graph-route.d.ts +1 -1
- package/dist/src/decorators/graph-route.d.ts.map +1 -1
- package/dist/src/decorators/graph-route.js +12 -7
- package/dist/src/decorators/graph-route.js.map +1 -1
- package/dist/src/decorators/immutable.d.ts +8 -0
- package/dist/src/decorators/immutable.d.ts.map +1 -0
- package/dist/src/decorators/immutable.js +12 -0
- package/dist/src/decorators/immutable.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/required-for-create.d.ts +10 -0
- package/dist/src/decorators/required-for-create.d.ts.map +1 -0
- package/dist/src/decorators/required-for-create.js +14 -0
- package/dist/src/decorators/required-for-create.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +20 -17
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +69 -48
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.js +1 -1
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/model.d.ts +1 -0
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +2 -1
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +3 -3
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +34 -8
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +1 -2
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/entities/property.d.ts.map +1 -1
- package/dist/src/entities/property.js +3 -0
- package/dist/src/entities/property.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 +16 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +4 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +4 -0
- package/dist/src/linter.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/filter.d.ts +4 -0
- package/dist/src/rules/filter.d.ts.map +1 -0
- package/dist/src/rules/filter.js +92 -0
- package/dist/src/rules/filter.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +5 -0
- package/dist/src/rules/graph-route.d.ts.map +1 -0
- package/dist/src/rules/graph-route.js +39 -0
- package/dist/src/rules/graph-route.js.map +1 -0
- package/dist/src/rules/index.d.ts +7 -3
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +7 -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/required-for-create.d.ts +2 -0
- package/dist/src/rules/required-for-create.d.ts.map +1 -0
- package/dist/src/rules/required-for-create.js +40 -0
- package/dist/src/rules/required-for-create.js.map +1 -0
- 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 +16 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +81 -31
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +32 -0
- package/lib/lib.tsp +4 -15
- package/package.json +1 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getInterfacesOfKinds, getNamespaceName, isExcludedCoreType, isNavigationSource } from "../utils.js";
|
|
1
|
+
import { getInterfacesOfKinds, getNamespaceName, isCollectionResource, isExcludedCoreType, isNavigationSource, isTopLevelNavigationSource } from "../utils.js";
|
|
2
2
|
import { GetMsGraphEnumTypeElement } from "./enum.js";
|
|
3
3
|
import { GetMsGraphModels } from "./model.js";
|
|
4
4
|
import { GetEntitySets, GetSingletons } from "./entity-container.js";
|
|
5
5
|
import { GetMsGraphOperations } from "./operation.js";
|
|
6
|
-
import {
|
|
6
|
+
import { GetCollectionAnnotations, GetResourceAnnotations } from "./annotations.js";
|
|
7
7
|
import { buildAttributes } from "../index.js";
|
|
8
8
|
export function GetMsGraphNamespaces(program) {
|
|
9
9
|
const root = program.checker.getGlobalNamespaceType();
|
|
@@ -28,12 +28,29 @@ function getMsGraphNamespace(program, namespace) {
|
|
|
28
28
|
const models = GetMsGraphModels(program, namespace.models);
|
|
29
29
|
const enums = [...namespace.enums].map(([_, e]) => GetMsGraphEnumTypeElement(program, e));
|
|
30
30
|
const sources = getNavigationSources(namespace.interfaces);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
31
|
+
const resourceSources = getInterfacesOfKinds(program, sources, ["Resource"]);
|
|
32
|
+
const collectionSources = getInterfacesOfKinds(program, sources, ["Collection"]);
|
|
33
|
+
resourceSources.forEach((entity, routePath) => {
|
|
34
|
+
if (isTopLevelNavigationSource(program, entity) && isCollectionResource(program, entity)) {
|
|
35
|
+
let operations = [...entity.operations.values()];
|
|
36
|
+
if (collectionSources.has(routePath)) {
|
|
37
|
+
const existing = collectionSources.get(routePath);
|
|
38
|
+
operations = [...operations, ...existing.operations];
|
|
39
|
+
}
|
|
40
|
+
collectionSources.set(routePath, {
|
|
41
|
+
theInterface: entity.theInterface,
|
|
42
|
+
operations: operations,
|
|
43
|
+
path: entity.path,
|
|
44
|
+
});
|
|
45
|
+
resourceSources.delete(routePath);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const singletonSources = getRootNavigationSources(program, resourceSources);
|
|
49
|
+
const entitySetSources = getRootNavigationSources(program, collectionSources);
|
|
33
50
|
const singletons = GetSingletons(program, singletonSources);
|
|
34
51
|
const entitySets = GetEntitySets(program, entitySetSources);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
52
|
+
const resourceAnnotations = GetResourceAnnotations(program, namespaceName, resourceSources);
|
|
53
|
+
const collectionAnnotations = GetCollectionAnnotations(program, namespaceName, collectionSources);
|
|
37
54
|
const operations = GetMsGraphOperations(program, namespace.interfaces);
|
|
38
55
|
return {
|
|
39
56
|
Name: namespaceName,
|
|
@@ -42,9 +59,9 @@ function getMsGraphNamespace(program, namespace) {
|
|
|
42
59
|
AgsAttributes: buildAttributes(program, namespace),
|
|
43
60
|
Singletons: singletons,
|
|
44
61
|
EntitySets: entitySets,
|
|
45
|
-
SingletonAnnotations: singletonAnnotations,
|
|
46
|
-
EntitySetAnnotations: entitySetAnnotations,
|
|
47
62
|
Operations: operations,
|
|
63
|
+
ResourceAnnotations: resourceAnnotations,
|
|
64
|
+
CollectionAnnotations: collectionAnnotations,
|
|
48
65
|
};
|
|
49
66
|
}
|
|
50
67
|
function getNavigationSources(interfaces) {
|
|
@@ -56,4 +73,13 @@ function getNavigationSources(interfaces) {
|
|
|
56
73
|
});
|
|
57
74
|
return navigationSources;
|
|
58
75
|
}
|
|
76
|
+
function getRootNavigationSources(program, sources) {
|
|
77
|
+
const rootSources = new Map();
|
|
78
|
+
sources.forEach((entity, routePath) => {
|
|
79
|
+
if (isTopLevelNavigationSource(program, entity)) {
|
|
80
|
+
rootSources.set(routePath, entity);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return rootSources;
|
|
84
|
+
}
|
|
59
85
|
//# sourceMappingURL=namespace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/entities/namespace.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/entities/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,E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AAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAgB,EAAE,OAAsC;IACxF,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAExD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;QACpC,IAAI,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;YAC/C,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;SACpC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuD,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuD,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO7G,oBAAY,aAAa;IACvB,OAAO,IAAA;IACP,MAAM,IAAA;IACN,QAAQ,IAAA;CACT;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,eAAe,EAAE,wBAAwB,EAAE,EAAE,CAAC;IAC9C,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IAEvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAClD,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,gBAAgB,EAAE,CAuB7G"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isVoidType, getDoc } from "@typespec/compiler";
|
|
2
2
|
import { isPathParam } from "@typespec/http";
|
|
3
|
-
import { getAction } from "
|
|
4
|
-
import { getFunction, isOperationParameters } from "../index.js";
|
|
3
|
+
import { getAction, getFunction, isOperationParameters } from "../index.js";
|
|
5
4
|
import { isTypeNullable, getPropertyTypeName, extractTypesFromUnion, getInterfaceNavigationSourceType } from "../utils.js";
|
|
6
5
|
import { getDefaultPropertyValue } from "./property.js";
|
|
7
6
|
import { buildAttributes } from "../decorators/ags-attribute.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAE,MAAM,EAAmC,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAE,MAAM,EAAmC,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,O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B,EAChB,UAAsC;IAEtC,MAAM,UAAU,GAA+B,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE;QACtF,IAAI,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;YAClC,OAAO,EAAE,CAAC;SACX;QAED,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;YACnF,OAAO,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAClE;QAED,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,UAAU,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC;gBAClD,gBAAgB,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC;gBAC7D,UAAU,EAAE,QAAQ,CAAC,QAAQ;gBAC7B,YAAY,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC;gBACxD,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;aACvC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../src/entities/property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG5D,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../src/entities/property.ts"],"names":[],"mappings":"AAAA,OAAO,E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ACjB,KAAK,WAAW;YACd,eAAe,GAAG,KAAK,CAAC;YACxB,MAAM;QACR,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY;YACf,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,UAAU;YACb,eAAe,GAAG,MAAM,CAAC;YACzB,MAAM;QACR,KAAK,oBAAoB;YACvB,eAAe,GAAG,gBAAgB,CAAC;YACnC,MAAM;QACR,KAAK,aAAa;YAChB,eAAe,GAAG,SAAS,CAAC;YAC5B,MAAM;QACR,KAAK,YAAY;YACf,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,UAAU;YACb,eAAe,GAAG,MAAM,CAAC;YACzB,MAAM;QACR,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe,CAAC;QACrB;YACE,OAAO,SAAS,CAAC;KACpB;IAED,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,iBAAiB,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -5,5 +5,5 @@ export interface RevisionDefinition {
|
|
|
5
5
|
Description?: string;
|
|
6
6
|
RemovalDate: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function GetRevisionDefinition(program: Program,
|
|
8
|
+
export declare function GetRevisionDefinition(program: Program, type: Model | ModelProperty | EnumMember | Enum | Operation | Namespace, namespace: Namespace | undefined): RevisionDefinition | undefined;
|
|
9
9
|
//# sourceMappingURL=revision-definition.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { getDeprecated } from "@typespec/compiler";
|
|
2
2
|
import { getPrivatePreview, getDeprecatedDefinitions, getPrivatePreviewDefinitions } from "../index.js";
|
|
3
|
-
export function GetRevisionDefinition(program,
|
|
3
|
+
export function GetRevisionDefinition(program, type, namespace) {
|
|
4
4
|
if (!namespace) {
|
|
5
5
|
return undefined;
|
|
6
6
|
}
|
|
7
|
-
const deprecated = getDeprecated(program,
|
|
7
|
+
const deprecated = getDeprecated(program, type);
|
|
8
8
|
if (deprecated) {
|
|
9
9
|
return getRevisionDefinitionFromDeprecation(program, namespace, deprecated);
|
|
10
10
|
}
|
|
11
|
-
const privatePreview = getPrivatePreview(program,
|
|
11
|
+
const privatePreview = getPrivatePreview(program, type);
|
|
12
12
|
if (privatePreview) {
|
|
13
13
|
return getRevisionDefinitionFromPrivatePreview(program, namespace, privatePreview);
|
|
14
14
|
}
|
package/dist/src/lib.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ 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.";
|
|
18
|
+
readonly propertyRequiredForCreate: import("@typespec/compiler").CallableMessage<["property", "model"]>;
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
readonly "decorator-invalid-use": {
|
|
@@ -23,10 +25,12 @@ export declare const libDef: {
|
|
|
23
25
|
readonly alternateKey: import("@typespec/compiler").CallableMessage<[]>;
|
|
24
26
|
readonly disallowedTypeSpecDecorators: import("@typespec/compiler").CallableMessage<["decorator"]>;
|
|
25
27
|
readonly expandProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
28
|
+
readonly filterProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
26
29
|
readonly key: import("@typespec/compiler").CallableMessage<[]>;
|
|
27
30
|
readonly orderByProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
28
31
|
readonly required: import("@typespec/compiler").CallableMessage<["decorator", "parameters"]>;
|
|
29
32
|
readonly wrongType: import("@typespec/compiler").CallableMessage<["decorator", "target"]>;
|
|
33
|
+
readonly graphRoute: import("@typespec/compiler").CallableMessage<[]>;
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
36
|
readonly "singleton-invalid-name": {
|
|
@@ -57,16 +61,20 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
57
61
|
"element-missing-dependencies": {
|
|
58
62
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
59
63
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
64
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
65
|
+
readonly propertyRequiredForCreate: import("@typespec/compiler").CallableMessage<["property", "model"]>;
|
|
60
66
|
};
|
|
61
67
|
"decorator-invalid-use": {
|
|
62
68
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
|
63
69
|
readonly alternateKey: import("@typespec/compiler").CallableMessage<[]>;
|
|
64
70
|
readonly disallowedTypeSpecDecorators: import("@typespec/compiler").CallableMessage<["decorator"]>;
|
|
65
71
|
readonly expandProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
72
|
+
readonly filterProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
66
73
|
readonly key: import("@typespec/compiler").CallableMessage<[]>;
|
|
67
74
|
readonly orderByProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
68
75
|
readonly required: import("@typespec/compiler").CallableMessage<["decorator", "parameters"]>;
|
|
69
76
|
readonly wrongType: import("@typespec/compiler").CallableMessage<["decorator", "target"]>;
|
|
77
|
+
readonly graphRoute: import("@typespec/compiler").CallableMessage<[]>;
|
|
70
78
|
};
|
|
71
79
|
"singleton-invalid-name": {
|
|
72
80
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
@@ -86,16 +94,20 @@ export declare const reportDiagnostic: <C extends "decorator-missing-dependencie
|
|
|
86
94
|
"element-missing-dependencies": {
|
|
87
95
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
88
96
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
97
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
98
|
+
readonly propertyRequiredForCreate: import("@typespec/compiler").CallableMessage<["property", "model"]>;
|
|
89
99
|
};
|
|
90
100
|
"decorator-invalid-use": {
|
|
91
101
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
|
92
102
|
readonly alternateKey: import("@typespec/compiler").CallableMessage<[]>;
|
|
93
103
|
readonly disallowedTypeSpecDecorators: import("@typespec/compiler").CallableMessage<["decorator"]>;
|
|
94
104
|
readonly expandProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
105
|
+
readonly filterProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
95
106
|
readonly key: import("@typespec/compiler").CallableMessage<[]>;
|
|
96
107
|
readonly orderByProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
97
108
|
readonly required: import("@typespec/compiler").CallableMessage<["decorator", "parameters"]>;
|
|
98
109
|
readonly wrongType: import("@typespec/compiler").CallableMessage<["decorator", "target"]>;
|
|
110
|
+
readonly graphRoute: import("@typespec/compiler").CallableMessage<[]>;
|
|
99
111
|
};
|
|
100
112
|
"singleton-invalid-name": {
|
|
101
113
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
@@ -114,16 +126,20 @@ export declare const reportDiagnostic: <C extends "decorator-missing-dependencie
|
|
|
114
126
|
"element-missing-dependencies": {
|
|
115
127
|
readonly default: import("@typespec/compiler").CallableMessage<["element", "other", "location"]>;
|
|
116
128
|
readonly operation: import("@typespec/compiler").CallableMessage<[]>;
|
|
129
|
+
readonly collectionNavigationPropertiesNotNullable: "Collection-valued navigation properties cannot be nullable.";
|
|
130
|
+
readonly propertyRequiredForCreate: import("@typespec/compiler").CallableMessage<["property", "model"]>;
|
|
117
131
|
};
|
|
118
132
|
"decorator-invalid-use": {
|
|
119
133
|
readonly default: import("@typespec/compiler").CallableMessage<["decorator", "other", "location"]>;
|
|
120
134
|
readonly alternateKey: import("@typespec/compiler").CallableMessage<[]>;
|
|
121
135
|
readonly disallowedTypeSpecDecorators: import("@typespec/compiler").CallableMessage<["decorator"]>;
|
|
122
136
|
readonly expandProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
137
|
+
readonly filterProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
123
138
|
readonly key: import("@typespec/compiler").CallableMessage<[]>;
|
|
124
139
|
readonly orderByProperties: import("@typespec/compiler").CallableMessage<["properties", "model"]>;
|
|
125
140
|
readonly required: import("@typespec/compiler").CallableMessage<["decorator", "parameters"]>;
|
|
126
141
|
readonly wrongType: import("@typespec/compiler").CallableMessage<["decorator", "target"]>;
|
|
142
|
+
readonly graphRoute: import("@typespec/compiler").CallableMessage<[]>;
|
|
127
143
|
};
|
|
128
144
|
"singleton-invalid-name": {
|
|
129
145
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDT,CAAC;AAEX,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAAgC,CAAC;AAClD,eAAO,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAS,CAAC"}
|
package/dist/src/lib.js
CHANGED
|
@@ -15,6 +15,8 @@ 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.`,
|
|
19
|
+
propertyRequiredForCreate: paramMessage `The property "${"property"}" on "${"model"}" must be nullable, computed, have a default value or be annotated with @requiredForCreate.`,
|
|
18
20
|
},
|
|
19
21
|
},
|
|
20
22
|
"decorator-invalid-use": {
|
|
@@ -24,10 +26,12 @@ export const libDef = {
|
|
|
24
26
|
alternateKey: paramMessage `The @alternateKey decorator can only be attached to a non-nullable primitive-typed property.`,
|
|
25
27
|
disallowedTypeSpecDecorators: paramMessage `The decorator ${"decorator"} may not be used in MSGraph TypeSpec.`,
|
|
26
28
|
expandProperties: paramMessage `The properties "${"properties"}" defined in the @expand decorator must be defined with @references or @contains in the referenced model "${"model"}" or its inheritance hierarchy.`,
|
|
29
|
+
filterProperties: paramMessage `The properties "${"properties"}" defined in the @filter decorator must be defined in the referenced model "${"model"}" or its inheritance hierarchy.`,
|
|
27
30
|
key: paramMessage `The @key decorator can only be attached to a non-nullable primitive type.`,
|
|
28
31
|
orderByProperties: paramMessage `The properties "${"properties"}" defined in the @orderBy decorator must not be defined with @references or @contains in the referenced model "${"model"}" or its inheritance hierarchy.`,
|
|
29
32
|
required: paramMessage `The ${"decorator"} decorator must define required ${"parameters"}.`,
|
|
30
33
|
wrongType: paramMessage `The ${"decorator"} decorator can only be applied to a ${"target"}.`,
|
|
34
|
+
graphRoute: paramMessage `@graphRoutes paths must not start with a /`,
|
|
31
35
|
},
|
|
32
36
|
},
|
|
33
37
|
"singleton-invalid-name": {
|
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,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MA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C"}
|
package/dist/src/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAwC7C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAG3C"}
|
package/dist/src/linter.js
CHANGED
|
@@ -15,6 +15,9 @@ linter.registerRules([
|
|
|
15
15
|
theRules.expandOnlyNavigationPropertiesRule,
|
|
16
16
|
theRules.expandOnlyOnGetNavigationSourceRule,
|
|
17
17
|
theRules.extendsOnSameTypeRule,
|
|
18
|
+
theRules.filterAppliesToGetOperationsThatReturnCollectionsRule,
|
|
19
|
+
theRules.filterOnlyAppliesToModelPropertiesRule,
|
|
20
|
+
theRules.filterPropertiesMustNotBeEmptyRule,
|
|
18
21
|
theRules.hasStreamOnlyOnEntity,
|
|
19
22
|
theRules.keyOnlyOnEntityNonNullablePrimitivePropertyRule,
|
|
20
23
|
theRules.openOnlyAppliesToStructuredType,
|
|
@@ -27,6 +30,7 @@ linter.registerRules([
|
|
|
27
30
|
theRules.topAppliesToGetOperationsThatReturnCollectionsRule,
|
|
28
31
|
theRules.useEvolvableEnumRule,
|
|
29
32
|
theRules.voidFunctionRule,
|
|
33
|
+
theRules.graphRouteLeadingSlashRule,
|
|
30
34
|
], { autoEnable: true });
|
|
31
35
|
export function $onValidate(program) {
|
|
32
36
|
linter.autoEnableRules();
|
package/dist/src/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3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CAAC,mCAAmC;IAC5C,QAAQ,CAAC,2BAA2B;IACpC,QAAQ,CAAC,gCAAgC;IACzC,QAAQ,CAAC,2CAA2C;IACpD,QAAQ,CAAC,oDAAoD;IAC7D,QAAQ,CAAC,gCAAgC;IACzC,QAAQ,CAAC,qBAAqB;IAC9B,QAAQ,CAAC,kCAAkC;IAC3C,QAAQ,CAAC,mCAAmC;IAC5C,QAAQ,CAAC,qBAAqB;IAC9B,QAAQ,CAAC,qDAAqD;IAC9D,QAAQ,CAAC,sCAAsC;IAC/C,QAAQ,CAAC,kCAAkC;IAC3C,QAAQ,CAAC,qBAAqB;IAC9B,QAAQ,CAAC,+CAA+C;IACxD,QAAQ,CAAC,+BAA+B;IACxC,QAAQ,CAAC,4BAA4B;IACrC,QAAQ,CAAC,sCAAsC;IAC/C,QAAQ,CAAC,sDAAsD;IAC/D,QAAQ,CAAC,6CAA6C;IACtD,QAAQ,CAAC,qDAAqD;IAC9D,QAAQ,CAAC,mDAAmD;IAC5D,QAAQ,CAAC,kDAAkD;IAC3D,QAAQ,CAAC,oBAAoB;IAC7B,QAAQ,CAAC,gBAAgB;IACzB,QAAQ,CAAC,0BAA0B;CACpC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,CAAC,eAAe,EAAE,CAAC;IACzB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACjC,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,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,
|
|
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"}
|
|
@@ -0,0 +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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const filterAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
|
|
2
|
+
export declare const filterOnlyAppliesToModelPropertiesRule: import("@typespec/lint").LintRule;
|
|
3
|
+
export declare const filterPropertiesMustNotBeEmptyRule: import("@typespec/lint").LintRule;
|
|
4
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/rules/filter.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qDAAqD,mCA6BhE,CAAC;AAEH,eAAO,MAAM,sCAAsC,mCAuCjD,CAAC;AAEH,eAAO,MAAM,kCAAkC,mCA0B7C,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getFilter, isFilter } from "../index.js";
|
|
3
|
+
import { getOperationVerb } from "@typespec/http";
|
|
4
|
+
import { getNavigationSourceType, isTypeCollection } from "../utils.js";
|
|
5
|
+
import { reportDiagnostic } from "../lib.js";
|
|
6
|
+
import { walkPropertiesInherited } from "@typespec/compiler";
|
|
7
|
+
export const filterAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
8
|
+
name: "filter-applies-to-get-operations-that-return-collections",
|
|
9
|
+
create({ program }) {
|
|
10
|
+
return {
|
|
11
|
+
operation: (operation) => {
|
|
12
|
+
if (!isFilter(program, operation)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (getOperationVerb(program, operation) === "get") {
|
|
16
|
+
const returnType = operation.returnType;
|
|
17
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
18
|
+
if (isCollection) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "decorator-invalid-use",
|
|
24
|
+
target: operation,
|
|
25
|
+
messageId: "wrongType",
|
|
26
|
+
format: {
|
|
27
|
+
decorator: "@filter",
|
|
28
|
+
target: "get operation that returns a collection",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const filterOnlyAppliesToModelPropertiesRule = createRule({
|
|
36
|
+
name: "filter-only-on-model-properties",
|
|
37
|
+
create({ program }) {
|
|
38
|
+
return {
|
|
39
|
+
operation: (operation) => {
|
|
40
|
+
if (!isFilter(program, operation)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const returnType = getNavigationSourceType(program, operation);
|
|
44
|
+
if (!returnType) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const modelType = returnType.indexer ? returnType.indexer.value : returnType;
|
|
48
|
+
const filterProperties = getFilter(program, operation);
|
|
49
|
+
const modelProperties = [...walkPropertiesInherited(modelType)].map((property) => property.name);
|
|
50
|
+
const invalidFilterProperties = filterProperties.filter((property) => !modelProperties.includes(property));
|
|
51
|
+
if (!invalidFilterProperties.length) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
reportDiagnostic(program, {
|
|
55
|
+
code: "decorator-invalid-use",
|
|
56
|
+
target: operation,
|
|
57
|
+
messageId: "filterProperties",
|
|
58
|
+
format: {
|
|
59
|
+
model: modelType.name,
|
|
60
|
+
properties: invalidFilterProperties.join(", "),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export const filterPropertiesMustNotBeEmptyRule = createRule({
|
|
68
|
+
name: "filter-properties-must-not-be-empty",
|
|
69
|
+
create({ program }) {
|
|
70
|
+
return {
|
|
71
|
+
operation: (operation) => {
|
|
72
|
+
if (!isFilter(program, operation)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const filterProperties = getFilter(program, operation);
|
|
76
|
+
if (filterProperties.length) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
reportDiagnostic(program, {
|
|
80
|
+
code: "decorator-invalid-use",
|
|
81
|
+
target: operation,
|
|
82
|
+
messageId: "required",
|
|
83
|
+
format: {
|
|
84
|
+
decorator: "@filter",
|
|
85
|
+
parameters: "filter properties",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=filter.js.map
|