@azure-tools/typespec-azure-resource-manager 0.74.0-dev.2 → 0.74.0-dev.21
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/README.md +14 -2
- package/dist/generated-defs/Azure.ResourceManager.BaseTypes.d.ts +11 -0
- package/dist/generated-defs/Azure.ResourceManager.BaseTypes.d.ts.map +1 -1
- package/dist/generated-defs/Azure.ResourceManager.Legacy.d.ts +33 -0
- package/dist/generated-defs/Azure.ResourceManager.Legacy.d.ts.map +1 -1
- package/dist/generated-defs/Azure.ResourceManager.d.ts +33 -0
- package/dist/generated-defs/Azure.ResourceManager.d.ts.map +1 -1
- package/dist/src/codefixes/delete-property.d.ts +4 -0
- package/dist/src/codefixes/delete-property.d.ts.map +1 -0
- package/dist/src/codefixes/delete-property.js +17 -0
- package/dist/src/codefixes/delete-property.js.map +1 -0
- package/dist/src/lib.d.ts +167 -2
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +66 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +32 -0
- package/dist/src/linter.js.map +1 -1
- package/dist/src/operations.d.ts +1 -2
- package/dist/src/operations.d.ts.map +1 -1
- package/dist/src/operations.js +19 -43
- package/dist/src/operations.js.map +1 -1
- package/dist/src/private.decorators.d.ts +2 -1
- package/dist/src/private.decorators.d.ts.map +1 -1
- package/dist/src/private.decorators.js +40 -10
- package/dist/src/private.decorators.js.map +1 -1
- package/dist/src/resource-name.d.ts +27 -0
- package/dist/src/resource-name.d.ts.map +1 -0
- package/dist/src/resource-name.js +82 -0
- package/dist/src/resource-name.js.map +1 -0
- package/dist/src/resource.d.ts +128 -11
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/resource.js +415 -109
- package/dist/src/resource.js.map +1 -1
- package/dist/src/rules/arm-custom-resource-usage-discourage.js +3 -20
- package/dist/src/rules/arm-custom-resource-usage-discourage.js.map +1 -1
- package/dist/src/rules/arm-resource-invalid-envelope-property.d.ts.map +1 -1
- package/dist/src/rules/arm-resource-invalid-envelope-property.js +12 -3
- package/dist/src/rules/arm-resource-invalid-envelope-property.js.map +1 -1
- package/dist/src/rules/http-response-utils.d.ts +16 -0
- package/dist/src/rules/http-response-utils.d.ts.map +1 -0
- package/dist/src/rules/http-response-utils.js +31 -0
- package/dist/src/rules/http-response-utils.js.map +1 -0
- package/dist/src/rules/lro-missing-polling-metadata.d.ts +4 -0
- package/dist/src/rules/lro-missing-polling-metadata.d.ts.map +1 -0
- package/dist/src/rules/lro-missing-polling-metadata.js +59 -0
- package/dist/src/rules/lro-missing-polling-metadata.js.map +1 -0
- package/dist/src/rules/model-utils.d.ts +4 -0
- package/dist/src/rules/model-utils.d.ts.map +1 -0
- package/dist/src/rules/model-utils.js +18 -0
- package/dist/src/rules/model-utils.js.map +1 -0
- package/dist/src/rules/no-empty-post-response.d.ts +4 -0
- package/dist/src/rules/no-empty-post-response.d.ts.map +1 -0
- package/dist/src/rules/no-empty-post-response.js +38 -0
- package/dist/src/rules/no-empty-post-response.js.map +1 -0
- package/dist/src/rules/no-repeated-path-info.d.ts +4 -0
- package/dist/src/rules/no-repeated-path-info.d.ts.map +1 -0
- package/dist/src/rules/no-repeated-path-info.js +63 -0
- package/dist/src/rules/no-repeated-path-info.js.map +1 -0
- package/dist/src/rules/no-reserved-resource-property.d.ts.map +1 -1
- package/dist/src/rules/no-reserved-resource-property.js +2 -1
- package/dist/src/rules/no-reserved-resource-property.js.map +1 -1
- package/dist/src/rules/no-resource-name-conflict.d.ts +4 -0
- package/dist/src/rules/no-resource-name-conflict.d.ts.map +1 -0
- package/dist/src/rules/no-resource-name-conflict.js +52 -0
- package/dist/src/rules/no-resource-name-conflict.js.map +1 -0
- package/dist/src/rules/no-response-body.d.ts +2 -1
- package/dist/src/rules/no-response-body.d.ts.map +1 -1
- package/dist/src/rules/no-response-body.js +20 -13
- package/dist/src/rules/no-response-body.js.map +1 -1
- package/dist/src/rules/no-tags-on-proxy-resource.d.ts +4 -0
- package/dist/src/rules/no-tags-on-proxy-resource.d.ts.map +1 -0
- package/dist/src/rules/no-tags-on-proxy-resource.js +58 -0
- package/dist/src/rules/no-tags-on-proxy-resource.js.map +1 -0
- package/dist/src/rules/private-endpoint-apis-missing.d.ts +4 -0
- package/dist/src/rules/private-endpoint-apis-missing.d.ts.map +1 -0
- package/dist/src/rules/private-endpoint-apis-missing.js +90 -0
- package/dist/src/rules/private-endpoint-apis-missing.js.map +1 -0
- package/dist/src/rules/resource-missing-read.d.ts +4 -0
- package/dist/src/rules/resource-missing-read.d.ts.map +1 -0
- package/dist/src/rules/resource-missing-read.js +55 -0
- package/dist/src/rules/resource-missing-read.js.map +1 -0
- package/dist/src/rules/use-resource-path-for-put.d.ts +4 -0
- package/dist/src/rules/use-resource-path-for-put.d.ts.map +1 -0
- package/dist/src/rules/use-resource-path-for-put.js +35 -0
- package/dist/src/rules/use-resource-path-for-put.js.map +1 -0
- package/dist/src/rules/use-scope-for-extension-routing.d.ts +4 -0
- package/dist/src/rules/use-scope-for-extension-routing.d.ts.map +1 -0
- package/dist/src/rules/use-scope-for-extension-routing.js +37 -0
- package/dist/src/rules/use-scope-for-extension-routing.js.map +1 -0
- package/dist/src/rules/use-scope-path-standard-name.d.ts +5 -0
- package/dist/src/rules/use-scope-path-standard-name.d.ts.map +1 -0
- package/dist/src/rules/use-scope-path-standard-name.js +46 -0
- package/dist/src/rules/use-scope-path-standard-name.js.map +1 -0
- package/dist/src/rules/use-standard-error.d.ts +5 -0
- package/dist/src/rules/use-standard-error.d.ts.map +1 -0
- package/dist/src/rules/use-standard-error.js +66 -0
- package/dist/src/rules/use-standard-error.js.map +1 -0
- package/dist/src/rules/use-standard-response-codes.d.ts +6 -0
- package/dist/src/rules/use-standard-response-codes.d.ts.map +1 -0
- package/dist/src/rules/use-standard-response-codes.js +67 -0
- package/dist/src/rules/use-standard-response-codes.js.map +1 -0
- package/dist/src/rules/utils.d.ts +2 -0
- package/dist/src/rules/utils.d.ts.map +1 -1
- package/dist/src/rules/utils.js +16 -0
- package/dist/src/rules/utils.js.map +1 -1
- package/dist/src/state.d.ts +1 -0
- package/dist/src/state.d.ts.map +1 -1
- package/dist/src/state.js +1 -0
- package/dist/src/state.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRule, fileRef, getProperty, isTemplateDeclarationOrInstance, paramMessage, } from "@typespec/compiler";
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
|
+
import { walkJsonProperties } from "./model-utils.js";
|
|
4
|
+
import { isTemplatedInterfaceOperation } from "./utils.js";
|
|
5
|
+
export const noRepeatedPathInfoRule = createRule({
|
|
6
|
+
name: "no-repeated-path-info",
|
|
7
|
+
docs: fileRef.fromPackageRoot("src/rules/no-repeated-path-info.md"),
|
|
8
|
+
description: "ARM PUT request bodies must not repeat path or query parameters in the resource properties bag.",
|
|
9
|
+
severity: "warning",
|
|
10
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-repeated-path-info",
|
|
11
|
+
messages: {
|
|
12
|
+
default: paramMessage `Request body property '${"name"}' repeats information already carried in the path or query.`,
|
|
13
|
+
},
|
|
14
|
+
create(context) {
|
|
15
|
+
return {
|
|
16
|
+
operation: (operation) => {
|
|
17
|
+
if (isTemplateDeclarationOrInstance(operation) ||
|
|
18
|
+
isTemplatedInterfaceOperation(operation)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const [httpOperation] = getHttpOperation(context.program, operation);
|
|
22
|
+
if (httpOperation.verb !== "put") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const repeatedNames = new Set(httpOperation.parameters.parameters
|
|
26
|
+
.filter((parameter) => parameter.type === "path" || parameter.type === "query")
|
|
27
|
+
.map((parameter) => parameter.name));
|
|
28
|
+
if (repeatedNames.size === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const body = httpOperation.parameters.body;
|
|
32
|
+
if (body === undefined || body.bodyKind !== "single" || body.type.kind !== "Model") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const propertiesModel = getPropertiesModel(body.type);
|
|
36
|
+
if (propertiesModel === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const reportedNames = new Set();
|
|
40
|
+
for (const [name, property] of walkJsonProperties(context.program, propertiesModel)) {
|
|
41
|
+
if (!repeatedNames.has(name)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (reportedNames.has(name)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
reportedNames.add(name);
|
|
48
|
+
context.reportDiagnostic({
|
|
49
|
+
target: property,
|
|
50
|
+
format: {
|
|
51
|
+
name,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
function getPropertiesModel(model) {
|
|
60
|
+
const property = getProperty(model, "properties");
|
|
61
|
+
return property?.type.kind === "Model" ? property.type : undefined;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=no-repeated-path-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-repeated-path-info.js","sourceRoot":"","sources":["../../../src/rules/no-repeated-path-info.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,OAAO,EACP,WAAW,EACX,+BAA+B,EAC/B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;IAC/C,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EA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S,EAAE,CAAC;oBAClC,OAAO;gBACT,CAAC;gBAED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;gBACxC,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC;oBACpF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC7B,SAAS;oBACX,CAAC;oBACD,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC5B,SAAS;oBACX,CAAC;oBACD,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAExB,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,QAAQ;wBAChB,MAAM,EAAE;4BACN,IAAI;yBACL;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,KAAY;IACtC,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAClD,OAAO,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-reserved-resource-property.d.ts","sourceRoot":"","sources":["../../../src/rules/no-reserved-resource-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-reserved-resource-property.d.ts","sourceRoot":"","sources":["../../../src/rules/no-reserved-resource-property.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,8BAA8B;;yBAmCzC,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { getProperties } from "./utils.js";
|
|
|
8
8
|
*/
|
|
9
9
|
const reservedProperties = new Map([
|
|
10
10
|
["billingData", "platform billing integration"],
|
|
11
|
+
["systemData", "resource system metadata"],
|
|
11
12
|
]);
|
|
12
13
|
/**
|
|
13
14
|
* Case-insensitive lookup keyed by the lowercased reserved name. Both the reserved names and the
|
|
@@ -18,7 +19,7 @@ const reservedPropertiesByLowerName = new Map([...reservedProperties].map(([name
|
|
|
18
19
|
export const noReservedResourcePropertyRule = createRule({
|
|
19
20
|
name: "no-reserved-resource-property",
|
|
20
21
|
docs: fileRef.fromPackageRoot("src/rules/no-reserved-resource-property.md"),
|
|
21
|
-
description: "Reserved property names
|
|
22
|
+
description: "Reserved property names must not be present in a resource's property bag. The property name is matched case-insensitively.",
|
|
22
23
|
severity: "warning",
|
|
23
24
|
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-reserved-resource-property",
|
|
24
25
|
messages: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-reserved-resource-property.js","sourceRoot":"","sources":["../../../src/rules/no-reserved-resource-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAiB;IACjD,CAAC,aAAa,EAAE,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"no-reserved-resource-property.js","sourceRoot":"","sources":["../../../src/rules/no-reserved-resource-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;GAIG;AACH,MAAM,kBAAkB,GAA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C,WAAW,EAAE,CAAC,CAAC;oBAChF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;wBAC3B,OAAO,CAAC,gBAAgB,CAAC;4BACvB,MAAM,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE;4BAChE,MAAM,EAAE,QAAQ;yBACjB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const noResourceNameConflictRule: import("@typespec/compiler").LinterRuleDefinition<"no-resource-name-conflict", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["name", "firstPath", "secondPath"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=no-resource-name-conflict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-resource-name-conflict.d.ts","sourceRoot":"","sources":["../../../src/rules/no-resource-name-conflict.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,0BAA0B;;yBAgDrC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRule, fileRef, listServices, paramMessage } from "@typespec/compiler";
|
|
2
|
+
import { isArmProviderNamespace } from "../namespace.js";
|
|
3
|
+
import { resolveArmResources } from "../resource.js";
|
|
4
|
+
import { isInternalTypeSpec } from "./utils.js";
|
|
5
|
+
export const noResourceNameConflictRule = createRule({
|
|
6
|
+
name: "no-resource-name-conflict",
|
|
7
|
+
description: "ARM resources must have unique logical resource names.",
|
|
8
|
+
severity: "warning",
|
|
9
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-resource-name-conflict",
|
|
10
|
+
docs: fileRef.fromPackageRoot("src/rules/no-resource-name-conflict.md"),
|
|
11
|
+
messages: {
|
|
12
|
+
default: paramMessage `Resources must have unique names. Resource name '${"name"}' is used by both '${"firstPath"}' and '${"secondPath"}'. Provide a unique resource name when instantiating the resource operations.`,
|
|
13
|
+
},
|
|
14
|
+
create(context) {
|
|
15
|
+
return {
|
|
16
|
+
root(program) {
|
|
17
|
+
const services = new Set(listServices(program)
|
|
18
|
+
.filter(({ type }) => isArmProviderNamespace(program, type))
|
|
19
|
+
.map(({ type }) => type));
|
|
20
|
+
const names = new Map();
|
|
21
|
+
for (const resource of resolveArmResources(program).resources ?? []) {
|
|
22
|
+
const operation = resource.operations.lifecycle.read?.[0]?.operation ??
|
|
23
|
+
resource.operations.lifecycle.createOrUpdate?.[0]?.operation;
|
|
24
|
+
// Synthetic parents have no identity operation and no author-controlled template name.
|
|
25
|
+
if (operation === undefined || isInternalTypeSpec(program, operation))
|
|
26
|
+
continue;
|
|
27
|
+
let namespace = operation.namespace;
|
|
28
|
+
while (namespace !== undefined && !services.has(namespace)) {
|
|
29
|
+
namespace = namespace.namespace;
|
|
30
|
+
}
|
|
31
|
+
if (namespace === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
const first = names.get(resource.resourceName);
|
|
34
|
+
if (first === undefined) {
|
|
35
|
+
names.set(resource.resourceName, resource);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
context.reportDiagnostic({
|
|
39
|
+
target: operation,
|
|
40
|
+
format: {
|
|
41
|
+
name: resource.resourceName,
|
|
42
|
+
firstPath: first.resourceInstancePath,
|
|
43
|
+
secondPath: resource.resourceInstancePath,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=no-resource-name-conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-resource-name-conflict.js","sourceRoot":"","sources":["../../../src/rules/no-resource-name-conflict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAA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AS,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC;wBAAE,SAAS;oBAEhF,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;oBACpC,OAAO,SAAS,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC3D,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;oBAClC,CAAC;oBACD,IAAI,SAAS,KAAK,SAAS;wBAAE,SAAS;oBAEtC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;oBAC/C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBACxB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;oBAC7C,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,gBAAgB,CAAC;4BACvB,MAAM,EAAE,SAAS;4BACjB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ,CAAC,YAAY;gCAC3B,SAAS,EAAE,KAAK,CAAC,oBAAoB;gCACrC,UAAU,EAAE,QAAQ,CAAC,oBAAoB;6BAC1C;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* verify that 202
|
|
2
|
+
* verify that 202, 204 and DELETE 200 responses do not contain a response body.
|
|
3
3
|
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
4
4
|
*/
|
|
5
5
|
export declare const noResponseBodyRule: import("@typespec/compiler").LinterRuleDefinition<"no-response-body", {
|
|
6
6
|
readonly default: "The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.";
|
|
7
|
+
readonly shouldBeEmpty200: "The body of 200 response for DELETE should be empty.";
|
|
7
8
|
readonly shouldBeEmpty202: "The body of 202 response should be empty.";
|
|
8
9
|
readonly shouldBeEmpty204: "The body of 204 response should be empty.";
|
|
9
10
|
}, Record<string, never>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-response-body.d.ts","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-response-body.d.ts","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;yBAyD7B,CAAC"}
|
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
import { createRule, fileRef, isTemplateInstance } from "@typespec/compiler";
|
|
2
|
-
import { getHttpOperation
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
3
|
import { isTemplatedInterfaceOperation } from "./utils.js";
|
|
4
4
|
/**
|
|
5
|
-
* verify that 202
|
|
5
|
+
* verify that 202, 204 and DELETE 200 responses do not contain a response body.
|
|
6
6
|
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
7
7
|
*/
|
|
8
8
|
export const noResponseBodyRule = createRule({
|
|
9
9
|
name: "no-response-body",
|
|
10
10
|
docs: fileRef.fromPackageRoot("src/rules/no-response-body.md"),
|
|
11
|
-
description: "Check that
|
|
11
|
+
description: "Check that 202, 204 and DELETE 200 responses have no body, and other success (2xx) responses have a body except for HEAD and POST 200.",
|
|
12
12
|
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body",
|
|
13
13
|
severity: "warning",
|
|
14
14
|
messages: {
|
|
15
15
|
default: `The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.`,
|
|
16
|
+
shouldBeEmpty200: `The body of 200 response for DELETE should be empty.`,
|
|
16
17
|
shouldBeEmpty202: `The body of 202 response should be empty.`,
|
|
17
18
|
shouldBeEmpty204: `The body of 204 response should be empty.`,
|
|
18
19
|
},
|
|
19
20
|
create(context) {
|
|
20
21
|
return {
|
|
21
22
|
operation: (op) => {
|
|
23
|
+
if (isTemplateInstance(op) || isTemplatedInterfaceOperation(op))
|
|
24
|
+
return;
|
|
22
25
|
const [httpOperation] = getHttpOperation(context.program, op);
|
|
23
|
-
if (
|
|
24
|
-
isTemplatedInterfaceOperation(op) ||
|
|
25
|
-
httpOperation.verb === "head")
|
|
26
|
+
if (httpOperation.verb === "head")
|
|
26
27
|
return;
|
|
27
|
-
const responses =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const responses = httpOperation.responses;
|
|
29
|
+
const response = responses.find((v) => v.statusCodes !== 204 && v.statusCodes !== 202);
|
|
30
|
+
if (response &&
|
|
31
|
+
!response.responses.every((v) => v.body) &&
|
|
32
|
+
!(["delete", "post"].includes(httpOperation.verb) && response.statusCodes === 200)) {
|
|
33
|
+
context.reportDiagnostic({
|
|
34
|
+
target: op,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (httpOperation.verb === "delete" && hasResponseBodyForCode(200, responses)) {
|
|
32
38
|
context.reportDiagnostic({
|
|
33
39
|
target: op,
|
|
40
|
+
messageId: "shouldBeEmpty200",
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
|
-
if (hasResponseBodyForCode(202,
|
|
43
|
+
if (hasResponseBodyForCode(202, responses)) {
|
|
37
44
|
context.reportDiagnostic({
|
|
38
45
|
target: op,
|
|
39
46
|
messageId: "shouldBeEmpty202",
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
|
-
if (hasResponseBodyForCode(204,
|
|
49
|
+
if (hasResponseBodyForCode(204, responses)) {
|
|
43
50
|
context.reportDiagnostic({
|
|
44
51
|
target: op,
|
|
45
52
|
messageId: "shouldBeEmpty204",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-response-body.js","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAkB,MAAM,oBAAoB,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CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const noTagsOnProxyResourceRule: import("@typespec/compiler").LinterRuleDefinition<"no-tags-on-proxy-resource", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["resourceName"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=no-tags-on-proxy-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-tags-on-proxy-resource.d.ts","sourceRoot":"","sources":["../../../src/rules/no-tags-on-proxy-resource.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,yBAAyB;;yBAqCpC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRule, fileRef, paramMessage, } from "@typespec/compiler";
|
|
2
|
+
import { SyntaxKind } from "@typespec/compiler/ast";
|
|
3
|
+
import { createDeletePropertyCodeFix } from "../codefixes/delete-property.js";
|
|
4
|
+
import { getArmResources } from "../resource.js";
|
|
5
|
+
import { walkJsonProperties } from "./model-utils.js";
|
|
6
|
+
export const noTagsOnProxyResourceRule = createRule({
|
|
7
|
+
name: "no-tags-on-proxy-resource",
|
|
8
|
+
docs: fileRef.fromPackageRoot("src/rules/no-tags-on-proxy-resource.md"),
|
|
9
|
+
description: "Non-tracked ARM resources must not declare a tags property on the resource envelope.",
|
|
10
|
+
severity: "warning",
|
|
11
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-tags-on-proxy-resource",
|
|
12
|
+
messages: {
|
|
13
|
+
default: paramMessage `Non-tracked resource '${"resourceName"}' must not declare \`tags\` on its resource envelope. Use a tracked resource if ARM tags are required.`,
|
|
14
|
+
},
|
|
15
|
+
create(context) {
|
|
16
|
+
return {
|
|
17
|
+
root: () => {
|
|
18
|
+
for (const armResource of getArmResources(context.program)) {
|
|
19
|
+
if (armResource.kind === "Tracked") {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const resourceTags = getPropertyInHierarchy(context.program, armResource.typespecType, "tags");
|
|
23
|
+
if (resourceTags) {
|
|
24
|
+
const codefix = createRemoveTagsCodeFix(armResource.typespecType, resourceTags);
|
|
25
|
+
context.reportDiagnostic({
|
|
26
|
+
target: resourceTags,
|
|
27
|
+
codefixes: codefix ? [codefix] : undefined,
|
|
28
|
+
format: {
|
|
29
|
+
resourceName: armResource.name,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
function createRemoveTagsCodeFix(resource, property) {
|
|
39
|
+
const node = property.node;
|
|
40
|
+
// Avoid editing inherited/copied properties and reusable resource templates.
|
|
41
|
+
if (property.model !== resource ||
|
|
42
|
+
property.sourceProperty ||
|
|
43
|
+
node?.kind !== SyntaxKind.ModelProperty ||
|
|
44
|
+
node.parent !== resource.node ||
|
|
45
|
+
(node.parent?.kind === SyntaxKind.ModelStatement && node.parent.templateParameters.length > 0)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return createDeletePropertyCodeFix(node);
|
|
49
|
+
}
|
|
50
|
+
function getPropertyInHierarchy(program, model, jsonName) {
|
|
51
|
+
for (const [name, property] of walkJsonProperties(program, model)) {
|
|
52
|
+
if (name === jsonName) {
|
|
53
|
+
return property;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=no-tags-on-proxy-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-tags-on-proxy-resource.js","sourceRoot":"","sources":["../../../src/rules/no-tags-on-proxy-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,GAKb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAA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AAC,QAAe,EAAE,QAAuB;IACvE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3B,6EAA6E;IAC7E,IACE,QAAQ,CAAC,KAAK,KAAK,QAAQ;QAC3B,QAAQ,CAAC,cAAc;QACvB,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,aAAa;QACvC,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,IAAI;QAC7B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,UAAU,CAAC,cAAc,IAAI,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,EAC9F,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,sBAAsB,CAC7B,OAAgB,EAChB,KAAY,EACZ,QAAgB;IAEhB,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QAClE,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const privateEndpointApisMissingRule: import("@typespec/compiler").LinterRuleDefinition<"private-endpoint-apis-missing", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["apiPath"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=private-endpoint-apis-missing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-endpoint-apis-missing.d.ts","sourceRoot":"","sources":["../../../src/rules/private-endpoint-apis-missing.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,8BAA8B;;yBAyDzC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createRule, fileRef, paramMessage, } from "@typespec/compiler";
|
|
2
|
+
import { getArmResourceOperationData } from "../operations.js";
|
|
3
|
+
import { getResourceOperation } from "../resource.js";
|
|
4
|
+
const privateEndpointConnectionPathRegExp = /^(.*)\/privateEndpointConnections\/\{[^/]+\}$/i;
|
|
5
|
+
const privateEndpointConnectionsPathRegExp = /^(.*)\/privateEndpointConnections$/i;
|
|
6
|
+
const privateLinkResourcesPathRegExp = /^(.*)\/privateLinkResources$/i;
|
|
7
|
+
export const privateEndpointApisMissingRule = createRule({
|
|
8
|
+
name: "private-endpoint-apis-missing",
|
|
9
|
+
docs: fileRef.fromPackageRoot("src/rules/private-endpoint-apis-missing.md"),
|
|
10
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/private-endpoint-apis-missing",
|
|
11
|
+
description: "Services that expose private endpoint APIs must implement the private endpoint connection collection, point, and private link resource collection APIs together.",
|
|
12
|
+
severity: "warning",
|
|
13
|
+
messages: {
|
|
14
|
+
default: paramMessage `The private endpoint API: ${"apiPath"} is missing.`,
|
|
15
|
+
},
|
|
16
|
+
create(context) {
|
|
17
|
+
const supportedResources = new Map();
|
|
18
|
+
return {
|
|
19
|
+
operation(operation) {
|
|
20
|
+
if (getArmResourceOperationData(context.program, operation) === undefined) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const resourceOperation = getResourceOperation(context.program, operation);
|
|
24
|
+
if (resourceOperation !== undefined) {
|
|
25
|
+
collectPath(supportedResources, resourceOperation);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
exit() {
|
|
29
|
+
for (const [basePath, apiSet] of supportedResources.entries()) {
|
|
30
|
+
const target = getDiagnosticTarget(apiSet);
|
|
31
|
+
if (!apiSet.privateEndpointConnectionPath) {
|
|
32
|
+
context.reportDiagnostic({
|
|
33
|
+
target,
|
|
34
|
+
format: {
|
|
35
|
+
apiPath: `${basePath}/privateEndpointConnections/{privateEndpointConnectionName}`,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (!apiSet.privateEndpointConnectionsPath) {
|
|
40
|
+
context.reportDiagnostic({
|
|
41
|
+
target,
|
|
42
|
+
format: {
|
|
43
|
+
apiPath: `${basePath}/privateEndpointConnections`,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!apiSet.privateLinkResourcesPath) {
|
|
48
|
+
context.reportDiagnostic({
|
|
49
|
+
target,
|
|
50
|
+
format: {
|
|
51
|
+
apiPath: `${basePath}/privateLinkResources`,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
function collectPath(supportedResources, operation) {
|
|
61
|
+
const target = operation.operation.interface ?? operation.operation;
|
|
62
|
+
const pointPath = operation.path.match(privateEndpointConnectionPathRegExp);
|
|
63
|
+
if (pointPath !== null) {
|
|
64
|
+
getOrCreateApiSet(supportedResources, pointPath[1]).privateEndpointConnectionPath ??= target;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const listPath = operation.path.match(privateEndpointConnectionsPathRegExp);
|
|
68
|
+
if (listPath !== null) {
|
|
69
|
+
getOrCreateApiSet(supportedResources, listPath[1]).privateEndpointConnectionsPath ??= target;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const privateLinkPath = operation.path.match(privateLinkResourcesPathRegExp);
|
|
73
|
+
if (privateLinkPath !== null) {
|
|
74
|
+
getOrCreateApiSet(supportedResources, privateLinkPath[1]).privateLinkResourcesPath ??= target;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function getOrCreateApiSet(supportedResources, key) {
|
|
78
|
+
let apiSet = supportedResources.get(key);
|
|
79
|
+
if (apiSet === undefined) {
|
|
80
|
+
apiSet = {};
|
|
81
|
+
supportedResources.set(key, apiSet);
|
|
82
|
+
}
|
|
83
|
+
return apiSet;
|
|
84
|
+
}
|
|
85
|
+
function getDiagnosticTarget(apiSet) {
|
|
86
|
+
return (apiSet.privateEndpointConnectionPath ??
|
|
87
|
+
apiSet.privateEndpointConnectionsPath ??
|
|
88
|
+
apiSet.privateLinkResourcesPath);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=private-endpoint-apis-missing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-endpoint-apis-missing.js","sourceRoot":"","sources":["../../../src/rules/private-endpoint-apis-missing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAA6B,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,mCAAmC,GAAG,gDAAgD,CAAC;AAC7F,MAAM,oCAAoC,GAAG,qCAAqC,CAAC;AACnF,MAAM,8BAA8B,GAAG,+BAA+B,CAAC;AAEvE,MAAM,CAAC,MAAM,8BAA8B,GAAG,UAAU,CAAC;IACvD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,4CAA4C,CAAC;IAC3E,GAAG,EAAE,kHAAkH;IACvH,WAAW,EACT,kKAAkK;IACpK,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,6BAA6B,SAAS,cAAc;KAC1E;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAiC,CAAC;QAEpE,OAAO;YACL,SAAS,CAAC,SAAS;gBACjB,IAAI,2BAA2B,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;oBAC1E,OAAO;gBACT,CAAC;gBAED,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC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iB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,6BAA6B,KAAK,MAAM,CAAC;QAC7F,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC5E,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,iBAAiB,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,8BAA8B,KAAK,MAAM,CAAC;QAC7F,OAAO;IACT,CAAC;IAED,MAAM,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,iBAAiB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,KAAK,MAAM,CAAC;IAChG,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,kBAAsD,EACtD,GAAW;IAEX,IAAI,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG,EAAE,CAAC;QACZ,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAA6B;IACxD,OAAO,CACL,MAAM,CAAC,6BAA6B;QACpC,MAAM,CAAC,8BAA8B;QACrC,MAAM,CAAC,wBAAyB,CACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const resourceMissingReadRule: import("@typespec/compiler").LinterRuleDefinition<"resource-missing-read", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=resource-missing-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-missing-read.d.ts","sourceRoot":"","sources":["../../../src/rules/resource-missing-read.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,uBAAuB;;yBA6BlC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createRule, fileRef, getDiscriminator, paramMessage, } from "@typespec/compiler";
|
|
2
|
+
import { getArmResources } from "../resource.js";
|
|
3
|
+
import { getInterface } from "./utils.js";
|
|
4
|
+
export const resourceMissingReadRule = createRule({
|
|
5
|
+
name: "resource-missing-read",
|
|
6
|
+
description: "ARM resources with create or update operations must define a read operation.",
|
|
7
|
+
docs: fileRef.fromPackageRoot("src/rules/resource-missing-read.md"),
|
|
8
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-missing-read",
|
|
9
|
+
severity: "warning",
|
|
10
|
+
messages: {
|
|
11
|
+
default: paramMessage `Resource '${"name"}' must have a get/read operation.`,
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
root: (program) => {
|
|
16
|
+
for (const resource of getArmResources(program)) {
|
|
17
|
+
if (!requiresRead(resource) ||
|
|
18
|
+
resource.operations.lifecycle.read !== undefined ||
|
|
19
|
+
hasDiscriminatorAncestor(program, resource.typespecType)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
context.reportDiagnostic({
|
|
23
|
+
target: getDiagnosticTarget(resource),
|
|
24
|
+
format: { name: resource.name },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
function requiresRead(resource) {
|
|
32
|
+
return (resource.operations.lifecycle.createOrUpdate !== undefined ||
|
|
33
|
+
resource.operations.lifecycle.update !== undefined);
|
|
34
|
+
}
|
|
35
|
+
function hasDiscriminatorAncestor(program, model) {
|
|
36
|
+
for (let current = model.baseModel; current !== undefined; current = current.baseModel) {
|
|
37
|
+
if (getDiscriminator(program, current) !== undefined) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function getDiagnosticTarget(resource) {
|
|
44
|
+
return (resource.operations.lifecycle.createOrUpdate?.operation.interface ??
|
|
45
|
+
resource.operations.lifecycle.update?.operation.interface ??
|
|
46
|
+
getInterface(resource) ??
|
|
47
|
+
getOperationInterface(Object.values(resource.operations.lists)) ??
|
|
48
|
+
getOperationInterface(Object.values(resource.operations.actions)) ??
|
|
49
|
+
resource.typespecType);
|
|
50
|
+
}
|
|
51
|
+
function getOperationInterface(operations) {
|
|
52
|
+
return operations.find((operation) => operation?.operation.interface !== undefined)?.operation
|
|
53
|
+
.interface;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=resource-missing-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-missing-read.js","sourceRoot":"","sources":["../../../src/rules/resource-missing-read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,YAAY,GAIb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAA2B,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;IAChD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,8EAA8E;IAC3F,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,oCAAoC,CAAC;IACnE,GAAG,EAAE,0GAA0G;IAC/G,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,aAAa,MAAM,mCAAmC;KAC5E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,CAAC,O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Q,CAAC;QACtB,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/D,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjE,QAAQ,CAAC,YAAY,CACtB,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAC5B,UAAmD;IAEnD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,EAAE,SAAS;SAC3F,SAAS,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const useResourcePathForPutRule: import("@typespec/compiler").LinterRuleDefinition<"use-resource-path-for-put", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["path"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=use-resource-path-for-put.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resource-path-for-put.d.ts","sourceRoot":"","sources":["../../../src/rules/use-resource-path-for-put.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,yBAAyB;;yBAmCpC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRule, fileRef, getLocationContext, isTemplateInstance, paramMessage, } from "@typespec/compiler";
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
|
+
import { isTemplatedInterfaceOperation } from "./utils.js";
|
|
4
|
+
const evenSegmentedArmPutPathPattern = /.*\/providers\/\w+\.\w+(\/\w+\/(default|\{\w+\}))+$/;
|
|
5
|
+
export const useResourcePathForPutRule = createRule({
|
|
6
|
+
name: "use-resource-path-for-put",
|
|
7
|
+
description: "ARM PUT paths must end in resource type and resource name pairs.",
|
|
8
|
+
severity: "warning",
|
|
9
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/use-resource-path-for-put",
|
|
10
|
+
docs: fileRef.fromPackageRoot("src/rules/use-resource-path-for-put.md"),
|
|
11
|
+
messages: {
|
|
12
|
+
default: paramMessage `ARM PUT path '${"path"}' must end in repeated /{resourceType}/{resourceName} or /{resourceType}/default pairs after the provider namespace.`,
|
|
13
|
+
},
|
|
14
|
+
create(context) {
|
|
15
|
+
return {
|
|
16
|
+
operation: (operation) => {
|
|
17
|
+
if (isTemplateInstance(operation) ||
|
|
18
|
+
isTemplatedInterfaceOperation(operation) ||
|
|
19
|
+
getLocationContext(context.program, operation).type !== "project") {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const [httpOperation] = getHttpOperation(context.program, operation);
|
|
23
|
+
if (httpOperation.verb !== "put" ||
|
|
24
|
+
evenSegmentedArmPutPathPattern.test(httpOperation.path)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
context.reportDiagnostic({
|
|
28
|
+
target: operation,
|
|
29
|
+
format: { path: httpOperation.path },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=use-resource-path-for-put.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resource-path-for-put.js","sourceRoot":"","sources":["../../../src/rules/use-resource-path-for-put.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,8BAA8B,GAAG,qDAAqD,CAAC;AAE7F,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAClD,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,kEAAkE;IAC/E,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,8GAA8G;IACnH,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,wCAAwC,CAAC;IACvE,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,iBAAiB,MAAM,sHAAsH;KACnK;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IACE,kBAAkB,CAAC,SAAS,CAAC;oBAC7B,6BAA6B,CAAC,SAAS,CAAC;oBACxC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,IAAI,KAAK,SAAS,EACjE,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,MAAM,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBACrE,IACE,aAAa,CAAC,IAAI,KAAK,KAAK;oBAC5B,8BAA8B,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EACvD,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,gBAAgB,CAAC;oBACvB,MAAM,EAAE,SAAS;oBACjB,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE;iBACrC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const useScopeForExtensionRoutingRule: import("@typespec/compiler").LinterRuleDefinition<"use-scope-for-extension-routing", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["path"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=use-scope-for-extension-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-scope-for-extension-routing.d.ts","sourceRoot":"","sources":["../../../src/rules/use-scope-for-extension-routing.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,+BAA+B;;yBAiC1C,CAAC"}
|