@azure-tools/typespec-azure-resource-manager 0.27.0
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/LICENSE +21 -0
- package/README.md +346 -0
- package/dist/src/common-types.d.ts +8 -0
- package/dist/src/common-types.d.ts.map +1 -0
- package/dist/src/common-types.js +14 -0
- package/dist/src/common-types.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal.d.ts +44 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +142 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/lib.d.ts +615 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +250 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/linter.d.ts +3 -0
- package/dist/src/linter.d.ts.map +1 -0
- package/dist/src/linter.js +42 -0
- package/dist/src/linter.js.map +1 -0
- package/dist/src/namespace.d.ts +16 -0
- package/dist/src/namespace.d.ts.map +1 -0
- package/dist/src/namespace.js +106 -0
- package/dist/src/namespace.js.map +1 -0
- package/dist/src/operations.d.ts +36 -0
- package/dist/src/operations.d.ts.map +1 -0
- package/dist/src/operations.js +186 -0
- package/dist/src/operations.js.map +1 -0
- package/dist/src/resource.d.ts +81 -0
- package/dist/src/resource.d.ts.map +1 -0
- package/dist/src/resource.js +358 -0
- package/dist/src/resource.js.map +1 -0
- package/dist/src/rules/arm-resource-action-no-segment.d.ts +2 -0
- package/dist/src/rules/arm-resource-action-no-segment.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-action-no-segment.js +31 -0
- package/dist/src/rules/arm-resource-action-no-segment.js.map +1 -0
- package/dist/src/rules/arm-resource-invalid-chars.d.ts +2 -0
- package/dist/src/rules/arm-resource-invalid-chars.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-invalid-chars.js +61 -0
- package/dist/src/rules/arm-resource-invalid-chars.js.map +1 -0
- package/dist/src/rules/arm-resource-invalid-version-format.d.ts +2 -0
- package/dist/src/rules/arm-resource-invalid-version-format.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-invalid-version-format.js +48 -0
- package/dist/src/rules/arm-resource-invalid-version-format.js.map +1 -0
- package/dist/src/rules/arm-resource-operations.d.ts +2 -0
- package/dist/src/rules/arm-resource-operations.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-operations.js +70 -0
- package/dist/src/rules/arm-resource-operations.js.map +1 -0
- package/dist/src/rules/arm-resource-properties.d.ts +2 -0
- package/dist/src/rules/arm-resource-properties.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-properties.js +55 -0
- package/dist/src/rules/arm-resource-properties.js.map +1 -0
- package/dist/src/rules/arm-resource-provisioning-state-rule.d.ts +2 -0
- package/dist/src/rules/arm-resource-provisioning-state-rule.d.ts.map +1 -0
- package/dist/src/rules/arm-resource-provisioning-state-rule.js +62 -0
- package/dist/src/rules/arm-resource-provisioning-state-rule.js.map +1 -0
- package/dist/src/rules/beyond-nesting-levels.d.ts +5 -0
- package/dist/src/rules/beyond-nesting-levels.d.ts.map +1 -0
- package/dist/src/rules/beyond-nesting-levels.js +37 -0
- package/dist/src/rules/beyond-nesting-levels.js.map +1 -0
- package/dist/src/rules/core-operations.d.ts +2 -0
- package/dist/src/rules/core-operations.d.ts.map +1 -0
- package/dist/src/rules/core-operations.js +181 -0
- package/dist/src/rules/core-operations.js.map +1 -0
- package/dist/src/rules/delete-operation.d.ts +5 -0
- package/dist/src/rules/delete-operation.d.ts.map +1 -0
- package/dist/src/rules/delete-operation.js +28 -0
- package/dist/src/rules/delete-operation.js.map +1 -0
- package/dist/src/rules/envelope-properties.d.ts +5 -0
- package/dist/src/rules/envelope-properties.d.ts.map +1 -0
- package/dist/src/rules/envelope-properties.js +62 -0
- package/dist/src/rules/envelope-properties.js.map +1 -0
- package/dist/src/rules/list-operation.d.ts +5 -0
- package/dist/src/rules/list-operation.d.ts.map +1 -0
- package/dist/src/rules/list-operation.js +35 -0
- package/dist/src/rules/list-operation.js.map +1 -0
- package/dist/src/rules/no-response-body.d.ts +5 -0
- package/dist/src/rules/no-response-body.d.ts.map +1 -0
- package/dist/src/rules/no-response-body.js +27 -0
- package/dist/src/rules/no-response-body.js.map +1 -0
- package/dist/src/rules/operations-interface-missing.d.ts +5 -0
- package/dist/src/rules/operations-interface-missing.d.ts.map +1 -0
- package/dist/src/rules/operations-interface-missing.js +37 -0
- package/dist/src/rules/operations-interface-missing.js.map +1 -0
- package/dist/src/rules/resource-name.d.ts +5 -0
- package/dist/src/rules/resource-name.d.ts.map +1 -0
- package/dist/src/rules/resource-name.js +47 -0
- package/dist/src/rules/resource-name.js.map +1 -0
- package/dist/src/rules/retry-after.d.ts +5 -0
- package/dist/src/rules/retry-after.d.ts.map +1 -0
- package/dist/src/rules/retry-after.js +31 -0
- package/dist/src/rules/retry-after.js.map +1 -0
- package/dist/src/rules/unsupported-types.d.ts +5 -0
- package/dist/src/rules/unsupported-types.d.ts.map +1 -0
- package/dist/src/rules/unsupported-types.js +39 -0
- package/dist/src/rules/unsupported-types.js.map +1 -0
- package/dist/src/rules/utils.d.ts +18 -0
- package/dist/src/rules/utils.d.ts.map +1 -0
- package/dist/src/rules/utils.js +77 -0
- package/dist/src/rules/utils.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +24 -0
- package/dist/src/testing/index.js.map +1 -0
- package/lib/arm.foundations.tsp +465 -0
- package/lib/arm.tsp +31 -0
- package/lib/decorators.tsp +87 -0
- package/lib/interfaces.tsp +287 -0
- package/lib/models.tsp +203 -0
- package/lib/operations.tsp +260 -0
- package/lib/parameters.tsp +126 -0
- package/lib/responses.tsp +47 -0
- package/package.json +85 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-action-no-segment.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-action-no-segment.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,mCAmBzC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isInternalTypeSpec } from "./utils.js";
|
|
4
|
+
export const armResourceActionNoSegmentRule = createRule({
|
|
5
|
+
name: "arm-resource-action-no-segment",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
operation: (operation) => {
|
|
9
|
+
var _a;
|
|
10
|
+
if (isInternalTypeSpec(program, operation)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const armResourceActionDec = getDecorator(operation, "armResourceAction");
|
|
14
|
+
const segmentDec = getDecorator(operation, "segment");
|
|
15
|
+
if (armResourceActionDec && segmentDec) {
|
|
16
|
+
reportDiagnostic(program, {
|
|
17
|
+
code: "arm-resource-action-no-segment",
|
|
18
|
+
target: (_a = segmentDec.node) !== null && _a !== void 0 ? _a : operation,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
function getDecorator(type, name) {
|
|
26
|
+
const decorator = type.decorators.filter((d) => `$${name}` === d.decorator.name);
|
|
27
|
+
if (decorator && decorator.length === 1)
|
|
28
|
+
return decorator[0];
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=arm-resource-action-no-segment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-action-no-segment.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-action-no-segment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,8BAA8B,GAAG,UAAU,CAAC;IACvD,IAAI,EAAE,gCAAgC;IACtC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAoB,EAAE,EAAE;;gBAClC,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC1C,OAAO;iBACR;gBACD,MAAM,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;gBAC1E,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACtD,IAAI,oBAAoB,IAAI,UAAU,EAAE;oBACtC,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,gCAAgC;wBACtC,MAAM,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,SAAS;qBACrC,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,YAAY,CAAC,IAAe,EAAE,IAAY;IACjD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjF,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-invalid-chars.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-invalid-chars.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,2BAA2B,mCAkCtC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getKeyName, } from "@typespec/compiler";
|
|
2
|
+
import { createRule } from "@typespec/lint";
|
|
3
|
+
import { getSegment } from "@typespec/rest";
|
|
4
|
+
import { reportDiagnostic } from "../lib.js";
|
|
5
|
+
import { isInternalTypeSpec, isResource } from "./utils.js";
|
|
6
|
+
export const armResourceInvalidCharsRule = createRule({
|
|
7
|
+
name: "arm-resource-invalid-chars",
|
|
8
|
+
create({ program }) {
|
|
9
|
+
return {
|
|
10
|
+
model: (model) => {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
if (!isInternalTypeSpec(program, model) &&
|
|
13
|
+
isResource(model) &&
|
|
14
|
+
model.properties.has("name")) {
|
|
15
|
+
const nameProperty = model.properties.get("name");
|
|
16
|
+
const separator = "/";
|
|
17
|
+
const segment = getSegment(program, nameProperty);
|
|
18
|
+
const key = getKeyName(program, nameProperty);
|
|
19
|
+
if (segment !== undefined && !isValidPathSegment(segment, separator)) {
|
|
20
|
+
reportDiagnostic(program, {
|
|
21
|
+
code: "arm-resource-path-segment-invalid-chars",
|
|
22
|
+
format: { segment: segment },
|
|
23
|
+
target: (_b = (_a = getDecoratorParam(nameProperty, "segment")) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : nameProperty,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (key !== undefined && !isValidKey(key)) {
|
|
27
|
+
reportDiagnostic(program, {
|
|
28
|
+
code: "arm-resource-key-invalid-chars",
|
|
29
|
+
format: { key: key },
|
|
30
|
+
target: (_d = (_c = getDecoratorParam(nameProperty, "key")) === null || _c === void 0 ? void 0 : _c.node) !== null && _d !== void 0 ? _d : nameProperty,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
function isValidPathSegment(path, separator) {
|
|
39
|
+
if (path.startsWith(separator))
|
|
40
|
+
path = path.replace(separator, "");
|
|
41
|
+
return isValidKey(path);
|
|
42
|
+
}
|
|
43
|
+
function isValidKey(key) {
|
|
44
|
+
const match = key.match(/^[a-z][A-z0-9-]+$/);
|
|
45
|
+
return match !== undefined && match !== null && match.length === 1;
|
|
46
|
+
}
|
|
47
|
+
function getDecorator(type, name) {
|
|
48
|
+
const decorator = type.decorators.filter((d) => `$${"name"}` === d.decorator.name);
|
|
49
|
+
if (decorator && decorator.length === 1)
|
|
50
|
+
return decorator[0];
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
function getDecoratorParam(type, name) {
|
|
54
|
+
const call = getDecorator(type, name);
|
|
55
|
+
if (call === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (call.args && call.args.length > 2)
|
|
58
|
+
return call.args[2];
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=arm-resource-invalid-chars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-invalid-chars.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-invalid-chars.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,GAGX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC;IACpD,IAAI,EAAE,4BAA4B;IAClC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAY,EAAE,EAAE;;gBACtB,IACE,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC;oBACnC,UAAU,CAAC,KAAK,CAAC;oBACjB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAC5B;oBACA,MAAM,YAAY,GA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CAAC;IAC7C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,YAAY,CAAC,IAA2B,EAAE,IAAY;IAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnF,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CACxB,IAA2B,EAC3B,IAAY;IAEZ,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-invalid-version-format.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-invalid-version-format.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mCAAmC,mCA8C9C,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getVersion } from "@typespec/versioning";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { isInternalTypeSpec } from "./utils.js";
|
|
5
|
+
export const armResourceInvalidVersionFormatRule = createRule({
|
|
6
|
+
name: "arm-resource-invalid-version-format",
|
|
7
|
+
create({ program }) {
|
|
8
|
+
return {
|
|
9
|
+
namespace: (namespace) => {
|
|
10
|
+
var _a;
|
|
11
|
+
// validate format of versions
|
|
12
|
+
if (isInternalTypeSpec(program, namespace)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const map = getVersion(program, namespace);
|
|
16
|
+
if (map !== undefined) {
|
|
17
|
+
for (const version of map.getVersions()) {
|
|
18
|
+
const versionValue = (_a = version.enumMember.value) !== null && _a !== void 0 ? _a : version.enumMember.name;
|
|
19
|
+
switch (typeof versionValue) {
|
|
20
|
+
case "number":
|
|
21
|
+
case "undefined":
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "arm-resource-invalid-version-format",
|
|
24
|
+
messageId: "invalidType",
|
|
25
|
+
format: { version: versionValue },
|
|
26
|
+
target: version.enumMember,
|
|
27
|
+
});
|
|
28
|
+
break;
|
|
29
|
+
case "string":
|
|
30
|
+
const versionMatch = versionValue.match(/^[\d]{4}-[\d]{2}-[\d]{2}(-[\w]+(\.\d+)?)?$/);
|
|
31
|
+
if (versionMatch === undefined ||
|
|
32
|
+
versionMatch === null ||
|
|
33
|
+
versionMatch.length < 1) {
|
|
34
|
+
reportDiagnostic(program, {
|
|
35
|
+
code: "arm-resource-invalid-version-format",
|
|
36
|
+
format: { version: versionValue },
|
|
37
|
+
target: version.enumMember,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=arm-resource-invalid-version-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-invalid-version-format.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-invalid-version-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,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AAE;wCACjC,MAAM,EAAE,OAAO,CAAC,UAAU;qCAC3B,CAAC,CAAC;iCACJ;gCACD,MAAM;yBACT;qBACF;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-operations.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-operations.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,yBAAyB,mCAwBpC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getEffectiveModelType, isErrorType } from "@typespec/compiler";
|
|
2
|
+
import { createRule } from "@typespec/lint";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { resolveResourceOperations } from "../operations.js";
|
|
5
|
+
import { getArmResource } from "../resource.js";
|
|
6
|
+
import { isInternalTypeSpec } from "./utils.js";
|
|
7
|
+
export const armResourceOperationsRule = createRule({
|
|
8
|
+
name: "arm-resource-operations",
|
|
9
|
+
create({ program }) {
|
|
10
|
+
return {
|
|
11
|
+
model: (model) => {
|
|
12
|
+
if (!isInternalTypeSpec(program, model)) {
|
|
13
|
+
const armResource = getArmResource(program, model);
|
|
14
|
+
if (armResource) {
|
|
15
|
+
const resourceOperations = resolveResourceOperations(program, model);
|
|
16
|
+
const kinds = ["read", "createOrUpdate", "update"];
|
|
17
|
+
kinds
|
|
18
|
+
.map((k) => resourceOperations.lifecycle[k])
|
|
19
|
+
.forEach((op) => op && checkArmResourceOperationReturnType(program, model, op.operation));
|
|
20
|
+
const lists = resourceOperations.lists;
|
|
21
|
+
for (const key in lists) {
|
|
22
|
+
checkArmResourceOperationReturnType(program, model, lists[key].operation);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
function checkArmResourceOperationReturnType(program, model, operation) {
|
|
31
|
+
if (!isInternalTypeSpec(program, operation)) {
|
|
32
|
+
const returnType = operation.returnType;
|
|
33
|
+
if (returnType.kind === "Model") {
|
|
34
|
+
checkIfArmModel(program, operation, model, returnType);
|
|
35
|
+
}
|
|
36
|
+
else if (returnType.kind === "Union") {
|
|
37
|
+
for (const variant of returnType.variants.values()) {
|
|
38
|
+
if (!isErrorType(variant.type) && variant.type.kind === "Model") {
|
|
39
|
+
const modelCandidate = getEffectiveModelType(program, variant.type);
|
|
40
|
+
checkIfArmModel(program, operation, model, modelCandidate);
|
|
41
|
+
if (modelCandidate.templateArguments !== undefined) {
|
|
42
|
+
// ArmResponse<FooResource>
|
|
43
|
+
for (const arg of modelCandidate.templateArguments) {
|
|
44
|
+
if (arg.kind === "Model") {
|
|
45
|
+
checkIfArmModel(program, operation, model, arg);
|
|
46
|
+
if (arg.templateArguments !== undefined) {
|
|
47
|
+
// ArmResponse<ResourceListResult<FooResource>>
|
|
48
|
+
for (const type of arg.templateArguments) {
|
|
49
|
+
if (type.kind === "Model") {
|
|
50
|
+
checkIfArmModel(program, operation, model, type);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function checkIfArmModel(program, operation, model, modelCandidate) {
|
|
63
|
+
if (getArmResource(program, modelCandidate) && modelCandidate !== model) {
|
|
64
|
+
reportDiagnostic(program, {
|
|
65
|
+
code: "arm-resource-operation-response",
|
|
66
|
+
target: operation,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=arm-resource-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-operations.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAA6B,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F;yBACF;qBACF;iBACF;aACF;SACF;KACF;AACH,CAAC;AAED,SAAS,eAAe,CACtB,OAAgB,EAChB,SAAoB,EACpB,KAAY,EACZ,cAAqB;IAErB,IAAI,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,cAAc,KAAK,KAAK,EAAE;QACvE,gBAAgB,CAAC,OAAO,EAAE;YACxB,IAAI,EAAE,iCAAiC;YACvC,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;KACJ;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-properties.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-properties.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,mCAkDhC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getProperty } from "@typespec/compiler";
|
|
2
|
+
import { createRule } from "@typespec/lint";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { getArmResource } from "../resource.js";
|
|
5
|
+
import { getNamespaceName, getSourceModel } from "./utils.js";
|
|
6
|
+
export const armResourceProperties = createRule({
|
|
7
|
+
name: "arm-resource-properties",
|
|
8
|
+
create({ program }) {
|
|
9
|
+
return {
|
|
10
|
+
model: (model) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const resourceModel = getArmResource(program, model);
|
|
13
|
+
if (resourceModel !== undefined) {
|
|
14
|
+
const resourceProperties = (_a = getProperty(model, "properties")) === null || _a === void 0 ? void 0 : _a.type;
|
|
15
|
+
for (const property of getProperties(model)) {
|
|
16
|
+
if (property.name !== "name") {
|
|
17
|
+
const sourceModel = getSourceModel(property);
|
|
18
|
+
const sourceNamespace = getNamespaceName(program, sourceModel);
|
|
19
|
+
if (sourceModel === undefined ||
|
|
20
|
+
sourceNamespace === undefined ||
|
|
21
|
+
!sourceNamespace.startsWith("Azure.ResourceManager")) {
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "arm-resource-invalid-envelope-property",
|
|
24
|
+
format: { propertyName: property.name },
|
|
25
|
+
target: property,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (resourceProperties !== undefined && resourceProperties.kind === "Model") {
|
|
30
|
+
const targetProperty = getProperty(resourceProperties, property.name);
|
|
31
|
+
if (targetProperty !== undefined) {
|
|
32
|
+
reportDiagnostic(program, {
|
|
33
|
+
code: "arm-resource-duplicate-property",
|
|
34
|
+
format: { propertyName: property.name },
|
|
35
|
+
target: targetProperty,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
function getProperties(model) {
|
|
44
|
+
const result = [];
|
|
45
|
+
let current = model;
|
|
46
|
+
while (current !== undefined) {
|
|
47
|
+
if (current.properties.size > 0)
|
|
48
|
+
result.push(...current.properties.values());
|
|
49
|
+
current = current.baseModel;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=arm-resource-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-properties.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC9C,IAAI,EAAE,yBAAyB;IAC/B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;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M,MAAM,GAAoB,EAAE,CAAC;YACnC,IAAI,OAAO,GAAsB,KAAK,CAAC;YACvC,OAAO,OAAO,KAAK,SAAS,EAAE;gBAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;oBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC7E,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-provisioning-state-rule.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-provisioning-state-rule.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gCAAgC,mCAsD3C,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getProperty } from "@typespec/compiler";
|
|
2
|
+
import { createRule } from "@typespec/lint";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { getArmResource } from "../resource.js";
|
|
5
|
+
import { getSourceProperty } from "./utils.js";
|
|
6
|
+
export const armResourceProvisioningStateRule = createRule({
|
|
7
|
+
name: "arm-resource-provisioning-state",
|
|
8
|
+
create({ program }) {
|
|
9
|
+
return {
|
|
10
|
+
model: (model) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const resourceModel = getArmResource(program, model);
|
|
13
|
+
if (resourceModel === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const resourceProperties = (_a = getProperty(model, "properties")) === null || _a === void 0 ? void 0 : _a.type;
|
|
17
|
+
if (resourceProperties === undefined || resourceProperties.kind !== "Model") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let provisioning = getProperty(resourceProperties, "provisioningState");
|
|
21
|
+
if (provisioning === undefined) {
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "arm-resource-provisioning-state",
|
|
24
|
+
target: resourceProperties,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
provisioning = getSourceProperty(provisioning);
|
|
29
|
+
const provisioningType = provisioning.type;
|
|
30
|
+
switch (provisioningType.kind) {
|
|
31
|
+
case "Enum":
|
|
32
|
+
const enumType = provisioningType;
|
|
33
|
+
const missing = [];
|
|
34
|
+
if (!enumType.members.get("Succeeded")) {
|
|
35
|
+
missing.push("Succeeded");
|
|
36
|
+
}
|
|
37
|
+
if (!enumType.members.get("Canceled")) {
|
|
38
|
+
missing.push("Canceled");
|
|
39
|
+
}
|
|
40
|
+
if (!enumType.members.get("Failed")) {
|
|
41
|
+
missing.push("Failed");
|
|
42
|
+
}
|
|
43
|
+
if (missing.length > 0) {
|
|
44
|
+
reportDiagnostic(program, {
|
|
45
|
+
code: "arm-resource-provisioning-state-values",
|
|
46
|
+
format: { missingValues: missing.join(", ") },
|
|
47
|
+
target: enumType,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
reportDiagnostic(program, {
|
|
53
|
+
code: "arm-resource-provisioning-state",
|
|
54
|
+
target: provisioning,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=arm-resource-provisioning-state-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arm-resource-provisioning-state-rule.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-provisioning-state-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAS,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,M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E;gCACrC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;6BAC1B;4BACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gCACnC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;6BACxB;4BACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gCACtB,gBAAgB,CAAC,OAAO,EAAE;oCACxB,IAAI,EAAE,wCAAwC;oCAC9C,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oCAC7C,MAAM,EAAE,QAAQ;iCACjB,CAAC,CAAC;6BACJ;4BACD,MAAM;wBACR;4BACE,gBAAgB,CAAC,OAAO,EAAE;gCACxB,IAAI,EAAE,iCAAiC;gCACvC,MAAM,EAAE,YAAY;6BACrB,CAAC,CAAC;qBACN;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beyond-nesting-levels.d.ts","sourceRoot":"","sources":["../../../src/rules/beyond-nesting-levels.ts"],"names":[],"mappings":"AAMA;;GAEG;AAEH,eAAO,MAAM,iBAAiB,mCA2B5B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getParentResource } from "@typespec/rest";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
import { isTrackedResource } from "./utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* verify if resource nesting beyond 3 levels
|
|
7
|
+
*/
|
|
8
|
+
export const beyondNestingRule = createRule({
|
|
9
|
+
name: "beyond-nesting",
|
|
10
|
+
create({ program }) {
|
|
11
|
+
return {
|
|
12
|
+
model: (model) => {
|
|
13
|
+
let levels = 1;
|
|
14
|
+
if (!isTrackedResource(model)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let parent = model;
|
|
18
|
+
while (levels < 4) {
|
|
19
|
+
parent = getParentResource(program, parent);
|
|
20
|
+
if (parent) {
|
|
21
|
+
levels++;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (levels === 4) {
|
|
28
|
+
reportDiagnostic(program, {
|
|
29
|
+
code: "beyond-nesting-levels",
|
|
30
|
+
target: model,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=beyond-nesting-levels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beyond-nesting-levels.js","sourceRoot":"","sources":["../../../src/rules/beyond-nesting-levels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,gBAAgB;IACtB,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAY,EAAE,EAAE;gBACtB,IAAI,MAAM,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE;oBAC7B,OAAO;iBACR;gBACD,IAAI,MAAM,GAAsB,KAAK,CAAC;gBACtC,OAAO,MAAM,GAAG,CAAC,EAAE;oBACjB,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC5C,IAAI,MAAM,EAAE;wBACV,MAAM,EAAE,CAAC;qBACV;yBAAM;wBACL,MAAM;qBACP;iBACF;gBACD,IAAI,MAAM,KAAK,CAAC,EAAE;oBAChB,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,uBAAuB;wBAC7B,MAAM,EAAE,KAAK;qBACd,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-operations.d.ts","sourceRoot":"","sources":["../../../src/rules/core-operations.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,kBAAkB,mCA2E7B,CAAC"}
|