@typespec/compiler 1.18.0-dev.4 → 1.18.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/dist/generated-defs/TypeSpec.d.ts +69 -1
- package/dist/generated-defs/TypeSpec.d.ts.map +1 -1
- package/dist/manifest.js +2 -2
- package/dist/src/config/config-to-options.d.ts +2 -0
- package/dist/src/config/config-to-options.d.ts.map +1 -1
- package/dist/src/config/config-to-options.js.map +1 -1
- package/dist/src/config/types.d.ts +26 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/checker.d.ts +23 -0
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/core/code-fixes.d.ts +6 -0
- package/dist/src/core/code-fixes.d.ts.map +1 -1
- package/dist/src/core/code-fixes.js +6 -0
- package/dist/src/core/code-fixes.js.map +1 -1
- package/dist/src/core/compiler-code-fixes/suppress.codefix.d.ts +7 -0
- package/dist/src/core/compiler-code-fixes/suppress.codefix.d.ts.map +1 -1
- package/dist/src/core/compiler-code-fixes/suppress.codefix.js +7 -0
- package/dist/src/core/compiler-code-fixes/suppress.codefix.js.map +1 -1
- package/dist/src/core/decorator-utils.d.ts +17 -0
- package/dist/src/core/decorator-utils.d.ts.map +1 -1
- package/dist/src/core/decorator-utils.js +5 -0
- package/dist/src/core/decorator-utils.js.map +1 -1
- package/dist/src/core/diagnostics.d.ts +9 -0
- package/dist/src/core/diagnostics.d.ts.map +1 -1
- package/dist/src/core/diagnostics.js +2 -0
- package/dist/src/core/diagnostics.js.map +1 -1
- package/dist/src/core/emitter-utils.d.ts +5 -0
- package/dist/src/core/emitter-utils.d.ts.map +1 -1
- package/dist/src/core/emitter-utils.js.map +1 -1
- package/dist/src/core/file-ref.d.ts +2 -0
- package/dist/src/core/file-ref.d.ts.map +1 -1
- package/dist/src/core/file-ref.js +1 -0
- package/dist/src/core/file-ref.js.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.d.ts +14 -0
- package/dist/src/core/helpers/discriminator-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/discriminator-utils.js +5 -0
- package/dist/src/core/helpers/discriminator-utils.js.map +1 -1
- package/dist/src/core/helpers/location-context.d.ts +1 -0
- package/dist/src/core/helpers/location-context.d.ts.map +1 -1
- package/dist/src/core/helpers/location-context.js +1 -0
- package/dist/src/core/helpers/location-context.js.map +1 -1
- package/dist/src/core/helpers/operation-utils.d.ts +1 -0
- package/dist/src/core/helpers/operation-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/operation-utils.js.map +1 -1
- package/dist/src/core/helpers/type-name-utils.d.ts +7 -0
- package/dist/src/core/helpers/type-name-utils.d.ts.map +1 -1
- package/dist/src/core/helpers/type-name-utils.js +3 -0
- package/dist/src/core/helpers/type-name-utils.js.map +1 -1
- package/dist/src/core/helpers/usage-resolver.d.ts +9 -0
- package/dist/src/core/helpers/usage-resolver.d.ts.map +1 -1
- package/dist/src/core/helpers/usage-resolver.js +4 -0
- package/dist/src/core/helpers/usage-resolver.js.map +1 -1
- package/dist/src/core/intrinsic-type-state.d.ts +44 -17
- package/dist/src/core/intrinsic-type-state.d.ts.map +1 -1
- package/dist/src/core/intrinsic-type-state.js +41 -17
- package/dist/src/core/intrinsic-type-state.js.map +1 -1
- package/dist/src/core/library.d.ts +2 -0
- package/dist/src/core/library.d.ts.map +1 -1
- package/dist/src/core/library.js +2 -0
- package/dist/src/core/library.js.map +1 -1
- package/dist/src/core/logger/console-sink.d.ts +4 -0
- package/dist/src/core/logger/console-sink.d.ts.map +1 -1
- package/dist/src/core/logger/console-sink.js +1 -0
- package/dist/src/core/logger/console-sink.js.map +1 -1
- package/dist/src/core/numeric.d.ts +11 -1
- package/dist/src/core/numeric.d.ts.map +1 -1
- package/dist/src/core/numeric.js.map +1 -1
- package/dist/src/core/options.d.ts +8 -2
- package/dist/src/core/options.d.ts.map +1 -1
- package/dist/src/core/param-message.d.ts +9 -0
- package/dist/src/core/param-message.d.ts.map +1 -1
- package/dist/src/core/param-message.js +9 -0
- package/dist/src/core/param-message.js.map +1 -1
- package/dist/src/core/parser.d.ts +19 -0
- package/dist/src/core/parser.d.ts.map +1 -1
- package/dist/src/core/parser.js +18 -0
- package/dist/src/core/parser.js.map +1 -1
- package/dist/src/core/path-utils.d.ts +24 -0
- package/dist/src/core/path-utils.d.ts.map +1 -1
- package/dist/src/core/path-utils.js +9 -1
- package/dist/src/core/path-utils.js.map +1 -1
- package/dist/src/core/perf.d.ts +8 -1
- package/dist/src/core/perf.d.ts.map +1 -1
- package/dist/src/core/perf.js +8 -1
- package/dist/src/core/perf.js.map +1 -1
- package/dist/src/core/program.d.ts +31 -1
- package/dist/src/core/program.d.ts.map +1 -1
- package/dist/src/core/program.js +5 -0
- package/dist/src/core/program.js.map +1 -1
- package/dist/src/core/semantic-walker.d.ts +20 -5
- package/dist/src/core/semantic-walker.d.ts.map +1 -1
- package/dist/src/core/semantic-walker.js +13 -3
- package/dist/src/core/semantic-walker.js.map +1 -1
- package/dist/src/core/source-file.d.ts +2 -0
- package/dist/src/core/source-file.d.ts.map +1 -1
- package/dist/src/core/source-file.js +2 -0
- package/dist/src/core/source-file.js.map +1 -1
- package/dist/src/core/type-utils.d.ts +8 -0
- package/dist/src/core/type-utils.d.ts.map +1 -1
- package/dist/src/core/type-utils.js +8 -0
- package/dist/src/core/type-utils.js.map +1 -1
- package/dist/src/core/types.d.ts +1004 -46
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js +130 -5
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/experimental/mutators.d.ts +32 -3
- package/dist/src/experimental/mutators.d.ts.map +1 -1
- package/dist/src/experimental/mutators.js +11 -3
- package/dist/src/experimental/mutators.js.map +1 -1
- package/dist/src/experimental/realm.d.ts +34 -1
- package/dist/src/experimental/realm.d.ts.map +1 -1
- package/dist/src/experimental/realm.js +34 -1
- package/dist/src/experimental/realm.js.map +1 -1
- package/dist/src/init/core-templates.d.ts +3 -0
- package/dist/src/init/core-templates.d.ts.map +1 -1
- package/dist/src/init/core-templates.js.map +1 -1
- package/dist/src/init/init-template.d.ts +9 -0
- package/dist/src/init/init-template.d.ts.map +1 -1
- package/dist/src/init/init-template.js.map +1 -1
- package/dist/src/init/scaffold.d.ts +1 -0
- package/dist/src/init/scaffold.d.ts.map +1 -1
- package/dist/src/init/scaffold.js.map +1 -1
- package/dist/src/init/template-source/types.d.ts +2 -0
- package/dist/src/init/template-source/types.d.ts.map +1 -1
- package/dist/src/init/template-source/types.js.map +1 -1
- package/dist/src/lib/decorators.d.ts +84 -2
- package/dist/src/lib/decorators.d.ts.map +1 -1
- package/dist/src/lib/decorators.js +71 -7
- package/dist/src/lib/decorators.js.map +1 -1
- package/dist/src/lib/encoded-names.d.ts +4 -0
- package/dist/src/lib/encoded-names.d.ts.map +1 -1
- package/dist/src/lib/encoded-names.js +4 -0
- package/dist/src/lib/encoded-names.js.map +1 -1
- package/dist/src/lib/examples.d.ts +29 -2
- package/dist/src/lib/examples.d.ts.map +1 -1
- package/dist/src/lib/examples.js +25 -2
- package/dist/src/lib/examples.js.map +1 -1
- package/dist/src/lib/key.d.ts +2 -0
- package/dist/src/lib/key.d.ts.map +1 -1
- package/dist/src/lib/key.js +2 -0
- package/dist/src/lib/key.js.map +1 -1
- package/dist/src/lib/paging.d.ts +27 -0
- package/dist/src/lib/paging.d.ts.map +1 -1
- package/dist/src/lib/paging.js +7 -0
- package/dist/src/lib/paging.js.map +1 -1
- package/dist/src/lib/service.d.ts +9 -2
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/lib/service.js +5 -2
- package/dist/src/lib/service.js.map +1 -1
- package/dist/src/lib/visibility.d.ts +44 -10
- package/dist/src/lib/visibility.d.ts.map +1 -1
- package/dist/src/lib/visibility.js +42 -10
- package/dist/src/lib/visibility.js.map +1 -1
- package/dist/src/manifest.d.ts +2 -0
- package/dist/src/manifest.d.ts.map +1 -1
- package/dist/src/manifest.js +1 -0
- package/dist/src/manifest.js.map +1 -1
- package/dist/src/module-resolver/module-resolver.d.ts +12 -1
- package/dist/src/module-resolver/module-resolver.d.ts.map +1 -1
- package/dist/src/module-resolver/module-resolver.js +7 -1
- package/dist/src/module-resolver/module-resolver.js.map +1 -1
- package/dist/src/module-resolver/types.d.ts +14 -1
- package/dist/src/module-resolver/types.d.ts.map +1 -1
- package/dist/src/server/client-config-provider.d.ts +14 -0
- package/dist/src/server/client-config-provider.d.ts.map +1 -1
- package/dist/src/server/client-config-provider.js.map +1 -1
- package/dist/src/server/server-compile-manager.d.ts +30 -4
- package/dist/src/server/server-compile-manager.d.ts.map +1 -1
- package/dist/src/server/server-compile-manager.js +21 -0
- package/dist/src/server/server-compile-manager.js.map +1 -1
- package/dist/src/server/serverlib.d.ts +9 -0
- package/dist/src/server/serverlib.d.ts.map +1 -1
- package/dist/src/server/serverlib.js +9 -0
- package/dist/src/server/serverlib.js.map +1 -1
- package/dist/src/server/types.d.ts +133 -0
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/src/server/types.js +26 -0
- package/dist/src/server/types.js.map +1 -1
- package/dist/src/server/update-manager.d.ts +24 -7
- package/dist/src/server/update-manager.d.ts.map +1 -1
- package/dist/src/server/update-manager.js +16 -7
- package/dist/src/server/update-manager.js.map +1 -1
- package/dist/src/testing/code-fix-testing.d.ts +2 -0
- package/dist/src/testing/code-fix-testing.d.ts.map +1 -1
- package/dist/src/testing/code-fix-testing.js.map +1 -1
- package/dist/src/testing/expect.d.ts +16 -10
- package/dist/src/testing/expect.d.ts.map +1 -1
- package/dist/src/testing/expect.js +9 -3
- package/dist/src/testing/expect.js.map +1 -1
- package/dist/src/testing/fourslash.d.ts +3 -3
- package/dist/src/testing/fourslash.d.ts.map +1 -1
- package/dist/src/testing/fs.d.ts +4 -0
- package/dist/src/testing/fs.d.ts.map +1 -1
- package/dist/src/testing/fs.js +4 -0
- package/dist/src/testing/fs.js.map +1 -1
- package/dist/src/testing/marked-template.d.ts +25 -2
- package/dist/src/testing/marked-template.d.ts.map +1 -1
- package/dist/src/testing/marked-template.js +7 -2
- package/dist/src/testing/marked-template.js.map +1 -1
- package/dist/src/testing/rule-tester.d.ts +22 -0
- package/dist/src/testing/rule-tester.d.ts.map +1 -1
- package/dist/src/testing/rule-tester.js +9 -0
- package/dist/src/testing/rule-tester.js.map +1 -1
- package/dist/src/testing/source-utils.d.ts +7 -2
- package/dist/src/testing/source-utils.d.ts.map +1 -1
- package/dist/src/testing/source-utils.js +2 -2
- package/dist/src/testing/source-utils.js.map +1 -1
- package/dist/src/testing/test-compiler-host.d.ts +8 -0
- package/dist/src/testing/test-compiler-host.d.ts.map +1 -1
- package/dist/src/testing/test-compiler-host.js +4 -0
- package/dist/src/testing/test-compiler-host.js.map +1 -1
- package/dist/src/testing/test-host.d.ts +4 -0
- package/dist/src/testing/test-host.d.ts.map +1 -1
- package/dist/src/testing/test-host.js +4 -0
- package/dist/src/testing/test-host.js.map +1 -1
- package/dist/src/testing/test-utils.d.ts +14 -2
- package/dist/src/testing/test-utils.d.ts.map +1 -1
- package/dist/src/testing/test-utils.js +9 -0
- package/dist/src/testing/test-utils.js.map +1 -1
- package/dist/src/testing/tester.d.ts +12 -0
- package/dist/src/testing/tester.d.ts.map +1 -1
- package/dist/src/testing/tester.js +7 -0
- package/dist/src/testing/tester.js.map +1 -1
- package/dist/src/testing/types.d.ts +101 -36
- package/dist/src/testing/types.d.ts.map +1 -1
- package/dist/src/testing/types.js +4 -1
- package/dist/src/testing/types.js.map +1 -1
- package/dist/src/typekit/define-kit.d.ts +6 -0
- package/dist/src/typekit/define-kit.d.ts.map +1 -1
- package/dist/src/typekit/define-kit.js.map +1 -1
- package/dist/src/typekit/kits/array.d.ts +3 -0
- package/dist/src/typekit/kits/array.d.ts.map +1 -1
- package/dist/src/typekit/kits/array.js.map +1 -1
- package/dist/src/typekit/kits/builtin.d.ts +3 -0
- package/dist/src/typekit/kits/builtin.d.ts.map +1 -1
- package/dist/src/typekit/kits/builtin.js.map +1 -1
- package/dist/src/typekit/kits/entity.d.ts +3 -0
- package/dist/src/typekit/kits/entity.d.ts.map +1 -1
- package/dist/src/typekit/kits/entity.js.map +1 -1
- package/dist/src/typekit/kits/enum-member.d.ts +3 -0
- package/dist/src/typekit/kits/enum-member.d.ts.map +1 -1
- package/dist/src/typekit/kits/enum-member.js.map +1 -1
- package/dist/src/typekit/kits/enum.d.ts +3 -0
- package/dist/src/typekit/kits/enum.d.ts.map +1 -1
- package/dist/src/typekit/kits/enum.js.map +1 -1
- package/dist/src/typekit/kits/intrinsic.d.ts +5 -0
- package/dist/src/typekit/kits/intrinsic.d.ts.map +1 -1
- package/dist/src/typekit/kits/intrinsic.js.map +1 -1
- package/dist/src/typekit/kits/model.d.ts +4 -0
- package/dist/src/typekit/kits/model.d.ts.map +1 -1
- package/dist/src/typekit/kits/model.js.map +1 -1
- package/dist/src/typekit/kits/record.d.ts +3 -0
- package/dist/src/typekit/kits/record.d.ts.map +1 -1
- package/dist/src/typekit/kits/record.js.map +1 -1
- package/dist/src/typekit/kits/scalar.d.ts +1 -1
- package/dist/src/typekit/kits/tuple.d.ts +5 -0
- package/dist/src/typekit/kits/tuple.d.ts.map +1 -1
- package/dist/src/typekit/kits/tuple.js.map +1 -1
- package/dist/src/typekit/kits/type.d.ts +5 -0
- package/dist/src/typekit/kits/type.d.ts.map +1 -1
- package/dist/src/typekit/kits/type.js.map +1 -1
- package/dist/src/typekit/kits/value.d.ts +8 -0
- package/dist/src/typekit/kits/value.d.ts.map +1 -1
- package/dist/src/typekit/kits/value.js.map +1 -1
- package/dist/src/types/package-json.d.ts +30 -0
- package/dist/src/types/package-json.d.ts.map +1 -1
- package/dist/src/utils/misc.d.ts +6 -0
- package/dist/src/utils/misc.d.ts.map +1 -1
- package/dist/src/utils/misc.js +6 -0
- package/dist/src/utils/misc.js.map +1 -1
- package/dist/src/utils/state-accessor.d.ts +10 -0
- package/dist/src/utils/state-accessor.d.ts.map +1 -1
- package/dist/src/utils/state-accessor.js +5 -0
- package/dist/src/utils/state-accessor.js.map +1 -1
- package/dist/src/yaml/types.d.ts +3 -0
- package/dist/src/yaml/types.d.ts.map +1 -1
- package/lib/std/decorators.tsp +16 -3
- package/lib/std/visibility.tsp +14 -0
- package/package.json +1 -1
|
@@ -9,9 +9,10 @@ export * from "./service.js";
|
|
|
9
9
|
export * from "./visibility.js";
|
|
10
10
|
export type { ExampleOptions };
|
|
11
11
|
export declare const namespace = "TypeSpec";
|
|
12
|
+
/** Gets the summary stored on this type, or `undefined` if none is set. */
|
|
12
13
|
declare const getSummary: (program: Program, type: Type) => string | undefined;
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* `@summary` attaches a documentation string. It is typically used to give a short, single-line
|
|
15
16
|
* description, and can be used in combination with or instead of @doc.
|
|
16
17
|
*
|
|
17
18
|
* The first argument to @summary is a string, which may contain template parameters, enclosed in braces,
|
|
@@ -37,6 +38,7 @@ export declare const $doc: DocDecorator;
|
|
|
37
38
|
* @returns Documentation value
|
|
38
39
|
*/
|
|
39
40
|
export declare function getDoc(program: Program, target: Type): string | undefined;
|
|
41
|
+
/** Attaches documentation describing an operation's successful return types, separately from its errors. */
|
|
40
42
|
export declare const $returnsDoc: ReturnsDocDecorator;
|
|
41
43
|
/**
|
|
42
44
|
* Get the documentation information for the return success types of an operation. In most cases you probably just want to use {@link getReturnsDoc}
|
|
@@ -52,6 +54,7 @@ export declare function getReturnsDocData(program: Program, target: Operation):
|
|
|
52
54
|
* @returns Documentation value
|
|
53
55
|
*/
|
|
54
56
|
export declare function getReturnsDoc(program: Program, target: Operation): string | undefined;
|
|
57
|
+
/** Attaches documentation describing an operation's error return types, separately from its successful results. */
|
|
55
58
|
export declare const $errorsDoc: ErrorsDocDecorator;
|
|
56
59
|
/**
|
|
57
60
|
* Get the documentation information for the return errors types of an operation. In most cases you probably just want to use {@link getErrorsDoc}
|
|
@@ -67,9 +70,13 @@ export declare function getErrorsDocData(program: Program, target: Operation): D
|
|
|
67
70
|
* @returns Documentation value
|
|
68
71
|
*/
|
|
69
72
|
export declare function getErrorsDoc(program: Program, target: Operation): string | undefined;
|
|
73
|
+
/** Logs an optional nonempty label followed by the target type object, to a depth of three, for debugging. */
|
|
70
74
|
export declare const $inspectType: InspectTypeDecorator;
|
|
75
|
+
/** Logs an optional nonempty label followed by the target's formatted TypeSpec name for debugging. */
|
|
71
76
|
export declare const $inspectTypeName: InspectTypeNameDecorator;
|
|
77
|
+
/** Tests whether the target is a scalar assignable to the standard `string` type, including derived scalars. */
|
|
72
78
|
export declare function isStringType(program: Program, target: Type): target is Scalar;
|
|
79
|
+
/** Tests whether the target is a scalar assignable to the standard `numeric` type, including derived scalars. */
|
|
73
80
|
export declare function isNumericType(program: Program, target: Type): target is Scalar;
|
|
74
81
|
export declare function isDateTimeType(program: Program, target: Type): target is Scalar;
|
|
75
82
|
/**
|
|
@@ -114,6 +121,7 @@ export declare function setMediaTypeHint(program: Program, target: MediaTypeHint
|
|
|
114
121
|
* @returns the default media type hint for the target, if any
|
|
115
122
|
*/
|
|
116
123
|
export declare function getMediaTypeHint(program: Program, target: Type): string | undefined;
|
|
124
|
+
/** Gets the format hint stored on this type, or `undefined` if none is set; does not search base types. */
|
|
117
125
|
declare const getFormat: (program: Program, type: Type) => string | undefined;
|
|
118
126
|
/**
|
|
119
127
|
* `@format` - specify the data format hint for a string type
|
|
@@ -131,10 +139,14 @@ declare const getFormat: (program: Program, type: Type) => string | undefined;
|
|
|
131
139
|
export declare const $format: FormatDecorator;
|
|
132
140
|
export { getFormat };
|
|
133
141
|
declare const getPatternData: (program: Program, type: Type) => PatternData | undefined;
|
|
142
|
+
/** A string validation pattern and optional human-readable explanation supplied by `@pattern`. */
|
|
134
143
|
export interface PatternData {
|
|
144
|
+
/** Regular expression source text, without enclosing slashes or flags. */
|
|
135
145
|
readonly pattern: string;
|
|
146
|
+
/** Optional explanation emitters can show when a value does not match the pattern. */
|
|
136
147
|
readonly validationMessage?: string;
|
|
137
148
|
}
|
|
149
|
+
/** Records a string validation pattern and optional failure message, reporting invalid regular expressions. */
|
|
138
150
|
export declare const $pattern: PatternDecorator;
|
|
139
151
|
/**
|
|
140
152
|
* Gets the pattern regular expression associated with a given type, if one has been set.
|
|
@@ -156,14 +168,23 @@ export {
|
|
|
156
168
|
* @returns the pattern data, if any was set
|
|
157
169
|
*/
|
|
158
170
|
getPatternData, };
|
|
171
|
+
/** Sets an inclusive minimum string length, rejecting a bound greater than the target's maximum length. */
|
|
159
172
|
export declare const $minLength: MinLengthDecorator;
|
|
173
|
+
/** Sets an inclusive maximum string length, rejecting a bound less than the target's minimum length. */
|
|
160
174
|
export declare const $maxLength: MaxLengthDecorator;
|
|
175
|
+
/** Sets an inclusive minimum array item count, rejecting a bound greater than the target's maximum count. */
|
|
161
176
|
export declare const $minItems: MinItemsDecorator;
|
|
177
|
+
/** Sets an inclusive maximum array item count, rejecting a bound less than the target's minimum count. */
|
|
162
178
|
export declare const $maxItems: MaxItemsDecorator;
|
|
179
|
+
/** Sets an inclusive lower bound for a numeric or date/time scalar or property, validating assignability. */
|
|
163
180
|
export declare const $minValue: MinValueDecorator;
|
|
181
|
+
/** Sets an inclusive upper bound for a numeric or date/time scalar or property, validating assignability. */
|
|
164
182
|
export declare const $maxValue: MaxValueDecorator;
|
|
183
|
+
/** Sets an exclusive lower bound for a numeric or date/time scalar or property, validating assignability. */
|
|
165
184
|
export declare const $minValueExclusive: MinValueExclusiveDecorator;
|
|
185
|
+
/** Sets an exclusive upper bound for a numeric or date/time scalar or property, validating assignability. */
|
|
166
186
|
export declare const $maxValueExclusive: MaxValueExclusiveDecorator;
|
|
187
|
+
/** Tests whether this type is marked with `@secret`; does not search base types. */
|
|
167
188
|
declare const isSecret: (program: Program, type: Type) => boolean;
|
|
168
189
|
/**
|
|
169
190
|
* Mark a value as a secret value that should be treated carefully to avoid exposure
|
|
@@ -172,9 +193,13 @@ declare const isSecret: (program: Program, type: Type) => boolean;
|
|
|
172
193
|
*/
|
|
173
194
|
export declare const $secret: SecretDecorator;
|
|
174
195
|
export { isSecret };
|
|
196
|
+
/** Standard date/time encoding names accepted by `@encode`, including string formats and Unix seconds. */
|
|
175
197
|
export type DateTimeKnownEncoding = "rfc3339" | "rfc7231" | "unixTimestamp";
|
|
198
|
+
/** Standard duration encoding names for ISO 8601 text or numeric seconds and milliseconds. */
|
|
176
199
|
export type DurationKnownEncoding = "ISO8601" | "seconds" | "milliseconds";
|
|
200
|
+
/** Standard encodings for representing bytes as Base64 or URL-safe Base64 text. */
|
|
177
201
|
export type BytesKnownEncoding = "base64" | "base64url";
|
|
202
|
+
/** Serialization instructions stored by `@encode`, pairing an encoding name with its wire scalar type. */
|
|
178
203
|
export interface EncodeData {
|
|
179
204
|
/**
|
|
180
205
|
* Known encoding key.
|
|
@@ -183,19 +208,50 @@ export interface EncodeData {
|
|
|
183
208
|
* For boolean this means using `true` or `false`.
|
|
184
209
|
*/
|
|
185
210
|
encoding?: DateTimeKnownEncoding | DurationKnownEncoding | BytesKnownEncoding | string;
|
|
211
|
+
/** Scalar used for the encoded representation; defaults to `string` when `@encode` omits it. */
|
|
186
212
|
type: Scalar;
|
|
187
213
|
}
|
|
214
|
+
/** Gets encoding instructions stored on this scalar or property, or `undefined`; does not search base scalars. */
|
|
188
215
|
declare const getEncode: (program: Program, type: ModelProperty | Scalar) => EncodeData | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* Records how a scalar or property is serialized, validating known encodings against the target and wire types.
|
|
218
|
+
* Named encodings default to a `string` representation; passing the `string` scalar encodes numeric or boolean values as text.
|
|
219
|
+
*/
|
|
189
220
|
export declare const $encode: EncodeDecorator;
|
|
190
221
|
export { getEncode };
|
|
222
|
+
/** Mutates every property in the target model's own property map to be optional; does not walk base models. */
|
|
191
223
|
export declare const $withOptionalProperties: WithOptionalPropertiesDecorator;
|
|
224
|
+
/**
|
|
225
|
+
* Removes named properties from the target model in place, without walking base models.
|
|
226
|
+
* Names come from a string literal or the string-literal variants of a union; other variants are ignored.
|
|
227
|
+
*/
|
|
192
228
|
export declare const $withoutOmittedProperties: WithoutOmittedPropertiesDecorator;
|
|
229
|
+
/**
|
|
230
|
+
* Removes all properties except the named ones from the target model in place, without walking base models.
|
|
231
|
+
* Names come from a string literal or the string-literal variants of a union; other variants are ignored.
|
|
232
|
+
*/
|
|
193
233
|
export declare const $withPickedProperties: WithPickedPropertiesDecorator;
|
|
234
|
+
/** Deletes default values from the target model's own properties in place; does not walk base models. */
|
|
194
235
|
export declare const $withoutDefaultValues: WithoutDefaultValuesDecorator;
|
|
236
|
+
/** Appends a tag to an operation, interface, or namespace; multiple tags and duplicate strings are retained. */
|
|
195
237
|
export declare const $tag: TagDecorator;
|
|
238
|
+
/**
|
|
239
|
+
* Gets only the tags stored directly on the target, or an empty array if none are set.
|
|
240
|
+
* The stored array is returned without copying; use {@link getAllTags} to include containing scopes.
|
|
241
|
+
*/
|
|
196
242
|
export declare function getTags(program: Program, target: Type): string[];
|
|
243
|
+
/**
|
|
244
|
+
* Collects unique tags from the target and its enclosing interface and namespaces.
|
|
245
|
+
* Tags are collected from inner to outer scopes and the deduplicated sequence is reversed before returning.
|
|
246
|
+
* Returns a new array, or `undefined` if no scope has tags.
|
|
247
|
+
*/
|
|
197
248
|
export declare function getAllTags(program: Program, target: Namespace | Interface | Operation): string[] | undefined;
|
|
249
|
+
/** Gets the friendly name stored on this type, or `undefined`; does not synthesize a name or search base types. */
|
|
198
250
|
declare const getFriendlyName: (program: Program, type: Type) => string | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* Stores an emitter-facing name without changing the type's TypeSpec name.
|
|
253
|
+
* When a source object is supplied, its properties replace `{property}` placeholders in the name.
|
|
254
|
+
*/
|
|
199
255
|
export declare const $friendlyName: FriendlyNameDecorator;
|
|
200
256
|
export { getFriendlyName };
|
|
201
257
|
/**
|
|
@@ -235,20 +291,46 @@ getOverloadedOperation,
|
|
|
235
291
|
* Get all operations that are marked as overloads of the given operation
|
|
236
292
|
* @param program Program
|
|
237
293
|
* @param operation Operation
|
|
238
|
-
* @returns
|
|
294
|
+
* @returns The stored array of overloads, or `undefined` if none have been registered.
|
|
239
295
|
*/
|
|
240
296
|
getOverloads, };
|
|
297
|
+
/**
|
|
298
|
+
* Configures and validates a discriminated union.
|
|
299
|
+
* Defaults to an object envelope with discriminator property `kind` and value property `value`.
|
|
300
|
+
*/
|
|
241
301
|
export declare const discriminatedDecorator: DiscriminatedDecorator;
|
|
302
|
+
/** Records the property used to distinguish a model's derived variants during serialization. */
|
|
242
303
|
export declare const $discriminator: DiscriminatorDecorator;
|
|
304
|
+
/** An example attached to a data type, retaining the TypeSpec value and optional display metadata. */
|
|
243
305
|
export interface Example extends ExampleOptions {
|
|
306
|
+
/** Original TypeSpec value, not serialized JSON; use {@link serializeValueAsJson} to convert it. */
|
|
244
307
|
readonly value: Value;
|
|
245
308
|
}
|
|
309
|
+
/** Example inputs and corresponding result attached to an operation, with optional display metadata. */
|
|
246
310
|
export interface OpExample extends ExampleOptions {
|
|
311
|
+
/** Value assignable to the operation's parameter model, or absent for a result-only example. */
|
|
247
312
|
readonly parameters?: Value;
|
|
313
|
+
/** Value assignable to the operation's return type, or absent for a parameter-only example. */
|
|
248
314
|
readonly returnType?: Value;
|
|
249
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Appends an example and optional display metadata to the target after checking value assignability.
|
|
318
|
+
* Reads the original TypeSpec value from the decorator application rather than the marshalled JS argument.
|
|
319
|
+
*/
|
|
250
320
|
export declare const $example: ExampleDecorator;
|
|
321
|
+
/**
|
|
322
|
+
* Gets examples stored on the target in registration order, or an empty array.
|
|
323
|
+
* Returns the stored collection as readonly without copying; values remain TypeSpec values, not JSON.
|
|
324
|
+
*/
|
|
251
325
|
export declare function getExamples(program: Program, target: Model | Scalar | Enum | Union | ModelProperty): readonly Example[];
|
|
326
|
+
/**
|
|
327
|
+
* Appends example parameter and result values with optional display metadata, checking each supplied value's assignability.
|
|
328
|
+
* Reads original TypeSpec values from the decorator application rather than the marshalled JS argument.
|
|
329
|
+
*/
|
|
252
330
|
export declare const $opExample: OpExampleDecorator;
|
|
331
|
+
/**
|
|
332
|
+
* Gets operation examples in registration order, or an empty array if none are set.
|
|
333
|
+
* Returns the stored array without copying; parameter and result values have not been serialized.
|
|
334
|
+
*/
|
|
253
335
|
export declare function getOpExamples(program: Program, target: Operation): OpExample[];
|
|
254
336
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/lib/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EAEtB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,EAC9B,MAAM,kCAAkC,CAAC;AAU1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AA2B/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAKV,IAAI,EAEJ,SAAS,EACT,KAAK,EACL,aAAa,EACb,SAAS,EAGT,SAAS,EACT,MAAM,EAGN,IAAI,EACJ,KAAK,EAEL,KAAK,EACN,MAAM,kBAAkB,CAAC;AAY1B,OAAO,EACL,YAAY,EACZ,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,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YAAY,GACb,CAAC;AAwBF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,sBAcpC,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,cAAc,EAAE,sBAM5B,CAAC;AAEF,sGAAsG;AACtG,MAAM,WAAW,OAAQ,SAAQ,cAAc;IAC7C,oGAAoG;IACpG,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AACD,wGAAwG;AACxG,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,gGAAgG;IAChG,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC5B,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;CAC7B;AAMD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,gBA+BtB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,aAAa,GACpD,SAAS,OAAO,EAAE,CAEpB;AAKD;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,kBA8CxB,CAAC;AAoBF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,CAE9E"}
|
|
@@ -20,9 +20,10 @@ export { getPagingOperation, isList } from "./paging.js";
|
|
|
20
20
|
export * from "./service.js";
|
|
21
21
|
export * from "./visibility.js";
|
|
22
22
|
export const namespace = "TypeSpec";
|
|
23
|
+
/** Gets the summary stored on this type, or `undefined` if none is set. */
|
|
23
24
|
const [getSummary, setSummary] = useStateMap(createStateSymbol("summary"));
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* `@summary` attaches a documentation string. It is typically used to give a short, single-line
|
|
26
27
|
* description, and can be used in combination with or instead of @doc.
|
|
27
28
|
*
|
|
28
29
|
* The first argument to @summary is a string, which may contain template parameters, enclosed in braces,
|
|
@@ -61,6 +62,7 @@ export const $doc = (context, target, text, sourceObject) => {
|
|
|
61
62
|
export function getDoc(program, target) {
|
|
62
63
|
return getDocDataInternal(program, target, "self")?.value;
|
|
63
64
|
}
|
|
65
|
+
/** Attaches documentation describing an operation's successful return types, separately from its errors. */
|
|
64
66
|
export const $returnsDoc = (context, target, text) => {
|
|
65
67
|
validateDecoratorUniqueOnNode(context, target, $doc);
|
|
66
68
|
setDocData(context.program, target, "returns", { value: text, source: "decorator" });
|
|
@@ -83,6 +85,7 @@ export function getReturnsDocData(program, target) {
|
|
|
83
85
|
export function getReturnsDoc(program, target) {
|
|
84
86
|
return getDocDataInternal(program, target, "returns")?.value;
|
|
85
87
|
}
|
|
88
|
+
/** Attaches documentation describing an operation's error return types, separately from its successful results. */
|
|
86
89
|
export const $errorsDoc = (context, target, text) => {
|
|
87
90
|
validateDecoratorUniqueOnNode(context, target, $doc);
|
|
88
91
|
setDocData(context.program, target, "errors", { value: text, source: "decorator" });
|
|
@@ -105,6 +108,7 @@ export function getErrorsDocData(program, target) {
|
|
|
105
108
|
export function getErrorsDoc(program, target) {
|
|
106
109
|
return getDocDataInternal(program, target, "errors")?.value;
|
|
107
110
|
}
|
|
111
|
+
/** Logs an optional nonempty label followed by the target type object, to a depth of three, for debugging. */
|
|
108
112
|
export const $inspectType = (context, target, text) => {
|
|
109
113
|
// eslint-disable-next-line no-console
|
|
110
114
|
if (text)
|
|
@@ -112,6 +116,7 @@ export const $inspectType = (context, target, text) => {
|
|
|
112
116
|
// eslint-disable-next-line no-console
|
|
113
117
|
console.dir(target, { depth: 3 });
|
|
114
118
|
};
|
|
119
|
+
/** Logs an optional nonempty label followed by the target's formatted TypeSpec name for debugging. */
|
|
115
120
|
export const $inspectTypeName = (context, target, text) => {
|
|
116
121
|
// eslint-disable-next-line no-console
|
|
117
122
|
if (text)
|
|
@@ -119,10 +124,12 @@ export const $inspectTypeName = (context, target, text) => {
|
|
|
119
124
|
// eslint-disable-next-line no-console
|
|
120
125
|
console.log(getTypeName(target));
|
|
121
126
|
};
|
|
127
|
+
/** Tests whether the target is a scalar assignable to the standard `string` type, including derived scalars. */
|
|
122
128
|
export function isStringType(program, target) {
|
|
123
129
|
const stringType = program.checker.getStdType("string");
|
|
124
130
|
return (target.kind === "Scalar" && program.checker.isTypeAssignableTo(target, stringType, target)[0]);
|
|
125
131
|
}
|
|
132
|
+
/** Tests whether the target is a scalar assignable to the standard `numeric` type, including derived scalars. */
|
|
126
133
|
export function isNumericType(program, target) {
|
|
127
134
|
const numericType = program.checker.getStdType("numeric");
|
|
128
135
|
return (target.kind === "Scalar" && program.checker.isTypeAssignableTo(target, numericType, target)[0]);
|
|
@@ -353,6 +360,7 @@ export function getMediaTypeHint(program, target) {
|
|
|
353
360
|
}
|
|
354
361
|
}
|
|
355
362
|
// -- @format decorator ---------------------
|
|
363
|
+
/** Gets the format hint stored on this type, or `undefined` if none is set; does not search base types. */
|
|
356
364
|
const [getFormat, setFormat] = useStateMap(createStateSymbol("format"));
|
|
357
365
|
/**
|
|
358
366
|
* `@format` - specify the data format hint for a string type
|
|
@@ -377,6 +385,7 @@ export const $format = (context, target, format) => {
|
|
|
377
385
|
export { getFormat };
|
|
378
386
|
// -- @pattern decorator ---------------------
|
|
379
387
|
const [getPatternData, setPatternData] = useStateMap(createStateSymbol("patternValues"));
|
|
388
|
+
/** Records a string validation pattern and optional failure message, reporting invalid regular expressions. */
|
|
380
389
|
export const $pattern = (context, target, pattern, validationMessage) => {
|
|
381
390
|
validateDecoratorUniqueOnNode(context, target, $pattern);
|
|
382
391
|
if (!validateTargetingAString(context, target, "@pattern")) {
|
|
@@ -420,6 +429,7 @@ export {
|
|
|
420
429
|
*/
|
|
421
430
|
getPatternData, };
|
|
422
431
|
// -- @minLength decorator ---------------------
|
|
432
|
+
/** Sets an inclusive minimum string length, rejecting a bound greater than the target's maximum length. */
|
|
423
433
|
export const $minLength = (context, target, minLength) => {
|
|
424
434
|
validateDecoratorUniqueOnNode(context, target, $minLength);
|
|
425
435
|
if (!validateTargetingAString(context, target, "@minLength") ||
|
|
@@ -429,6 +439,7 @@ export const $minLength = (context, target, minLength) => {
|
|
|
429
439
|
setMinLength(context.program, target, minLength);
|
|
430
440
|
};
|
|
431
441
|
// -- @maxLength decorator ---------------------
|
|
442
|
+
/** Sets an inclusive maximum string length, rejecting a bound less than the target's minimum length. */
|
|
432
443
|
export const $maxLength = (context, target, maxLength) => {
|
|
433
444
|
validateDecoratorUniqueOnNode(context, target, $maxLength);
|
|
434
445
|
if (!validateTargetingAString(context, target, "@maxLength") ||
|
|
@@ -438,6 +449,7 @@ export const $maxLength = (context, target, maxLength) => {
|
|
|
438
449
|
setMaxLength(context.program, target, maxLength);
|
|
439
450
|
};
|
|
440
451
|
// -- @minItems decorator ---------------------
|
|
452
|
+
/** Sets an inclusive minimum array item count, rejecting a bound greater than the target's maximum count. */
|
|
441
453
|
export const $minItems = (context, target, minItems) => {
|
|
442
454
|
validateDecoratorUniqueOnNode(context, target, $minItems);
|
|
443
455
|
if (!validateTargetingAnArray(context, target, "@minItems")) {
|
|
@@ -449,6 +461,7 @@ export const $minItems = (context, target, minItems) => {
|
|
|
449
461
|
setMinItems(context.program, target, minItems);
|
|
450
462
|
};
|
|
451
463
|
// -- @maxLength decorator ---------------------
|
|
464
|
+
/** Sets an inclusive maximum array item count, rejecting a bound less than the target's minimum count. */
|
|
452
465
|
export const $maxItems = (context, target, maxItems) => {
|
|
453
466
|
validateDecoratorUniqueOnNode(context, target, $maxItems);
|
|
454
467
|
if (!validateTargetingAnArray(context, target, "@maxItems")) {
|
|
@@ -460,6 +473,7 @@ export const $maxItems = (context, target, maxItems) => {
|
|
|
460
473
|
setMaxItems(context.program, target, maxItems);
|
|
461
474
|
};
|
|
462
475
|
// -- @minValue decorator ---------------------
|
|
476
|
+
/** Sets an inclusive lower bound for a numeric or date/time scalar or property, validating assignability. */
|
|
463
477
|
export const $minValue = (context, target, minValue) => {
|
|
464
478
|
validateDecoratorUniqueOnNode(context, target, $minValue);
|
|
465
479
|
validateDecoratorNotOnType(context, target, $minValueExclusive, $minValue);
|
|
@@ -477,6 +491,7 @@ export const $minValue = (context, target, minValue) => {
|
|
|
477
491
|
setMinValue(program, target, minValue);
|
|
478
492
|
};
|
|
479
493
|
// -- @maxValue decorator ---------------------
|
|
494
|
+
/** Sets an inclusive upper bound for a numeric or date/time scalar or property, validating assignability. */
|
|
480
495
|
export const $maxValue = (context, target, maxValue) => {
|
|
481
496
|
validateDecoratorUniqueOnNode(context, target, $maxValue);
|
|
482
497
|
validateDecoratorNotOnType(context, target, $maxValueExclusive, $maxValue);
|
|
@@ -494,6 +509,7 @@ export const $maxValue = (context, target, maxValue) => {
|
|
|
494
509
|
setMaxValue(program, target, maxValue);
|
|
495
510
|
};
|
|
496
511
|
// -- @minValueExclusive decorator ---------------------
|
|
512
|
+
/** Sets an exclusive lower bound for a numeric or date/time scalar or property, validating assignability. */
|
|
497
513
|
export const $minValueExclusive = (context, target, minValueExclusive) => {
|
|
498
514
|
validateDecoratorUniqueOnNode(context, target, $minValueExclusive);
|
|
499
515
|
validateDecoratorNotOnType(context, target, $minValue, $minValueExclusive);
|
|
@@ -511,6 +527,7 @@ export const $minValueExclusive = (context, target, minValueExclusive) => {
|
|
|
511
527
|
setMinValueExclusive(program, target, minValueExclusive);
|
|
512
528
|
};
|
|
513
529
|
// -- @maxValueExclusive decorator ---------------------
|
|
530
|
+
/** Sets an exclusive upper bound for a numeric or date/time scalar or property, validating assignability. */
|
|
514
531
|
export const $maxValueExclusive = (context, target, maxValueExclusive) => {
|
|
515
532
|
validateDecoratorUniqueOnNode(context, target, $maxValueExclusive);
|
|
516
533
|
validateDecoratorNotOnType(context, target, $maxValue, $maxValueExclusive);
|
|
@@ -528,6 +545,7 @@ export const $maxValueExclusive = (context, target, maxValueExclusive) => {
|
|
|
528
545
|
setMaxValueExclusive(program, target, maxValueExclusive);
|
|
529
546
|
};
|
|
530
547
|
// -- @secret decorator ---------------------
|
|
548
|
+
/** Tests whether this type is marked with `@secret`; does not search base types. */
|
|
531
549
|
const [isSecret, markSecret] = useStateSet(createStateSymbol("secretTypes"));
|
|
532
550
|
/**
|
|
533
551
|
* Mark a value as a secret value that should be treated carefully to avoid exposure
|
|
@@ -539,7 +557,12 @@ export const $secret = (context, target) => {
|
|
|
539
557
|
markSecret(context.program, target);
|
|
540
558
|
};
|
|
541
559
|
export { isSecret };
|
|
560
|
+
/** Gets encoding instructions stored on this scalar or property, or `undefined`; does not search base scalars. */
|
|
542
561
|
const [getEncode, setEncodeData] = useStateMap(createStateSymbol("encode"));
|
|
562
|
+
/**
|
|
563
|
+
* Records how a scalar or property is serialized, validating known encodings against the target and wire types.
|
|
564
|
+
* Named encodings default to a `string` representation; passing the `string` scalar encodes numeric or boolean values as text.
|
|
565
|
+
*/
|
|
543
566
|
export const $encode = (context, target, encoding, encodeAs) => {
|
|
544
567
|
validateDecoratorUniqueOnNode(context, target, $encode);
|
|
545
568
|
const encodeData = computeEncoding(context.program, encoding, encodeAs);
|
|
@@ -637,11 +660,16 @@ function validateEncodeData(context, target, encodeData) {
|
|
|
637
660
|
}
|
|
638
661
|
export { getEncode };
|
|
639
662
|
// -- @withOptionalProperties decorator ---------------------
|
|
663
|
+
/** Mutates every property in the target model's own property map to be optional; does not walk base models. */
|
|
640
664
|
export const $withOptionalProperties = (context, target) => {
|
|
641
665
|
// Make all properties of the target type optional
|
|
642
666
|
target.properties.forEach((p) => (p.optional = true));
|
|
643
667
|
};
|
|
644
668
|
// -- @withoutOmittedProperties decorator ----------------------
|
|
669
|
+
/**
|
|
670
|
+
* Removes named properties from the target model in place, without walking base models.
|
|
671
|
+
* Names come from a string literal or the string-literal variants of a union; other variants are ignored.
|
|
672
|
+
*/
|
|
645
673
|
export const $withoutOmittedProperties = (context, target, omitProperties) => {
|
|
646
674
|
// Get the property or properties to omit
|
|
647
675
|
const omitNames = new Set();
|
|
@@ -659,6 +687,10 @@ export const $withoutOmittedProperties = (context, target, omitProperties) => {
|
|
|
659
687
|
filterModelPropertiesInPlace(target, (prop) => !omitNames.has(prop.name));
|
|
660
688
|
};
|
|
661
689
|
// -- @withPickedProperties decorator ----------------------
|
|
690
|
+
/**
|
|
691
|
+
* Removes all properties except the named ones from the target model in place, without walking base models.
|
|
692
|
+
* Names come from a string literal or the string-literal variants of a union; other variants are ignored.
|
|
693
|
+
*/
|
|
662
694
|
export const $withPickedProperties = (context, target, pickedProperties) => {
|
|
663
695
|
// Get the property or properties to pick
|
|
664
696
|
const pickedNames = new Set();
|
|
@@ -676,6 +708,7 @@ export const $withPickedProperties = (context, target, pickedProperties) => {
|
|
|
676
708
|
filterModelPropertiesInPlace(target, (prop) => pickedNames.has(prop.name));
|
|
677
709
|
};
|
|
678
710
|
// -- @withoutDefaultValues decorator ----------------------
|
|
711
|
+
/** Deletes default values from the target model's own properties in place; does not walk base models. */
|
|
679
712
|
export const $withoutDefaultValues = (context, target) => {
|
|
680
713
|
// remove all read-only properties from the target type
|
|
681
714
|
target.properties.forEach((p) => {
|
|
@@ -684,8 +717,7 @@ export const $withoutDefaultValues = (context, target) => {
|
|
|
684
717
|
};
|
|
685
718
|
// -- @tag decorator ---------------------
|
|
686
719
|
const [getTagsState, setTags] = useStateMap(createStateSymbol("tagProperties"));
|
|
687
|
-
|
|
688
|
-
// operation, interface, or namespace.
|
|
720
|
+
/** Appends a tag to an operation, interface, or namespace; multiple tags and duplicate strings are retained. */
|
|
689
721
|
export const $tag = (context, target, tag) => {
|
|
690
722
|
const tags = getTagsState(context.program, target);
|
|
691
723
|
if (tags) {
|
|
@@ -695,12 +727,18 @@ export const $tag = (context, target, tag) => {
|
|
|
695
727
|
setTags(context.program, target, [tag]);
|
|
696
728
|
}
|
|
697
729
|
};
|
|
698
|
-
|
|
730
|
+
/**
|
|
731
|
+
* Gets only the tags stored directly on the target, or an empty array if none are set.
|
|
732
|
+
* The stored array is returned without copying; use {@link getAllTags} to include containing scopes.
|
|
733
|
+
*/
|
|
699
734
|
export function getTags(program, target) {
|
|
700
735
|
return getTagsState(program, target) || [];
|
|
701
736
|
}
|
|
702
|
-
|
|
703
|
-
|
|
737
|
+
/**
|
|
738
|
+
* Collects unique tags from the target and its enclosing interface and namespaces.
|
|
739
|
+
* Tags are collected from inner to outer scopes and the deduplicated sequence is reversed before returning.
|
|
740
|
+
* Returns a new array, or `undefined` if no scope has tags.
|
|
741
|
+
*/
|
|
704
742
|
export function getAllTags(program, target) {
|
|
705
743
|
const tags = new Set();
|
|
706
744
|
let current = target;
|
|
@@ -720,7 +758,12 @@ export function getAllTags(program, target) {
|
|
|
720
758
|
return tags.size > 0 ? Array.from(tags).reverse() : undefined;
|
|
721
759
|
}
|
|
722
760
|
// -- @friendlyName decorator ---------------------
|
|
761
|
+
/** Gets the friendly name stored on this type, or `undefined`; does not synthesize a name or search base types. */
|
|
723
762
|
const [getFriendlyName, setFriendlyName] = useStateMap(createStateSymbol("friendlyNames"));
|
|
763
|
+
/**
|
|
764
|
+
* Stores an emitter-facing name without changing the type's TypeSpec name.
|
|
765
|
+
* When a source object is supplied, its properties replace `{property}` placeholders in the name.
|
|
766
|
+
*/
|
|
724
767
|
export const $friendlyName = (context, target, friendlyName, sourceObject) => {
|
|
725
768
|
// workaround for current lack of functionality in compiler
|
|
726
769
|
// https://github.com/microsoft/typespec/issues/2717
|
|
@@ -822,7 +865,7 @@ getOverloadedOperation,
|
|
|
822
865
|
* Get all operations that are marked as overloads of the given operation
|
|
823
866
|
* @param program Program
|
|
824
867
|
* @param operation Operation
|
|
825
|
-
* @returns
|
|
868
|
+
* @returns The stored array of overloads, or `undefined` if none have been registered.
|
|
826
869
|
*/
|
|
827
870
|
getOverloads, };
|
|
828
871
|
function validateRange(context, min, max) {
|
|
@@ -842,6 +885,10 @@ function validateRange(context, min, max) {
|
|
|
842
885
|
}
|
|
843
886
|
return true;
|
|
844
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* Configures and validates a discriminated union.
|
|
890
|
+
* Defaults to an object envelope with discriminator property `kind` and value property `value`.
|
|
891
|
+
*/
|
|
845
892
|
export const discriminatedDecorator = (context, entity, options = {}) => {
|
|
846
893
|
setDiscriminatedOptions(context.program, entity, {
|
|
847
894
|
envelope: "object",
|
|
@@ -852,10 +899,15 @@ export const discriminatedDecorator = (context, entity, options = {}) => {
|
|
|
852
899
|
const [_, diagnostics] = getDiscriminatedUnion(context.program, entity);
|
|
853
900
|
context.program.reportDiagnostics(diagnostics);
|
|
854
901
|
};
|
|
902
|
+
/** Records the property used to distinguish a model's derived variants during serialization. */
|
|
855
903
|
export const $discriminator = (context, entity, propertyName) => {
|
|
856
904
|
setDiscriminator(context.program, entity, { propertyName });
|
|
857
905
|
};
|
|
858
906
|
const [getExamplesState, setExamples] = useStateMap(createStateSymbol("examples"));
|
|
907
|
+
/**
|
|
908
|
+
* Appends an example and optional display metadata to the target after checking value assignability.
|
|
909
|
+
* Reads the original TypeSpec value from the decorator application rather than the marshalled JS argument.
|
|
910
|
+
*/
|
|
859
911
|
export const $example = (context, target, _example, options) => {
|
|
860
912
|
const decorator = target.decorators.find((d) => d.decorator === $example && d.node === context.decoratorTarget);
|
|
861
913
|
compilerAssert(decorator, `Couldn't find @example decorator`, context.decoratorTarget);
|
|
@@ -873,10 +925,18 @@ export const $example = (context, target, _example, options) => {
|
|
|
873
925
|
}
|
|
874
926
|
list.push({ value: rawExample, ...options });
|
|
875
927
|
};
|
|
928
|
+
/**
|
|
929
|
+
* Gets examples stored on the target in registration order, or an empty array.
|
|
930
|
+
* Returns the stored collection as readonly without copying; values remain TypeSpec values, not JSON.
|
|
931
|
+
*/
|
|
876
932
|
export function getExamples(program, target) {
|
|
877
933
|
return getExamplesState(program, target) ?? [];
|
|
878
934
|
}
|
|
879
935
|
const [getOpExamplesState, setOpExamples] = useStateMap(createStateSymbol("opExamples"));
|
|
936
|
+
/**
|
|
937
|
+
* Appends example parameter and result values with optional display metadata, checking each supplied value's assignability.
|
|
938
|
+
* Reads original TypeSpec values from the decorator application rather than the marshalled JS argument.
|
|
939
|
+
*/
|
|
880
940
|
export const $opExample = (context, target, _example, options) => {
|
|
881
941
|
const decorator = target.decorators.find((d) => d.decorator === $opExample && d.node === context.decoratorTarget);
|
|
882
942
|
compilerAssert(decorator, `Couldn't find @opExample decorator`, context.decoratorTarget);
|
|
@@ -909,6 +969,10 @@ function checkExampleValid(program, value, target, diagnosticTarget) {
|
|
|
909
969
|
}
|
|
910
970
|
return assignable;
|
|
911
971
|
}
|
|
972
|
+
/**
|
|
973
|
+
* Gets operation examples in registration order, or an empty array if none are set.
|
|
974
|
+
* Returns the stored array without copying; parameter and result values have not been serialized.
|
|
975
|
+
*/
|
|
912
976
|
export function getOpExamples(program, target) {
|
|
913
977
|
return getOpExamplesState(program, target) ?? [];
|
|
914
978
|
}
|