23
23
import java .util .stream .Collectors ;
24
24
import software .amazon .smithy .codegen .core .CodegenException ;
25
25
import software .amazon .smithy .model .Model ;
26
+ import software .amazon .smithy .model .node .BooleanNode ;
26
27
import software .amazon .smithy .model .node .Node ;
27
28
import software .amazon .smithy .model .node .ObjectNode ;
28
29
import software .amazon .smithy .model .node .StringNode ;
@@ -45,6 +46,7 @@ public final class TypeScriptSettings {
45
46
private static final String PACKAGE_JSON = "packageJson" ;
46
47
private static final String SERVICE = "service" ;
47
48
private static final String PROTOCOL = "protocol" ;
49
+ private static final String PRIVATE = "private" ;
48
50
49
51
private String packageName ;
50
52
private String packageDescription = "" ;
@@ -53,6 +55,7 @@ public final class TypeScriptSettings {
53
55
private ShapeId service ;
54
56
private ObjectNode pluginSettings = Node .objectNode ();
55
57
private String protocol = "" ;
58
+ private boolean isPrivate ;
56
59
57
60
/**
58
61
* Create a settings object from a configuration object node.
@@ -64,7 +67,8 @@ public final class TypeScriptSettings {
64
67
public static TypeScriptSettings from (Model model , ObjectNode config ) {
65
68
TypeScriptSettings settings = new TypeScriptSettings ();
66
69
config .warnIfAdditionalProperties (Arrays .asList (
67
- PACKAGE , PACKAGE_DESCRIPTION , PACKAGE_JSON , PACKAGE_VERSION , SERVICE , PROTOCOL , TARGET_NAMESPACE ));
70
+ PACKAGE , PACKAGE_DESCRIPTION , PACKAGE_JSON , PACKAGE_VERSION ,
71
+ SERVICE , PROTOCOL , TARGET_NAMESPACE , PRIVATE ));
68
72
69
73
// Get the service from the settings or infer one from the given model.
70
74
settings .setService (config .getStringMember (SERVICE )
@@ -77,6 +81,7 @@ public static TypeScriptSettings from(Model model, ObjectNode config) {
77
81
PACKAGE_DESCRIPTION , settings .getPackageName () + " client" ));
78
82
settings .packageJson = config .getObjectMember (PACKAGE_JSON ).orElse (Node .objectNode ());
79
83
config .getStringMember (PROTOCOL ).map (StringNode ::getValue ).ifPresent (settings ::setProtocol );
84
+ settings .setPrivate (config .getBooleanMember (PRIVATE ).map (BooleanNode ::getValue ).orElse (false ));
80
85
81
86
settings .setPluginSettings (config );
82
87
return settings ;
@@ -196,6 +201,19 @@ public void setPluginSettings(ObjectNode pluginSettings) {
196
201
this .pluginSettings = Objects .requireNonNull (pluginSettings );
197
202
}
198
203
204
+ /**
205
+ * Returns if the generated package will be made private.
206
+ *
207
+ * @return If the package will be private.
208
+ */
209
+ public boolean isPrivate () {
210
+ return isPrivate ;
211
+ }
212
+
213
+ public void setPrivate (boolean isPrivate ) {
214
+ this .isPrivate = isPrivate ;
215
+ }
216
+
199
217
/**
200
218
* Gets the corresponding {@link ServiceShape} from a model.
201
219
*
0 commit comments