@azure-tools/typespec-azure-core 0.37.0-dev.5 → 0.37.0-dev.6

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
@@ -28,40 +28,41 @@ Available ruleSets:
28
28
 
29
29
  ### Rules
30
30
 
31
- | Name | Description |
32
- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
33
- | `@azure-tools/typespec-azure-core/operation-missing-api-version` | Operations need an api version parameter. |
34
- | `@azure-tools/typespec-azure-core/auth-required` | Enforce service authentication. |
35
- | `@azure-tools/typespec-azure-core/no-operation-id` | Operation ID is automatically generated by the OpenAPI emitters and should not normally be specified. |
36
- | `@azure-tools/typespec-azure-core/request-body-problem` | Request body should not be of raw array type. |
37
- | `@azure-tools/typespec-azure-core/byos` | Use the BYOS pattern recommended for Azure Services. |
38
- | `@azure-tools/typespec-azure-core/casing-style` | Ensure proper casing style. |
39
- | `@azure-tools/typespec-azure-core/spread-discriminated-model` | Check a model with a discriminator has not been used in composition. |
40
- | `@azure-tools/typespec-azure-core/composition-over-inheritance` | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. |
41
- | `@azure-tools/typespec-azure-core/prefer-csv-collection-format` | It is recommended to use "csv" for collection format of parameters. |
42
- | `@azure-tools/typespec-azure-core/use-extensible-enum` | Enums should be extensible. |
43
- | `@azure-tools/typespec-azure-core/known-encoding` | Check for supported encodings. |
44
- | `@azure-tools/typespec-azure-core/use-standard-operations` | Operations should be defined using a signature from the Azure.Core namespace. |
45
- | [`@azure-tools/typespec-azure-core/no-enum`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-enum) | Azure services should not use enums. |
46
- | `@azure-tools/typespec-azure-core/no-error-status-codes` | Recommend using the error response defined by Azure REST API guidelines. |
47
- | `@azure-tools/typespec-azure-core/no-fixed-enum-discriminator` | Discriminator shouldn't be a fixed enum. |
48
- | `@azure-tools/typespec-azure-core/no-nullable` | Use `?` for optional properties. |
49
- | `@azure-tools/typespec-azure-core/no-offsetdatetime` | Prefer using `utcDateTime` when representing a datetime unless an offset is necessary. |
50
- | `@azure-tools/typespec-azure-core/no-rpc-path-params` | Operations defined using RpcOperation should not have path parameters. |
51
- | `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
52
- | `@azure-tools/typespec-azure-core/no-response-body` | Ensure that the body is set correctly for the response type. |
53
- | `@azure-tools/typespec-azure-core/no-format` | Azure services should not use the `@format` decorator. |
54
- | `@azure-tools/typespec-azure-core/no-multiple-discriminator` | Classes should have at most one discriminator. |
55
- | `@azure-tools/typespec-azure-core/no-rest-library-interfaces` | Resource interfaces from the TypeSpec.Rest.Resource library are incompatible with Azure.Core. |
56
- | `@azure-tools/typespec-azure-core/no-unknown` | Azure services must not have properties of type `unknown`. |
57
- | `@azure-tools/typespec-azure-core/bad-record-type` | Identify bad record definitions. |
58
- | `@azure-tools/typespec-azure-core/response-schema-problem` | Warn about operations having multiple non-error response schemas. |
59
- | `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts. |
60
- | `@azure-tools/typespec-azure-core/rpc-operation-request-body` | Warning for RPC body problems. |
61
- | `@azure-tools/typespec-azure-core/documentation-required` | Require documentation over enums, models, and operations. |
62
- | `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have an explicit visibility setting. |
63
- | `@azure-tools/typespec-azure-core/long-running-polling-operation-required` | Long-running operations should have a linked polling operation. |
64
- | `@azure-tools/typespec-azure-core/use-standard-names` | Use recommended names for operations. |
31
+ | Name | Description |
32
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
33
+ | `@azure-tools/typespec-azure-core/operation-missing-api-version` | Operations need an api version parameter. |
34
+ | `@azure-tools/typespec-azure-core/auth-required` | Enforce service authentication. |
35
+ | `@azure-tools/typespec-azure-core/no-operation-id` | Operation ID is automatically generated by the OpenAPI emitters and should not normally be specified. |
36
+ | `@azure-tools/typespec-azure-core/request-body-problem` | Request body should not be of raw array type. |
37
+ | `@azure-tools/typespec-azure-core/byos` | Use the BYOS pattern recommended for Azure Services. |
38
+ | `@azure-tools/typespec-azure-core/casing-style` | Ensure proper casing style. |
39
+ | `@azure-tools/typespec-azure-core/spread-discriminated-model` | Check a model with a discriminator has not been used in composition. |
40
+ | `@azure-tools/typespec-azure-core/composition-over-inheritance` | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. |
41
+ | `@azure-tools/typespec-azure-core/prefer-csv-collection-format` | It is recommended to use "csv" for collection format of parameters. |
42
+ | `@azure-tools/typespec-azure-core/use-extensible-enum` | Enums should be extensible. |
43
+ | `@azure-tools/typespec-azure-core/known-encoding` | Check for supported encodings. |
44
+ | `@azure-tools/typespec-azure-core/use-standard-operations` | Operations should be defined using a signature from the Azure.Core namespace. |
45
+ | [`@azure-tools/typespec-azure-core/no-closed-literal-union`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-closed-literal-union) | Unions of literals should include the base scalar type to mark them as open enum. |
46
+ | [`@azure-tools/typespec-azure-core/no-enum`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-enum) | Azure services should not use enums. |
47
+ | `@azure-tools/typespec-azure-core/no-error-status-codes` | Recommend using the error response defined by Azure REST API guidelines. |
48
+ | `@azure-tools/typespec-azure-core/no-fixed-enum-discriminator` | Discriminator shouldn't be a fixed enum. |
49
+ | `@azure-tools/typespec-azure-core/no-nullable` | Use `?` for optional properties. |
50
+ | `@azure-tools/typespec-azure-core/no-offsetdatetime` | Prefer using `utcDateTime` when representing a datetime unless an offset is necessary. |
51
+ | `@azure-tools/typespec-azure-core/no-rpc-path-params` | Operations defined using RpcOperation should not have path parameters. |
52
+ | `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
53
+ | `@azure-tools/typespec-azure-core/no-response-body` | Ensure that the body is set correctly for the response type. |
54
+ | `@azure-tools/typespec-azure-core/no-format` | Azure services should not use the `@format` decorator. |
55
+ | `@azure-tools/typespec-azure-core/no-multiple-discriminator` | Classes should have at most one discriminator. |
56
+ | `@azure-tools/typespec-azure-core/no-rest-library-interfaces` | Resource interfaces from the TypeSpec.Rest.Resource library are incompatible with Azure.Core. |
57
+ | `@azure-tools/typespec-azure-core/no-unknown` | Azure services must not have properties of type `unknown`. |
58
+ | `@azure-tools/typespec-azure-core/bad-record-type` | Identify bad record definitions. |
59
+ | `@azure-tools/typespec-azure-core/response-schema-problem` | Warn about operations having multiple non-error response schemas. |
60
+ | `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts. |
61
+ | `@azure-tools/typespec-azure-core/rpc-operation-request-body` | Warning for RPC body problems. |
62
+ | `@azure-tools/typespec-azure-core/documentation-required` | Require documentation over enums, models, and operations. |
63
+ | `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have an explicit visibility setting. |
64
+ | `@azure-tools/typespec-azure-core/long-running-polling-operation-required` | Long-running operations should have a linked polling operation. |
65
+ | `@azure-tools/typespec-azure-core/use-standard-names` | Use recommended names for operations. |
65
66
 
