@typespec/compiler 0.41.0
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/LICENSE +21 -0
- package/README.md +9 -0
- package/cmd/tsp-server.js +3 -0
- package/cmd/tsp.js +3 -0
- package/dist/cmd/runner.d.ts +9 -0
- package/dist/cmd/runner.d.ts.map +1 -0
- package/dist/cmd/runner.js +62 -0
- package/dist/cmd/runner.js.map +1 -0
- package/dist/config/config-interpolation.d.ts +11 -0
- package/dist/config/config-interpolation.d.ts.map +1 -0
- package/dist/config/config-interpolation.js +109 -0
- package/dist/config/config-interpolation.js.map +1 -0
- package/dist/config/config-loader.d.ts +25 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +182 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/config-schema.d.ts +4 -0
- package/dist/config/config-schema.d.ts.map +1 -0
- package/dist/config/config-schema.js +84 -0
- package/dist/config/config-schema.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +79 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/binder.d.ts +29 -0
- package/dist/core/binder.d.ts.map +1 -0
- package/dist/core/binder.js +455 -0
- package/dist/core/binder.js.map +1 -0
- package/dist/core/charcode.d.ts +130 -0
- package/dist/core/charcode.d.ts.map +1 -0
- package/dist/core/charcode.js +115 -0
- package/dist/core/charcode.js.map +1 -0
- package/dist/core/checker.d.ts +138 -0
- package/dist/core/checker.d.ts.map +1 -0
- package/dist/core/checker.js +4070 -0
- package/dist/core/checker.js.map +1 -0
- package/dist/core/cli/args.d.ts +18 -0
- package/dist/core/cli/args.d.ts.map +1 -0
- package/dist/core/cli/args.js +108 -0
- package/dist/core/cli/args.js.map +1 -0
- package/dist/core/cli/cli.d.ts +2 -0
- package/dist/core/cli/cli.d.ts.map +1 -0
- package/dist/core/cli/cli.js +477 -0
- package/dist/core/cli/cli.js.map +1 -0
- package/dist/core/cli/index.d.ts +2 -0
- package/dist/core/cli/index.d.ts.map +1 -0
- package/dist/core/cli/index.js +2 -0
- package/dist/core/cli/index.js.map +1 -0
- package/dist/core/decorator-utils.d.ts +108 -0
- package/dist/core/decorator-utils.d.ts.map +1 -0
- package/dist/core/decorator-utils.js +326 -0
- package/dist/core/decorator-utils.js.map +1 -0
- package/dist/core/diagnostics.d.ts +93 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +315 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/emitter-utils.d.ts +14 -0
- package/dist/core/emitter-utils.d.ts.map +1 -0
- package/dist/core/emitter-utils.js +16 -0
- package/dist/core/emitter-utils.js.map +1 -0
- package/dist/core/formatter-fs.d.ts +21 -0
- package/dist/core/formatter-fs.d.ts.map +1 -0
- package/dist/core/formatter-fs.js +79 -0
- package/dist/core/formatter-fs.js.map +1 -0
- package/dist/core/formatter.d.ts +10 -0
- package/dist/core/formatter.d.ts.map +1 -0
- package/dist/core/formatter.js +24 -0
- package/dist/core/formatter.js.map +1 -0
- package/dist/core/helpers/discriminator-utils.d.ts +14 -0
- package/dist/core/helpers/discriminator-utils.d.ts.map +1 -0
- package/dist/core/helpers/discriminator-utils.js +169 -0
- package/dist/core/helpers/discriminator-utils.js.map +1 -0
- package/dist/core/helpers/index.d.ts +6 -0
- package/dist/core/helpers/index.d.ts.map +1 -0
- package/dist/core/helpers/index.js +6 -0
- package/dist/core/helpers/index.js.map +1 -0
- package/dist/core/helpers/operation-utils.d.ts +15 -0
- package/dist/core/helpers/operation-utils.d.ts.map +1 -0
- package/dist/core/helpers/operation-utils.js +35 -0
- package/dist/core/helpers/operation-utils.js.map +1 -0
- package/dist/core/helpers/projected-names-utils.d.ts +20 -0
- package/dist/core/helpers/projected-names-utils.d.ts.map +1 -0
- package/dist/core/helpers/projected-names-utils.js +40 -0
- package/dist/core/helpers/projected-names-utils.js.map +1 -0
- package/dist/core/helpers/type-name-utils.d.ts +14 -0
- package/dist/core/helpers/type-name-utils.d.ts.map +1 -0
- package/dist/core/helpers/type-name-utils.js +122 -0
- package/dist/core/helpers/type-name-utils.js.map +1 -0
- package/dist/core/helpers/usage-resolver.d.ts +20 -0
- package/dist/core/helpers/usage-resolver.d.ts.map +1 -0
- package/dist/core/helpers/usage-resolver.js +108 -0
- package/dist/core/helpers/usage-resolver.js.map +1 -0
- package/dist/core/index.d.ts +26 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +26 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/install.d.ts +2 -0
- package/dist/core/install.d.ts.map +1 -0
- package/dist/core/install.js +26 -0
- package/dist/core/install.js.map +1 -0
- package/dist/core/library.d.ts +34 -0
- package/dist/core/library.d.ts.map +1 -0
- package/dist/core/library.js +100 -0
- package/dist/core/library.js.map +1 -0
- package/dist/core/logger/console-sink.browser.d.ts +4 -0
- package/dist/core/logger/console-sink.browser.d.ts.map +1 -0
- package/dist/core/logger/console-sink.browser.js +14 -0
- package/dist/core/logger/console-sink.browser.js.map +1 -0
- package/dist/core/logger/console-sink.d.ts +9 -0
- package/dist/core/logger/console-sink.d.ts.map +1 -0
- package/dist/core/logger/console-sink.js +81 -0
- package/dist/core/logger/console-sink.js.map +1 -0
- package/dist/core/logger/index.d.ts +3 -0
- package/dist/core/logger/index.d.ts.map +1 -0
- package/dist/core/logger/index.js +3 -0
- package/dist/core/logger/index.js.map +1 -0
- package/dist/core/logger/logger.d.ts +7 -0
- package/dist/core/logger/logger.d.ts.map +1 -0
- package/dist/core/logger/logger.js +32 -0
- package/dist/core/logger/logger.js.map +1 -0
- package/dist/core/logger/tracer.d.ts +3 -0
- package/dist/core/logger/tracer.d.ts.map +1 -0
- package/dist/core/logger/tracer.js +91 -0
- package/dist/core/logger/tracer.js.map +1 -0
- package/dist/core/manifest.d.ts +21 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +8 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/messages.d.ts +2253 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +749 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/module-resolver.d.ts +84 -0
- package/dist/core/module-resolver.d.ts.map +1 -0
- package/dist/core/module-resolver.js +170 -0
- package/dist/core/module-resolver.js.map +1 -0
- package/dist/core/node-host.browser.d.ts +2 -0
- package/dist/core/node-host.browser.d.ts.map +1 -0
- package/dist/core/node-host.browser.js +2 -0
- package/dist/core/node-host.browser.js.map +1 -0
- package/dist/core/node-host.d.ts +7 -0
- package/dist/core/node-host.d.ts.map +1 -0
- package/dist/core/node-host.js +43 -0
- package/dist/core/node-host.js.map +1 -0
- package/dist/core/nonascii.d.ts +2 -0
- package/dist/core/nonascii.d.ts.map +1 -0
- package/dist/core/nonascii.js +712 -0
- package/dist/core/nonascii.js.map +1 -0
- package/dist/core/options.d.ts +46 -0
- package/dist/core/options.d.ts.map +1 -0
- package/dist/core/options.js +2 -0
- package/dist/core/options.js.map +1 -0
- package/dist/core/parser.d.ts +17 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +2561 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/path-utils.d.ts +193 -0
- package/dist/core/path-utils.d.ts.map +1 -0
- package/dist/core/path-utils.js +427 -0
- package/dist/core/path-utils.js.map +1 -0
- package/dist/core/program.d.ts +104 -0
- package/dist/core/program.d.ts.map +1 -0
- package/dist/core/program.js +898 -0
- package/dist/core/program.js.map +1 -0
- package/dist/core/projection-members.d.ts +8 -0
- package/dist/core/projection-members.d.ts.map +1 -0
- package/dist/core/projection-members.js +387 -0
- package/dist/core/projection-members.js.map +1 -0
- package/dist/core/projector.d.ts +26 -0
- package/dist/core/projector.d.ts.map +1 -0
- package/dist/core/projector.js +523 -0
- package/dist/core/projector.js.map +1 -0
- package/dist/core/scanner.d.ts +125 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +1012 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/schema-validator.d.ts +6 -0
- package/dist/core/schema-validator.d.ts.map +1 -0
- package/dist/core/schema-validator.js +38 -0
- package/dist/core/schema-validator.js.map +1 -0
- package/dist/core/semantic-walker.d.ts +53 -0
- package/dist/core/semantic-walker.d.ts.map +1 -0
- package/dist/core/semantic-walker.js +355 -0
- package/dist/core/semantic-walker.js.map +1 -0
- package/dist/core/type-utils.d.ts +49 -0
- package/dist/core/type-utils.d.ts.map +1 -0
- package/dist/core/type-utils.js +95 -0
- package/dist/core/type-utils.js.map +1 -0
- package/dist/core/types.d.ts +1345 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +105 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/util.d.ts +150 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +417 -0
- package/dist/core/util.js.map +1 -0
- package/dist/emitter-framework/asset-emitter.d.ts +5 -0
- package/dist/emitter-framework/asset-emitter.d.ts.map +1 -0
- package/dist/emitter-framework/asset-emitter.js +610 -0
- package/dist/emitter-framework/asset-emitter.js.map +1 -0
- package/dist/emitter-framework/builders/array-builder.d.ts +7 -0
- package/dist/emitter-framework/builders/array-builder.d.ts.map +1 -0
- package/dist/emitter-framework/builders/array-builder.js +45 -0
- package/dist/emitter-framework/builders/array-builder.js.map +1 -0
- package/dist/emitter-framework/builders/object-builder.d.ts +9 -0
- package/dist/emitter-framework/builders/object-builder.d.ts.map +1 -0
- package/dist/emitter-framework/builders/object-builder.js +30 -0
- package/dist/emitter-framework/builders/object-builder.js.map +1 -0
- package/dist/emitter-framework/builders/string-builder.d.ts +13 -0
- package/dist/emitter-framework/builders/string-builder.d.ts.map +1 -0
- package/dist/emitter-framework/builders/string-builder.js +98 -0
- package/dist/emitter-framework/builders/string-builder.js.map +1 -0
- package/dist/emitter-framework/custom-key-map.d.ts +29 -0
- package/dist/emitter-framework/custom-key-map.d.ts.map +1 -0
- package/dist/emitter-framework/custom-key-map.js +62 -0
- package/dist/emitter-framework/custom-key-map.js.map +1 -0
- package/dist/emitter-framework/index.d.ts +8 -0
- package/dist/emitter-framework/index.d.ts.map +1 -0
- package/dist/emitter-framework/index.js +8 -0
- package/dist/emitter-framework/index.js.map +1 -0
- package/dist/emitter-framework/placeholder.d.ts +12 -0
- package/dist/emitter-framework/placeholder.d.ts.map +1 -0
- package/dist/emitter-framework/placeholder.js +27 -0
- package/dist/emitter-framework/placeholder.js.map +1 -0
- package/dist/emitter-framework/type-emitter.d.ts +314 -0
- package/dist/emitter-framework/type-emitter.d.ts.map +1 -0
- package/dist/emitter-framework/type-emitter.js +612 -0
- package/dist/emitter-framework/type-emitter.js.map +1 -0
- package/dist/emitter-framework/types.d.ts +124 -0
- package/dist/emitter-framework/types.d.ts.map +1 -0
- package/dist/emitter-framework/types.js +39 -0
- package/dist/emitter-framework/types.js.map +1 -0
- package/dist/formatter/index.d.ts +11 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +28 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/formatter/parser.d.ts +16 -0
- package/dist/formatter/parser.d.ts.map +1 -0
- package/dist/formatter/parser.js +23 -0
- package/dist/formatter/parser.js.map +1 -0
- package/dist/formatter/print/comment-handler.d.ts +7 -0
- package/dist/formatter/print/comment-handler.d.ts.map +1 -0
- package/dist/formatter/print/comment-handler.js +81 -0
- package/dist/formatter/print/comment-handler.js.map +1 -0
- package/dist/formatter/print/index.d.ts +3 -0
- package/dist/formatter/print/index.d.ts.map +1 -0
- package/dist/formatter/print/index.js +3 -0
- package/dist/formatter/print/index.js.map +1 -0
- package/dist/formatter/print/needs-parens.d.ts +10 -0
- package/dist/formatter/print/needs-parens.d.ts.map +1 -0
- package/dist/formatter/print/needs-parens.js +27 -0
- package/dist/formatter/print/needs-parens.js.map +1 -0
- package/dist/formatter/print/printer.d.ts +62 -0
- package/dist/formatter/print/printer.d.ts.map +1 -0
- package/dist/formatter/print/printer.js +1025 -0
- package/dist/formatter/print/printer.js.map +1 -0
- package/dist/formatter/print/types.d.ts +9 -0
- package/dist/formatter/print/types.d.ts.map +1 -0
- package/dist/formatter/print/types.js +2 -0
- package/dist/formatter/print/types.js.map +1 -0
- package/dist/init/index.d.ts +2 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +2 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/init-template.d.ts +45 -0
- package/dist/init/init-template.d.ts.map +1 -0
- package/dist/init/init-template.js +45 -0
- package/dist/init/init-template.js.map +1 -0
- package/dist/init/init.d.ts +49 -0
- package/dist/init/init.d.ts.map +1 -0
- package/dist/init/init.js +224 -0
- package/dist/init/init.js.map +1 -0
- package/dist/lib/decorators.d.ts +222 -0
- package/dist/lib/decorators.d.ts.map +1 -0
- package/dist/lib/decorators.js +745 -0
- package/dist/lib/decorators.js.map +1 -0
- package/dist/lib/service.d.ts +38 -0
- package/dist/lib/service.d.ts.map +1 -0
- package/dist/lib/service.js +78 -0
- package/dist/lib/service.js.map +1 -0
- package/dist/manifest.js +4 -0
- package/dist/server/completion.d.ts +10 -0
- package/dist/server/completion.d.ts.map +1 -0
- package/dist/server/completion.js +207 -0
- package/dist/server/completion.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/language-config.d.ts +195 -0
- package/dist/server/language-config.d.ts.map +1 -0
- package/dist/server/language-config.js +102 -0
- package/dist/server/language-config.js.map +1 -0
- package/dist/server/server.d.ts +2 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +131 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/serverlib.d.ts +72 -0
- package/dist/server/serverlib.d.ts.map +1 -0
- package/dist/server/serverlib.js +1034 -0
- package/dist/server/serverlib.js.map +1 -0
- package/dist/server/symbol-structure.d.ts +4 -0
- package/dist/server/symbol-structure.d.ts.map +1 -0
- package/dist/server/symbol-structure.js +121 -0
- package/dist/server/symbol-structure.js.map +1 -0
- package/dist/server/tmlanguage.d.ts +3 -0
- package/dist/server/tmlanguage.d.ts.map +1 -0
- package/dist/server/tmlanguage.js +713 -0
- package/dist/server/tmlanguage.js.map +1 -0
- package/dist/server/type-details.d.ts +11 -0
- package/dist/server/type-details.d.ts.map +1 -0
- package/dist/server/type-details.js +72 -0
- package/dist/server/type-details.js.map +1 -0
- package/dist/server/type-signature.d.ts +2 -0
- package/dist/server/type-signature.d.ts.map +1 -0
- package/dist/server/type-signature.js +108 -0
- package/dist/server/type-signature.js.map +1 -0
- package/dist/testing/expect.d.ts +49 -0
- package/dist/testing/expect.d.ts.map +1 -0
- package/dist/testing/expect.js +83 -0
- package/dist/testing/expect.js.map +1 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +6 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/test-host.d.ts +14 -0
- package/dist/testing/test-host.d.ts.map +1 -0
- package/dist/testing/test-host.js +271 -0
- package/dist/testing/test-host.js.map +1 -0
- package/dist/testing/test-server-host.d.ts +39 -0
- package/dist/testing/test-server-host.d.ts.map +1 -0
- package/dist/testing/test-server-host.js +112 -0
- package/dist/testing/test-server-host.js.map +1 -0
- package/dist/testing/test-utils.d.ts +22 -0
- package/dist/testing/test-utils.d.ts.map +1 -0
- package/dist/testing/test-utils.js +60 -0
- package/dist/testing/test-utils.js.map +1 -0
- package/dist/testing/types.d.ts +69 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing/types.js +7 -0
- package/dist/testing/types.js.map +1 -0
- package/dist/typespec.tmLanguage +1760 -0
- package/lib/decorators.tsp +420 -0
- package/lib/lib.tsp +158 -0
- package/lib/main.tsp +4 -0
- package/lib/projected-names.tsp +94 -0
- package/lib/reflection.tsp +10 -0
- package/package.json +119 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import "../dist/lib/decorators.js";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Reflection;
|
|
4
|
+
|
|
5
|
+
namespace TypeSpec;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Typically a short, single-line description.
|
|
9
|
+
* @param summary Summary string.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typespec
|
|
13
|
+
* @summary("This is a pet")
|
|
14
|
+
* model Pet {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
extern dec summary(target: unknown, summary: string);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Attach a documentation string.
|
|
21
|
+
* @param doc Documentation string
|
|
22
|
+
* @param formatArgs Record with key value pair that can be interpolated in the doc.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typespec
|
|
26
|
+
* @doc("Represent a Pet available in the PetStore")
|
|
27
|
+
* model Pet {}
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
extern dec doc(target: unknown, doc: string, formatArgs?: object);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Mark this type as deprecated
|
|
34
|
+
* @param message Deprecation message.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```typespec
|
|
39
|
+
* @deprecated("Use ActionV2")
|
|
40
|
+
* op Action<T>(): T;
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
extern dec deprecated(target: unknown, message: string);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Service options.
|
|
47
|
+
*/
|
|
48
|
+
model ServiceOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Title of the service.
|
|
51
|
+
*/
|
|
52
|
+
title?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Version of the service.
|
|
55
|
+
*/
|
|
56
|
+
version?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Mark this namespace as describing a service and configure service properties.
|
|
61
|
+
* @param options Optional configuration for the service.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typespec
|
|
65
|
+
* @service
|
|
66
|
+
* namespace PetStore;
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example Setting service title
|
|
70
|
+
* ```typespec
|
|
71
|
+
* @service({title: "Pet store"})
|
|
72
|
+
* namespace PetStore;
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example Setting service version
|
|
76
|
+
* ```typespec
|
|
77
|
+
* @service({version: "1.0"})
|
|
78
|
+
* namespace PetStore;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
extern dec service(target: Namespace, options?: ServiceOptions);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Specify that this model is an error type. Operations return error types when the operation has failed.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typespec
|
|
88
|
+
* @error
|
|
89
|
+
* model PetStoreError {
|
|
90
|
+
* code: string;
|
|
91
|
+
* message: string;
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
extern dec error(target: object);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Specify a known data format hint for this string type. For example `uuid`, `uri`, etc.
|
|
99
|
+
* This differ from the @pattern decorator that is meant to specify a regular expression while @format takes in a known format name.
|
|
100
|
+
* The format names are open ended and are left to emitter to interpret.
|
|
101
|
+
*
|
|
102
|
+
* @param format format name.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typespec
|
|
106
|
+
* @format("uuid")
|
|
107
|
+
* scalar uuid extends string;
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
extern dec format(target: string | bytes | ModelProperty, format: string);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Specify the the pattern this string should respect using simple regular expression syntax.
|
|
114
|
+
* The following syntax is allowed: alternations (`|`), quantifiers (`?`, `*`, `+`, and `{ }`), wildcard (`.`), and grouping parentheses.
|
|
115
|
+
* Advanced features like look-around, capture groups, and references are not supported.
|
|
116
|
+
*
|
|
117
|
+
* @param pattern Regular expression.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typespec
|
|
121
|
+
* @pattern("[a-z]+")
|
|
122
|
+
* scalar LowerAlpha extends string;
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
extern dec pattern(target: string | bytes | ModelProperty, pattern: string);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Specify the minimum length this string type should be.
|
|
129
|
+
* @param value Minimum length
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typespec
|
|
133
|
+
* @minLength(2)
|
|
134
|
+
* scalar Username extends string;
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
extern dec minLength(target: string | ModelProperty, value: integer);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Specify the maximum length this string type should be.
|
|
141
|
+
* @param value Maximum length
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typespec
|
|
145
|
+
* @maxLength(20)
|
|
146
|
+
* scalar Username extends string;
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
extern dec maxLength(target: string | ModelProperty, value: integer);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Specify the minimum number of items this array should have.
|
|
153
|
+
* @param value Minimum number
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typespec
|
|
157
|
+
* @minItems(1)
|
|
158
|
+
* model Endpoints is string[];
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
extern dec minItems(target: unknown[] | ModelProperty, value: integer);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Specify the maximum number of items this array should have.
|
|
165
|
+
* @param value Maximum number
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typespec
|
|
169
|
+
* @maxItems(5)
|
|
170
|
+
* model Endpoints is string[];
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
extern dec maxItems(target: unknown[] | ModelProperty, value: integer);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Specify the minimum value this numeric type should be.
|
|
177
|
+
* @param value Minimum value
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typespec
|
|
181
|
+
* @minValue(18)
|
|
182
|
+
* scalar Age is int32;
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
extern dec minValue(target: numeric | ModelProperty, value: numeric);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Specify the maximum value this numeric type should be.
|
|
189
|
+
* @param value Maximum value
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typespec
|
|
193
|
+
* @maxValue(200)
|
|
194
|
+
* scalar Age is int32;
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
extern dec maxValue(target: numeric | ModelProperty, value: numeric);
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Specify the minimum value this numeric type should be, exclusive of the given
|
|
201
|
+
* value.
|
|
202
|
+
* @param value Minimum value
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typespec
|
|
206
|
+
* @minValueExclusive(0)
|
|
207
|
+
* scalar distance is float64;
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
extern dec minValueExclusive(target: numeric | ModelProperty, value: numeric);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Specify the maximum value this numeric type should be, exclusive of the given
|
|
214
|
+
* value.
|
|
215
|
+
* @param value Maximum value
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typespec
|
|
219
|
+
* @maxValueExclusive(50)
|
|
220
|
+
* scalar distance is float64;
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
extern dec maxValueExclusive(target: numeric | ModelProperty, value: numeric);
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Mark this string as a secret value that should be treated carefully to avoid exposure
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typespec
|
|
230
|
+
* @secret
|
|
231
|
+
* scalar Password is string;
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
extern dec secret(target: string | ModelProperty);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Attaches a tag to an operation, interface, or namespace. Multiple `@tag` decorators can be specified to attach multiple tags to a TypeSpec element.
|
|
238
|
+
* @param tag Tag value
|
|
239
|
+
*/
|
|
240
|
+
extern dec tag(target: Namespace | Interface | Operation, tag: string);
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Specifies how a templated type should name their instances.
|
|
244
|
+
* @param name name the template instance should take
|
|
245
|
+
* @formatArgs Model with key value used to interpolate the name
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typespec
|
|
249
|
+
* @friendlyName("{name}List", T)
|
|
250
|
+
* model List<T> {
|
|
251
|
+
* value: T[];
|
|
252
|
+
* nextLink: string;
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
extern dec friendlyName(target: unknown, name: string, formatArgs?: unknown);
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Provide a set of known values to a string type.
|
|
260
|
+
* @param values Known values enum.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typespec
|
|
264
|
+
* @knownValues(KnownErrorCode)
|
|
265
|
+
* scalar ErrorCode extends string;
|
|
266
|
+
*
|
|
267
|
+
* enum KnownErrorCode {
|
|
268
|
+
* NotFound,
|
|
269
|
+
* Invalid,
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
extern dec knownValues(target: string | numeric | ModelProperty, values: Enum);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Mark a model property as the key to identify instances of that type
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typespec
|
|
280
|
+
* model Pet {
|
|
281
|
+
* @key id: string;
|
|
282
|
+
* }
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
extern dec key(target: ModelProperty, altName?: string);
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Specify this operation is an overload of the given operation.
|
|
289
|
+
* @param overloadbase Base operation that should be a union of all overloads
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typespec
|
|
293
|
+
* op upload(data: string | bytes, @header contentType: "text/plain" | "application/octet-stream"): void;
|
|
294
|
+
* @overload(upload)
|
|
295
|
+
* op uploadString(data: string, @header contentType: "text/plain" ): void;
|
|
296
|
+
* @overload(upload)
|
|
297
|
+
* op uploadBytes(data: bytes, @header contentType: "application/octet-stream"): void;
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
extern dec overload(target: Operation, overloadbase: Operation);
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Provide an alternative name for this type.
|
|
304
|
+
* @param targetName Projection target
|
|
305
|
+
* @param projectedName Alternative name
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typespec
|
|
309
|
+
* model Certificate {
|
|
310
|
+
* @projectedName("json", "exp")
|
|
311
|
+
* expireAt: int32;
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
extern dec projectedName(target: unknown, targetName: string, projectedName: string);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Specify the property to be used to discriminate this type.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
*
|
|
322
|
+
* ```typespec
|
|
323
|
+
* @discriminator("kind")
|
|
324
|
+
* union Pet{ cat: Cat, dog: Dog }
|
|
325
|
+
*
|
|
326
|
+
* model Cat {kind: "cat", meow: boolean}
|
|
327
|
+
* model Dog {kind: "dog", bark: boolean}
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* ```typespec
|
|
331
|
+
* @discriminator("kind")
|
|
332
|
+
* model Pet{ kind: string }
|
|
333
|
+
*
|
|
334
|
+
* model Cat extends Pet {kind: "cat", meow: boolean}
|
|
335
|
+
* model Dog extends Pet {kind: "dog", bark: boolean}
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
extern dec discriminator(target: object | Union, propertyName: string);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Indicates that a property is only considered to be present or applicable ("visible") with
|
|
342
|
+
* the in the given named contexts ("visibilities"). When a property has no visibilities applied
|
|
343
|
+
* to it, it is implicitly visible always.
|
|
344
|
+
*
|
|
345
|
+
* As far as the TypeSpec core library is concerned, visibilities are open-ended and can be arbitrary
|
|
346
|
+
* strings, but the following visibilities are well-known to standard libraries and should be used
|
|
347
|
+
* with standard emitters that interpret them as follows:
|
|
348
|
+
*
|
|
349
|
+
* - "read": output of any operation.
|
|
350
|
+
* - "create": input to operations that create an entity..
|
|
351
|
+
* - "query": input to operations that read data.
|
|
352
|
+
* - "update": input to operations that update data.
|
|
353
|
+
* - "delete": input to operations that delete data.
|
|
354
|
+
*
|
|
355
|
+
* See also: [Automatic visibility](https://microsoft.github.io/typespec/standard-library/rest/operations#automatic-visibility)
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
*
|
|
359
|
+
* ```typespec
|
|
360
|
+
* model Dog {
|
|
361
|
+
* // the service will generate an ID, so you don't need to send it.
|
|
362
|
+
* @visibility("read") id: int32;
|
|
363
|
+
* // the service will store this secret name, but won't ever return it
|
|
364
|
+
* @visibility("create", "update") secretName: string;
|
|
365
|
+
* // the regular name is always present
|
|
366
|
+
* name: string;
|
|
367
|
+
* }
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
extern dec visibility(target: ModelProperty, ...visibilities: string[]);
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Removes properties that are not considered to be present or applicable
|
|
374
|
+
* ("visible") in the given named contexts ("visibilities"). Can be used
|
|
375
|
+
* together with spread to effectively spread only visible properties into
|
|
376
|
+
* a new model.
|
|
377
|
+
*
|
|
378
|
+
* See also: [Automatic visibility](https://microsoft.github.io/typespec/standard-library/rest/operations#automatic-visibility)
|
|
379
|
+
*
|
|
380
|
+
* When using an emitter that applies visibility automatically, it is generally
|
|
381
|
+
* not necessary to use this decorator.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typespec
|
|
385
|
+
* model Dog {
|
|
386
|
+
* @visibility("read") id: int32;
|
|
387
|
+
* @visibility("create", "update") secretName: string;
|
|
388
|
+
* name: string;
|
|
389
|
+
* }
|
|
390
|
+
*
|
|
391
|
+
* // The spread operator will copy all the properties of Dog into DogRead,
|
|
392
|
+
* // and @withVisibility will then remove those that are not visible with
|
|
393
|
+
* // create or update visibility.
|
|
394
|
+
* //
|
|
395
|
+
* // In this case, the id property is removed, and the name and secretName
|
|
396
|
+
* // properties are kept.
|
|
397
|
+
* @withVisibility("create", "update")
|
|
398
|
+
* model DogCreateOrUpdate {
|
|
399
|
+
* ...Dog;
|
|
400
|
+
* }
|
|
401
|
+
*
|
|
402
|
+
* // In this case the id and name properties are kept and the secretName property
|
|
403
|
+
* // is removed.
|
|
404
|
+
* @withVisibility("read")
|
|
405
|
+
* model DogRead {
|
|
406
|
+
* ...Dog;
|
|
407
|
+
* }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
extern dec withVisibility(target: object, ...visibilities: string[]);
|
|
411
|
+
extern dec withDefaultKeyVisibility(target: object, visibility: unknown);
|
|
412
|
+
extern dec withUpdateableProperties(target: object);
|
|
413
|
+
extern dec withoutDefaultValues(target: object);
|
|
414
|
+
extern dec withoutOmittedProperties(target: object, omit: string | Union);
|
|
415
|
+
|
|
416
|
+
//---------------------------------------------------------------------------
|
|
417
|
+
// Debugging
|
|
418
|
+
//---------------------------------------------------------------------------
|
|
419
|
+
extern dec inspectType(target: unknown, text: string);
|
|
420
|
+
extern dec inspectTypeName(target: unknown, text: string);
|
package/lib/lib.tsp
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
namespace TypeSpec;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represent a byte array
|
|
5
|
+
*/
|
|
6
|
+
scalar bytes;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A numeric type
|
|
10
|
+
*/
|
|
11
|
+
scalar numeric;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A whole number
|
|
15
|
+
*/
|
|
16
|
+
scalar integer extends numeric;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A number with decimal value
|
|
20
|
+
*/
|
|
21
|
+
scalar float extends numeric;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A 64-bit integer. (`-9,223,372,036,854,775,808` to `9,223,372,036,854,775,807`)
|
|
25
|
+
*/
|
|
26
|
+
scalar int64 extends integer;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`)
|
|
30
|
+
*/
|
|
31
|
+
scalar int32 extends int64;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A 16-bit integer. (`-32,768` to `32,767`)
|
|
35
|
+
*/
|
|
36
|
+
scalar int16 extends int32;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A 8-bit integer. (`-128` to `127`)
|
|
40
|
+
*/
|
|
41
|
+
scalar int8 extends int16;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A 64-bit unsigned integer (`0` to `18,446,744,073,709,551,615`)
|
|
45
|
+
*/
|
|
46
|
+
scalar uint64 extends integer;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A 32-bit unsigned integer (`0` to `4,294,967,295`)
|
|
50
|
+
*/
|
|
51
|
+
scalar uint32 extends uint64;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A 16-bit unsigned integer (`0` to `65,535`)
|
|
55
|
+
*/
|
|
56
|
+
scalar uint16 extends uint32;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A 8-bit unsigned integer (`0` to `255`)
|
|
60
|
+
*/
|
|
61
|
+
scalar uint8 extends uint16;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* An integer that can be serialized to JSON (`−9007199254740991 (−(2^53 − 1))` to `9007199254740991 (2^53 − 1)` )
|
|
65
|
+
*/
|
|
66
|
+
scalar safeint extends int64;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A 32 bit floating point number. (`±1.5 x 10^−45` to `±3.4 x 10^38`)
|
|
70
|
+
*/
|
|
71
|
+
scalar float64 extends float;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A 32 bit floating point number. (`±5.0 × 10^−324` to `±1.7 × 10^308`)
|
|
75
|
+
*/
|
|
76
|
+
scalar float32 extends float64;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A sequence of textual characters.
|
|
80
|
+
*/
|
|
81
|
+
scalar string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A date on a calendar without a time zone, e.g. "April 10th"
|
|
85
|
+
*/
|
|
86
|
+
scalar plainDate;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A time on a clock without a time zone, e.g. "3:00 am"
|
|
90
|
+
*/
|
|
91
|
+
scalar plainTime;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST"
|
|
95
|
+
*/
|
|
96
|
+
scalar zonedDateTime;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A duration/time period. e.g 5s, 10h
|
|
100
|
+
*/
|
|
101
|
+
scalar duration;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Boolean with `true` and `false` values.
|
|
105
|
+
*/
|
|
106
|
+
scalar boolean;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Represent any structured model.(With properties)
|
|
110
|
+
*/
|
|
111
|
+
model object {}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Array model type, equivalent to `T[]`
|
|
115
|
+
*/
|
|
116
|
+
@indexer(integer, T)
|
|
117
|
+
model Array<T> {}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Model with string properties where all the properties have type `T`
|
|
121
|
+
*/
|
|
122
|
+
@indexer(string, T)
|
|
123
|
+
model Record<T> {}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Represent a URI string as described by https://url.spec.whatwg.org/#relative-url-string.
|
|
127
|
+
*/
|
|
128
|
+
@format("url")
|
|
129
|
+
scalar url extends string;
|
|
130
|
+
|
|
131
|
+
@doc("The template for adding optional properties.")
|
|
132
|
+
@withOptionalProperties
|
|
133
|
+
model OptionalProperties<T> {
|
|
134
|
+
...T;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@doc("The template for adding updateable properties.")
|
|
138
|
+
@withUpdateableProperties
|
|
139
|
+
model UpdateableProperties<T> {
|
|
140
|
+
...T;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@doc("The template for omitting properties.")
|
|
144
|
+
@withoutOmittedProperties(TKeys)
|
|
145
|
+
model OmitProperties<T, TKeys extends string> {
|
|
146
|
+
...T;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@withoutDefaultValues
|
|
150
|
+
model OmitDefaults<T> {
|
|
151
|
+
...T;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@doc("The template for setting the default visibility of key properties.")
|
|
155
|
+
@withDefaultKeyVisibility(Visibility)
|
|
156
|
+
model DefaultKeyVisibility<T, Visibility extends string> {
|
|
157
|
+
...T;
|
|
158
|
+
}
|
package/lib/main.tsp
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Set of projections consuming the @projectedName decorator
|
|
2
|
+
#suppress "projections-are-experimental"
|
|
3
|
+
projection op#target {
|
|
4
|
+
to(targetName) {
|
|
5
|
+
if hasProjectedName(self, targetName) {
|
|
6
|
+
self::rename(getProjectedName(self, targetName));
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
from(targetName) {
|
|
10
|
+
if hasProjectedName(self, targetName) {
|
|
11
|
+
self::rename(self::projectionBase::name);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#suppress "projections-are-experimental"
|
|
17
|
+
projection interface#target {
|
|
18
|
+
to(targetName) {
|
|
19
|
+
if hasProjectedName(self, targetName) {
|
|
20
|
+
self::rename(getProjectedName(self, targetName));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
from(targetName) {
|
|
24
|
+
if hasProjectedName(self, targetName) {
|
|
25
|
+
self::rename(self::projectionBase::name);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#suppress "projections-are-experimental"
|
|
31
|
+
projection model#target {
|
|
32
|
+
to(targetName) {
|
|
33
|
+
if hasProjectedName(self, targetName) {
|
|
34
|
+
self::rename(getProjectedName(self, targetName));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
self::properties::forEach((p) => {
|
|
38
|
+
if hasProjectedName(p, targetName) {
|
|
39
|
+
self::renameProperty(p::name, getProjectedName(p, targetName));
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
from(targetName) {
|
|
44
|
+
if hasProjectedName(self, targetName) {
|
|
45
|
+
self::rename(self::projectionBase::name);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
self::projectionBase::properties::forEach((p) => {
|
|
49
|
+
if hasProjectedName(p, targetName) {
|
|
50
|
+
self::renameProperty(getProjectedName(p, targetName), p::name);
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#suppress "projections-are-experimental"
|
|
57
|
+
projection enum#target {
|
|
58
|
+
to(targetName) {
|
|
59
|
+
if hasProjectedName(self, targetName) {
|
|
60
|
+
self::rename(getProjectedName(self, targetName));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
self::members::forEach((p) => {
|
|
64
|
+
if hasProjectedName(p, targetName) {
|
|
65
|
+
self::renameMember(p::name, getProjectedName(p, targetName));
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
from(targetName) {
|
|
70
|
+
if hasProjectedName(self, targetName) {
|
|
71
|
+
self::rename(self::projectionBase::name);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
self::projectionBase::members::forEach((p) => {
|
|
75
|
+
if hasProjectedName(p, targetName) {
|
|
76
|
+
self::renameMember(getProjectedName(p, targetName), p::name);
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#suppress "projections-are-experimental"
|
|
83
|
+
projection union#target {
|
|
84
|
+
to(targetName) {
|
|
85
|
+
if hasProjectedName(self, targetName) {
|
|
86
|
+
self::rename(getProjectedName(self, targetName));
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
from(targetName) {
|
|
90
|
+
if hasProjectedName(self, targetName) {
|
|
91
|
+
self::rename(self::projectionBase::name);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|