@typespec/compiler 0.65.0-dev.1 → 0.65.0-dev.3
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 +66 -32
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +1 -2
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/compiler-code-fixes/convert-to-value.codefix.d.ts +10 -0
- package/dist/src/core/compiler-code-fixes/convert-to-value.codefix.d.ts.map +1 -0
- package/dist/src/core/compiler-code-fixes/convert-to-value.codefix.js +68 -0
- package/dist/src/core/compiler-code-fixes/convert-to-value.codefix.js.map +1 -0
- package/dist/src/core/visibility/core.d.ts +13 -0
- package/dist/src/core/visibility/core.d.ts.map +1 -1
- package/dist/src/core/visibility/core.js +19 -20
- package/dist/src/core/visibility/core.js.map +1 -1
- package/dist/src/core/visibility/index.d.ts +1 -1
- package/dist/src/core/visibility/index.d.ts.map +1 -1
- package/dist/src/core/visibility/index.js +1 -1
- package/dist/src/core/visibility/index.js.map +1 -1
- package/dist/src/core/visibility/lifecycle.d.ts.map +1 -1
- package/dist/src/core/visibility/lifecycle.js +8 -0
- package/dist/src/core/visibility/lifecycle.js.map +1 -1
- package/dist/src/lib/visibility.d.ts +54 -0
- package/dist/src/lib/visibility.d.ts.map +1 -1
- package/dist/src/lib/visibility.js +84 -1
- package/dist/src/lib/visibility.js.map +1 -1
- package/lib/std/visibility.tsp +210 -36
- package/package.json +1 -1
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.d.ts +0 -6
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.d.ts.map +0 -1
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.js +0 -15
- package/dist/src/core/compiler-code-fixes/model-to-object-literal.codefix.js.map +0 -1
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.d.ts +0 -6
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.d.ts.map +0 -1
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.js +0 -15
- package/dist/src/core/compiler-code-fixes/tuple-to-array-value.codefix.js.map +0 -1
package/lib/std/visibility.tsp
CHANGED
|
@@ -8,19 +8,31 @@ using TypeSpec.Reflection;
|
|
|
8
8
|
namespace TypeSpec;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* to it, it is implicitly visible always.
|
|
11
|
+
* Sets the visibility modifiers that are active on a property, indicating that it is only considered to be present
|
|
12
|
+
* (or "visible") in contexts that select for the given modifiers.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* with standard emitters that interpret them as follows:
|
|
14
|
+
* A property without any visibility settings applied for any visibility class (e.g. `Lifecycle`) is considered to have
|
|
15
|
+
* the default visibility settings for that class.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
17
|
+
* If visibility for the property has already been set for a visibility class (for example, using `@invisible` or
|
|
18
|
+
* `@removeVisibility`), this decorator will **add** the specified visibility modifiers to the property.
|
|
19
|
+
*
|
|
20
|
+
* See: [Visibility](https://typespec.io/docs/language-basics/visibility)
|
|
21
|
+
*
|
|
22
|
+
* The `@typespec/http` library uses `Lifecycle` visibility to determine which properties are included in the request or
|
|
23
|
+
* response bodies of HTTP operations. By default, it uses the following visibility settings:
|
|
24
|
+
*
|
|
25
|
+
* - For the return type of operations, properties are included if they have `Lifecycle.Read` visibility.
|
|
26
|
+
* - For POST operation parameters, properties are included if they have `Lifecycle.Create` visibility.
|
|
27
|
+
* - For PUT operation parameters, properties are included if they have `Lifecycle.Create` or `Lifecycle.Update` visibility.
|
|
28
|
+
* - For PATCH operation parameters, properties are included if they have `Lifecycle.Update` visibility.
|
|
29
|
+
* - For DELETE operation parameters, properties are included if they have `Lifecycle.Delete` visibility.
|
|
30
|
+
* - For GET or HEAD operation parameters, properties are included if they have `Lifecycle.Query` visibility.
|
|
31
|
+
*
|
|
32
|
+
* By default, properties have all five Lifecycle visibility modifiers enabled, so a property is visible in all contexts
|
|
33
|
+
* by default.
|
|
34
|
+
*
|
|
35
|
+
* The default settings may be overridden using the `@returnTypeVisibility` and `@parameterVisibility` decorators.
|
|
24
36
|
*
|
|
25
37
|
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
|
26
38
|
*
|
|
@@ -30,11 +42,15 @@ namespace TypeSpec;
|
|
|
30
42
|
*
|
|
31
43
|
* ```typespec
|
|
32
44
|
* model Dog {
|
|
33
|
-
* //
|
|
34
|
-
* @visibility(Lifecycle.Read)
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* //
|
|
45
|
+
* // The service will generate an ID, so you don't need to send it.
|
|
46
|
+
* @visibility(Lifecycle.Read)
|
|
47
|
+
* id: int32;
|
|
48
|
+
*
|
|
49
|
+
* // The service will store this secret name, but won't ever return it.
|
|
50
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
51
|
+
* secretName: string;
|
|
52
|
+
*
|
|
53
|
+
* // The regular name has all vi
|
|
38
54
|
* name: string;
|
|
39
55
|
* }
|
|
40
56
|
* ```
|
|
@@ -45,7 +61,8 @@ extern dec visibility(target: ModelProperty, ...visibilities: valueof (string |
|
|
|
45
61
|
* Indicates that a property is not visible in the given visibility class.
|
|
46
62
|
*
|
|
47
63
|
* This decorator removes all active visibility modifiers from the property within
|
|
48
|
-
* the given visibility class
|
|
64
|
+
* the given visibility class, making it invisible to any context that selects for
|
|
65
|
+
* visibility modifiers within that class.
|
|
49
66
|
*
|
|
50
67
|
* @param visibilityClass The visibility class to make the property invisible within.
|
|
51
68
|
*
|
|
@@ -72,8 +89,8 @@ extern dec invisible(target: ModelProperty, visibilityClass: Enum);
|
|
|
72
89
|
* @example
|
|
73
90
|
* ```typespec
|
|
74
91
|
* model Example {
|
|
75
|
-
* // This property will have
|
|
76
|
-
* //
|
|
92
|
+
* // This property will have all Lifecycle visibilities except the Read
|
|
93
|
+
* // visibility, since it is removed.
|
|
77
94
|
* @removeVisibility(Lifecycle.Read)
|
|
78
95
|
* secret_property: string;
|
|
79
96
|
* }
|
|
@@ -82,23 +99,27 @@ extern dec invisible(target: ModelProperty, visibilityClass: Enum);
|
|
|
82
99
|
extern dec removeVisibility(target: ModelProperty, ...visibilities: valueof EnumMember[]);
|
|
83
100
|
|
|
84
101
|
/**
|
|
85
|
-
* Removes properties that
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
102
|
+
* Removes properties that do not have at least one of the given visibility modifiers
|
|
103
|
+
* active.
|
|
104
|
+
*
|
|
105
|
+
* If no visibility modifiers are supplied, this decorator has no effect.
|
|
89
106
|
*
|
|
90
107
|
* See also: [Automatic visibility](https://typespec.io/docs/libraries/http/operations#automatic-visibility)
|
|
91
108
|
*
|
|
92
109
|
* When using an emitter that applies visibility automatically, it is generally
|
|
93
110
|
* not necessary to use this decorator.
|
|
94
111
|
*
|
|
95
|
-
* @param visibilities List of visibilities
|
|
112
|
+
* @param visibilities List of visibilities that apply to this property.
|
|
96
113
|
*
|
|
97
114
|
* @example
|
|
98
115
|
* ```typespec
|
|
99
116
|
* model Dog {
|
|
100
|
-
* @visibility(
|
|
101
|
-
*
|
|
117
|
+
* @visibility(Lifecycle.Read)
|
|
118
|
+
* id: int32;
|
|
119
|
+
*
|
|
120
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
121
|
+
* secretName: string;
|
|
122
|
+
*
|
|
102
123
|
* name: string;
|
|
103
124
|
* }
|
|
104
125
|
*
|
|
@@ -108,14 +129,14 @@ extern dec removeVisibility(target: ModelProperty, ...visibilities: valueof Enum
|
|
|
108
129
|
* //
|
|
109
130
|
* // In this case, the id property is removed, and the name and secretName
|
|
110
131
|
* // properties are kept.
|
|
111
|
-
* @withVisibility(
|
|
132
|
+
* @withVisibility(Lifecycle.Create, Lifecycle.Update)
|
|
112
133
|
* model DogCreateOrUpdate {
|
|
113
134
|
* ...Dog;
|
|
114
135
|
* }
|
|
115
136
|
*
|
|
116
137
|
* // In this case the id and name properties are kept and the secretName property
|
|
117
138
|
* // is removed.
|
|
118
|
-
* @withVisibility(
|
|
139
|
+
* @withVisibility(Lifecycle.Read)
|
|
119
140
|
* model DogRead {
|
|
120
141
|
* ...Dog;
|
|
121
142
|
* }
|
|
@@ -141,15 +162,29 @@ extern dec withVisibility(target: Model, ...visibilities: valueof (string | Enum
|
|
|
141
162
|
extern dec withDefaultKeyVisibility(target: Model, visibility: valueof string | EnumMember);
|
|
142
163
|
|
|
143
164
|
/**
|
|
144
|
-
*
|
|
165
|
+
* Declares the visibility constraint of the parameters of a given operation.
|
|
145
166
|
*
|
|
146
|
-
*
|
|
167
|
+
* A parameter or property nested within a parameter will be visible if it has _any_ of the visibilities
|
|
168
|
+
* in the list.
|
|
169
|
+
*
|
|
170
|
+
* WARNING: If no arguments are provided to this decorator, the `@typespec/http` library considers only properties
|
|
171
|
+
* that do not have visibility modifiers _explicitly_ configured to be visible. Additionally, the HTTP library will
|
|
172
|
+
* disable the feature of `@patch` operations that causes the properties of the request body to become effectively
|
|
173
|
+
* optional. Some specifications have used this configuration in the past to describe exact PATCH bodies, but using this
|
|
174
|
+
* decorator with no arguments in that manner is not recommended. The legacy behavior of `@parameterVisibility` with no
|
|
175
|
+
* arguments is preserved for backwards compatibility pending a future review and possible deprecation.
|
|
176
|
+
*
|
|
177
|
+
* @param visibilities List of visibility modifiers that apply to the parameters of this operation.
|
|
147
178
|
*/
|
|
148
179
|
extern dec parameterVisibility(target: Operation, ...visibilities: valueof (string | EnumMember)[]);
|
|
149
180
|
|
|
150
181
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
182
|
+
* Declares the visibility constraint of the return type of a given operation.
|
|
183
|
+
*
|
|
184
|
+
* A property within the return type of the operation will be visible if it has _any_ of the visibilities
|
|
185
|
+
* in the list, or if the list is empty (in which case the property is always visible).
|
|
186
|
+
*
|
|
187
|
+
* @param visibilities List of visibility modifiers that apply to the return type of this operation.
|
|
153
188
|
*/
|
|
154
189
|
extern dec returnTypeVisibility(
|
|
155
190
|
target: Operation,
|
|
@@ -176,14 +211,17 @@ extern dec defaultVisibility(target: Enum, ...visibilities: valueof EnumMember[]
|
|
|
176
211
|
/**
|
|
177
212
|
* A visibility class for resource lifecycle phases.
|
|
178
213
|
*
|
|
179
|
-
* These visibilities control whether a property is visible during the
|
|
180
|
-
* lifecycle.
|
|
214
|
+
* These visibilities control whether a property is visible during the various phases of a resource's lifecycle.
|
|
181
215
|
*
|
|
182
216
|
* @example
|
|
183
217
|
* ```typespec
|
|
184
218
|
* model Dog {
|
|
185
|
-
* @visibility(Lifecycle.Read)
|
|
186
|
-
*
|
|
219
|
+
* @visibility(Lifecycle.Read)
|
|
220
|
+
* id: int32;
|
|
221
|
+
*
|
|
222
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
223
|
+
* secretName: string;
|
|
224
|
+
*
|
|
187
225
|
* name: string;
|
|
188
226
|
* }
|
|
189
227
|
* ```
|
|
@@ -195,9 +233,32 @@ extern dec defaultVisibility(target: Enum, ...visibilities: valueof EnumMember[]
|
|
|
195
233
|
* therefore visible in all phases.
|
|
196
234
|
*/
|
|
197
235
|
enum Lifecycle {
|
|
236
|
+
/**
|
|
237
|
+
* The property is visible when a resource is being created.
|
|
238
|
+
*/
|
|
198
239
|
Create,
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The property is visible when a resource is being read.
|
|
243
|
+
*/
|
|
199
244
|
Read,
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The property is visible when a resource is being updated.
|
|
248
|
+
*/
|
|
200
249
|
Update,
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The property is visible when a resource is being deleted.
|
|
253
|
+
*/
|
|
254
|
+
Delete,
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The property is visible when a resource is being queried.
|
|
258
|
+
*
|
|
259
|
+
* In HTTP APIs, this visibility applies to parameters of GET or HEAD operations.
|
|
260
|
+
*/
|
|
261
|
+
Query,
|
|
201
262
|
}
|
|
202
263
|
|
|
203
264
|
/**
|
|
@@ -293,6 +354,7 @@ extern dec withLifecycleUpdate(target: Model);
|
|
|
293
354
|
* name: string;
|
|
294
355
|
* }
|
|
295
356
|
*
|
|
357
|
+
* // This model has only the `name` field.
|
|
296
358
|
* model CreateDog is Create<Dog>;
|
|
297
359
|
* ```
|
|
298
360
|
*/
|
|
@@ -306,6 +368,9 @@ model Create<T extends Reflection.Model, NameTemplate extends valueof string = "
|
|
|
306
368
|
* A copy of the input model `T` with only the properties that are visible during the
|
|
307
369
|
* "Read" resource lifecycle phase.
|
|
308
370
|
*
|
|
371
|
+
* The "Read" lifecycle phase is used for properties returned by operations that read data, like
|
|
372
|
+
* HTTP GET operations.
|
|
373
|
+
*
|
|
309
374
|
* This transformation is recursive, and will include only properties that have the
|
|
310
375
|
* `Lifecycle.Read` visibility modifier.
|
|
311
376
|
*
|
|
@@ -321,9 +386,13 @@ model Create<T extends Reflection.Model, NameTemplate extends valueof string = "
|
|
|
321
386
|
* @visibility(Lifecycle.Read)
|
|
322
387
|
* id: int32;
|
|
323
388
|
*
|
|
389
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
390
|
+
* secretName: string;
|
|
391
|
+
*
|
|
324
392
|
* name: string;
|
|
325
393
|
* }
|
|
326
394
|
*
|
|
395
|
+
* // This model has the `id` and `name` fields, but not `secretName`.
|
|
327
396
|
* model ReadDog is Read<Dog>;
|
|
328
397
|
* ```
|
|
329
398
|
*/
|
|
@@ -337,6 +406,9 @@ model Read<T extends Reflection.Model, NameTemplate extends valueof string = "Re
|
|
|
337
406
|
* A copy of the input model `T` with only the properties that are visible during the
|
|
338
407
|
* "Update" resource lifecycle phase.
|
|
339
408
|
*
|
|
409
|
+
* The "Update" lifecycle phase is used for properties passed as parameters to operations
|
|
410
|
+
* that update data, like HTTP PATCH operations.
|
|
411
|
+
*
|
|
340
412
|
* This transformation will include only the properties that have the `Lifecycle.Update`
|
|
341
413
|
* visibility modifier, and the types of all properties will be replaced with the
|
|
342
414
|
* equivalent `CreateOrUpdate` transformation.
|
|
@@ -353,9 +425,13 @@ model Read<T extends Reflection.Model, NameTemplate extends valueof string = "Re
|
|
|
353
425
|
* @visibility(Lifecycle.Read)
|
|
354
426
|
* id: int32;
|
|
355
427
|
*
|
|
428
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
429
|
+
* secretName: string;
|
|
430
|
+
*
|
|
356
431
|
* name: string;
|
|
357
432
|
* }
|
|
358
433
|
*
|
|
434
|
+
* // This model will have the `secretName` and `name` fields, but not the `id` field.
|
|
359
435
|
* model UpdateDog is Update<Dog>;
|
|
360
436
|
* ```
|
|
361
437
|
*/
|
|
@@ -369,6 +445,9 @@ model Update<T extends Reflection.Model, NameTemplate extends valueof string = "
|
|
|
369
445
|
* A copy of the input model `T` with only the properties that are visible during the
|
|
370
446
|
* "Create" or "Update" resource lifecycle phases.
|
|
371
447
|
*
|
|
448
|
+
* The "CreateOrUpdate" lifecycle phase is used by default for properties passed as parameters to operations
|
|
449
|
+
* that can create _or_ update data, like HTTP PUT operations.
|
|
450
|
+
*
|
|
372
451
|
* This transformation is recursive, and will include only properties that have the
|
|
373
452
|
* `Lifecycle.Create` or `Lifecycle.Update` visibility modifier.
|
|
374
453
|
*
|
|
@@ -384,9 +463,16 @@ model Update<T extends Reflection.Model, NameTemplate extends valueof string = "
|
|
|
384
463
|
* @visibility(Lifecycle.Read)
|
|
385
464
|
* id: int32;
|
|
386
465
|
*
|
|
466
|
+
* @visibility(Lifecycle.Create)
|
|
467
|
+
* immutableSecret: string;
|
|
468
|
+
*
|
|
469
|
+
* @visibility(Lifecycle.Create, Lifecycle.Update)
|
|
470
|
+
* secretName: string;
|
|
471
|
+
*
|
|
387
472
|
* name: string;
|
|
388
473
|
* }
|
|
389
474
|
*
|
|
475
|
+
* // This model will have the `immutableSecret`, `secretName`, and `name` fields, but not the `id` field.
|
|
390
476
|
* model CreateOrUpdateDog is CreateOrUpdate<Dog>;
|
|
391
477
|
* ```
|
|
392
478
|
*/
|
|
@@ -398,3 +484,91 @@ model CreateOrUpdate<
|
|
|
398
484
|
> {
|
|
399
485
|
...T;
|
|
400
486
|
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* A copy of the input model `T` with only the properties that are visible during the
|
|
490
|
+
* "Delete" resource lifecycle phase.
|
|
491
|
+
*
|
|
492
|
+
* The "Delete" lifecycle phase is used for properties passed as parameters to operations
|
|
493
|
+
* that delete data, like HTTP DELETE operations.
|
|
494
|
+
*
|
|
495
|
+
* This transformation is recursive, and will include only properties that have the
|
|
496
|
+
* `Lifecycle.Delete` visibility modifier.
|
|
497
|
+
*
|
|
498
|
+
* If a `NameTemplate` is provided, the new model will be named according to the template.
|
|
499
|
+
* The template uses the same syntax as the `@friendlyName` decorator.
|
|
500
|
+
*
|
|
501
|
+
* @template T The model to transform.
|
|
502
|
+
* @template NameTemplate The name template to use for the new model.
|
|
503
|
+
*
|
|
504
|
+
* * @example
|
|
505
|
+
* ```typespec
|
|
506
|
+
* model Dog {
|
|
507
|
+
* @visibility(Lifecycle.Read)
|
|
508
|
+
* id: int32;
|
|
509
|
+
*
|
|
510
|
+
* // Set when the Dog is removed from our data store. This happens when the
|
|
511
|
+
* // Dog is re-homed to a new owner.
|
|
512
|
+
* @visibility(Lifecycle.Delete)
|
|
513
|
+
* nextOwner: string;
|
|
514
|
+
*
|
|
515
|
+
* name: string;
|
|
516
|
+
* }
|
|
517
|
+
*
|
|
518
|
+
* // This model will have the `nextOwner` and `name` fields, but not the `id` field.
|
|
519
|
+
* model DeleteDog is Delete<Dog>;
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
@friendlyName(NameTemplate, T)
|
|
523
|
+
@withVisibilityFilter(#{ all: #[Lifecycle.Delete] })
|
|
524
|
+
model Delete<T extends Reflection.Model, NameTemplate extends valueof string = "Delete{name}"> {
|
|
525
|
+
...T;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* A copy of the input model `T` with only the properties that are visible during the
|
|
530
|
+
* "Query" resource lifecycle phase.
|
|
531
|
+
*
|
|
532
|
+
* The "Query" lifecycle phase is used for properties passed as parameters to operations
|
|
533
|
+
* that read data, like HTTP GET or HEAD operations. This should not be confused for
|
|
534
|
+
* the `@query` decorator, which specifies that the property is transmitted in the
|
|
535
|
+
* query string of an HTTP request.
|
|
536
|
+
*
|
|
537
|
+
* This transformation is recursive, and will include only properties that have the
|
|
538
|
+
* `Lifecycle.Query` visibility modifier.
|
|
539
|
+
*
|
|
540
|
+
* If a `NameTemplate` is provided, the new model will be named according to the template.
|
|
541
|
+
* The template uses the same syntax as the `@friendlyName` decorator.
|
|
542
|
+
*
|
|
543
|
+
* @template T The model to transform.
|
|
544
|
+
* @template NameTemplate The name template to use for the new model.
|
|
545
|
+
*
|
|
546
|
+
* * @example
|
|
547
|
+
* ```typespec
|
|
548
|
+
* model Dog {
|
|
549
|
+
* @visibility(Lifecycle.Read)
|
|
550
|
+
* id: int32;
|
|
551
|
+
*
|
|
552
|
+
* // When getting information for a Dog, you can set this field to true to include
|
|
553
|
+
* // some extra information about the Dog's pedigree that is normally not returned.
|
|
554
|
+
* // Alternatively, you could just use a separate option parameter to get this
|
|
555
|
+
* // information.
|
|
556
|
+
* @visibility(Lifecycle.Query)
|
|
557
|
+
* includePedigree?: boolean;
|
|
558
|
+
*
|
|
559
|
+
* name: string;
|
|
560
|
+
*
|
|
561
|
+
* // Only included if `includePedigree` is set to true in the request.
|
|
562
|
+
* @visibility(Lifecycle.Read)
|
|
563
|
+
* pedigree?: string;
|
|
564
|
+
* }
|
|
565
|
+
*
|
|
566
|
+
* // This model will have the `includePedigree` and `name` fields, but not `id` or `pedigree`.
|
|
567
|
+
* model QueryDog is Query<Dog>;
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
@friendlyName(NameTemplate, T)
|
|
571
|
+
@withVisibilityFilter(#{ all: #[Lifecycle.Query] })
|
|
572
|
+
model Query<T extends Reflection.Model, NameTemplate extends valueof string = "Query{name}"> {
|
|
573
|
+
...T;
|
|
574
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ModelExpressionNode } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Quick fix that convert a model expression to an object value.
|
|
4
|
-
*/
|
|
5
|
-
export declare function createModelToObjectValueCodeFix(node: ModelExpressionNode): import("../types.js").CodeFix;
|
|
6
|
-
//# sourceMappingURL=model-to-object-literal.codefix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-to-object-literal.codefix.d.ts","sourceRoot":"","sources":["../../../../src/core/compiler-code-fixes/model-to-object-literal.codefix.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,mBAAmB,iCASxE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineCodeFix, getSourceLocation } from "../diagnostics.js";
|
|
2
|
-
/**
|
|
3
|
-
* Quick fix that convert a model expression to an object value.
|
|
4
|
-
*/
|
|
5
|
-
export function createModelToObjectValueCodeFix(node) {
|
|
6
|
-
return defineCodeFix({
|
|
7
|
-
id: "model-to-object-value",
|
|
8
|
-
label: `Convert to an object value \`#{}\``,
|
|
9
|
-
fix: (context) => {
|
|
10
|
-
const location = getSourceLocation(node);
|
|
11
|
-
return context.prependText(location, "#");
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=model-to-object-literal.codefix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model-to-object-literal.codefix.js","sourceRoot":"","sources":["../../../../src/core/compiler-code-fixes/model-to-object-literal.codefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGrE;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAAC,IAAyB;IACvE,OAAO,aAAa,CAAC;QACnB,EAAE,EAAE,uBAAuB;QAC3B,KAAK,EAAE,oCAAoC;QAC3C,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACf,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACzC,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TupleExpressionNode } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Quick fix that convert a tuple to an array value.
|
|
4
|
-
*/
|
|
5
|
-
export declare function createTupleToArrayValueCodeFix(node: TupleExpressionNode): import("../types.js").CodeFix;
|
|
6
|
-
//# sourceMappingURL=tuple-to-array-value.codefix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuple-to-array-value.codefix.d.ts","sourceRoot":"","sources":["../../../../src/core/compiler-code-fixes/tuple-to-array-value.codefix.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,mBAAmB,iCASvE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineCodeFix, getSourceLocation } from "../diagnostics.js";
|
|
2
|
-
/**
|
|
3
|
-
* Quick fix that convert a tuple to an array value.
|
|
4
|
-
*/
|
|
5
|
-
export function createTupleToArrayValueCodeFix(node) {
|
|
6
|
-
return defineCodeFix({
|
|
7
|
-
id: "tuple-to-array-value",
|
|
8
|
-
label: `Convert to an array value \`#[]\``,
|
|
9
|
-
fix: (context) => {
|
|
10
|
-
const location = getSourceLocation(node);
|
|
11
|
-
return context.prependText(location, "#");
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=tuple-to-array-value.codefix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuple-to-array-value.codefix.js","sourceRoot":"","sources":["../../../../src/core/compiler-code-fixes/tuple-to-array-value.codefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGrE;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAyB;IACtE,OAAO,aAAa,CAAC;QACnB,EAAE,EAAE,sBAAsB;QAC1B,KAAK,EAAE,mCAAmC;QAC1C,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACf,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACzC,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|