Skip to content

Commit abbaac6

Browse files
authored
Javascript (v3): SSM - Basics scenario (#6792)
1 parent 48a3915 commit abbaac6

29 files changed

+2173
-13
lines changed

.doc_gen/metadata/ssm_metadata.yaml

+109
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ ssm_Hello:
1313
- description:
1414
snippet_tags:
1515
- ssm.java2.hello.main
16+
JavaScript:
17+
versions:
18+
- sdk_version: 3
19+
github: javascriptv3/example_code/ssm
20+
sdkguide:
21+
excerpts:
22+
- description:
23+
snippet_tags:
24+
- ssm.JavaScript.Basics.hello
1625
Python:
1726
versions:
1827
- sdk_version: 3
@@ -88,6 +97,15 @@ ssm_CreateOpsItem:
8897
- description:
8998
snippet_tags:
9099
- ssm.java2.create_ops.main
100+
JavaScript:
101+
versions:
102+
- sdk_version: 3
103+
github: javascriptv3/example_code/ssm
104+
sdkguide:
105+
excerpts:
106+
- description:
107+
snippet_tags:
108+
- ssm.JavaScript.Basics.createOpsItem
91109
Python:
92110
versions:
93111
- sdk_version: 3
@@ -111,6 +129,15 @@ ssm_UpdateMaintenanceWindow:
111129
- description:
112130
snippet_tags:
113131
- ssm.java2.update_window.main
132+
JavaScript:
133+
versions:
134+
- sdk_version: 3
135+
github: javascriptv3/example_code/ssm
136+
sdkguide:
137+
excerpts:
138+
- description:
139+
snippet_tags:
140+
- ssm.JavaScript.Basics.updateMaintenanceWindow
114141
Python:
115142
versions:
116143
- sdk_version: 3
@@ -134,6 +161,15 @@ ssm_CreateMaintenanceWindow:
134161
- description:
135162
snippet_tags:
136163
- ssm.java2.create_window.main
164+
JavaScript:
165+
versions:
166+
- sdk_version: 3
167+
github: javascriptv3/example_code/ssm
168+
sdkguide:
169+
excerpts:
170+
- description:
171+
snippet_tags:
172+
- ssm.JavaScript.Basics.createMaintenanceWindow
137173
Python:
138174
versions:
139175
- sdk_version: 3
@@ -157,6 +193,15 @@ ssm_SendCommand:
157193
- description:
158194
snippet_tags:
159195
- ssm.Java2.send_command.main
196+
JavaScript:
197+
versions:
198+
- sdk_version: 3
199+
github: javascriptv3/example_code/ssm
200+
sdkguide:
201+
excerpts:
202+
- description:
203+
snippet_tags:
204+
- ssm.JavaScript.Basics.sendCommand
160205
Python:
161206
versions:
162207
- sdk_version: 3
@@ -171,6 +216,15 @@ ssm_SendCommand:
171216
ssm: {SendCommand}
172217
ssm_ListCommandInvocations:
173218
languages:
219+
JavaScript:
220+
versions:
221+
- sdk_version: 3
222+
github: javascriptv3/example_code/ssm
223+
sdkguide:
224+
excerpts:
225+
- description:
226+
snippet_tags:
227+
- ssm.JavaScript.Basics.listCommandInvocations
174228
Python:
175229
versions:
176230
- sdk_version: 3
@@ -194,6 +248,15 @@ ssm_CreateDocument:
194248
- description:
195249
snippet_tags:
196250
- ssm.java2.create_doc.main
251+
JavaScript:
252+
versions:
253+
- sdk_version: 3
254+
github: javascriptv3/example_code/ssm
255+
sdkguide:
256+
excerpts:
257+
- description:
258+
snippet_tags:
259+
- ssm.JavaScript.Basics.createDocument
197260
Python:
198261
versions:
199262
- sdk_version: 3
@@ -217,6 +280,15 @@ ssm_DescribeOpsItems:
217280
- description:
218281
snippet_tags:
219282
- ssm.java2.describe_ops.main
283+
JavaScript:
284+
versions:
285+
- sdk_version: 3
286+
github: javascriptv3/example_code/ssm
287+
sdkguide:
288+
excerpts:
289+
- description:
290+
snippet_tags:
291+
- ssm.JavaScript.Basics.describeOpsItems
220292
Python:
221293
versions:
222294
- sdk_version: 3
@@ -254,6 +326,15 @@ ssm_DeleteMaintenanceWindow:
254326
- description:
255327
snippet_tags:
256328
- ssm.java2.delete_window.main
329+
JavaScript:
330+
versions:
331+
- sdk_version: 3
332+
github: javascriptv3/example_code/ssm
333+
sdkguide:
334+
excerpts:
335+
- description:
336+
snippet_tags:
337+
- ssm.JavaScript.Basics.deleteMaintenanceWindow
257338
Python:
258339
versions:
259340
- sdk_version: 3
@@ -277,6 +358,15 @@ ssm_DeleteDocument:
277358
- description:
278359
snippet_tags:
279360
- ssm.Java2.delete_doc.main
361+
JavaScript:
362+
versions:
363+
- sdk_version: 3
364+
github: javascriptv3/example_code/ssm
365+
sdkguide:
366+
excerpts:
367+
- description:
368+
snippet_tags:
369+
- ssm.JavaScript.Basics.deleteDocument
280370
Python:
281371
versions:
282372
- sdk_version: 3
@@ -300,6 +390,15 @@ ssm_UpdateOpsItem:
300390
- description:
301391
snippet_tags:
302392
- ssm.Java2.resolve_ops.main
393+
JavaScript:
394+
versions:
395+
- sdk_version: 3
396+
github: javascriptv3/example_code/ssm
397+
sdkguide:
398+
excerpts:
399+
- description:
400+
snippet_tags:
401+
- ssm.JavaScript.Basics.updateOpsItem
303402
Python:
304403
versions:
305404
- sdk_version: 3
@@ -328,6 +427,16 @@ ssm_Scenario:
328427
- description: A wrapper class for &SYS; SDK methods.
329428
snippet_tags:
330429
- ssm.java2.actions.main
430+
JavaScript:
431+
versions:
432+
- sdk_version: 3
433+
github: javascriptv3/example_code/ssm
434+
sdkguide:
435+
genai: some
436+
excerpts:
437+
- description:
438+
snippet_tags:
439+
- ssm.JavaScript.Basics.scenario
331440
Python:
332441
versions:
333442
- sdk_version: 3

javascriptv3/example_code/libs/scenario/scenario.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export class Step {
4646
console.log(
4747
`[DEBUG ${new Date().toISOString()}] Handling step: ${
4848
this.constructor.name
49-
}<${this.name}>`,
49+
}<${this.name}>`
5050
);
5151
console.log(
52-
`[DEBUG ${new Date().toISOString()}] State: ${JSON.stringify(state)}`,
52+
`[DEBUG ${new Date().toISOString()}] State: ${JSON.stringify(state)}`
5353
);
5454
}
5555
}
@@ -150,16 +150,19 @@ export class ScenarioInput extends Step {
150150
? this.stepOptions.default(state)
151151
: this.stepOptions.default;
152152

153-
if (stepHandlerOptions.confirmAll && this.default) {
154-
state[this.name] = this.default;
153+
if (
154+
stepHandlerOptions.confirmAll &&
155+
this.stepOptions.default != undefined
156+
) {
157+
state[this.name] = this.stepOptions.default;
155158
return state[this.name];
156-
} else if (stepHandlerOptions.confirmAll && !this.default) {
159+
} else if (stepHandlerOptions.confirmAll) {
157160
if (this.stepOptions?.type === "confirm") {
158161
state[this.name] = true;
159162
return true;
160163
}
161164
throw new Error(
162-
`Error handling ScenarioInput. confirmAll was selected for ${this.name} but no default was provided.`,
165+
`Error handling ScenarioInput. confirmAll was selected for ${this.name} but no default was provided.`
163166
);
164167
}
165168

@@ -178,7 +181,7 @@ export class ScenarioInput extends Step {
178181
break;
179182
default:
180183
throw new Error(
181-
`Error handling ScenarioInput, ${this.stepOptions?.type} is not supported.`,
184+
`Error handling ScenarioInput, ${this.stepOptions?.type} is not supported.`
182185
);
183186
}
184187

@@ -200,7 +203,7 @@ export class ScenarioInput extends Step {
200203

201204
if (!rawChoices) {
202205
throw new Error(
203-
`Error handling ScenarioInput. Could not get choices for ${this.name}.`,
206+
`Error handling ScenarioInput. Could not get choices for ${this.name}.`
204207
);
205208
}
206209

@@ -232,7 +235,7 @@ export class ScenarioInput extends Step {
232235
state[this.name] = this.default;
233236
} else if (!result.length) {
234237
throw new Error(
235-
`Error handing ScenarioInput. Result of ${this.name} was empty.`,
238+
`Error handing ScenarioInput. Result of ${this.name} was empty.`
236239
);
237240
} else {
238241
state[this.name] = result;
@@ -260,7 +263,7 @@ export class ScenarioInput extends Step {
260263
state[this.name] = this.default;
261264
} else if (!result) {
262265
throw new Error(
263-
`Error handing ScenarioInput. Result of ${this.name} was empty.`,
266+
`Error handing ScenarioInput. Result of ${this.name} was empty.`
264267
);
265268
} else {
266269
state[this.name] = result;
@@ -284,9 +287,9 @@ export class ScenarioInput extends Step {
284287

285288
if (!result && this.default) {
286289
state[this.name] = this.default;
287-
} else if (!result) {
290+
} else if (result === undefined) {
288291
throw new Error(
289-
`Error handing ScenarioInput. Result of ${this.name} was empty.`,
292+
`Error handing ScenarioInput. Result of ${this.name} was empty.`
290293
);
291294
} else {
292295
state[this.name] = result;
@@ -359,7 +362,7 @@ export class ScenarioAction extends Step {
359362
output &&
360363
(await this.stepOptions.whileConfig.output.handle(
361364
state,
362-
stepHandlerOptions,
365+
stepHandlerOptions
363366
));
364367
await input.handle(state, stepHandlerOptions);
365368
runAction = whileFn(state);

0 commit comments

Comments
 (0)