@azure-tools/typespec-azure-resource-manager 0.46.0-dev.1 → 0.46.0-dev.2
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
CHANGED
|
@@ -30,7 +30,7 @@ Available ruleSets:
|
|
|
30
30
|
|
|
31
31
|
| Name | Description |
|
|
32
32
|
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
-
| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-record)
|
|
33
|
+
| [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-record) | Don't use Record types for ARM resources. |
|
|
34
34
|
| `@azure-tools/typespec-azure-resource-manager/arm-common-types-version` | Specify the ARM common-types version using @armCommonTypesVersion. |
|
|
35
35
|
| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/delete-operation-response-codes) | Ensure delete operations have the appropriate status codes. |
|
|
36
36
|
| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/put-operation-response-codes) | Ensure put operations have the appropriate status codes. |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arm-no-record.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-no-record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arm-no-record.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-no-record.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe;;;;EAsC1B,CAAC"}
|
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
import { createRule } from "@typespec/compiler";
|
|
2
|
-
import { getArmResources } from "../resource.js";
|
|
1
|
+
import { createRule, } from "@typespec/compiler";
|
|
3
2
|
export const armNoRecordRule = createRule({
|
|
4
3
|
name: "arm-no-record",
|
|
5
4
|
severity: "warning",
|
|
6
5
|
description: "Don't use Record types for ARM resources.",
|
|
7
|
-
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-record",
|
|
6
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-record",
|
|
8
7
|
messages: {
|
|
9
8
|
default: "Model properties or operation parameters should not be of type Record. ARM requires Resource provider teams to define types explicitly.",
|
|
10
9
|
extends: "Models should not extend type Record. ARM requires Resource provider teams to define types explicitly.",
|
|
11
10
|
is: "Models should not equate to type Record. ARM requires Resource provider teams to define types explicitly.",
|
|
12
11
|
},
|
|
13
12
|
create(context) {
|
|
13
|
+
function checkModel(model) {
|
|
14
|
+
if (model.baseModel !== undefined) {
|
|
15
|
+
checkNoRecord(model.baseModel, model, "extends");
|
|
16
|
+
}
|
|
17
|
+
else if (model.sourceModel !== undefined) {
|
|
18
|
+
checkNoRecord(model.sourceModel, model, "is");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function checkNoRecord(type, target, kind) {
|
|
22
|
+
if (type.kind === "Model" && type.name === "Record") {
|
|
23
|
+
context.reportDiagnostic({
|
|
24
|
+
code: "arm-no-record",
|
|
25
|
+
target: target,
|
|
26
|
+
messageId: kind || "default",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
code: "arm-no-record",
|
|
20
|
-
target: target,
|
|
21
|
-
messageId: kind || "default",
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
else if (model.baseModel !== undefined) {
|
|
25
|
-
checkModel(model.baseModel, model, "extends");
|
|
26
|
-
}
|
|
27
|
-
else if (model.sourceModel !== undefined) {
|
|
28
|
-
checkModel(model.sourceModel, model, "is");
|
|
29
|
-
}
|
|
30
|
-
if (model?.properties !== undefined) {
|
|
31
|
-
for (const prop of model.properties.values()) {
|
|
32
|
-
if (prop.type.kind === "Model") {
|
|
33
|
-
checkModel(prop.type, prop);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// ensure only ARM resources and models they touch are checked
|
|
39
|
-
const resources = getArmResources(context.program);
|
|
40
|
-
for (const resource of resources) {
|
|
41
|
-
checkModel(resource.typespecType, resource.typespecType);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
31
|
+
operation: (op) => checkNoRecord(op.returnType, op),
|
|
32
|
+
model: (type) => checkModel(type),
|
|
33
|
+
modelProperty: (prop) => checkNoRecord(prop.type, prop),
|
|
34
|
+
unionVariant: (variant) => checkNoRecord(variant.type, variant),
|
|
44
35
|
};
|
|
45
36
|
},
|
|
46
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arm-no-record.js","sourceRoot":"","sources":["../../../src/rules/arm-no-record.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"arm-no-record.js","sourceRoot":"","sources":["../../../src/rules/arm-no-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACxC,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,2CAA2C;IACxD,GAAG,EAAE,kGAAkG;IACvG,QAAQ,EAAE;QACR,OAAO,EACL,yIAAyI;QAC3I,OAAO,EACL,wGAAwG;QAC1G,EAAE,EAAE,2GAA2G;KAChH;IACD,MAAM,CAAC,OAAO;QACZ,SAAS,UAAU,CAAC,KAAY;YAC9B,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBAClC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC;iBAAM,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC3C,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,SAAS,aAAa,CAAC,IAAU,EAAE,MAAwB,EAAE,IAAuB;YAClF,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACpD,OAAO,CAAC,gBAAgB,CAAC;oBACvB,IAAI,EAAE,eAAe;oBACrB,MAAM,EAAE,MAAM;oBACd,SAAS,EAAE,IAAI,IAAI,SAAS;iBAC7B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC;YACnD,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YACjC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;YACvD,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SAChE,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-azure-resource-manager",
|
|
3
|
-
"version": "0.46.0-dev.
|
|
3
|
+
"version": "0.46.0-dev.2",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|