@azure-tools/typespec-azure-core 0.52.0-dev.0 → 0.52.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
@@ -56,7 +56,7 @@ Available ruleSets:
56
56
  | `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts between a property and a model of the same name. |
57
57
  | [`@azure-tools/typespec-azure-core/bad-record-type`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/bad-record-type) | Identify bad record definitions. |
58
58
  | `@azure-tools/typespec-azure-core/documentation-required` | Require documentation over enums, models, and operations. |
59
- | `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have an explicit visibility setting. |
59
+ | `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have a Lifecycle visibility setting. |
60
60
  | `@azure-tools/typespec-azure-core/response-schema-problem` | Warn about operations having multiple non-error response schemas. |
61
61
  | `@azure-tools/typespec-azure-core/rpc-operation-request-body` | Warning for RPC body problems. |
62
62
  | [`@azure-tools/typespec-azure-core/spread-discriminated-model`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/spread-discriminated-model) | Check a model with a discriminator has not been used in composition. |
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-csv-collection-format.d.ts","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B;;EAqBxC,CAAC"}
1
+ {"version":3,"file":"prefer-csv-collection-format.d.ts","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B;;EAsBxC,CAAC"}
@@ -14,6 +14,7 @@ export const preferCsvCollectionFormatRule = createRule({
14
14
  if (isExcludedCoreType(context.program, property))
15
15
  return;
16
16
  const headerOptions = getHeaderFieldOptions(context.program, property);
17
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
17
18
  if (headerOptions?.format !== undefined && headerOptions?.format !== "csv") {
18
19
  context.reportDiagnostic({
19
20
  target: property,
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-csv-collection-format.js","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;IACtD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,qEAAqE;IAClF,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,qEAAqE;KAC/E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,aAAa,EAAE,CAAC,QAAuB,EAAE,EAAE;gBACzC,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAE1D,MAAM,aAAa,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACvE,IAAI,aAAa,EAAE,MAAM,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,KAAK,KAAK,EAAE,CAAC;oBAC3E,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"prefer-csv-collection-format.js","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;IACtD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,qEAAqE;IAClF,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,qEAAqE;KAC/E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,aAAa,EAAE,CAAC,QAAuB,EAAE,EAAE;gBACzC,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAE1D,MAAM,aAAa,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACvE,4DAA4D;gBAC5D,IAAI,aAAa,EAAE,MAAM,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,KAAK,KAAK,EAAE,CAAC;oBAC3E,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"require-key-visibility.d.ts","sourceRoot":"","sources":["../../../src/rules/require-key-visibility.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;EA6B/B,CAAC"}
1
+ {"version":3,"file":"require-key-visibility.d.ts","sourceRoot":"","sources":["../../../src/rules/require-key-visibility.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB;;EAiC/B,CAAC"}
@@ -1,13 +1,14 @@
1
- import { createRule, getVisibility, isKey, paramMessage } from "@typespec/compiler";
1
+ import { createRule, getLifecycleVisibilityEnum, getVisibilityForClass, isKey, paramMessage, } from "@typespec/compiler";
2
2
  import { isExcludedCoreType, isInlineModel, isTemplateDeclarationType } from "./utils.js";
3
3
  export const requireKeyVisibility = createRule({
4
4
  name: "key-visibility-required",
5
- description: "Key properties need to have an explicit visibility setting.",
5
+ description: "Key properties need to have a Lifecycle visibility setting.",
6
6
  severity: "warning",
7
7
  messages: {
8
- default: paramMessage `The key property '${"name"}' does not have an explicit visibility setting, please use the @visibility decorator to set it.`,
8
+ default: paramMessage `The key property '${"name"}' has default Lifecycle visibility, please use the @visibility decorator to change it.`,
9
9
  },
10
10
  create(context) {
11
+ const Lifecycle = getLifecycleVisibilityEnum(context.program);
11
12
  return {
12
13
  model: (model) => {
13
14
  if (!isTemplateDeclarationType(model) &&
@@ -15,8 +16,9 @@ export const requireKeyVisibility = createRule({
15
16
  !isExcludedCoreType(context.program, model) &&
16
17
  model.name !== "object") {
17
18
  for (const [name, prop] of model.properties) {
18
- // eslint-disable-next-line @typescript-eslint/no-deprecated
19
- if (isKey(context.program, prop) && !getVisibility(context.program, prop)) {
19
+ const hasExplicitVisibility = getVisibilityForClass(context.program, prop, Lifecycle).size !==
20
+ Lifecycle.members.size;
21
+ if (isKey(context.program, prop) && !hasExplicitVisibility) {
20
22
  context.reportDiagnostic({
21
23
  target: prop,
22
24
  format: { name },
@@ -1 +1 @@
1
- {"version":3,"file":"require-key-visibility.js","sourceRoot":"","sources":["../../../src/rules/require-key-visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE1F,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,6DAA6D;IAC1E,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,qBAAqB,MAAM,iGAAiG;KAClJ;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,EAAE,CAAC,KAAY,EAAE,EAAE;gBACtB,IACE,CAAC,yBAAyB,CAAC,KAAK,CAAC;oBACjC,CAAC,aAAa,CA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C;oBACjC,CAAC,aAAa,CAAC,KAAK,CAAC;oBACrB,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC;oBAC3C,KAAK,CAAC,IAAI,KAAK,QAAQ,EACvB,CAAC;oBACD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;wBAC5C,MAAM,qBAAqB,GACzB,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI;4BAC5D,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;wBAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;4BAC3D,OAAO,CAAC,gBAAgB,CAAC;gCACvB,MAAM,EAAE,IAAI;gCACZ,MAAM,EAAE,EAAE,IAAI,EAAE;6BACjB,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -179,13 +179,13 @@ model InnerError {
179
179
  */
180
180
  @omitKeyProperties
181
181
  model ResourceCreateOrReplaceModel<Resource extends TypeSpec.Reflection.Model>
182
- is UpdateableProperties<DefaultKeyVisibility<Resource, "read">>;
182
+ is UpdateableProperties<DefaultKeyVisibility<Resource, Lifecycle.Read>>;
183
183
 
184
184
  /**
185
185
  * Collection of properties from a resource that are visible to create or update scopes.
186
186
  * @template Resource The type of the resource.
187
187
  */
188
- @withVisibility("create", "update")
188
+ @withVisibility(Lifecycle.Create, Lifecycle.Update)
189
189
  model CreateableAndUpdateableProperties<Resource> {
190
190
  ...Resource;
191
191
  }
@@ -196,7 +196,10 @@ model CreateableAndUpdateableProperties<Resource> {
196
196
  */
197
197
  @omitKeyProperties
198
198
  model ResourceCreateOrUpdateModel<Resource>
199
- is OptionalProperties<CreateableAndUpdateableProperties<DefaultKeyVisibility<Resource, "read">>>;
199
+ is OptionalProperties<CreateableAndUpdateableProperties<DefaultKeyVisibility<
200
+ Resource,
201
+ Lifecycle.Read
202
+ >>>;
200
203
 
201
204
  /**
202
205
  * Version of a model for an update operation which only includes updateable properties.
@@ -204,7 +207,7 @@ model ResourceCreateOrUpdateModel<Resource>
204
207
  */
205
208
  @omitKeyProperties
206
209
  model ResourceUpdateModel<Resource>
207
- is OptionalProperties<UpdateableProperties<DefaultKeyVisibility<Resource, "read">>>;
210
+ is OptionalProperties<UpdateableProperties<DefaultKeyVisibility<Resource, Lifecycle.Read>>>;
208
211
 
209
212
  /**
210
213
  * A model containing the keys of the provided resource.
package/lib/models.tsp CHANGED
@@ -129,22 +129,22 @@ model StandardListQueryParameters {
129
129
 
130
130
  @doc("Provides the 'If-*' headers to enable conditional (cached) responses")
131
131
  model ConditionalRequestHeaders {
132
- @visibility("read", "query", "create", "update", "delete")
132
+ @visibility(Lifecycle.Read, Lifecycle.Query, Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
133
133
  @header("If-Match")
134
134
  @doc("The request should only proceed if an entity matches this string.")
135
135
  ifMatch?: string;
136
136
 
137
- @visibility("read", "query", "create", "update", "delete")
137
+ @visibility(Lifecycle.Read, Lifecycle.Query, Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
138
138
  @header("If-None-Match")
139
139
  @doc("The request should only proceed if no entity matches this string.")
140
140
  ifNoneMatch?: string;
141
141
 
142
- @visibility("read", "query", "create", "update", "delete")
142
+ @visibility(Lifecycle.Read, Lifecycle.Query, Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
143
143
  @header("If-Unmodified-Since")
144
144
  @doc("The request should only proceed if the entity was not modified after this time.")
145
145
  ifUnmodifiedSince?: utcDateTime;
146
146
 
147
- @visibility("read", "query", "create", "update", "delete")
147
+ @visibility(Lifecycle.Read, Lifecycle.Query, Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
148
148
  @header("If-Modified-Since")
149
149
  @doc("The request should only proceed if the entity was modified after this time.")
150
150
  ifModifiedSince?: utcDateTime;
@@ -155,7 +155,7 @@ model ConditionalRequestHeaders {
155
155
  into responses and item models to convey the ETag when it cannot simply conveyed in a header.
156
156
  """)
157
157
  model EtagProperty {
158
- @visibility("read")
158
+ @visibility(Lifecycle.Read)
159
159
  @doc("The entity tag for this resource.")
160
160
  etag: eTag;
161
161
  }
@@ -163,7 +163,7 @@ model EtagProperty {
163
163
  @doc("Provides the 'ETag' header to enable conditional (cached) requests")
164
164
  model EtagResponseEnvelope {
165
165
  @header("ETag")
166
- @visibility("read")
166
+ @visibility(Lifecycle.Read)
167
167
  @doc("The entity tag for the response.")
168
168
  etagHeader?: string;
169
169
  }
@@ -172,12 +172,12 @@ model EtagResponseEnvelope {
172
172
 
173
173
  @doc("Provides the 'Repeatability-*' headers to enable repeatable requests.")
174
174
  model RepeatabilityRequestHeaders {
175
- @visibility("create", "update", "delete")
175
+ @visibility(Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
176
176
  @header("Repeatability-Request-ID")
177
177
  @doc("An opaque, globally-unique, client-generated string identifier for the request.")
178
178
  repeatabilityRequestId?: string;
179
179
 
180
- @visibility("create", "update", "delete")
180
+ @visibility(Lifecycle.Create, Lifecycle.Update, Lifecycle.Delete)
181
181
  @doc("Specifies the date and time at which the request was first created.")
182
182
  @header("Repeatability-First-Sent")
183
183
  repeatabilityFirstSent?: utcDateTime;
@@ -185,7 +185,7 @@ model RepeatabilityRequestHeaders {
185
185
 
186
186
  @doc("Provides the 'Repeatability-*' headers to enable repeatable requests.")
187
187
  model RepeatabilityResponseHeaders {
188
- @visibility("read")
188
+ @visibility(Lifecycle.Read)
189
189
  @header("Repeatability-Result")
190
190
  @doc("Indicates whether the repeatable request was accepted or rejected.")
191
191
  repeatabilityResult?: RepeatabilityResult;
@@ -214,7 +214,7 @@ model ClientRequestIdHeader {
214
214
 
215
215
  @doc("Provides the 'x-ms-request-id' header to enable request correlation in responses.")
216
216
  model RequestIdResponseHeader {
217
- @visibility("read")
217
+ @visibility(Lifecycle.Read)
218
218
  @header("x-ms-request-id")
219
219
  @doc("An opaque, globally-unique, server-generated string identifier for the request.")
220
220
  requestId?: uuid;
@@ -157,7 +157,7 @@ interface ResourceOperations<
157
157
  */
158
158
  @Foundations.Private.ensureVerb("ResourceCreateOrUpdate", "PATCH")
159
159
  @createsOrUpdatesResource(Resource)
160
- @parameterVisibility("create", "update")
160
+ @parameterVisibility(Lifecycle.Create, Lifecycle.Update)
161
161
  ResourceCreateOrUpdate<
162
162
  Resource extends TypeSpec.Reflection.Model,
163
163
  Traits extends TypeSpec.Reflection.Model = {}
@@ -192,7 +192,7 @@ interface ResourceOperations<
192
192
  */
193
193
  @Foundations.Private.ensureVerb("LongRunningResourceCreateOrUpdate", "PATCH")
194
194
  @createsOrUpdatesResource(Resource)
195
- @parameterVisibility("create", "update")
195
+ @parameterVisibility(Lifecycle.Create, Lifecycle.Update)
196
196
  LongRunningResourceCreateOrUpdate<
197
197
  Resource extends TypeSpec.Reflection.Model,
198
198
  Traits extends TypeSpec.Reflection.Model = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-core",
3
- "version": "0.52.0-dev.0",
3
+ "version": "0.52.0-dev.2",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Core library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",
@@ -39,13 +39,13 @@
39
39
  "!dist/test/**"
40
40
  ],
41
41
  "peerDependencies": {
42
- "@typespec/compiler": "~0.65.0 || >=0.66.0-dev <0.66.0",
42
+ "@typespec/compiler": "~0.65.3 || >=0.66.0-dev <0.66.0",
43
43
  "@typespec/http": "~0.65.0 || >=0.66.0-dev <0.66.0",
44
44
  "@typespec/rest": "~0.65.0 || >=0.66.0-dev <0.66.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "~22.10.10",
48
- "@typespec/compiler": "~0.65.0 || >=0.66.0-dev <0.66.0",
48
+ "@typespec/compiler": "~0.65.3 || >=0.66.0-dev <0.66.0",
49
49
  "@typespec/http": "~0.65.0 || >=0.66.0-dev <0.66.0",
50
50
  "@typespec/library-linter": "~0.65.0 || >=0.66.0-dev <0.66.0",
51
51
  "@typespec/openapi": "~0.65.0 || >=0.66.0-dev <0.66.0",