66
67
  ## Decorators
67
68
 
@@ -0,0 +1,71 @@
1
+ import { Diagnostic, Union, UnionVariant } from "@typespec/compiler";
2
+ export interface UnionEnumBase<K extends string, T> {
3
+ kind: K;
4
+ /** Reference to the type used to construct this enum */
5
+ union: Union;
6
+ /** Member of this enum. */
7
+ members: Map<string | symbol, UnionEnumVariant<T>>;
8
+ /** Any union used as a union variant. */
9
+ include: UnionEnumBase<K, T>;
10
+ /** Flattened member of this enum, this is the {@see members} with the members of the {@see include} union flattened inside. */
11
+ flattenedMembers: Map<string | symbol, UnionEnumVariant<T>>;
12
+ /** If the enum is open. */
13
+ open: boolean;
14
+ /** If the union included null as a variant */
15
+ nullable: boolean;
16
+ }
17
+ export interface UnionEnumVariant<T> {
18
+ value: T;
19
+ /** Reference to the type used to construct this enum */
20
+ variant: UnionVariant;
21
+ }
22
+ export type UnionEnum = UnionEnumBase<"string", string> | UnionEnumBase<"number", number>;
23
+ /**
24
+ * Tries to convert a union into an enum.
25
+ * If the union only contains the same type of literal options with optionally
26
+ * the base scalar to mark extensibility we can represent this union as an enum of that type.
27
+ *
28
+ * @param union Union to try to convert
29
+ *
30
+ * @example
31
+ *
32
+ * Simple closed string enum
33
+ *
34
+ * ```tsp
35
+ * union PetKind { "cat", "dog" }
36
+ * ```
37
+ *
38
+ * ```ts
39
+ * const [enum, diagnostics] = getUnionAsEnum(union);
40
+ * enum.open === false
41
+ * enum.open.members.get("cat") // { value: "cat", variant: ... }
42
+ * enum.open.members.get("dog") // { value: "dog", variant: ... }
43
+ * ```
44
+ *
45
+ * Simple open string enum
46
+ *
47
+ * ```tsp
48
+ * union PetKind { Cat: "cat", Dog: "dog", string }
49
+ * ```
50
+ *
51
+ * ```ts
52
+ * const [enum, diagnostics] = getUnionAsEnum(union);
53
+ * enum.open === true
54
+ * enum.open.members.get("Cat") // { value: "cat", variant: ... }
55
+ * enum.open.members.get("Dog") // { value: "dog", variant: ... }
56
+ * ```
57
+ *
58
+ * Invalid case
59
+ *
60
+ * ```tsp
61
+ * union PetKind { Cat: "cat", Dog: 123, string }
62
+ * ```
63
+ *
64
+ * ```ts
65
+ * const [enum, diagnostics] = getUnionAsEnum(union);
66
+ * enum === undefined
67
+ * diagnostics.length === 1
68
+ * ```
69
+ */
70
+ export declare function getUnionAsEnum(union: Union): [UnionEnum | undefined, readonly Diagnostic[]];
71
+ //# sourceMappingURL=union-enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-enums.d.ts","sourceRoot":"","sources":["../../../src/helpers/union-enums.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,KAAK,EACL,YAAY,EAGb,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC;IACR,wDAAwD;IACxD,KAAK,EAAE,KAAK,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,yCAAyC;IACzC,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,+HAA+H;IAC/H,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,2BAA2B;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC;IACT,wDAAwD;IACxD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,SAAS,GAAG,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC,CAE3F"}
@@ -0,0 +1,162 @@
1
+ import { createDiagnosticCollector, isNullType, } from "@typespec/compiler";
2
+ import { createDiagnostic } from "../lib.js";
3
+ /**
4
+ * Tries to convert a union into an enum.
5
+ * If the union only contains the same type of literal options with optionally
6
+ * the base scalar to mark extensibility we can represent this union as an enum of that type.
7
+ *
8
+ * @param union Union to try to convert
9
+ *
10
+ * @example
11
+ *
12
+ * Simple closed string enum
13
+ *
14
+ * ```tsp
15
+ * union PetKind { "cat", "dog" }
16
+ * ```
17
+ *
18
+ * ```ts
19
+ * const [enum, diagnostics] = getUnionAsEnum(union);
20
+ * enum.open === false
21
+ * enum.open.members.get("cat") // { value: "cat", variant: ... }
22
+ * enum.open.members.get("dog") // { value: "dog", variant: ... }
23
+ * ```
24
+ *
25
+ * Simple open string enum
26
+ *
27
+ * ```tsp
28
+ * union PetKind { Cat: "cat", Dog: "dog", string }
29
+ * ```
30
+ *
31
+ * ```ts
32
+ * const [enum, diagnostics] = getUnionAsEnum(union);
33
+ * enum.open === true
34
+ * enum.open.members.get("Cat") // { value: "cat", variant: ... }
35
+ * enum.open.members.get("Dog") // { value: "dog", variant: ... }
36
+ * ```
37
+ *
38
+ * Invalid case
39
+ *
40
+ * ```tsp
41
+ * union PetKind { Cat: "cat", Dog: 123, string }
42
+ * ```
43
+ *
44
+ * ```ts
45
+ * const [enum, diagnostics] = getUnionAsEnum(union);
46
+ * enum === undefined
47
+ * diagnostics.length === 1
48
+ * ```
49
+ */
50
+ export function getUnionAsEnum(union) {
51
+ return getUnionAsEnumInternal(union, new Set());
52
+ }
53
+ function getUnionAsEnumInternal(union, visited) {
54
+ if (visited.has(union)) {
55
+ return [undefined, [createDiagnostic({ code: "union-enums-circular", target: union })]];
56
+ }
57
+ visited.add(union);
58
+ const diagnostics = createDiagnosticCollector();
59
+ function reportInvalidKind(type) {
60
+ diagnostics.add(createDiagnostic({
61
+ code: "union-enums-invalid-kind",
62
+ format: { kind: type.kind },
63
+ target: union,
64
+ }));
65
+ }
66
+ const kinds = new Set();
67
+ const members = new Map();
68
+ const flattenedMembers = new Map();
69
+ let open = false;
70
+ let nullable = false;
71
+ for (const variant of union.variants.values()) {
72
+ switch (variant.type.kind) {
73
+ case "Intrinsic":
74
+ if (isNullType(variant.type)) {
75
+ nullable = true;
76
+ }
77
+ else {
78
+ reportInvalidKind(variant.type);
79
+ }
80
+ break;
81
+ case "String":
82
+ kinds.add("string");
83
+ members.set(variant.name, { value: variant.type.value, variant });
84
+ break;
85
+ case "Number":
86
+ kinds.add("number");
87
+ members.set(variant.name, { value: variant.type.value, variant });
88
+ break;
89
+ case "Union":
90
+ const parentUnion = diagnostics.pipe(getUnionAsEnumInternal(variant.type, visited));
91
+ if (parentUnion !== undefined) {
92
+ kinds.add(parentUnion.kind);
93
+ if (parentUnion.open) {
94
+ open = true;
95
+ }
96
+ if (parentUnion.nullable) {
97
+ nullable = true;
98
+ }
99
+ for (const [key, value] of parentUnion.flattenedMembers) {
100
+ flattenedMembers.set(key, value);
101
+ }
102
+ }
103
+ break;
104
+ case "Scalar":
105
+ const scalar = variant.type;
106
+ switch (scalar.name) {
107
+ case "string":
108
+ kinds.add("string");
109
+ open = true;
110
+ break;
111
+ case "float":
112
+ case "float32":
113
+ case "float64":
114
+ case "integer":
115
+ case "int8":
116
+ case "int16":
117
+ case "int32":
118
+ case "int64":
119
+ case "uint8":
120
+ case "uint16":
121
+ case "uint32":
122
+ case "uint64":
123
+ kinds.add("number");
124
+ open = true;
125
+ break;
126
+ default:
127
+ reportInvalidKind(variant.type);
128
+ }
129
+ break;
130
+ default:
131
+ reportInvalidKind(variant.type);
132
+ }
133
+ }
134
+ for (const [key, value] of members) {
135
+ flattenedMembers.set(key, value);
136
+ }
137
+ if (kinds.size > 1) {
138
+ diagnostics.add(createDiagnostic({
139
+ code: "union-enums-multiple-kind",
140
+ format: { kinds: [...kinds].join(", ") },
141
+ target: union,
142
+ }));
143
+ }
144
+ if (diagnostics.diagnostics.length > 0) {
145
+ return diagnostics.wrap(undefined);
146
+ }
147
+ if (flattenedMembers.size === 0) {
148
+ return [undefined, []];
149
+ }
150
+ return [
151
+ {
152
+ kind: [...kinds][0],
153
+ union,
154
+ members,
155
+ flattenedMembers,
156
+ open,
157
+ nullable,
158
+ },
159
+ [],
160
+ ];
161
+ }
162
+ //# sourceMappingURL=union-enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-enums.js","sourceRoot":"","sources":["../../../src/helpers/union-enums.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,yBAAyB,EACzB,UAAU,GACX,MAAM,oBA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E,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,KAAK;YACL,OAAO;YACP,gBAAgB;YAChB,IAAI;YACJ,QAAQ;SACF;QACR,EAAE;KACH,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from "./decorators.js";
2
2
  export { $lib } from "./lib.js";
