@azure-tools/typespec-azure-resource-manager 0.39.0-dev.2 → 0.39.1

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.
@@ -1,5 +1,5 @@
1
1
  export declare const armResourceProvisioningStateRule: import("@typespec/compiler").LinterRuleDefinition<"arm-resource-provisioning-state", {
2
- readonly default: "The RP-specific property model in the 'properties' property of this resource must contain a 'provisioningState property. The property type should be an enum, and it must specify known state values 'Succeeded', 'Failed', and 'Canceled'.";
2
+ readonly default: "The RP-specific property model in the 'properties' property of this resource must contain a 'provisioningState property. The property type should be an enum or a union of string values, and it must specify known state values 'Succeeded', 'Failed', and 'Canceled'.";
3
3
  readonly missingValues: import("@typespec/compiler").CallableMessage<[string]>;
4
4
  }>;
5
5
  //# sourceMappingURL=arm-resource-provisioning-state-rule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arm-resource-provisioning-state-rule.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-provisioning-state-rule.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gCAAgC;;;EA2D3C,CAAC"}
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;;;EAwF3C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { createRule, getProperty, paramMessage } from "@typespec/compiler";
2
+ import { getUnionAsEnum } from "@azure-tools/typespec-azure-core";
2
3
  import { getArmResource } from "../resource.js";
3
4
  import { getSourceProperty } from "./utils.js";
