@typespec/compiler 0.55.0-dev.5 → 0.55.0-dev.7
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/dist/generated-defs/TypeSpec.d.ts +498 -0
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -0
- package/dist/generated-defs/TypeSpec.js +2 -0
- package/dist/generated-defs/TypeSpec.js.map +1 -0
- package/dist/generated-defs/TypeSpec.ts-test.d.ts +2 -0
- package/dist/generated-defs/TypeSpec.ts-test.d.ts.map +1 -0
- package/dist/generated-defs/TypeSpec.ts-test.js +45 -0
- package/dist/generated-defs/TypeSpec.ts-test.js.map +1 -0
- package/dist/manifest.js +2 -2
- package/dist/src/lib/decorators.d.ts +40 -40
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +84 -80
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/service.d.ts +3 -2
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/lib/service.js +10 -2
- package/dist/src/lib/service.js.map +1 -1
- package/dist/src/server/tmlanguage.d.ts.map +1 -1
- package/dist/src/server/tmlanguage.js +3 -2
- package/dist/src/server/tmlanguage.js.map +1 -1
- package/dist/typespec.tmLanguage +12 -0
- package/package.json +2 -1
- package/dist/.scripts/build-init-templates.d.ts +0 -2
- package/dist/.scripts/build-init-templates.d.ts.map +0 -1
- package/dist/.scripts/build-init-templates.js +0 -48
- package/dist/.scripts/build-init-templates.js.map +0 -1
- package/dist/.scripts/helpers.d.ts +0 -4
- package/dist/.scripts/helpers.d.ts.map +0 -1
- package/dist/.scripts/helpers.js +0 -44
- package/dist/.scripts/helpers.js.map +0 -1
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import type { DecoratorContext, Enum, Interface, Model, ModelProperty, Namespace, Operation, Scalar, Type, Union } from "../src/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Specify how to encode the target type.
|
|
4
|
+
*
|
|
5
|
+
* @param encoding Known name of an encoding.
|
|
6
|
+
* @param encodedAs What target type is this being encoded as. Default to string.
|
|
7
|
+
* @example offsetDateTime encoded with rfc7231
|
|
8
|
+
*
|
|
9
|
+
* ```tsp
|
|
10
|
+
* @encode("rfc7231")
|
|
11
|
+
* scalar myDateTime extends offsetDateTime;
|
|
12
|
+
* ```
|
|
13
|
+
* @example utcDateTime encoded with unixTimestamp
|
|
14
|
+
*
|
|
15
|
+
* ```tsp
|
|
16
|
+
* @encode("unixTimestamp", int32)
|
|
17
|
+
* scalar myDateTime extends unixTimestamp;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type EncodeDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, encoding: Type, encodedAs?: Scalar) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Attach a documentation string.
|
|
23
|
+
*
|
|
24
|
+
* @param doc Documentation string
|
|
25
|
+
* @param formatArgs Record with key value pair that can be interpolated in the doc.
|
|
26
|
+
* @example
|
|
27
|
+
* ```typespec
|
|
28
|
+
* @doc("Represent a Pet available in the PetStore")
|
|
29
|
+
* model Pet {}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export type DocDecorator = (context: DecoratorContext, target: Type, doc: string, formatArgs?: Type) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the model with required properties removed.
|
|
35
|
+
*/
|
|
36
|
+
export type WithOptionalPropertiesDecorator = (context: DecoratorContext, target: Model) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the model with non-updateable properties removed.
|
|
39
|
+
*/
|
|
40
|
+
export type WithUpdateablePropertiesDecorator = (context: DecoratorContext, target: Model) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the model with the given properties omitted.
|
|
43
|
+
*
|
|
44
|
+
* @param omit List of properties to omit
|
|
45
|
+
*/
|
|
46
|
+
export type WithoutOmittedPropertiesDecorator = (context: DecoratorContext, target: Model, omit: Type) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the model with any default values removed.
|
|
49
|
+
*/
|
|
50
|
+
export type WithoutDefaultValuesDecorator = (context: DecoratorContext, target: Model) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Set the visibility of key properties in a model if not already set.
|
|
53
|
+
*
|
|
54
|
+
* @param visibility The desired default visibility value. If a key property already has a `visibility` decorator then the default visibility is not applied.
|
|
55
|
+
*/
|
|
56
|
+
export type WithDefaultKeyVisibilityDecorator = (context: DecoratorContext, target: Model, visibility: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Typically a short, single-line description.
|
|
59
|
+
*
|
|
60
|
+
* @param summary Summary string.
|
|
61
|
+
* @example
|
|
62
|
+
* ```typespec
|
|
63
|
+
* @summary("This is a pet")
|
|
64
|
+
* model Pet {}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export type SummaryDecorator = (context: DecoratorContext, target: Type, summary: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Attach a documentation string to describe the successful return types of an operation.
|
|
70
|
+
* If an operation returns a union of success and errors it only describe the success. See `@errorsDoc` for error documentation.
|
|
71
|
+
*
|
|
72
|
+
* @param doc Documentation string
|
|
73
|
+
* @example
|
|
74
|
+
* ```typespec
|
|
75
|
+
* @returnsDoc("Returns doc")
|
|
76
|
+
* op get(): Pet | NotFound;
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export type ReturnsDocDecorator = (context: DecoratorContext, target: Operation, doc: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Attach a documentation string to describe the error return types of an operation.
|
|
82
|
+
* If an operation returns a union of success and errors it only describe the errors. See `@errorsDoc` for success documentation.
|
|
83
|
+
*
|
|
84
|
+
* @param doc Documentation string
|
|
85
|
+
* @example
|
|
86
|
+
* ```typespec
|
|
87
|
+
* @errorsDoc("Returns doc")
|
|
88
|
+
* op get(): Pet | NotFound;
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export type ErrorsDocDecorator = (context: DecoratorContext, target: Operation, doc: string) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Mark this type as deprecated.
|
|
94
|
+
*
|
|
95
|
+
* NOTE: This decorator **should not** be used, use the `#deprecated` directive instead.
|
|
96
|
+
*
|
|
97
|
+
* @deprecated Use the `#deprecated` directive instead.
|
|
98
|
+
* @param message Deprecation message.
|
|
99
|
+
* @example
|
|
100
|
+
* Use the `#deprecated` directive instead:
|
|
101
|
+
*
|
|
102
|
+
* ```typespec
|
|
103
|
+
* #deprecated "Use ActionV2"
|
|
104
|
+
* op Action<Result>(): Result;
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export type DeprecatedDecorator = (context: DecoratorContext, target: Type, message: string) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Mark this namespace as describing a service and configure service properties.
|
|
110
|
+
*
|
|
111
|
+
* @param options Optional configuration for the service.
|
|
112
|
+
* @example
|
|
113
|
+
* ```typespec
|
|
114
|
+
* @service
|
|
115
|
+
* namespace PetStore;
|
|
116
|
+
* ```
|
|
117
|
+
* @example Setting service title
|
|
118
|
+
* ```typespec
|
|
119
|
+
* @service({title: "Pet store"})
|
|
120
|
+
* namespace PetStore;
|
|
121
|
+
* ```
|
|
122
|
+
* @example Setting service version
|
|
123
|
+
* ```typespec
|
|
124
|
+
* @service({version: "1.0"})
|
|
125
|
+
* namespace PetStore;
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export type ServiceDecorator = (context: DecoratorContext, target: Namespace, options?: Type) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Specify that this model is an error type. Operations return error types when the operation has failed.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typespec
|
|
134
|
+
* @error
|
|
135
|
+
* model PetStoreError {
|
|
136
|
+
* code: string;
|
|
137
|
+
* message: string;
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export type ErrorDecorator = (context: DecoratorContext, target: Model) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Specify a known data format hint for this string type. For example `uuid`, `uri`, etc.
|
|
144
|
+
* This differs from the `@pattern` decorator which is meant to specify a regular expression while `@format` accepts a known format name.
|
|
145
|
+
* The format names are open ended and are left to emitter to interpret.
|
|
146
|
+
*
|
|
147
|
+
* @param format format name.
|
|
148
|
+
* @example
|
|
149
|
+
* ```typespec
|
|
150
|
+
* @format("uuid")
|
|
151
|
+
* scalar uuid extends string;
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export type FormatDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, format: string) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Specify the the pattern this string should respect using simple regular expression syntax.
|
|
157
|
+
* The following syntax is allowed: alternations (`|`), quantifiers (`?`, `*`, `+`, and `{ }`), wildcard (`.`), and grouping parentheses.
|
|
158
|
+
* Advanced features like look-around, capture groups, and references are not supported.
|
|
159
|
+
*
|
|
160
|
+
* This decorator may optionally provide a custom validation _message_. Emitters may choose to use the message to provide
|
|
161
|
+
* context when pattern validation fails. For the sake of consistency, the message should be a phrase that describes in
|
|
162
|
+
* plain language what sort of content the pattern attempts to validate. For example, a complex regular expression that
|
|
163
|
+
* validates a GUID string might have a message like "Must be a valid GUID."
|
|
164
|
+
*
|
|
165
|
+
* @param pattern Regular expression.
|
|
166
|
+
* @param validationMessage Optional validation message that may provide context when validation fails.
|
|
167
|
+
* @example
|
|
168
|
+
* ```typespec
|
|
169
|
+
* @pattern("[a-z]+", "Must be a string consisting of only lower case letters and of at least one character.")
|
|
170
|
+
* scalar LowerAlpha extends string;
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export type PatternDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, pattern: string, validationMessage?: string) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Specify the minimum length this string type should be.
|
|
176
|
+
*
|
|
177
|
+
* @param value Minimum length
|
|
178
|
+
* @example
|
|
179
|
+
* ```typespec
|
|
180
|
+
* @minLength(2)
|
|
181
|
+
* scalar Username extends string;
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export type MinLengthDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
185
|
+
/**
|
|
186
|
+
* Specify the maximum length this string type should be.
|
|
187
|
+
*
|
|
188
|
+
* @param value Maximum length
|
|
189
|
+
* @example
|
|
190
|
+
* ```typespec
|
|
191
|
+
* @maxLength(20)
|
|
192
|
+
* scalar Username extends string;
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export type MaxLengthDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Specify the minimum number of items this array should have.
|
|
198
|
+
*
|
|
199
|
+
* @param value Minimum number
|
|
200
|
+
* @example
|
|
201
|
+
* ```typespec
|
|
202
|
+
* @minItems(1)
|
|
203
|
+
* model Endpoints is string[];
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export type MinItemsDecorator = (context: DecoratorContext, target: Type | ModelProperty, value: number) => void;
|
|
207
|
+
/**
|
|
208
|
+
* Specify the maximum number of items this array should have.
|
|
209
|
+
*
|
|
210
|
+
* @param value Maximum number
|
|
211
|
+
* @example
|
|
212
|
+
* ```typespec
|
|
213
|
+
* @maxItems(5)
|
|
214
|
+
* model Endpoints is string[];
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export type MaxItemsDecorator = (context: DecoratorContext, target: Type | ModelProperty, value: number) => void;
|
|
218
|
+
/**
|
|
219
|
+
* Specify the minimum value this numeric type should be.
|
|
220
|
+
*
|
|
221
|
+
* @param value Minimum value
|
|
222
|
+
* @example
|
|
223
|
+
* ```typespec
|
|
224
|
+
* @minValue(18)
|
|
225
|
+
* scalar Age is int32;
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export type MinValueDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Specify the maximum value this numeric type should be.
|
|
231
|
+
*
|
|
232
|
+
* @param value Maximum value
|
|
233
|
+
* @example
|
|
234
|
+
* ```typespec
|
|
235
|
+
* @maxValue(200)
|
|
236
|
+
* scalar Age is int32;
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export type MaxValueDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
240
|
+
/**
|
|
241
|
+
* Specify the minimum value this numeric type should be, exclusive of the given
|
|
242
|
+
* value.
|
|
243
|
+
*
|
|
244
|
+
* @param value Minimum value
|
|
245
|
+
* @example
|
|
246
|
+
* ```typespec
|
|
247
|
+
* @minValueExclusive(0)
|
|
248
|
+
* scalar distance is float64;
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export type MinValueExclusiveDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
252
|
+
/**
|
|
253
|
+
* Specify the maximum value this numeric type should be, exclusive of the given
|
|
254
|
+
* value.
|
|
255
|
+
*
|
|
256
|
+
* @param value Maximum value
|
|
257
|
+
* @example
|
|
258
|
+
* ```typespec
|
|
259
|
+
* @maxValueExclusive(50)
|
|
260
|
+
* scalar distance is float64;
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export type MaxValueExclusiveDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: number) => void;
|
|
264
|
+
/**
|
|
265
|
+
* Mark this string as a secret value that should be treated carefully to avoid exposure
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typespec
|
|
269
|
+
* @secret
|
|
270
|
+
* scalar Password is string;
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
export type SecretDecorator = (context: DecoratorContext, target: Scalar | ModelProperty) => void;
|
|
274
|
+
/**
|
|
275
|
+
* Mark this operation as a `list` operation for resource types.
|
|
276
|
+
*
|
|
277
|
+
* @deprecated Use the `listsResource` decorator in `@typespec/rest` instead.
|
|
278
|
+
* @param listedType Optional type of the items in the list.
|
|
279
|
+
*/
|
|
280
|
+
export type ListDecorator = (context: DecoratorContext, target: Operation, listedType?: Model) => void;
|
|
281
|
+
/**
|
|
282
|
+
* Attaches a tag to an operation, interface, or namespace. Multiple `@tag` decorators can be specified to attach multiple tags to a TypeSpec element.
|
|
283
|
+
*
|
|
284
|
+
* @param tag Tag value
|
|
285
|
+
*/
|
|
286
|
+
export type TagDecorator = (context: DecoratorContext, target: Namespace | Interface | Operation, tag: string) => void;
|
|
287
|
+
/**
|
|
288
|
+
* Specifies how a templated type should name their instances.
|
|
289
|
+
*
|
|
290
|
+
* @param name name the template instance should take
|
|
291
|
+
* @param formatArgs Model with key value used to interpolate the name
|
|
292
|
+
* @example
|
|
293
|
+
* ```typespec
|
|
294
|
+
* @friendlyName("{name}List", T)
|
|
295
|
+
* model List<Item> {
|
|
296
|
+
* value: Item[];
|
|
297
|
+
* nextLink: string;
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
export type FriendlyNameDecorator = (context: DecoratorContext, target: Type, name: string, formatArgs?: Type) => void;
|
|
302
|
+
/**
|
|
303
|
+
* Provide a set of known values to a string type.
|
|
304
|
+
*
|
|
305
|
+
* @param values Known values enum.
|
|
306
|
+
* @example
|
|
307
|
+
* ```typespec
|
|
308
|
+
* @knownValues(KnownErrorCode)
|
|
309
|
+
* scalar ErrorCode extends string;
|
|
310
|
+
*
|
|
311
|
+
* enum KnownErrorCode {
|
|
312
|
+
* NotFound,
|
|
313
|
+
* Invalid,
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export type KnownValuesDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, values: Enum) => void;
|
|
318
|
+
/**
|
|
319
|
+
* Mark a model property as the key to identify instances of that type
|
|
320
|
+
*
|
|
321
|
+
* @param altName Name of the property. If not specified, the decorated property name is used.
|
|
322
|
+
* @example
|
|
323
|
+
* ```typespec
|
|
324
|
+
* model Pet {
|
|
325
|
+
* @key id: string;
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
export type KeyDecorator = (context: DecoratorContext, target: ModelProperty, altName?: string) => void;
|
|
330
|
+
/**
|
|
331
|
+
* Specify this operation is an overload of the given operation.
|
|
332
|
+
*
|
|
333
|
+
* @param overloadbase Base operation that should be a union of all overloads
|
|
334
|
+
* @example
|
|
335
|
+
* ```typespec
|
|
336
|
+
* op upload(data: string | bytes, @header contentType: "text/plain" | "application/octet-stream"): void;
|
|
337
|
+
* @overload(upload)
|
|
338
|
+
* op uploadString(data: string, @header contentType: "text/plain" ): void;
|
|
339
|
+
* @overload(upload)
|
|
340
|
+
* op uploadBytes(data: bytes, @header contentType: "application/octet-stream"): void;
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
export type OverloadDecorator = (context: DecoratorContext, target: Operation, overloadbase: Operation) => void;
|
|
344
|
+
/**
|
|
345
|
+
* DEPRECATED: Use `@encodedName` instead.
|
|
346
|
+
*
|
|
347
|
+
* Provide an alternative name for this type.
|
|
348
|
+
*
|
|
349
|
+
* @param targetName Projection target
|
|
350
|
+
* @param projectedName Alternative name
|
|
351
|
+
* @example
|
|
352
|
+
* ```typespec
|
|
353
|
+
* model Certificate {
|
|
354
|
+
* @projectedName("json", "exp")
|
|
355
|
+
* expireAt: int32;
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
export type ProjectedNameDecorator = (context: DecoratorContext, target: Type, targetName: string, projectedName: string) => void;
|
|
360
|
+
/**
|
|
361
|
+
* Provide an alternative name for this type when serialized to the given mime type.
|
|
362
|
+
*
|
|
363
|
+
* @param mimeType Mime type this should apply to. The mime type should be a known mime type as described here https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types without any suffix (e.g. `+json`)
|
|
364
|
+
* @param name Alternative name
|
|
365
|
+
* @example
|
|
366
|
+
* ```typespec
|
|
367
|
+
* model Certificate {
|
|
368
|
+
* @encodedName("application/json", "exp")
|
|
369
|
+
* @encodedName("application/xml", "expiry")
|
|
370
|
+
* expireAt: int32;
|
|
371
|
+
* }
|
|
372
|
+
* ```
|
|
373
|
+
* @example Invalid values
|
|
374
|
+
*
|
|
375
|
+
* ```typespec
|
|
376
|
+
* @encodedName("application/merge-patch+json", "exp")
|
|
377
|
+
* ^ error cannot use subtype
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
export type EncodedNameDecorator = (context: DecoratorContext, target: Type, mimeType: string, name: string) => void;
|
|
381
|
+
/**
|
|
382
|
+
* Specify the property to be used to discriminate this type.
|
|
383
|
+
*
|
|
384
|
+
* @param propertyName The property name to use for discrimination
|
|
385
|
+
* @example
|
|
386
|
+
* ```typespec
|
|
387
|
+
* @discriminator("kind")
|
|
388
|
+
* union Pet{ cat: Cat, dog: Dog }
|
|
389
|
+
*
|
|
390
|
+
* model Cat {kind: "cat", meow: boolean}
|
|
391
|
+
* model Dog {kind: "dog", bark: boolean}
|
|
392
|
+
* ```
|
|
393
|
+
*
|
|
394
|
+
* ```typespec
|
|
395
|
+
* @discriminator("kind")
|
|
396
|
+
* model Pet{ kind: string }
|
|
397
|
+
*
|
|
398
|
+
* model Cat extends Pet {kind: "cat", meow: boolean}
|
|
399
|
+
* model Dog extends Pet {kind: "dog", bark: boolean}
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export type DiscriminatorDecorator = (context: DecoratorContext, target: Model | Union, propertyName: string) => void;
|
|
403
|
+
/**
|
|
404
|
+
* Indicates that a property is only considered to be present or applicable ("visible") with
|
|
405
|
+
* the in the given named contexts ("visibilities"). When a property has no visibilities applied
|
|
406
|
+
* to it, it is implicitly visible always.
|
|
407
|
+
*
|
|
408
|
+
* As far as the TypeSpec core library is concerned, visibilities are open-ended and can be arbitrary
|
|
409
|
+
* strings, but the following visibilities are well-known to standard libraries and should be used
|
|
410
|
+
* with standard emitters that interpret them as follows:
|
|
411
|
+
*
|
|
412
|
+
* - "read": output of any operation.
|
|
413
|
+
* - "create": input to operations that create an entity..
|
|
414
|
+
* - "query": input to operations that read data.
|
|
415
|
+
* - "update": input to operations that update data.
|
|
416
|
+
* - "delete": input to operations that delete data.
|
|
417
|
+
*
|
|
418
|
+
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
|
419
|
+
*
|
|
420
|
+
* @param visibilities List of visibilities which apply to this property.
|
|
421
|
+
* @example
|
|
422
|
+
* ```typespec
|
|
423
|
+
* model Dog {
|
|
424
|
+
* // the service will generate an ID, so you don't need to send it.
|
|
425
|
+
* @visibility("read") id: int32;
|
|
426
|
+
* // the service will store this secret name, but won't ever return it
|
|
427
|
+
* @visibility("create", "update") secretName: string;
|
|
428
|
+
* // the regular name is always present
|
|
429
|
+
* name: string;
|
|
430
|
+
* }
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
export type VisibilityDecorator = (context: DecoratorContext, target: ModelProperty, ...visibilities: string[]) => void;
|
|
434
|
+
/**
|
|
435
|
+
* Removes properties that are not considered to be present or applicable
|
|
436
|
+
* ("visible") in the given named contexts ("visibilities"). Can be used
|
|
437
|
+
* together with spread to effectively spread only visible properties into
|
|
438
|
+
* a new model.
|
|
439
|
+
*
|
|
440
|
+
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
|
441
|
+
*
|
|
442
|
+
* When using an emitter that applies visibility automatically, it is generally
|
|
443
|
+
* not necessary to use this decorator.
|
|
444
|
+
*
|
|
445
|
+
* @param visibilities List of visibilities which apply to this property.
|
|
446
|
+
* @example
|
|
447
|
+
* ```typespec
|
|
448
|
+
* model Dog {
|
|
449
|
+
* @visibility("read") id: int32;
|
|
450
|
+
* @visibility("create", "update") secretName: string;
|
|
451
|
+
* name: string;
|
|
452
|
+
* }
|
|
453
|
+
*
|
|
454
|
+
* // The spread operator will copy all the properties of Dog into DogRead,
|
|
455
|
+
* // and @withVisibility will then remove those that are not visible with
|
|
456
|
+
* // create or update visibility.
|
|
457
|
+
* //
|
|
458
|
+
* // In this case, the id property is removed, and the name and secretName
|
|
459
|
+
* // properties are kept.
|
|
460
|
+
* @withVisibility("create", "update")
|
|
461
|
+
* model DogCreateOrUpdate {
|
|
462
|
+
* ...Dog;
|
|
463
|
+
* }
|
|
464
|
+
*
|
|
465
|
+
* // In this case the id and name properties are kept and the secretName property
|
|
466
|
+
* // is removed.
|
|
467
|
+
* @withVisibility("read")
|
|
468
|
+
* model DogRead {
|
|
469
|
+
* ...Dog;
|
|
470
|
+
* }
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
export type WithVisibilityDecorator = (context: DecoratorContext, target: Model, ...visibilities: string[]) => void;
|
|
474
|
+
/**
|
|
475
|
+
* A debugging decorator used to inspect a type.
|
|
476
|
+
*
|
|
477
|
+
* @param text Custom text to log
|
|
478
|
+
*/
|
|
479
|
+
export type InspectTypeDecorator = (context: DecoratorContext, target: Type, text: string) => void;
|
|
480
|
+
/**
|
|
481
|
+
* A debugging decorator used to inspect a type name.
|
|
482
|
+
*
|
|
483
|
+
* @param text Custom text to log
|
|
484
|
+
*/
|
|
485
|
+
export type InspectTypeNameDecorator = (context: DecoratorContext, target: Type, text: string) => void;
|
|
486
|
+
/**
|
|
487
|
+
* Sets which visibilities apply to parameters for the given operation.
|
|
488
|
+
*
|
|
489
|
+
* @param visibilities List of visibility strings which apply to this operation.
|
|
490
|
+
*/
|
|
491
|
+
export type ParameterVisibilityDecorator = (context: DecoratorContext, target: Operation, ...visibilities: string[]) => void;
|
|
492
|
+
/**
|
|
493
|
+
* Sets which visibilities apply to the return type for the given operation.
|
|
494
|
+
*
|
|
495
|
+
* @param visibilities List of visibility strings which apply to this operation.
|
|
496
|
+
*/
|
|
497
|
+
export type ReturnTypeVisibilityDecorator = (context: DecoratorContext, target: Operation, ...visibilities: string[]) => void;
|
|
498
|
+
//# sourceMappingURL=TypeSpec.d.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E,KACtB,IAAI,CAAC;AAEV;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAC1C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,GAAG,YAAY,EAAE,MAAM,EAAE,KACtB,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSpec.js","sourceRoot":"","sources":["../../generated-defs/TypeSpec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSpec.ts-test.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.ts-test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
|
|
2
|
+
import { $deprecated, $discriminator, $doc, $encode, $encodedName, $error, $errorsDoc, $format, $friendlyName, $inspectType, $inspectTypeName, $key, $knownValues, $list, $maxItems, $maxLength, $maxValue, $maxValueExclusive, $minItems, $minLength, $minValue, $minValueExclusive, $overload, $parameterVisibility, $pattern, $projectedName, $returnTypeVisibility, $returnsDoc, $secret, $service, $summary, $tag, $visibility, $withDefaultKeyVisibility, $withOptionalProperties, $withUpdateableProperties, $withVisibility, $withoutDefaultValues, $withoutOmittedProperties, } from "../src/index.js";
|
|
3
|
+
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
|
|
4
|
+
const _ = {
|
|
5
|
+
$encode,
|
|
6
|
+
$doc,
|
|
7
|
+
$withOptionalProperties,
|
|
8
|
+
$withUpdateableProperties,
|
|
9
|
+
$withoutOmittedProperties,
|
|
10
|
+
$withoutDefaultValues,
|
|
11
|
+
$withDefaultKeyVisibility,
|
|
12
|
+
$summary,
|
|
13
|
+
$returnsDoc,
|
|
14
|
+
$errorsDoc,
|
|
15
|
+
$deprecated,
|
|
16
|
+
$service,
|
|
17
|
+
$error,
|
|
18
|
+
$format,
|
|
19
|
+
$pattern,
|
|
20
|
+
$minLength,
|
|
21
|
+
$maxLength,
|
|
22
|
+
$minItems,
|
|
23
|
+
$maxItems,
|
|
24
|
+
$minValue,
|
|
25
|
+
$maxValue,
|
|
26
|
+
$minValueExclusive,
|
|
27
|
+
$maxValueExclusive,
|
|
28
|
+
$secret,
|
|
29
|
+
$list,
|
|
30
|
+
$tag,
|
|
31
|
+
$friendlyName,
|
|
32
|
+
$knownValues,
|
|
33
|
+
$key,
|
|
34
|
+
$overload,
|
|
35
|
+
$projectedName,
|
|
36
|
+
$encodedName,
|
|
37
|
+
$discriminator,
|
|
38
|
+
$visibility,
|
|
39
|
+
$withVisibility,
|
|
40
|
+
$inspectType,
|
|
41
|
+
$inspectTypeName,
|
|
42
|
+
$parameterVisibility,
|
|
43
|
+
$returnTypeVisibility,
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=TypeSpec.ts-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSpec.ts-test.js","sourceRoot":"","sources":["../../generated-defs/TypeSpec.ts-test.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EACL,WAAW,EACX,cAAc,EACd,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,MAAM,EACN,UAAU,EACV,OAAO,EACP,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EACpB,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAqFzB,qKAAqK;AACrK,MAAM,CAAC,GAAe;IACpB,OAAO;IACP,IAAI;IACJ,uBAAuB;IACvB,yBAAyB;IACzB,yBAAyB;IACzB,qBAAqB;IACrB,yBAAyB;IACzB,QAAQ;IACR,WAAW;IACX,UAAU;IACV,WAAW;IACX,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,UAAU;IACV,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,OAAO;IACP,KAAK;IACL,IAAI;IACJ,aAAa;IACb,YAAY;IACZ,IAAI;IACJ,SAAS;IACT,cAAc;IACd,YAAY;IACZ,cAAc;IACd,WAAW;IACX,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC"}
|
package/dist/manifest.js
CHANGED