3
+ export { UnionEnum, getUnionAsEnum } from "./helpers/union-enums.js";
3
4
  export * from "./lro-helpers.js";
4
5
  export * from "./rules/prevent-rest-library.js";
5
6
  export * from "./rules/use-standard-ops.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./decorators.js";
2
2
  export { $lib } from "./lib.js";
3
+ export { getUnionAsEnum } from "./helpers/union-enums.js";
3
4
  export * from "./lro-helpers.js";
4
5
  export * from "./rules/prevent-rest-library.js";
5
6
  export * from "./rules/use-standard-ops.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAa,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
package/dist/src/lib.d.ts CHANGED
@@ -95,8 +95,17 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
95
95
  "rpc-operation-needs-route": {
96
96
  default: string;
97
97
  };
98
+ "union-enums-multiple-kind": {
99
+ default: import("@typespec/compiler").CallableMessage<[string]>;
100
+ };
101
+ "union-enums-invalid-kind": {
102
+ default: import("@typespec/compiler").CallableMessage<[string]>;
103
+ };
104
+ "union-enums-circular": {
105
+ default: string;
106
+ };
98
107
  }, Record<string, any>>;
99
- export declare const reportDiagnostic: <C extends "bad-record-type" | "lro-status-union-non-string" | "lro-status-property-invalid-type" | "lro-status-missing" | "lro-status-monitor-invalid-result-property" | "request-parameter-invalid" | "response-property-invalid" | "operation-link-parameter-invalid" | "operation-link-parameter-invalid-target" | "invalid-resource-type" | "polling-operation-return-model" | "polling-operation-no-status-monitor" | "polling-operation-no-lro-success" | "polling-operation-no-lro-failure" | "polling-operation-no-ref-or-link" | "invalid-final-operation" | "invalid-trait-property-count" | "invalid-trait-property-type" | "invalid-trait-context" | "trait-property-without-location" | "expected-trait-missing" | "client-request-id-trait-missing" | "repeatable-requests-trait-missing" | "conditional-requests-trait-missing" | "expected-trait-diagnostic-missing" | "invalid-parameter" | "expected-success-response" | "lro-polling-data-missing-from-operation-response" | "no-object" | "verb-conflict" | "rpc-operation-needs-route", M extends keyof {
108
+ export declare const reportDiagnostic: <C extends "lro-status-union-non-string" | "lro-status-property-invalid-type" | "lro-status-missing" | "lro-status-monitor-invalid-result-property" | "bad-record-type" | "request-parameter-invalid" | "response-property-invalid" | "operation-link-parameter-invalid" | "operation-link-parameter-invalid-target" | "invalid-resource-type" | "polling-operation-return-model" | "polling-operation-no-status-monitor" | "polling-operation-no-lro-success" | "polling-operation-no-lro-failure" | "polling-operation-no-ref-or-link" | "invalid-final-operation" | "invalid-trait-property-count" | "invalid-trait-property-type" | "invalid-trait-context" | "trait-property-without-location" | "expected-trait-missing" | "client-request-id-trait-missing" | "repeatable-requests-trait-missing" | "conditional-requests-trait-missing" | "expected-trait-diagnostic-missing" | "invalid-parameter" | "expected-success-response" | "lro-polling-data-missing-from-operation-response" | "no-object" | "verb-conflict" | "rpc-operation-needs-route" | "union-enums-multiple-kind" | "union-enums-invalid-kind" | "union-enums-circular", M extends keyof {
100
109
  "lro-status-union-non-string": {
101
110
  default: import("@typespec/compiler").CallableMessage<[string]>;
102
111
  };
@@ -192,6 +201,15 @@ export declare const reportDiagnostic: <C extends "bad-record-type" | "lro-statu
192
201
  "rpc-operation-needs-route": {
193
202
  default: string;
194
203
  };
204
+ "union-enums-multiple-kind": {
205
+ default: import("@typespec/compiler").CallableMessage<[string]>;
206
+ };
207
+ "union-enums-invalid-kind": {
208
+ default: import("@typespec/compiler").CallableMessage<[string]>;
209
+ };
210
+ "union-enums-circular": {
211
+ default: string;
212
+ };
195
213
  }[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
196
214
  "lro-status-union-non-string": {
197
215
  default: import("@typespec/compiler").CallableMessage<[string]>;
@@ -288,7 +306,16 @@ export declare const reportDiagnostic: <C extends "bad-record-type" | "lro-statu
288
306
  "rpc-operation-needs-route": {
289
307
  default: string;
290
308
  };
291
- }, C, M>) => void, createDiagnostic: <C extends "bad-record-type" | "lro-status-union-non-string" | "lro-status-property-invalid-type" | "lro-status-missing" | "lro-status-monitor-invalid-result-property" | "request-parameter-invalid" | "response-property-invalid" | "operation-link-parameter-invalid" | "operation-link-parameter-invalid-target" | "invalid-resource-type" | "polling-operation-return-model" | "polling-operation-no-status-monitor" | "polling-operation-no-lro-success" | "polling-operation-no-lro-failure" | "polling-operation-no-ref-or-link" | "invalid-final-operation" | "invalid-trait-property-count" | "invalid-trait-property-type" | "invalid-trait-context" | "trait-property-without-location" | "expected-trait-missing" | "client-request-id-trait-missing" | "repeatable-requests-trait-missing" | "conditional-requests-trait-missing" | "expected-trait-diagnostic-missing" | "invalid-parameter" | "expected-success-response" | "lro-polling-data-missing-from-operation-response" | "no-object" | "verb-conflict" | "rpc-operation-needs-route", M extends keyof {
309
+ "union-enums-multiple-kind": {
310
+ default: import("@typespec/compiler").CallableMessage<[string]>;
311
+ };
312
+ "union-enums-invalid-kind": {
313
+ default: import("@typespec/compiler").CallableMessage<[string]>;
314
+ };
315
+ "union-enums-circular": {
316
+ default: string;
317
+ };
318
+ }, C, M>) => void, createDiagnostic: <C extends "lro-status-union-non-string" | "lro-status-property-invalid-type" | "lro-status-missing" | "lro-status-monitor-invalid-result-property" | "bad-record-type" | "request-parameter-invalid" | "response-property-invalid" | "operation-link-parameter-invalid" | "operation-link-parameter-invalid-target" | "invalid-resource-type" | "polling-operation-return-model" | "polling-operation-no-status-monitor" | "polling-operation-no-lro-success" | "polling-operation-no-lro-failure" | "polling-operation-no-ref-or-link" | "invalid-final-operation" | "invalid-trait-property-count" | "invalid-trait-property-type" | "invalid-trait-context" | "trait-property-without-location" | "expected-trait-missing" | "client-request-id-trait-missing" | "repeatable-requests-trait-missing" | "conditional-requests-trait-missing" | "expected-trait-diagnostic-missing" | "invalid-parameter" | "expected-success-response" | "lro-polling-data-missing-from-operation-response" | "no-object" | "verb-conflict" | "rpc-operation-needs-route" | "union-enums-multiple-kind" | "union-enums-invalid-kind" | "union-enums-circular", M extends keyof {
292
319
  "lro-status-union-non-string": {
293
320
  default: import("@typespec/compiler").CallableMessage<[string]>;
294
321
  };
@@ -384,6 +411,15 @@ export declare const reportDiagnostic: <C extends "bad-record-type" | "lro-statu
384
411
  "rpc-operation-needs-route": {
385
412
  default: string;
386
413
  };
414
+ "union-enums-multiple-kind": {
415
+ default: import("@typespec/compiler").CallableMessage<[string]>;
416
+ };
417
+ "union-enums-invalid-kind": {
418
+ default: import("@typespec/compiler").CallableMessage<[string]>;
419
+ };
420
+ "union-enums-circular": {
421
+ default: string;
422
+ };
387
423
  }[C]>(diag: import("@typespec/compiler").DiagnosticReport<{
388
424
  "lro-status-union-non-string": {
389
425
  default: import("@typespec/compiler").CallableMessage<[string]>;
@@ -480,5 +516,14 @@ export declare const reportDiagnostic: <C extends "bad-record-type" | "lro-statu
480
516
  "rpc-operation-needs-route": {
481
517
  default: string;
482
518
  };
519
+ "union-enums-multiple-kind": {
520
+ default: import("@typespec/compiler").CallableMessage<[string]>;
521
+ };
522
+ "union-enums-invalid-kind": {
523
+ default: import("@typespec/compiler").CallableMessage<[string]>;
524
+ };
525
+ "union-enums-circular": {
526
+ default: string;
527
+ };
483
528
  }, C, M>) => import("@typespec/compiler").Diagnostic, createStateSymbol: (name: string) => symbol;
484
529
  //# sourceMappingURL=lib.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAAE,iBAAiB,0BAAS,CAAC"}
package/dist/src/lib.js CHANGED
@@ -8,6 +8,7 @@ import { extensibleEnumRule } from "./rules/extensible-enums.js";
8
8
  import { friendlyNameRule } from "./rules/friendly-name.js";
9
9
  import { knownEncodingRule } from "./rules/known-encoding.js";
10
10
  import { longRunningOperationsRequirePollingOperation } from "./rules/lro-polling-operation.js";
11
+ import { noClosedLiteralUnionRule } from "./rules/no-closed-literal-union.js";
11
12
  import { noEnumRule } from "./rules/no-enum.js";
12
13
  import { noErrorStatusCodesRule } from "./rules/no-error-status-codes.js";
13
14
  import { noExplicitRoutesResourceOps } from "./rules/no-explicit-routes-resource-ops.js";
@@ -224,6 +225,24 @@ export const $lib = createTypeSpecLibrary({
224
225
  default: "The operation needs a @route",
225
226
  },
226
227
  },
228
+ "union-enums-multiple-kind": {
229
+ severity: "warning",
230
+ messages: {
231
+ default: paramMessage `Couldn't resolve the kind of the union as it has multiple types: ${"kinds"}`,
232
+ },
233
+ },
234
+ "union-enums-invalid-kind": {
235
+ severity: "warning",
236
+ messages: {
237
+ default: paramMessage `Kind ${"kind"} prevents this union from being resolved as an enum.`,
238
+ },
239
+ },
240
+ "union-enums-circular": {
241
+ severity: "warning",
242
+ messages: {
243
+ default: `Union is referencing itself and cannot be resolved as an enum.`,
244
+ },
245
+ },
227
246
  },