4
5
  export const armResourceProvisioningStateRule = createRule({
@@ -6,7 +7,7 @@ export const armResourceProvisioningStateRule = createRule({
6
7
  severity: "warning",
7
8
  description: "Check for properly configured provisioningState property.",
8
9
  messages: {
9
- default: "The RP-specific property model in the 'properties' property of this resource must contain a 'provisioningState property. The property type should be an enum, and it must specify known state values 'Succeeded', 'Failed', and 'Canceled'.",
10
+ default: "The RP-specific property model in the 'properties' property of this resource must contain a 'provisioningState property. The property type should be an enum or a union of string values, and it must specify known state values 'Succeeded', 'Failed', and 'Canceled'.",
10
11
  missingValues: paramMessage `The "@knownValues" decorator for provisioningState, must reference an enum with 'Succeeded', 'Failed', 'Canceled' values. The enum is missing the values: [${"missingValues"}].`,
11
12
  },
12
13
  create(context) {
@@ -31,7 +32,7 @@ export const armResourceProvisioningStateRule = createRule({
31
32
  provisioning = getSourceProperty(provisioning);
32
33
  const provisioningType = provisioning.type;
33
34
  switch (provisioningType.kind) {
34
- case "Enum":
35
+ case "Enum": {
35
36
  const enumType = provisioningType;
36
37
  const missing = [];
37
38
  if (!enumType.members.get("Succeeded")) {
@@ -51,6 +52,34 @@ export const armResourceProvisioningStateRule = createRule({
51
52
  });
52
53
  }
53
54
  break;
55
+ }
56
+ case "Union": {
57
+ const [unionAsEnum] = getUnionAsEnum(provisioningType);
58
+ if (unionAsEnum === undefined) {
59
+ context.reportDiagnostic({
60
+ target: resourceProperties,
61
+ });
62
+ break;
63
+ }
64
+ const missing = [];
65
+ if (!unionAsEnum.flattenedMembers.get("Succeeded")) {
66
+ missing.push("Succeeded");
67
+ }
68
+ if (!unionAsEnum.flattenedMembers.get("Canceled")) {
69
+ missing.push("Canceled");
70
+ }
71
+ if (!unionAsEnum.flattenedMembers.get("Failed")) {
72
+ missing.push("Failed");
73
+ }
74
+ if (missing.length > 0) {
75
+ context.reportDiagnostic({
76
+ messageId: "missingValues",
77
+ format: { missingValues: missing.join(", ") },
78
+ target: provisioningType,
79
+ });
80
+ }
81
+ break;
82
+ }
54
83
  default:
55
84
  context.reportDiagnostic({
56
85
  target: provisioning,
@@ -1 +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,EAAe,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;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AC7B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gCACvC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;4BAC5B,CAAC;4BACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gCACtC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;4BAC3B,CAAC;4BACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gCACpC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;4BACzB,CAAC;4BACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCACvB,OAAO,CAAC,gBAAgB,CAAC;oCACvB,SAAS,EAAE,eAAe;oCAC1B,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oCAC7C,MAAM,EAAE,QAAQ;iCACjB,CAAC,CAAC;4BACL,CAAC;4BACD,MAAM;wBACR;4BACE,OAAO,CAAC,gBAAgB,CAAC;gCACvB,MAAM,EAAE,YAAY;6BACrB,CAAC,CAAC;oBACP,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"arm-resource-provisioning-state-rule.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-provisioning-state-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAA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EAAE,CAAC;gCAChD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;4BACzB,CAAC;4BACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCACvB,OAAO,CAAC,gBAAgB,CAAC;oCACvB,SAAS,EAAE,eAAe;oCAC1B,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oCAC7C,MAAM,EAAE,gBAAgB;iCACzB,CAAC,CAAC;4BACL,CAAC;4BACD,MAAM;wBACR,CAAC;wBAED;4BACE,OAAO,CAAC,gBAAgB,CAAC;gCACvB,MAAM,EAAE,YAAY;6BACrB,CAAC,CAAC;oBACP,CAAC;gBACH,CAAC;YACH,CAAC;SACF,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.39.0-dev.2",
3
+ "version": "0.39.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Resource Manager library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",
@@ -39,26 +39,26 @@
39
39
  "!dist/test/**"
40
40
  ],
41
41
  "peerDependencies": {
42
- "@typespec/compiler": "~0.52.0 || >=0.53.0-dev <0.53.0",
43
- "@azure-tools/typespec-azure-core": "~0.38.0 || >=0.39.0-dev <0.39.0",
44
- "@azure-tools/typespec-autorest": "~0.38.1 || >=0.39.0-dev <0.39.0",
45
- "@typespec/openapi": "~0.52.0 || >=0.53.0-dev <0.53.0",
46
- "@typespec/rest": "~0.52.0 || >=0.53.0-dev <0.53.0",
47
- "@typespec/http": "~0.52.0 || >=0.53.0-dev <0.53.0",
48
- "@typespec/versioning": "~0.52.0 || >=0.53.0-dev <0.53.0"
42
+ "@typespec/compiler": "~0.53.1",
43
+ "@azure-tools/typespec-azure-core": "~0.39.1",
44
+ "@azure-tools/typespec-autorest": "~0.39.2",
45
+ "@typespec/openapi": "~0.53.0",
46
+ "@typespec/rest": "~0.53.0",
47
+ "@typespec/http": "~0.53.0",
48
+ "@typespec/versioning": "~0.53.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@typespec/compiler": "~0.52.0 || >=0.53.0-dev <0.53.0",
52
- "@typespec/openapi": "~0.52.0 || >=0.53.0-dev <0.53.0",
53
- "@azure-tools/typespec-azure-core": "~0.38.0 || >=0.39.0-dev <0.39.0",
54
- "@azure-tools/typespec-autorest": "~0.38.1 || >=0.39.0-dev <0.39.0",
55
- "@typespec/rest": "~0.52.0 || >=0.53.0-dev <0.53.0",
56
- "@typespec/http": "~0.52.0 || >=0.53.0-dev <0.53.0",
57
- "@typespec/versioning": "~0.52.0 || >=0.53.0-dev <0.53.0",
51
+ "@typespec/compiler": "~0.53.1",
52
+ "@typespec/openapi": "~0.53.0",
53
+ "@azure-tools/typespec-azure-core": "~0.39.1",
54
+ "@azure-tools/typespec-autorest": "~0.39.2",
55
+ "@typespec/rest": "~0.53.0",
56
+ "@typespec/http": "~0.53.0",
57
+ "@typespec/versioning": "~0.53.0",
58
58
  "@types/node": "~18.11.9",
59
- "@typespec/eslint-config-typespec": "~0.52.0 || >=0.53.0-dev <0.53.0",
60
- "@typespec/library-linter": "~0.52.0 || >=0.53.0-dev <0.53.0",
61
- "@typespec/eslint-plugin": "~0.52.0 || >=0.53.0-dev <0.53.0",
59
+ "@typespec/eslint-config-typespec": "~0.53.0",
60
+ "@typespec/library-linter": "~0.53.0",
61
+ "@typespec/eslint-plugin": "~0.53.0",
62
62
  "@typespec/tspd": "~0.46.0",
63
63
  "eslint": "^8.55.0",
64
64
  "vitest": "^1.2.0",
@@ -68,7 +68,6 @@
68
68
  "rimraf": "~5.0.1",
69
69
  "typescript": "~5.3.3"
70
70
  },
71
- "dependencies": {},
72
71
  "scripts": {
73
72
  "clean": "rimraf ./dist ./temp",
74
73
  "build": "tsc -p . && npm run lint-typespec-library",