@typespec/versioning 0.79.0-dev.3 → 0.79.0-dev.5
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
|
@@ -214,7 +214,12 @@ op newName(): void;
|
|
|
214
214
|
|
|
215
215
|
#### `@returnTypeChangedFrom`
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
Declares that the return type of an operation has changed starting at a given version,
|
|
218
|
+
while keeping earlier versions consistent with the previous return type.
|
|
219
|
+
|
|
220
|
+
This decorator is used to track return type changes across API versions. When applied,
|
|
221
|
+
the operation will return `oldType` in versions before the specified `version`,
|
|
222
|
+
and the current return type definition in the specified version and later.
|
|
218
223
|
|
|
219
224
|
```typespec
|
|
220
225
|
@TypeSpec.Versioning.returnTypeChangedFrom(version: EnumMember, oldType: unknown)
|
|
@@ -226,14 +231,28 @@ Identifies when the target type changed.
|
|
|
226
231
|
|
|
227
232
|
##### Parameters
|
|
228
233
|
|
|
229
|
-
| Name | Type | Description
|
|
230
|
-
| ------- | ------------ |
|
|
231
|
-
| version | `EnumMember` | The version
|
|
232
|
-
| oldType | `unknown` | The previous type
|
|
234
|
+
| Name | Type | Description |
|
|
235
|
+
| ------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
236
|
+
| version | `EnumMember` | The version when the return type change takes effect. The new return type applies<br />from this version onwards, while the old return type applies to earlier versions. |
|
|
237
|
+
| oldType | `unknown` | The previous return type used before the specified version. |
|
|
238
|
+
|
|
239
|
+
##### Examples
|
|
240
|
+
|
|
241
|
+
```tsp
|
|
242
|
+
// In v1: returns a string
|
|
243
|
+
// In v2+: returns an int32
|
|
244
|
+
@returnTypeChangedFrom(Versions.v2, string)
|
|
245
|
+
op getUserId(): int32;
|
|
246
|
+
```
|
|
233
247
|
|
|
234
248
|
#### `@typeChangedFrom`
|
|
235
249
|
|
|
236
|
-
|
|
250
|
+
Declares that the type of a model property has changed starting at a given version,
|
|
251
|
+
while keeping earlier versions consistent with the previous type.
|
|
252
|
+
|
|
253
|
+
This decorator is used to track type changes across API versions. When applied,
|
|
254
|
+
the property will use `oldType` in versions before the specified `version`,
|
|
255
|
+
and the current type definition in the specified version and later.
|
|
237
256
|
|
|
238
257
|
```typespec
|
|
239
258
|
@TypeSpec.Versioning.typeChangedFrom(version: EnumMember, oldType: unknown)
|
|
@@ -245,10 +264,21 @@ Identifies when the target type changed.
|
|
|
245
264
|
|
|
246
265
|
##### Parameters
|
|
247
266
|
|
|
248
|
-
| Name | Type | Description
|
|
249
|
-
| ------- | ------------ |
|
|
250
|
-
| version | `EnumMember` | The version
|
|
251
|
-
| oldType | `unknown` | The previous type
|
|
267
|
+
| Name | Type | Description |
|
|
268
|
+
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
269
|
+
| version | `EnumMember` | The version when the type change takes effect. The new type applies<br />from this version onwards, while the old type applies to earlier versions. |
|
|
270
|
+
| oldType | `unknown` | The previous type used before the specified version. |
|
|
271
|
+
|
|
272
|
+
##### Examples
|
|
273
|
+
|
|
274
|
+
```tsp
|
|
275
|
+
model Foo {
|
|
276
|
+
// In v1: id is a string
|
|
277
|
+
// In v2+: id is an int32
|
|
278
|
+
@typeChangedFrom(Versions.v2, string)
|
|
279
|
+
id: int32;
|
|
280
|
+
}
|
|
281
|
+
```
|
|
252
282
|
|
|
253
283
|
#### `@useDependency`
|
|
254
284
|
|
|
@@ -124,17 +124,45 @@ export type MadeOptionalDecorator = (context: DecoratorContext, target: ModelPro
|
|
|
124
124
|
*/
|
|
125
125
|
export type MadeRequiredDecorator = (context: DecoratorContext, target: ModelProperty, version: EnumMember) => DecoratorValidatorCallbacks | void;
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* Declares that the type of a model property has changed starting at a given version,
|
|
128
|
+
* while keeping earlier versions consistent with the previous type.
|
|
128
129
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
130
|
+
* This decorator is used to track type changes across API versions. When applied,
|
|
131
|
+
* the property will use `oldType` in versions before the specified `version`,
|
|
132
|
+
* and the current type definition in the specified version and later.
|
|
133
|
+
*
|
|
134
|
+
* @param version The version when the type change takes effect. The new type applies
|
|
135
|
+
* from this version onwards, while the old type applies to earlier versions.
|
|
136
|
+
* @param oldType The previous type used before the specified version.
|
|
137
|
+
* @example
|
|
138
|
+
* ```tsp
|
|
139
|
+
* model Foo {
|
|
140
|
+
* // In v1: id is a string
|
|
141
|
+
* // In v2+: id is an int32
|
|
142
|
+
* @typeChangedFrom(Versions.v2, string)
|
|
143
|
+
* id: int32;
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
131
146
|
*/
|
|
132
147
|
export type TypeChangedFromDecorator = (context: DecoratorContext, target: ModelProperty, version: EnumMember, oldType: Type) => DecoratorValidatorCallbacks | void;
|
|
133
148
|
/**
|
|
134
|
-
*
|
|
149
|
+
* Declares that the return type of an operation has changed starting at a given version,
|
|
150
|
+
* while keeping earlier versions consistent with the previous return type.
|
|
151
|
+
*
|
|
152
|
+
* This decorator is used to track return type changes across API versions. When applied,
|
|
153
|
+
* the operation will return `oldType` in versions before the specified `version`,
|
|
154
|
+
* and the current return type definition in the specified version and later.
|
|
135
155
|
*
|
|
136
|
-
* @param version The version
|
|
137
|
-
*
|
|
156
|
+
* @param version The version when the return type change takes effect. The new return type applies
|
|
157
|
+
* from this version onwards, while the old return type applies to earlier versions.
|
|
158
|
+
* @param oldType The previous return type used before the specified version.
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsp
|
|
161
|
+
* // In v1: returns a string
|
|
162
|
+
* // In v2+: returns an int32
|
|
163
|
+
* @returnTypeChangedFrom(Versions.v2, string)
|
|
164
|
+
* op getUserId(): int32;
|
|
165
|
+
* ```
|
|
138
166
|
*/
|
|
139
167
|
export type ReturnTypeChangedFromDecorator = (context: DecoratorContext, target: Operation, version: EnumMember, oldType: Type) => DecoratorValidatorCallbacks | void;
|
|
140
168
|
export type TypeSpecVersioningDecorators = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.Versioning.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.Versioning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,IAAI,EACJ,UAAU,EACV,SAAS,EACT,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,IAAI,KACX,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,GAAG,cAAc,EAAE,UAAU,EAAE,KAC5B,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EACF,KAAK,GACL,aAAa,GACb,SAAS,GACT,IAAI,GACJ,UAAU,GACV,KAAK,GACL,YAAY,GACZ,MAAM,GACN,SAAS,EACb,OAAO,EAAE,UAAU,KAChB,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EACF,KAAK,GACL,aAAa,GACb,SAAS,GACT,IAAI,GACJ,UAAU,GACV,KAAK,GACL,YAAY,GACZ,MAAM,GACN,SAAS,EACb,OAAO,EAAE,UAAU,KAChB,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EACF,KAAK,GACL,aAAa,GACb,SAAS,GACT,IAAI,GACJ,UAAU,GACV,KAAK,GACL,YAAY,GACZ,MAAM,GACN,SAAS,EACb,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,MAAM,KACZ,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,UAAU,KAChB,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,UAAU,KAChB,2BAA2B,GAAG,IAAI,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"TypeSpec.Versioning.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.Versioning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,IAAI,EACJ,UAAU,EACV,SAAS,EACT,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,IAAI,KACX,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,GAAG,cAAc,EAAE,UAAU,EAAE,KAC5B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gBAAgB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,IAAI,KACV,2BAA2B,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,8BAA8B,GAAG,CAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,IAAI,KACV,2BAA2B,GAAG,IAAI,CAAC;AAExC,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,sBAAsB,CAAC;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,WAAW,EAAE,oBAAoB,CAAC;IAClC,YAAY,EAAE,qBAAqB,CAAC;IACpC,YAAY,EAAE,qBAAqB,CAAC;IACpC,eAAe,EAAE,wBAAwB,CAAC;IAC1C,qBAAqB,EAAE,8BAA8B,CAAC;CACvD,CAAC"}
|
package/lib/decorators.tsp
CHANGED
|
@@ -178,15 +178,49 @@ extern dec madeOptional(target: ModelProperty, version: EnumMember);
|
|
|
178
178
|
extern dec madeRequired(target: ModelProperty, version: EnumMember);
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
181
|
+
* Declares that the type of a model property has changed starting at a given version,
|
|
182
|
+
* while keeping earlier versions consistent with the previous type.
|
|
183
|
+
*
|
|
184
|
+
* This decorator is used to track type changes across API versions. When applied,
|
|
185
|
+
* the property will use `oldType` in versions before the specified `version`,
|
|
186
|
+
* and the current type definition in the specified version and later.
|
|
187
|
+
*
|
|
188
|
+
* @param version The version when the type change takes effect. The new type applies
|
|
189
|
+
* from this version onwards, while the old type applies to earlier versions.
|
|
190
|
+
* @param oldType The previous type used before the specified version.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
*
|
|
194
|
+
* ```tsp
|
|
195
|
+
* model Foo {
|
|
196
|
+
* // In v1: id is a string
|
|
197
|
+
* // In v2+: id is an int32
|
|
198
|
+
* @typeChangedFrom(Versions.v2, string)
|
|
199
|
+
* id: int32;
|
|
200
|
+
* }
|
|
201
|
+
* ```
|
|
184
202
|
*/
|
|
185
203
|
extern dec typeChangedFrom(target: ModelProperty, version: EnumMember, oldType: unknown);
|
|
186
204
|
|
|
187
205
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
206
|
+
* Declares that the return type of an operation has changed starting at a given version,
|
|
207
|
+
* while keeping earlier versions consistent with the previous return type.
|
|
208
|
+
*
|
|
209
|
+
* This decorator is used to track return type changes across API versions. When applied,
|
|
210
|
+
* the operation will return `oldType` in versions before the specified `version`,
|
|
211
|
+
* and the current return type definition in the specified version and later.
|
|
212
|
+
*
|
|
213
|
+
* @param version The version when the return type change takes effect. The new return type applies
|
|
214
|
+
* from this version onwards, while the old return type applies to earlier versions.
|
|
215
|
+
* @param oldType The previous return type used before the specified version.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
*
|
|
219
|
+
* ```tsp
|
|
220
|
+
* // In v1: returns a string
|
|
221
|
+
* // In v2+: returns an int32
|
|
222
|
+
* @returnTypeChangedFrom(Versions.v2, string)
|
|
223
|
+
* op getUserId(): int32;
|
|
224
|
+
* ```
|
|
191
225
|
*/
|
|
192
226
|
extern dec returnTypeChangedFrom(target: Operation, version: EnumMember, oldType: unknown);
|
package/package.json
CHANGED