228
247
  linter: {
229
248
  rules: [
@@ -239,6 +258,7 @@ export const $lib = createTypeSpecLibrary({
239
258
  extensibleEnumRule,
240
259
  knownEncodingRule,
241
260
  useStandardOperations,
261
+ noClosedLiteralUnionRule,
242
262
  noEnumRule,
243
263
  noErrorStatusCodesRule,
244
264
  noFixedEnumDiscriminatorRule,
@@ -1 +1 @@
1
- {"version":3,"file":"l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CAAoC,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;oBACvE,CAAC,oCAAoC,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;oBACvE,CAAC,oCAAoC,4CAA4C,CAAC,IAAI,EAAE,CAAC,EACvF,IAAI;oBACN,CAAC,oCAAoC,gBAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;oBACnE,CAAC,oCAAoC,gBAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;oBACnE,CAAC,oCAAoC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK;iBAC/D;gBACD,OAAO,EAAE,CAAC,oBAAoB,CAAC;aAChC;SACF;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const noClosedLiteralUnionRule: import("@typespec/compiler").LinterRuleDefinition<"no-closed-literal-union", {
2
+ readonly default: "Union of literals should include the base scalar as a variant to make it an open enum. (ex: `union Choice { Yes: \"yes\", No: \"no\", string };`).";
3
+ }>;
4
+ //# sourceMappingURL=no-closed-literal-union.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-closed-literal-union.d.ts","sourceRoot":"","sources":["../../../src/rules/no-closed-literal-union.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB;;EAuBnC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { createRule, ignoreDiagnostics } from "@typespec/compiler";
2
+ import { getUnionAsEnum } from "../helpers/union-enums.js";
3
+ export const noClosedLiteralUnionRule = createRule({
4
+ name: "no-closed-literal-union",
5
+ description: "Unions of literals should include the base scalar type to mark them as open enum.",
6
+ severity: "warning",
7
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-closed-literal-union",
8
+ messages: {
9
+ default: `Union of literals should include the base scalar as a variant to make it an open enum. (ex: \`union Choice { Yes: "yes", No: "no", string };\`).`,
10
+ },
11
+ create(context) {
12
+ return {
13
+ union: (union) => {
14
+ const e = ignoreDiagnostics(getUnionAsEnum(union));
15
+ if (e === undefined) {
16
+ return;
17
+ }
18
+ if (!e.open) {
19
+ context.reportDiagnostic({
20
+ target: union,
21
+ });
22
+ }
23
+ },
24
+ };
25
+ },
26
+ });
27
+ //# sourceMappingURL=no-closed-literal-union.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-closed-literal-union.js","sourceRoot":"","sources":["../../../src/rules/no-closed-literal-union.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;IACjD,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,mFAAmF;IAChG,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,gGAAgG;IACrG,QAAQ,EAAE;QACR,OAAO,EAAE,kJAAkJ;KAC5J;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,EAAE,CAAC,KAAY,EAAE,EAAE;gBACtB,MAAM,CAAC,GAAG,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;gBACnD,IAAI,CAAC,KAAK,SAAS,EAAE;oBACnB,OAAO;iBACR;gBACD,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;oBACX,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,KAAK;qBACd,CAAC,CAAC;iBACJ;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-core",
3
- "version": "0.37.0-dev.5",
3
+ "version": "0.37.0-dev.6",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Core library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",