@microsoft/typespec-msgraph 0.0.1-Preview.14 → 0.0.1-Preview.16
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 +2 -2
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/entity-container-element.js +2 -6
- package/dist/src/components/entity-container-element.js.map +1 -1
- package/dist/src/components/open-property-type-constraint-annotation-element.d.ts +5 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.d.ts.map +1 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.js +7 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.js.map +1 -0
- package/dist/src/components/operation-element.js +2 -2
- package/dist/src/components/operation-element.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/structured-type-element.d.ts.map +1 -1
- package/dist/src/components/structured-type-element.js +7 -5
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/update-restrictions-annotation.d.ts +2 -1
- package/dist/src/components/update-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/update-restrictions-annotation.js +6 -4
- package/dist/src/components/update-restrictions-annotation.js.map +1 -1
- package/dist/src/decorators/address-url-msa.d.ts +12 -0
- package/dist/src/decorators/address-url-msa.d.ts.map +1 -0
- package/dist/src/decorators/address-url-msa.js +19 -0
- package/dist/src/decorators/address-url-msa.js.map +1 -0
- package/dist/src/decorators/address-url.d.ts.map +1 -1
- package/dist/src/decorators/function.d.ts +7 -2
- package/dist/src/decorators/function.d.ts.map +1 -1
- package/dist/src/decorators/function.js +2 -2
- package/dist/src/decorators/function.js.map +1 -1
- package/dist/src/decorators/graph-route.d.ts +1 -0
- package/dist/src/decorators/graph-route.d.ts.map +1 -1
- package/dist/src/decorators/graph-route.js +17 -0
- package/dist/src/decorators/graph-route.js.map +1 -1
- package/dist/src/decorators/index.d.ts +13 -10
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +13 -10
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/media.d.ts +10 -0
- package/dist/src/decorators/media.d.ts.map +1 -0
- package/dist/src/decorators/media.js +16 -0
- package/dist/src/decorators/media.js.map +1 -0
- package/dist/src/decorators/passthrough-address-url-msa.d.ts +11 -0
- package/dist/src/decorators/passthrough-address-url-msa.d.ts.map +1 -0
- package/dist/src/decorators/passthrough-address-url-msa.js +17 -0
- package/dist/src/decorators/passthrough-address-url-msa.js.map +1 -0
- package/dist/src/decorators/passthrough-address-url.d.ts +11 -0
- package/dist/src/decorators/passthrough-address-url.d.ts.map +1 -0
- package/dist/src/decorators/passthrough-address-url.js +17 -0
- package/dist/src/decorators/passthrough-address-url.js.map +1 -0
- package/dist/src/dom/error-interceptor.d.ts +2 -0
- package/dist/src/dom/error-interceptor.d.ts.map +1 -0
- package/dist/src/dom/error-interceptor.js +13 -0
- package/dist/src/dom/error-interceptor.js.map +1 -0
- package/dist/src/dom/renderer.d.ts +1 -0
- package/dist/src/dom/renderer.d.ts.map +1 -1
- package/dist/src/dom/renderer.js +1 -0
- package/dist/src/dom/renderer.js.map +1 -1
- package/dist/src/entities/address-url.d.ts +4 -0
- package/dist/src/entities/address-url.d.ts.map +1 -1
- package/dist/src/entities/address-url.js +40 -11
- package/dist/src/entities/address-url.js.map +1 -1
- package/dist/src/entities/annotations.d.ts +9 -2
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +34 -3
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.d.ts +6 -0
- package/dist/src/entities/entity-container.d.ts.map +1 -1
- package/dist/src/entities/entity-container.js +7 -1
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/model.d.ts +8 -4
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +54 -8
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/ms-graph-route.d.ts.map +1 -1
- package/dist/src/entities/ms-graph-route.js +15 -15
- package/dist/src/entities/ms-graph-route.js.map +1 -1
- package/dist/src/entities/operation.d.ts +1 -0
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +11 -5
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +17 -3
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +11 -5
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts +2 -0
- package/dist/src/linter.d.ts.map +1 -0
- package/dist/src/linter.js +17 -0
- package/dist/src/linter.js.map +1 -0
- package/dist/src/rules/address-url.d.ts +13 -0
- package/dist/src/rules/address-url.d.ts.map +1 -1
- package/dist/src/rules/address-url.js +128 -7
- package/dist/src/rules/address-url.js.map +1 -1
- package/dist/src/rules/contains.d.ts +1 -1
- package/dist/src/rules/contains.js +1 -1
- package/dist/src/rules/expand.d.ts.map +1 -1
- package/dist/src/rules/expand.js +3 -1
- package/dist/src/rules/expand.js.map +1 -1
- package/dist/src/rules/graph-route.d.ts +2 -0
- package/dist/src/rules/graph-route.d.ts.map +1 -1
- package/dist/src/rules/graph-route.js +65 -1
- package/dist/src/rules/graph-route.js.map +1 -1
- package/dist/src/rules/index.d.ts +3 -1
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +3 -1
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/media.d.ts +10 -0
- package/dist/src/rules/media.d.ts.map +1 -0
- package/dist/src/rules/media.js +122 -0
- package/dist/src/rules/media.js.map +1 -0
- package/dist/src/rules/model.d.ts +4 -0
- package/dist/src/rules/model.d.ts.map +1 -0
- package/dist/src/rules/model.js +36 -0
- package/dist/src/rules/model.js.map +1 -0
- package/dist/src/rules/record-t.d.ts +5 -0
- package/dist/src/rules/record-t.d.ts.map +1 -0
- package/dist/src/rules/record-t.js +78 -0
- package/dist/src/rules/record-t.js.map +1 -0
- package/dist/src/rules/reference-target.d.ts +1 -1
- package/dist/src/rules/reference-target.d.ts.map +1 -1
- package/dist/src/rules/reference-target.js +11 -12
- package/dist/src/rules/reference-target.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 +24 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +12 -3
- package/dist/src/validate.js.map +1 -1
- package/lib/bodies.tsp +71 -0
- package/lib/decorators.tsp +39 -4
- package/lib/msgraph.tsp +1 -0
- package/lib/porcelain.tsp +43 -18
- package/lib/responses.tsp +4 -52
- package/lib/shared-models.tsp +2 -2
- package/package.json +4 -4
- package/dist/src/decorators/has-stream.d.ts +0 -10
- package/dist/src/decorators/has-stream.d.ts.map +0 -1
- package/dist/src/decorators/has-stream.js +0 -17
- package/dist/src/decorators/has-stream.js.map +0 -1
- package/dist/src/rules/has-stream.d.ts +0 -3
- package/dist/src/rules/has-stream.d.ts.map +0 -1
- package/dist/src/rules/has-stream.js +0 -30
- package/dist/src/rules/has-stream.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { hasAddressUrl, hasGraphRoute, isAction } from "../index.js";
|
|
1
|
+
import { hasAddressUrl, hasAddressUrlMsa, hasGraphRoute, hasPassthroughAddressUrl, isAction, } from "../index.js";
|
|
2
2
|
import { reportDiagnostic } from "../lib.js";
|
|
3
3
|
import { navigateTypesInNamespace } from "@typespec/compiler";
|
|
4
4
|
import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
5
|
+
import { hasPassthroughAddressUrlMsa } from "../decorators/passthrough-address-url-msa.js";
|
|
6
|
+
import { getIdForType } from "../utils.js";
|
|
5
7
|
/**
|
|
6
8
|
* @addressUrl only applies to either routed interfaces (entity sets, singletons and navigation properties) or action operations.
|
|
7
9
|
*/
|
|
@@ -9,18 +11,137 @@ export function validateAddressUrlOnlyAppliesToRoutedInterfacesOrActionOperation
|
|
|
9
11
|
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
10
12
|
navigateTypesInNamespace(namespace, {
|
|
11
13
|
interface: (theInterface) => {
|
|
12
|
-
|
|
14
|
+
if (hasAddressUrl(program, theInterface)) {
|
|
15
|
+
validateAddressUrlApplication(program, theInterface, "@addressUrl");
|
|
16
|
+
}
|
|
13
17
|
},
|
|
14
18
|
operation: (operation) => {
|
|
15
|
-
|
|
19
|
+
if (hasAddressUrl(program, operation)) {
|
|
20
|
+
validateAddressUrlApplication(program, operation, "@addressUrl");
|
|
21
|
+
}
|
|
16
22
|
},
|
|
17
23
|
});
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @addressUrlMsa only applies to either routed interfaces (entity sets, singletons and navigation properties) or action operations.
|
|
28
|
+
*/
|
|
29
|
+
export function validateAddressUrlMsaOnlyAppliesToRoutedInterfacesOrActionOperations(program) {
|
|
30
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
31
|
+
navigateTypesInNamespace(namespace, {
|
|
32
|
+
interface: (theInterface) => {
|
|
33
|
+
if (hasAddressUrlMsa(program, theInterface)) {
|
|
34
|
+
validateAddressUrlApplication(program, theInterface, "@addressUrlMsa");
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
operation: (operation) => {
|
|
38
|
+
if (hasAddressUrlMsa(program, operation)) {
|
|
39
|
+
validateAddressUrlApplication(program, operation, "@addressUrlMsa");
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @passthroughAddressUrl only applies to either routed interfaces (entity sets, singletons and navigation properties) or action operations.
|
|
47
|
+
*/
|
|
48
|
+
export function validatePassthroughAddressUrlOnlyAppliesToRoutedInterfacesOrActionOperations(program) {
|
|
49
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
50
|
+
navigateTypesInNamespace(namespace, {
|
|
51
|
+
interface: (theInterface) => {
|
|
52
|
+
if (hasPassthroughAddressUrl(program, theInterface)) {
|
|
53
|
+
validateAddressUrlApplication(program, theInterface, "@passthroughAddressUrl");
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
operation: (operation) => {
|
|
57
|
+
if (hasPassthroughAddressUrl(program, operation)) {
|
|
58
|
+
validateAddressUrlApplication(program, operation, "@passthroughAddressUrl");
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
23
62
|
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @passthroughAddressUrlMsa only applies to either routed interfaces (entity sets, singletons and navigation properties) or action operations.
|
|
66
|
+
*/
|
|
67
|
+
export function validatePassthroughAddressUrlMsaOnlyAppliesToRoutedInterfacesOrActionOperations(program) {
|
|
68
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
69
|
+
navigateTypesInNamespace(namespace, {
|
|
70
|
+
interface: (theInterface) => {
|
|
71
|
+
if (hasPassthroughAddressUrlMsa(program, theInterface)) {
|
|
72
|
+
validateAddressUrlApplication(program, theInterface, "@passthroughAddressUrlMsa");
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
operation: (operation) => {
|
|
76
|
+
if (hasPassthroughAddressUrlMsa(program, operation)) {
|
|
77
|
+
validateAddressUrlApplication(program, operation, "@passthroughAddressUrlMsa");
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function validatePassthroughAddressUrlDecoratorIsUsedTogetherWithAddressUrlDecorator(program) {
|
|
84
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
85
|
+
navigateTypesInNamespace(namespace, {
|
|
86
|
+
interface: (theInterface) => {
|
|
87
|
+
if (hasPassthroughAddressUrl(program, theInterface) &&
|
|
88
|
+
!hasAddressUrl(program, theInterface)) {
|
|
89
|
+
reportDiagnostic(program, {
|
|
90
|
+
code: "decorator-missing-dependencies",
|
|
91
|
+
target: theInterface,
|
|
92
|
+
messageId: "default",
|
|
93
|
+
format: {
|
|
94
|
+
decorator: "@passthroughAddressUrl",
|
|
95
|
+
required: "@addressUrl",
|
|
96
|
+
location: `interface "${getIdForType(program, theInterface)}"`,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (hasPassthroughAddressUrlMsa(program, theInterface) &&
|
|
101
|
+
!hasAddressUrlMsa(program, theInterface)) {
|
|
102
|
+
reportDiagnostic(program, {
|
|
103
|
+
code: "decorator-missing-dependencies",
|
|
104
|
+
target: theInterface,
|
|
105
|
+
messageId: "default",
|
|
106
|
+
format: {
|
|
107
|
+
decorator: "@passthroughAddressUrlMsa",
|
|
108
|
+
required: "@addressUrlMsa",
|
|
109
|
+
location: `interface "${getIdForType(program, theInterface)}"`,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
operation: (operation) => {
|
|
115
|
+
if (hasPassthroughAddressUrl(program, operation) && !hasAddressUrl(program, operation)) {
|
|
116
|
+
reportDiagnostic(program, {
|
|
117
|
+
code: "decorator-missing-dependencies",
|
|
118
|
+
target: operation,
|
|
119
|
+
messageId: "default",
|
|
120
|
+
format: {
|
|
121
|
+
decorator: "@passthroughAddressUrl",
|
|
122
|
+
required: "@addressUrl",
|
|
123
|
+
location: `operation "${getIdForType(program, operation)}"`,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (hasPassthroughAddressUrlMsa(program, operation) &&
|
|
128
|
+
!hasAddressUrlMsa(program, operation)) {
|
|
129
|
+
reportDiagnostic(program, {
|
|
130
|
+
code: "decorator-missing-dependencies",
|
|
131
|
+
target: operation,
|
|
132
|
+
messageId: "default",
|
|
133
|
+
format: {
|
|
134
|
+
decorator: "@passthroughAddressUrlMsa",
|
|
135
|
+
required: "@addressUrlMsa",
|
|
136
|
+
location: `operation "${getIdForType(program, operation)}"`,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function validateAddressUrlApplication(program, target, decorator) {
|
|
24
145
|
if (target.kind === "Interface" && hasGraphRoute(program, target)) {
|
|
25
146
|
return;
|
|
26
147
|
}
|
|
@@ -32,7 +153,7 @@ function validateAddressUrlApplication(program, target) {
|
|
|
32
153
|
target: target,
|
|
33
154
|
messageId: "wrongType",
|
|
34
155
|
format: {
|
|
35
|
-
decorator:
|
|
156
|
+
decorator: decorator,
|
|
36
157
|
target: "routed interface (entityset, singleton or navigation property) or an action operation",
|
|
37
158
|
},
|
|
38
159
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-url.js","sourceRoot":"","sources":["../../../src/rules/address-url.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"address-url.js","sourceRoot":"","sources":["../../../src/rules/address-url.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,wBAAwB,EACxB,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAiC,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,iEAAiE,CAC/E,OAAgB;IAEhB,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE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N,SAAS,EAAE,2BAA2B;4BACtC,QAAQ,EAAE,gBAAgB;4BAC1B,QAAQ,EAAE,cAAc,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG;yBAC5D;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAED,SAAS,6BAA6B,CACpC,OAAgB,EAChB,MAA6B,EAC7B,SAI+B;IAE/B,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;QACjE,OAAO;KACR;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;QAC5D,OAAO;KACR;IAED,gBAAgB,CAAC,OAAO,EAAE;QACxB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE;YACN,SAAS,EAAE,SAAS;YACpB,MAAM,EACJ,uFAAuF;SAC1F;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,5 +2,5 @@ import { Program } from "@typespec/compiler";
|
|
|
2
2
|
/**
|
|
3
3
|
* @contains applies to a navigation property.
|
|
4
4
|
*/
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function validateContainsOnlyAppliesToNavigationProperty(program: Program): void;
|
|
6
6
|
//# sourceMappingURL=contains.d.ts.map
|
|
@@ -6,7 +6,7 @@ import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* @contains applies to a navigation property.
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function validateContainsOnlyAppliesToNavigationProperty(program) {
|
|
10
10
|
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
11
11
|
navigateTypesInNamespace(namespace, {
|
|
12
12
|
modelProperty: (property) => {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,QAyCtE"}
|
package/dist/src/rules/expand.js
CHANGED
|
@@ -46,7 +46,9 @@ export function validateExpandOnlyNavigationProperties(program) {
|
|
|
46
46
|
const navigationProperties = [...walkPropertiesInherited(modelType)]
|
|
47
47
|
.filter((property) => isContains(program, property) || isReferences(program, property))
|
|
48
48
|
.map((property) => property.name);
|
|
49
|
-
const invalidExpansions = expanded.filter((property) =>
|
|
49
|
+
const invalidExpansions = expanded.filter((property) => {
|
|
50
|
+
return !navigationProperties.includes(property) && property !== "$value";
|
|
51
|
+
});
|
|
50
52
|
if (!invalidExpansions.length) {
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
@@ -1 +1 @@
|
|
|
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,MA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vC,CAAC,QAAQ,EAAE,EAAE;oBACX,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,QAAQ,CAAA;gBAC1E,CAAC,CACF,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"}
|
|
@@ -9,4 +9,6 @@ export declare function validateGraphRouteAndInterfaceExtendsMatchForCollections
|
|
|
9
9
|
* A interface decorated with @graphRoute must ultimately extend one of the standard graph interface i.e Resource<T> or Collection<T>.
|
|
10
10
|
*/
|
|
11
11
|
export declare function validateGraphRouteInterfaceExtendsGraphStandardInterface(program: Program): void;
|
|
12
|
+
export declare function validateDuplicateGraphRoutesNotAllowed(program: Program): void;
|
|
13
|
+
export declare function validateGraphRouteParametersMustBeUnique(program: Program): void;
|
|
12
14
|
//# sourceMappingURL=graph-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-route.d.ts","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,OAAO,EAAkC,MAAM,oBAAoB,CAAC;AAInG;;GAEG;AAEH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,QAW9D;AAyBD,wBAAgB,oDAAoD,CAAC,OAAO,EAAE,OAAO,QAWpF;AAqDD,wBAAgB,wDAAwD,CAAC,OAAO,EAAE,OAAO,QA2BxF;AAeD;;GAEG;AACH,wBAAgB,wDAAwD,CAAC,OAAO,EAAE,OAAO,QA0BxF"}
|
|
1
|
+
{"version":3,"file":"graph-route.d.ts","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,OAAO,EAAkC,MAAM,oBAAoB,CAAC;AAInG;;GAEG;AAEH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,QAW9D;AAyBD,wBAAgB,oDAAoD,CAAC,OAAO,EAAE,OAAO,QAWpF;AAqDD,wBAAgB,wDAAwD,CAAC,OAAO,EAAE,OAAO,QA2BxF;AAeD;;GAEG;AACH,wBAAgB,wDAAwD,CAAC,OAAO,EAAE,OAAO,QA0BxF;AAED,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,OAAO,QAwBtE;AAgBD,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,OAAO,QA6BxE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reportDiagnostic } from "../lib.js";
|
|
2
|
-
import { extractParamsFromPath, getGraphRoutePaths, hasGraphRoute } from "../index.js";
|
|
2
|
+
import { extractParamsFromPath, getGraphRoutePaths, getGraphRoutes, hasGraphRoute } from "../index.js";
|
|
3
3
|
import { navigateTypesInNamespace } from "@typespec/compiler";
|
|
4
4
|
import { getIdForType, getSourceInterfaces } from "../utils.js";
|
|
5
5
|
import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
@@ -158,4 +158,68 @@ export function validateGraphRouteInterfaceExtendsGraphStandardInterface(program
|
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
export function validateDuplicateGraphRoutesNotAllowed(program) {
|
|
162
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
163
|
+
navigateTypesInNamespace(namespace, {
|
|
164
|
+
interface: ($interface) => {
|
|
165
|
+
if (!hasGraphRoute(program, $interface)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const existingRoutes = getGraphRoutes(program);
|
|
169
|
+
const graphRoutePaths = getGraphRoutePaths(program, $interface);
|
|
170
|
+
const uniqueGraphRoutePaths = new Set(graphRoutePaths);
|
|
171
|
+
if (graphRoutePaths.length !== uniqueGraphRoutePaths.size) {
|
|
172
|
+
const duplicates = graphRoutePaths.filter((path, index) => graphRoutePaths.indexOf(path) !== index);
|
|
173
|
+
reportDuplicateRouteDiagnostics(program, $interface, duplicates[0], existingRoutes);
|
|
174
|
+
}
|
|
175
|
+
for (const graphRoutePath of graphRoutePaths) {
|
|
176
|
+
if (existingRoutes.has(graphRoutePath) && existingRoutes.get(graphRoutePath) !== $interface) {
|
|
177
|
+
reportDuplicateRouteDiagnostics(program, $interface, graphRoutePath, existingRoutes);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function reportDuplicateRouteDiagnostics(program, $interface, graphRoutePath, existingRoutes) {
|
|
185
|
+
reportDiagnostic(program, {
|
|
186
|
+
code: "decorator-invalid-use",
|
|
187
|
+
target: $interface,
|
|
188
|
+
messageId: "duplicateGraphRouteNotAllowed",
|
|
189
|
+
format: {
|
|
190
|
+
target: getIdForType(program, $interface),
|
|
191
|
+
graphRoute: graphRoutePath,
|
|
192
|
+
existing: getIdForType(program, existingRoutes.get(graphRoutePath))
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
export function validateGraphRouteParametersMustBeUnique(program) {
|
|
197
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
198
|
+
navigateTypesInNamespace(namespace, {
|
|
199
|
+
interface: ($interface) => {
|
|
200
|
+
if (!hasGraphRoute(program, $interface)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const graphRoutePaths = getGraphRoutePaths(program, $interface);
|
|
204
|
+
for (const graphRoutePath of graphRoutePaths) {
|
|
205
|
+
const params = extractParamsFromPath(graphRoutePath);
|
|
206
|
+
const uniqueParams = new Set(params);
|
|
207
|
+
const duplicateParameters = params.filter(param => params.indexOf(param) !== params.lastIndexOf(param));
|
|
208
|
+
if (params.length !== uniqueParams.size) {
|
|
209
|
+
reportDiagnostic(program, {
|
|
210
|
+
code: "decorator-invalid-use",
|
|
211
|
+
target: $interface,
|
|
212
|
+
messageId: "duplicateParametersAreNotAllowedInGraphRoute",
|
|
213
|
+
format: {
|
|
214
|
+
graphRoute: graphRoutePath,
|
|
215
|
+
target: $interface.name,
|
|
216
|
+
parameters: duplicateParameters.join(", ")
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
161
225
|
//# sourceMappingURL=graph-route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-route.js","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"graph-route.js","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EAAuC,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;GAEG;AAEH,MAAM,UAAU,8BAA8B,CAAC,OAAgB;IAC7D,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wB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K,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAC;QACrD,wBAAwB,CAAC,SAAS,EAAE;YAClC,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE;gBACxB,IAAG,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,EAAC;oBACrC,OAAO;iBACR;gBAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAE,CAAC;gBACjE,KAAI,MAAM,cAAc,IAAI,eAAe,EAAC;oBAC1C,MAAM,MAAM,GAAG,qBAAqB,CAAC,cAAc,CAAC,CAAC;oBACrD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;oBACrC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;oBACxG,IAAG,MAAM,CAAC,MAAM,KAAK,YAAY,CAAC,IAAI,EAAC;wBACrC,gBAAgB,CAAC,OAAO,EAAE;4BACxB,IAAI,EAAE,uBAAuB;4BAC7B,MAAM,EAAE,UAAU;4BAClB,SAAS,EAAE,8CAA8C;4BACzD,MAAM,EAAE;gCACN,UAAU,EAAE,cAAc;gCAC1B,MAAM,EAAE,UAAU,CAAC,IAAI;gCACvB,UAAU,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;6BAC3C;yBACF,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC,CAAA;KACH;AACH,CAAC"}
|
|
@@ -13,7 +13,7 @@ export * from "./extends-on-same-type.js";
|
|
|
13
13
|
export * from "./filter.js";
|
|
14
14
|
export * from "./function.js";
|
|
15
15
|
export * from "./graph-route.js";
|
|
16
|
-
export * from "./
|
|
16
|
+
export * from "./media.js";
|
|
17
17
|
export * from "./namespace.js";
|
|
18
18
|
export * from "./open.js";
|
|
19
19
|
export * from "./operation-inside-interface.js";
|
|
@@ -30,4 +30,6 @@ export * from "./graph-deprecated.js";
|
|
|
30
30
|
export * from "./ownerless.js";
|
|
31
31
|
export * from "./global-operation.js";
|
|
32
32
|
export * from "./reference-target.js";
|
|
33
|
+
export * from "./record-t.js";
|
|
34
|
+
export * from "./model.js";
|
|
33
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/src/rules/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export * from "./extends-on-same-type.js";
|
|
|
13
13
|
export * from "./filter.js";
|
|
14
14
|
export * from "./function.js";
|
|
15
15
|
export * from "./graph-route.js";
|
|
16
|
-
export * from "./
|
|
16
|
+
export * from "./media.js";
|
|
17
17
|
export * from "./namespace.js";
|
|
18
18
|
export * from "./open.js";
|
|
19
19
|
export * from "./operation-inside-interface.js";
|
|
@@ -30,4 +30,6 @@ export * from "./graph-deprecated.js";
|
|
|
30
30
|
export * from "./ownerless.js";
|
|
31
31
|
export * from "./global-operation.js";
|
|
32
32
|
export * from "./reference-target.js";
|
|
33
|
+
export * from "./record-t.js";
|
|
34
|
+
export * from "./model.js";
|
|
33
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Program } from "@typespec/compiler";
|
|
2
|
+
export declare function validateIsMediaOnlyOnEntity(program: Program): void;
|
|
3
|
+
export declare const mediaTypeValuesShouldBeMinimallyFormattedForMIMETypes: import("@typespec/compiler").LinterRuleDefinition<"media-type-values-should-be-minimally-formatted", {
|
|
4
|
+
readonly default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecified: import("@typespec/compiler").LinterRuleDefinition<"navigation-source-should-have-media-if-value-is-specified", {
|
|
7
|
+
readonly interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInRoute: import("@typespec/compiler").CallableMessage<[string, string]>;
|
|
8
|
+
readonly interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInParameters: import("@typespec/compiler").CallableMessage<[string]>;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/rules/media.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAsD,MAAM,oBAAoB,CAAC;AAIjG,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QAsB3D;AAED,eAAO,MAAM,qDAAqD;;EA6BhE,CAAA;AAEF,eAAO,MAAM,2DAA2D;;;EA4DtE,CAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { getMediaTypes, isMedia } from "../decorators/media.js";
|
|
2
|
+
import { getExpand, getGraphRoutePaths, hasGraphRoute, isEntity } from "../index.js";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { createRule, navigateTypesInNamespace, paramMessage } from "@typespec/compiler";
|
|
5
|
+
import { GetDeclaredNamespaces } from "../entities/namespace.js";
|
|
6
|
+
import { getInterfaceNavigationSourceType, getNavigationSourceType } from "../utils.js";
|
|
7
|
+
export function validateIsMediaOnlyOnEntity(program) {
|
|
8
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
9
|
+
navigateTypesInNamespace(namespace, {
|
|
10
|
+
model: (model) => {
|
|
11
|
+
if (!isMedia(program, model)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (isEntity(program, model)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
reportDiagnostic(program, {
|
|
18
|
+
code: "decorator-invalid-use",
|
|
19
|
+
target: model,
|
|
20
|
+
messageId: "wrongType",
|
|
21
|
+
format: {
|
|
22
|
+
decorator: "@media",
|
|
23
|
+
target: "@entity model",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
;
|
|
31
|
+
export const mediaTypeValuesShouldBeMinimallyFormattedForMIMETypes = createRule({
|
|
32
|
+
name: "media-type-values-should-be-minimally-formatted",
|
|
33
|
+
severity: "warning",
|
|
34
|
+
description: "Media type values should be two part strings with a / separator",
|
|
35
|
+
messages: {
|
|
36
|
+
default: paramMessage `Media type value '${"value"}' should be a two part string with a \/ separator.`,
|
|
37
|
+
},
|
|
38
|
+
create(context) {
|
|
39
|
+
return {
|
|
40
|
+
model: (model) => {
|
|
41
|
+
if (!isMedia(context.program, model)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const mediaTypes = getMediaTypes(context.program, model);
|
|
45
|
+
if (mediaTypes.length > 0) {
|
|
46
|
+
for (const mediaType of mediaTypes) {
|
|
47
|
+
if (mediaType.split("/").length !== 2) {
|
|
48
|
+
context.reportDiagnostic({
|
|
49
|
+
target: model,
|
|
50
|
+
format: {
|
|
51
|
+
value: mediaType,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export const interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecified = createRule({
|
|
62
|
+
name: "navigation-source-should-have-media-if-value-is-specified",
|
|
63
|
+
severity: "warning",
|
|
64
|
+
description: "Interface navigation source should have media if $value is specified",
|
|
65
|
+
messages: {
|
|
66
|
+
interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInRoute: paramMessage `Interface navigation source '${"model"}' should have @media if $value is specified in the interface route '${"route"}'.`,
|
|
67
|
+
interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInParameters: paramMessage `Interface navigation source '${"model"}' should have @media if $value is specified in the parameters.`,
|
|
68
|
+
},
|
|
69
|
+
create(context) {
|
|
70
|
+
return {
|
|
71
|
+
operation: (operation) => {
|
|
72
|
+
operation.decorators.forEach((decorator) => {
|
|
73
|
+
if (decorator.decorator.name === "$expand") {
|
|
74
|
+
const expanded = getExpand(context.program, operation);
|
|
75
|
+
if (expanded.includes("$value")) {
|
|
76
|
+
const navigationSource = getNavigationSourceType(context.program, operation);
|
|
77
|
+
if (!navigationSource) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!isMedia(context.program, navigationSource)) {
|
|
81
|
+
context.reportDiagnostic({
|
|
82
|
+
target: operation,
|
|
83
|
+
format: {
|
|
84
|
+
model: navigationSource.name,
|
|
85
|
+
},
|
|
86
|
+
messageId: "interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInParameters",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
interface: (_interface) => {
|
|
94
|
+
if (!hasGraphRoute(context.program, _interface)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const graphRoutes = getGraphRoutePaths(context.program, _interface);
|
|
98
|
+
if (graphRoutes && graphRoutes.length > 0) {
|
|
99
|
+
for (const graphRoute of graphRoutes) {
|
|
100
|
+
if (graphRoute.includes("$value")) {
|
|
101
|
+
const navigationSource = getInterfaceNavigationSourceType(context.program, _interface);
|
|
102
|
+
if (!navigationSource) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!isMedia(context.program, navigationSource)) {
|
|
106
|
+
context.reportDiagnostic({
|
|
107
|
+
target: _interface,
|
|
108
|
+
format: {
|
|
109
|
+
model: navigationSource.name,
|
|
110
|
+
route: graphRoute,
|
|
111
|
+
},
|
|
112
|
+
messageId: "interfaceNavigationSourceShouldHaveMediaIf$ValueIsSpecifiedInRoute"
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/rules/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAW,UAAU,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExF,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACtD,wBAAwB,CAAC,SAAS,EAAE;YAClC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC5B,OAAO;iBACR;gBACD,IAAI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MAAM,GAAG,CAAC,EAAC;oBACvC,KAAM,MAAM,UAAU,IAAI,WAAW,EAAC;wBACpC,IAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC;4BAC/B,MAAM,gBAAgB,GAAG,gCAAgC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;4BACvF,IAAG,CAAC,gBAAgB,EAAC;gCACnB,OAAO;6BACR;4BACD,IAAG,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAC;gCAC7C,OAAO,CAAC,gBAAgB,CAAC;oCACvB,MAAM,EAAE,UAAU;oCAClB,MAAM,EAAE;wCACN,KAAK,EAAE,gBAAgB,CAAC,IAAI;wCAC5B,KAAK,EAAE,UAAU;qCAClB;oCACD,SAAS,EAAE,oEAAoE;iCAChF,CAAC,CAAC;6BACJ;yBACF;qBACF;iBACF;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/rules/model.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gCAAgC;;EAmC3C,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRule, getLocationContext, paramMessage } from "@typespec/compiler";
|
|
2
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
3
|
+
import { isEntity, isComplex } from "../index.js";
|
|
4
|
+
export const modelShouldBeEntityOrComplexType = createRule({
|
|
5
|
+
name: "model-should-be-entity-or-complex-type",
|
|
6
|
+
severity: "warning",
|
|
7
|
+
description: "Model should be entity or complex type",
|
|
8
|
+
messages: {
|
|
9
|
+
default: paramMessage `Model '${"model"}' should be entity or complex type.`,
|
|
10
|
+
},
|
|
11
|
+
create(context) {
|
|
12
|
+
return {
|
|
13
|
+
model: (model) => {
|
|
14
|
+
if (isExcludedCoreType(context.program, model) || getLocationContext(context.program, model).type === "library") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (isEntity(context.program, model) || isComplex(context.program, model)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const modelDecorators = model.decorators;
|
|
21
|
+
for (const decorator of modelDecorators) {
|
|
22
|
+
if (decorator.decorator.name === "$operationParameters") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
context.reportDiagnostic({
|
|
27
|
+
target: model,
|
|
28
|
+
format: {
|
|
29
|
+
model: model.name,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/rules/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAAC;IACzD,IAAI,EAAE,wCAAwC;IAC9C,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,wCAAwC;IACrD,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,UAAU,OAAO,qCAAqC;KAC5E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE;oBAC/G,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACzE,OAAO;iBACR;gBAED,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC;gBACzC,KAAI,MAAM,SAAS,IAAI,eAAe,EAAC;oBACrC,IAAG,SAAS,CAAC,SAAS,CAAC,IAAI,KAAK,sBAAsB,EAAC;wBACrD,OAAO;qBACR;iBACF;gBAED,OAAO,CAAC,gBAAgB,CAAC;oBACvB,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE;wBACN,KAAK,EAAE,KAAK,CAAC,IAAI;qBAClB;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CAEF,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Program } from "@typespec/compiler";
|
|
2
|
+
export declare function validateRecordsCannotBePrepopulated(program: Program): void;
|
|
3
|
+
export declare function validateRecordTypeCannotBeNull(program: Program): void;
|
|
4
|
+
export declare function validateRecordTypeCannotBeUsedInLine(program: Program): void;
|
|
5
|
+
//# sourceMappingURL=record-t.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-t.d.ts","sourceRoot":"","sources":["../../../src/rules/record-t.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAgD,MAAM,oBAAoB,CAAC;AAKlG,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,OAAO,QAyBnE;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,QA4B9D;AAED,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,OAAO,QAiBpE"}
|