@azure-tools/typespec-azure-resource-manager 0.72.0-dev.2 → 0.72.0-dev.4
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 +2 -0
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +4 -0
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/no-query-in-point-op.d.ts +4 -0
- package/dist/src/rules/no-query-in-point-op.d.ts.map +1 -0
- package/dist/src/rules/no-query-in-point-op.js +50 -0
- package/dist/src/rules/no-query-in-point-op.js.map +1 -0
- package/dist/src/rules/use-application-json-content-type.d.ts +4 -0
- package/dist/src/rules/use-application-json-content-type.d.ts.map +1 -0
- package/dist/src/rules/use-application-json-content-type.js +59 -0
- package/dist/src/rules/use-application-json-content-type.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ Available ruleSets:
|
|
|
46
46
|
| [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-name-pattern) | The resource name parameter should be defined with a 'pattern' restriction. |
|
|
47
47
|
| [`@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation-response) | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. |
|
|
48
48
|
| [`@azure-tools/typespec-azure-resource-manager/use-api-version`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/use-api-version) | Validate ARM Resource operations include the api-version parameter referencing Azure.ResourceManager.CommonTypes.ApiVersionParameter. |
|
|
49
|
+
| [`@azure-tools/typespec-azure-resource-manager/use-application-json-content-type`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/use-application-json-content-type) | ARM operations must only use application/json content types in request and response bodies. |
|
|
49
50
|
| [`@azure-tools/typespec-azure-resource-manager/use-operation-decorator`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/use-operation-decorator) | Validate ARM Resource operations use the correct decorator for the HTTP verb. |
|
|
50
51
|
| [`@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-path-segment-invalid-chars) | Arm resource name must contain only alphanumeric characters. |
|
|
51
52
|
| [`@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-provisioning-state) | Check for properly configured provisioningState property. |
|
|
@@ -73,6 +74,7 @@ Available ruleSets:
|
|
|
73
74
|
| [`@azure-tools/typespec-azure-resource-manager/secret-prop`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/secret-prop) | RPC-v1-13: Check that property with names indicating sensitive information(e.g. contains auth, password, token, secret, etc.) are marked with @secret decorator. |
|
|
74
75
|
| [`@azure-tools/typespec-azure-resource-manager/no-empty-model`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-empty-model) | ARM Properties with type:object that don't reference a model definition are not allowed. ARM doesn't allow generic type definitions as this leads to bad customer experience. |
|
|
75
76
|
| [`@azure-tools/typespec-azure-resource-manager/no-reserved-resource-property`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-reserved-resource-property) | Reserved property names (for example 'billingData') must not be present in a resource's property bag. The property name is matched case-insensitively. |
|
|
77
|
+
| [`@azure-tools/typespec-azure-resource-manager/no-query-in-point-op`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-query-in-point-op) | Point operations must not declare query parameters beyond api-version. |
|
|
76
78
|
|
|
77
79
|
## Decorators
|
|
78
80
|
|
package/dist/src/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAmGA,eAAO,MAAM,OAAO,+CAElB,CAAC"}
|
package/dist/src/linter.js
CHANGED
|
@@ -30,6 +30,7 @@ import { missingXmsIdentifiersRule } from "./rules/missing-x-ms-identifiers.js";
|
|
|
30
30
|
import { noEmptyModel } from "./rules/no-empty-model.js";
|
|
31
31
|
import { noOverridePropsRule } from "./rules/no-override-props.js";
|
|
32
32
|
import { noQueryInCollectionRule } from "./rules/no-query-in-collection.js";
|
|
33
|
+
import { noQueryInPointOpRule } from "./rules/no-query-in-point-op.js";
|
|
33
34
|
import { noReservedResourcePropertyRule } from "./rules/no-reserved-resource-property.js";
|
|
34
35
|
import { deleteOperationMissingRule } from "./rules/no-resource-delete-operation.js";
|
|
35
36
|
import { noResponseBodyRule } from "./rules/no-response-body.js";
|
|
@@ -40,6 +41,7 @@ import { retryAfterRule } from "./rules/retry-after.js";
|
|
|
40
41
|
import { secretProprule } from "./rules/secret-prop.js";
|
|
41
42
|
import { unsupportedTypeRule } from "./rules/unsupported-type.js";
|
|
42
43
|
import { useApiVersionRule } from "./rules/use-api-version.js";
|
|
44
|
+
import { useApplicationJsonContentTypeRule } from "./rules/use-application-json-content-type.js";
|
|
43
45
|
import { useInterfaceRule } from "./rules/use-interface.js";
|
|
44
46
|
import { useOperationDecoratorRule } from "./rules/use-operation-decorator.js";
|
|
45
47
|
import { useRelationshipRequiredPropertiesRule } from "./rules/use-relationship-required-properties.js";
|
|
@@ -63,6 +65,7 @@ const rules = [
|
|
|
63
65
|
armResourceNamePatternRule,
|
|
64
66
|
armResourceOperationsRule,
|
|
65
67
|
useApiVersionRule,
|
|
68
|
+
useApplicationJsonContentTypeRule,
|
|
66
69
|
useOperationDecoratorRule,
|
|
67
70
|
armResourcePathInvalidCharsRule,
|
|
68
71
|
armResourceProvisioningStateRule,
|
|
@@ -90,6 +93,7 @@ const rules = [
|
|
|
90
93
|
secretProprule,
|
|
91
94
|
noEmptyModel,
|
|
92
95
|
noReservedResourcePropertyRule,
|
|
96
|
+
noQueryInPointOpRule,
|
|
93
97
|
];
|
|
94
98
|
export const $linter = defineLinter({
|
|
95
99
|
rules,
|
package/dist/src/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kCAAkC,EAAE,MAAM,gDAAgD,CAAC;AACpG,OAAO,EAAE,uCAAuC,EAAE,MAAM,qDAAqD,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,kCAAkC,EAAE,MAAM,4CAA4C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AAClG,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,2C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C;IAClC,6BAA6B;IAC7B,mCAAmC;IACnC,8BAA8B;IAC9B,0BAA0B;IAC1B,yBAAyB;IACzB,iBAAiB;IACjB,iCAAiC;IACjC,yBAAyB;IACzB,+BAA+B;IAC/B,gCAAgC;IAChC,sBAAsB;IACtB,sBAAsB;IACtB,gCAAgC;IAChC,6BAA6B;IAC7B,iBAAiB;IACjB,uBAAuB;IACvB,gBAAgB;IAChB,0BAA0B;IAC1B,uBAAuB;IACvB,cAAc;IACd,gCAAgC;IAChC,qCAAqC;IACrC,qBAAqB;IACrB,yBAAyB;IACzB,kBAAkB;IAClB,8BAA8B;IAC9B,4BAA4B;IAC5B,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,mBAAmB;IACnB,cAAc;IACd,YAAY;IACZ,8BAA8B;IAC9B,oBAAoB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;IAClC,KAAK;CACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const noQueryInPointOpRule: import("@typespec/compiler").LinterRuleDefinition<"no-query-in-point-op", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["name", "verb"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=no-query-in-point-op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-query-in-point-op.d.ts","sourceRoot":"","sources":["../../../src/rules/no-query-in-point-op.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,oBAAoB;;yBAuC/B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createRule, fileRef, paramMessage } from "@typespec/compiler";
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
|
+
const pointOperationVerbs = new Set(["get", "put", "patch", "delete"]);
|
|
4
|
+
const providerAndNamespace = "/providers/[^/]+";
|
|
5
|
+
const resourceTypeAndResourceName = "(?:/\\w+/default|/\\w+/{[^/]+})";
|
|
6
|
+
const queryParameter = "(?:\\?\\w+)";
|
|
7
|
+
const pointOperationPathRegExp = new RegExp(`${providerAndNamespace}${resourceTypeAndResourceName}+${queryParameter}?$`, "i");
|
|
8
|
+
export const noQueryInPointOpRule = createRule({
|
|
9
|
+
name: "no-query-in-point-op",
|
|
10
|
+
docs: fileRef.fromPackageRoot("src/rules/no-query-in-point-op.md"),
|
|
11
|
+
description: "Point operations must not declare query parameters beyond api-version.",
|
|
12
|
+
severity: "warning",
|
|
13
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-query-in-point-op",
|
|
14
|
+
messages: {
|
|
15
|
+
default: paramMessage `Query parameter '${"name"}' should be removed. Point operation '${"verb"}' MUST not have query parameters other than api-version.`,
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
return {
|
|
19
|
+
operation: (operation) => {
|
|
20
|
+
const [httpOperation] = getHttpOperation(context.program, operation);
|
|
21
|
+
if (!pointOperationVerbs.has(httpOperation.verb) ||
|
|
22
|
+
!isPointOperationPath(httpOperation.path)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (const parameter of httpOperation.parameters.properties) {
|
|
26
|
+
if (parameter.kind !== "query" ||
|
|
27
|
+
parameter.options.name.toLowerCase() === "api-version") {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
context.reportDiagnostic({
|
|
31
|
+
target: parameter.property,
|
|
32
|
+
format: {
|
|
33
|
+
name: parameter.options.name,
|
|
34
|
+
verb: httpOperation.verb,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether the path targets a specific ARM resource instance after the provider namespace.
|
|
44
|
+
* Each resource type segment must be followed by a resource name parameter or the `default` name.
|
|
45
|
+
*/
|
|
46
|
+
function isPointOperationPath(path) {
|
|
47
|
+
const index = path.lastIndexOf("/providers/");
|
|
48
|
+
return index !== -1 && pointOperationPathRegExp.test(path.slice(index));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=no-query-in-point-op.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-query-in-point-op.js","sourceRoot":"","sources":["../../../src/rules/no-query-in-point-op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AACvE,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,2BAA2B,GAAG,iCAAiC,CAAC;AACtE,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,MAAM,wBAAwB,GAAG,IAAI,MAAM,CACzC,GAAG,oBAAoB,GAAG,2BAA2B,IAAI,cAAc,IAAI,EAC3E,GAAG,CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,mCAAmC,CAAC;IAClE,WAAW,EAAE,wEAAwE;IACrF,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,yGAAyG;IAC9G,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,oBAAoB,MAAM,yCAAyC,MAAM,0DAA0D;KACzJ;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBACrE,IACE,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC;oBAC5C,CAAC,oBAAoB,CAAC,aAAa,CAAC,IAAI,CAAC,EACzC,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,KAAK,MAAM,SAAS,IAAI,aAAa,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;oBAC5D,IACE,SAAS,CAAC,IAAI,KAAK,OAAO;wBAC1B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,aAAa,EACtD,CAAC;wBACD,SAAS;oBACX,CAAC;oBAED,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,SAAS,CAAC,QAAQ;wBAC1B,MAAM,EAAE;4BACN,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI;4BAC5B,IAAI,EAAE,aAAa,CAAC,IAAI;yBACzB;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC9C,OAAO,KAAK,KAAK,CAAC,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const useApplicationJsonContentTypeRule: import("@typespec/compiler").LinterRuleDefinition<"use-application-json-content-type", {
|
|
2
|
+
readonly default: "Only content-type 'application/json' is supported by ARM.";
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=use-application-json-content-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-application-json-content-type.d.ts","sourceRoot":"","sources":["../../../src/rules/use-application-json-content-type.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,iCAAiC;;yBA8B5C,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createRule, fileRef, getLocationContext, } from "@typespec/compiler";
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
|
+
import { isArmProviderNamespace } from "../namespace.js";
|
|
4
|
+
export const useApplicationJsonContentTypeRule = createRule({
|
|
5
|
+
name: "use-application-json-content-type",
|
|
6
|
+
docs: fileRef.fromPackageRoot("src/rules/use-application-json-content-type.md"),
|
|
7
|
+
description: "ARM operations must only use application/json content types in request and response bodies.",
|
|
8
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/use-application-json-content-type",
|
|
9
|
+
severity: "warning",
|
|
10
|
+
messages: {
|
|
11
|
+
default: "Only content-type 'application/json' is supported by ARM.",
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
operation: (operation) => {
|
|
16
|
+
const namespace = operation.interface?.namespace ?? operation.namespace;
|
|
17
|
+
if (!isArmProviderNamespace(context.program, namespace)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const [httpOperation] = getHttpOperation(context.program, operation);
|
|
21
|
+
reportInvalidBody(context, operation, httpOperation.parameters.body);
|
|
22
|
+
for (const response of httpOperation.responses) {
|
|
23
|
+
for (const content of response.responses) {
|
|
24
|
+
reportInvalidBody(context, operation, content.body);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
function reportInvalidBody(context, operation, body) {
|
|
32
|
+
if (body === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const contentType of body.contentTypes) {
|
|
36
|
+
if (contentType.includes("application/json")) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
context.reportDiagnostic({
|
|
40
|
+
target: getDiagnosticTarget(context.program, operation, body),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getDiagnosticTarget(program, operation, body) {
|
|
45
|
+
if (body.contentTypeProperty !== undefined &&
|
|
46
|
+
getLocationContext(program, body.contentTypeProperty).type === "project") {
|
|
47
|
+
return body.contentTypeProperty;
|
|
48
|
+
}
|
|
49
|
+
if ("property" in body &&
|
|
50
|
+
body.property !== undefined &&
|
|
51
|
+
getLocationContext(program, body.property).type === "project") {
|
|
52
|
+
return body.property;
|
|
53
|
+
}
|
|
54
|
+
if (getLocationContext(program, operation).type === "project") {
|
|
55
|
+
return operation;
|
|
56
|
+
}
|
|
57
|
+
return operation.interface ?? operation;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=use-application-json-content-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-application-json-content-type.js","sourceRoot":"","sources":["../../../src/rules/use-application-json-content-type.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,CAAC,MAAM,iCAAiC,GAAG,UAAU,CAAC;IAC1D,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,gDAAgD,CAAC;IAC/E,WAAW,EACT,6FAA6F;IAC/F,GAAG,EAAE,sHAAsH;IAC3H,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,2DAA2D;KACrE;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC;gBACxE,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,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AK,SAAS;QAC3B,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,SAAS,EAC7D,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-azure-resource-manager",
|
|
3
|
-
"version": "0.72.0-dev.
|
|
3
|
+
"version": "0.72.0-dev.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@typespec/compiler": "^1.15.0",
|
|
52
52
|
"@typespec/http": "^1.15.0",
|
|
53
53
|
"@typespec/openapi": "^1.15.0",
|
|
54
|
-
"@typespec/
|
|
55
|
-
"@typespec/
|
|
54
|
+
"@typespec/versioning": "^0.85.0",
|
|
55
|
+
"@typespec/rest": "^0.85.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@azure-tools/typespec-azure-core": "^0.71.0 || >= 0.72.0-dev.1",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"rimraf": "^6.1.3",
|
|
64
64
|
"typescript": "~6.0.2",
|
|
65
65
|
"vitest": "^4.1.3",
|
|
66
|
-
"@typespec/compiler": "^1.15.0",
|
|
67
66
|
"@typespec/rest": "^0.85.0",
|
|
67
|
+
"@typespec/compiler": "^1.15.0",
|
|
68
68
|
"@typespec/library-linter": "^0.85.0",
|
|
69
69
|
"@typespec/tspd": "^0.77.0",
|
|
70
|
-
"@typespec/http": "^1.15.0",
|
|
71
70
|
"@typespec/versioning": "^0.85.0",
|
|
71
|
+
"@typespec/http": "^1.15.0",
|
|
72
72
|
"@typespec/openapi": "^1.15.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|