@pulumi/pulumi 3.163.0-alpha.x5bf1e8a → 3.163.0-alpha.xa463c1e

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.
Files changed (70) hide show
  1. package/automation/cmd.js +92 -111
  2. package/automation/cmd.js.map +1 -1
  3. package/automation/localWorkspace.js +383 -476
  4. package/automation/localWorkspace.js.map +1 -1
  5. package/automation/remoteWorkspace.js +38 -55
  6. package/automation/remoteWorkspace.js.map +1 -1
  7. package/automation/server.js +6 -16
  8. package/automation/server.js.map +1 -1
  9. package/automation/stack.js +537 -608
  10. package/automation/stack.js.map +1 -1
  11. package/cmd/dynamic-provider/index.js +204 -235
  12. package/cmd/dynamic-provider/index.js.map +1 -1
  13. package/cmd/run/error.js +3 -3
  14. package/cmd/run/error.js.map +1 -1
  15. package/cmd/run/run.js +322 -336
  16. package/cmd/run/run.js.map +1 -1
  17. package/cmd/run/tracing.js +1 -2
  18. package/cmd/run/tracing.js.map +1 -1
  19. package/cmd/run-plugin/run.js +13 -17
  20. package/cmd/run-plugin/run.js.map +1 -1
  21. package/cmd/run-policy-pack/run.js +12 -16
  22. package/cmd/run-policy-pack/run.js.map +1 -1
  23. package/output.js +61 -78
  24. package/output.js.map +1 -1
  25. package/package.json +1 -1
  26. package/provider/experimental/analyzer.js +122 -205
  27. package/provider/experimental/analyzer.js.map +1 -1
  28. package/provider/experimental/provider.js +22 -36
  29. package/provider/experimental/provider.js.map +1 -1
  30. package/provider/server.js +359 -397
  31. package/provider/server.js.map +1 -1
  32. package/resource.js +29 -41
  33. package/resource.js.map +1 -1
  34. package/runtime/asyncIterableUtil.js +6 -17
  35. package/runtime/asyncIterableUtil.js.map +1 -1
  36. package/runtime/callbacks.js +254 -269
  37. package/runtime/callbacks.js.map +1 -1
  38. package/runtime/closure/codePaths.js +117 -135
  39. package/runtime/closure/codePaths.js.map +1 -1
  40. package/runtime/closure/createClosure.js +807 -871
  41. package/runtime/closure/createClosure.js.map +1 -1
  42. package/runtime/closure/parseFunction.js +2 -3
  43. package/runtime/closure/parseFunction.js.map +1 -1
  44. package/runtime/closure/serializeClosure.js +17 -30
  45. package/runtime/closure/serializeClosure.js.map +1 -1
  46. package/runtime/closure/v8.js +166 -190
  47. package/runtime/closure/v8.js.map +1 -1
  48. package/runtime/closure/v8Hooks.js +19 -34
  49. package/runtime/closure/v8Hooks.js.map +1 -1
  50. package/runtime/dependsOn.js +61 -80
  51. package/runtime/dependsOn.js.map +1 -1
  52. package/runtime/invoke.js +155 -170
  53. package/runtime/invoke.js.map +1 -1
  54. package/runtime/mocks.js +77 -96
  55. package/runtime/mocks.js.map +1 -1
  56. package/runtime/resource.js +238 -252
  57. package/runtime/resource.js.map +1 -1
  58. package/runtime/rpc.js +193 -215
  59. package/runtime/rpc.js.map +1 -1
  60. package/runtime/settings.js +70 -87
  61. package/runtime/settings.js.map +1 -1
  62. package/runtime/stack.js +111 -131
  63. package/runtime/stack.js.map +1 -1
  64. package/stackReference.js +39 -58
  65. package/stackReference.js.map +1 -1
  66. package/tsutils.js +1 -2
  67. package/tsutils.js.map +1 -1
  68. package/utils.js +2 -3
  69. package/utils.js.map +1 -1
  70. package/version.js +1 -1
@@ -89,7 +89,7 @@ class Analyzer {
89
89
  else if ((ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) && node.name) {
90
90
  // Collect documentation for types
91
91
  const dNode = node;
92
- if ((dNode === null || dNode === void 0 ? void 0 : dNode.jsDoc) && dNode.jsDoc.length > 0) {
92
+ if (dNode?.jsDoc && dNode.jsDoc.length > 0) {
93
93
  const typeDocString = dNode.jsDoc.map((doc) => doc.comment).join("\n");
94
94
  if (typeDocString) {
95
95
  this.docStrings[node.name.text] = typeDocString;
@@ -211,15 +211,14 @@ Please ensure these components are properly imported to your package's entry poi
211
211
  return importedFiles;
212
212
  }
213
213
  analyzeComponent(node) {
214
- var _a;
215
- const componentName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.text;
214
+ const componentName = node.name?.text;
216
215
  // We expect exactly 1 constructor, and it must have and 'args'
217
216
  // parameter that has an interface type.
218
217
  const constructors = node.members.filter((member) => ts.isConstructorDeclaration(member));
219
218
  if (constructors.length !== 1) {
220
219
  throw new Error(`Component '${componentName}' must have exactly one constructor`);
221
220
  }
222
- const argsParam = constructors === null || constructors === void 0 ? void 0 : constructors[0].parameters.find((param) => {
221
+ const argsParam = constructors?.[0].parameters.find((param) => {
223
222
  return ts.isIdentifier(param.name) && param.name.escapedText === "args";
224
223
  });
225
224
  if (!argsParam) {
@@ -240,7 +239,7 @@ Please ensure these components are properly imported to your package's entry poi
240
239
  let outputs = {};
241
240
  const classType = this.checker.getTypeAtLocation(node);
242
241
  const classSymbol = classType.getSymbol();
243
- if (classSymbol === null || classSymbol === void 0 ? void 0 : classSymbol.members) {
242
+ if (classSymbol?.members) {
244
243
  outputs = this.analyzeSymbols({ component: componentName, inputOutput: InputOutput.Output }, symbolTableToSymbols(classSymbol.members), node);
245
244
  }
246
245
  const definition = {
@@ -260,12 +259,11 @@ Please ensure these components are properly imported to your package's entry poi
260
259
  }
261
260
  return node.heritageClauses.some((clause) => {
262
261
  return clause.types.some((clauseNode) => {
263
- var _a;
264
262
  const type = this.checker.getTypeAtLocation(clauseNode);
265
263
  const symbol = type.getSymbol();
266
- const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "ComponentResource";
267
- const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
268
- const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.d.ts"));
264
+ const matchesName = symbol?.escapedName === "ComponentResource";
265
+ const sourceFile = symbol?.declarations?.[0].getSourceFile();
266
+ const matchesSourceFile = sourceFile?.fileName.endsWith("resource.ts") || sourceFile?.fileName.endsWith("resource.d.ts");
269
267
  return matchesName && matchesSourceFile;
270
268
  });
271
269
  });
@@ -277,7 +275,7 @@ Please ensure these components are properly imported to your package's entry poi
277
275
  return;
278
276
  }
279
277
  const name = member.escapedName;
280
- properties[name] = this.analyzeSymbol(Object.assign(Object.assign({}, context), { property: name }), member, location);
278
+ properties[name] = this.analyzeSymbol({ ...context, property: name }, member, location);
281
279
  });
282
280
  return properties;
283
281
  }
@@ -288,15 +286,13 @@ Please ensure these components are properly imported to your package's entry poi
288
286
  const optional = isOptional(symbol);
289
287
  const dNode = symbol.valueDeclaration;
290
288
  let docString = undefined;
291
- if ((dNode === null || dNode === void 0 ? void 0 : dNode.jsDoc) && dNode.jsDoc.length > 0) {
289
+ if (dNode?.jsDoc && dNode.jsDoc.length > 0) {
292
290
  docString = dNode.jsDoc.map((doc) => doc.comment).join("\n");
293
291
  }
294
- return this.analyzeType(Object.assign(Object.assign({}, context), { inputOutput: InputOutput.Neither }), propType, location, optional, docString);
292
+ return this.analyzeType({ ...context, inputOutput: InputOutput.Neither }, propType, location, optional, docString);
295
293
  }
296
294
  analyzeType(context, type, location, optional = false, docString = undefined) {
297
- var _a, _b, _c;
298
- if (isSimpleType(type)) {
299
- const prop = { type: tsTypeToPropertyType(type) };
295
+ const makeProp = (prop) => {
300
296
  if (optional) {
301
297
  prop.optional = true;
302
298
  }
@@ -307,101 +303,55 @@ Please ensure these components are properly imported to your package's entry poi
307
303
  prop.description = docString;
308
304
  }
309
305
  return prop;
306
+ };
307
+ const propType = getSimplePropertyType(type);
308
+ if (propType) {
309
+ return makeProp({ type: propType });
310
310
  }
311
- else if (isInput(type)) {
312
- // Grab the promise type from the `T | Promise<T> | OutputInstance<T>`
313
- // union, and get the type reference `T` from there. With that we
314
- // can recursively analyze the type, passing through the optional
315
- // flag. The type can now not be plain anymore, since it's in an
316
- // input.
317
- const base = (_b = (_a = type) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.find(isPromise);
318
- if (!base) {
319
- // unreachable due to the isInput check
320
- throw new Error(`Input type union must include a Promise: ${this.formatErrorContext(context)} has type '${this.checker.typeToString(type)}'`);
321
- }
322
- const innerType = this.unwrapTypeReference(context, base);
323
- return this.analyzeType(Object.assign(Object.assign({}, context), { inputOutput: InputOutput.Input }), innerType, location, optional, docString);
311
+ const innerInputType = getInputInnerType(type);
312
+ if (innerInputType) {
313
+ const innerType = this.unwrapTypeReference(context, innerInputType);
314
+ return this.analyzeType({ ...context, inputOutput: InputOutput.Input }, innerType, location, optional, docString);
324
315
  }
325
- else if (isOutput(type)) {
316
+ if (isOutput(type)) {
326
317
  type = unwrapOutputIntersection(type);
327
318
  // Grab the inner type of the OutputInstance<T> type, and then
328
319
  // recurse, passing through the optional flag. The type can now not
329
320
  // be plain anymore, since it's wrapped in an output.
330
321
  const innerType = this.unwrapTypeReference(context, type);
331
- return this.analyzeType(Object.assign(Object.assign({}, context), { inputOutput: InputOutput.Output }), innerType, location, optional, docString);
322
+ return this.analyzeType({ ...context, inputOutput: InputOutput.Output }, innerType, location, optional, docString);
332
323
  }
333
- else if (isAny(type)) {
334
- const $ref = "pulumi.json#/Any";
335
- const prop = { $ref };
336
- if (optional) {
337
- prop.optional = true;
338
- }
339
- if (docString) {
340
- prop.description = docString;
341
- }
324
+ if (isAny(type)) {
325
+ const prop = makeProp({ $ref: "pulumi.json#/Any" });
326
+ // Any is never plain, since it can be anything, including an Input<T>.
327
+ // biome-ignore lint/performance/noDelete: Completely remove the property to not include it in the schema.
328
+ delete prop.plain;
342
329
  return prop;
343
330
  }
344
- else if (isAsset(type)) {
345
- const $ref = "pulumi.json#/Asset";
346
- const prop = { $ref };
347
- if (optional) {
348
- prop.optional = true;
349
- }
350
- if (context.inputOutput === InputOutput.Neither) {
351
- prop.plain = true;
352
- }
353
- if (docString) {
354
- prop.description = docString;
355
- }
356
- return prop;
331
+ if (isAsset(type)) {
332
+ return makeProp({ $ref: "pulumi.json#/Asset" });
357
333
  }
358
- else if (isArchive(type)) {
359
- const $ref = "pulumi.json#/Archive";
360
- const prop = { $ref };
361
- if (optional) {
362
- prop.optional = true;
363
- }
364
- if (context.inputOutput === InputOutput.Neither) {
365
- prop.plain = true;
366
- }
367
- if (docString) {
368
- prop.description = docString;
369
- }
370
- return prop;
334
+ if (isArchive(type)) {
335
+ return makeProp({ $ref: "pulumi.json#/Archive" });
371
336
  }
372
- else if (isResourceReference(type, this.checker)) {
337
+ if (isResourceReference(type, this.checker)) {
373
338
  const { packageName, packageVersion, pulumiType } = this.getResourceType(context, type);
374
- const $ref = `/${packageName}/v${packageVersion}/schema.json#/resources/${pulumiType.replace("/", "%2F")}`;
375
339
  this.packageReferences[packageName] = packageVersion;
376
- const prop = { $ref };
377
- if (optional) {
378
- prop.optional = true;
379
- }
380
- if (context.inputOutput === InputOutput.Neither) {
381
- prop.plain = true;
382
- }
383
- if (docString) {
384
- prop.description = docString;
385
- }
386
- return prop;
340
+ return makeProp({
341
+ $ref: `/${packageName}/v${packageVersion}/schema.json#/resources/${pulumiType.replace("/", "%2F")}`,
342
+ });
387
343
  }
388
- else if (type.isClassOrInterface()) {
344
+ if (type.isClassOrInterface()) {
389
345
  // This is a complex type, create a typedef and then reference it in
390
346
  // the PropertyDefinition.
391
- const name = (_c = type.getSymbol()) === null || _c === void 0 ? void 0 : _c.escapedName;
347
+ const name = type.getSymbol()?.escapedName;
392
348
  if (!name) {
393
349
  throw new Error(`Class or interface has no name: ${this.formatErrorContext(context)} has type '${this.checker.typeToString(type)}'`);
394
350
  }
395
351
  if (this.typeDefinitions[name]) {
396
352
  // Type already exists, just reference it and we're done.
397
353
  const refProp = { $ref: `#/types/${this.providerName}:index:${name}` };
398
- if (optional) {
399
- refProp.optional = true;
400
- }
401
- if (context.inputOutput === InputOutput.Neither) {
402
- refProp.plain = true;
403
- }
404
- return refProp;
354
+ return makeProp(refProp);
405
355
  }
406
356
  // Immediately add an empty type definition, so that it can be
407
357
  // referenced recursively, then analyze the properties.
@@ -409,85 +359,44 @@ Please ensure these components are properly imported to your package's entry poi
409
359
  if (this.docStrings[name]) {
410
360
  this.typeDefinitions[name].description = this.docStrings[name];
411
361
  }
412
- const typeContext = Object.assign(Object.assign({}, context), { typeName: name });
362
+ const typeContext = { ...context, typeName: name };
413
363
  const properties = this.analyzeSymbols(typeContext, type.getProperties(), location);
414
364
  this.typeDefinitions[name].properties = properties;
415
- const $ref = `#/types/${this.providerName}:index:${name}`;
416
- const prop = { $ref };
417
- if (optional) {
418
- prop.optional = true;
419
- }
420
- if (context.inputOutput === InputOutput.Neither) {
421
- prop.plain = true;
422
- }
423
- if (docString) {
424
- prop.description = docString;
425
- }
426
- return prop;
427
- }
428
- else if (isArrayType(type)) {
429
- const prop = { type: "array" };
430
- if (optional) {
431
- prop.optional = true;
432
- }
433
- if (context.inputOutput === InputOutput.Neither) {
434
- prop.plain = true;
435
- }
436
- const typeArguments = type.typeArguments;
437
- if (!typeArguments || typeArguments.length !== 1) {
438
- throw new Error(`Expected exactly one type argument in '${this.checker.typeToString(type)}': ${this.formatErrorContext(context)} has ${(typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) || 0} type arguments`);
439
- }
440
- const innerType = typeArguments[0];
441
- prop.items = this.analyzeType(Object.assign(Object.assign({}, context), { property: `${context.property}[]`, inputOutput: context.inputOutput === InputOutput.Output ? InputOutput.Output : InputOutput.Neither }), innerType, location, false /* optional */);
442
- if (docString) {
443
- prop.description = docString;
444
- }
445
- return prop;
365
+ return makeProp({ $ref: `#/types/${this.providerName}:index:${name}` });
366
+ }
367
+ const arrayItemType = getArrayType(type);
368
+ if (arrayItemType) {
369
+ return makeProp({
370
+ type: "array",
371
+ items: this.analyzeType({
372
+ ...context,
373
+ property: `${context.property}[]`,
374
+ inputOutput: context.inputOutput === InputOutput.Output ? InputOutput.Output : InputOutput.Neither,
375
+ }, arrayItemType, location, false /* optional */),
376
+ });
446
377
  }
447
- else if (isMapType(type, this.checker)) {
448
- const prop = { type: "object" };
449
- if (optional) {
450
- prop.optional = true;
451
- }
452
- if (context.inputOutput === InputOutput.Neither) {
453
- prop.plain = true;
454
- }
455
- // We got { [key: string]: <indexInfo.type> }
456
- const indexInfo = this.checker.getIndexInfoOfType(type, ts.IndexKind.String);
457
- if (!indexInfo) {
458
- // We can't actually get here because isMapType checks for indexInfo
459
- throw new Error(`Map type has no index info`);
460
- }
461
- if (docString) {
462
- prop.description = docString;
463
- }
464
- prop.additionalProperties = this.analyzeType(Object.assign(Object.assign({}, context), { property: `${context.property} values` }), indexInfo.type, location, false);
465
- return prop;
378
+ const mapType = getMapType(type, this.checker);
379
+ if (mapType) {
380
+ return makeProp({
381
+ type: "object",
382
+ additionalProperties: this.analyzeType({
383
+ ...context,
384
+ property: `${context.property} values`,
385
+ }, mapType, location, false),
386
+ });
466
387
  }
467
- else if (isBooleanOptionalType(type, this.checker)) {
388
+ if (isBooleanOptionalType(type, this.checker)) {
468
389
  // This is the special case for true | false | undefined
469
- const prop = { type: "boolean" };
470
- prop.optional = true;
471
- if (context.inputOutput === InputOutput.Neither) {
472
- prop.plain = true;
473
- }
474
- if (docString) {
475
- prop.description = docString;
476
- }
477
- return prop;
390
+ return makeProp({ type: "boolean", optional: true });
478
391
  }
479
- else if (isOptionalType(type, this.checker)) {
480
- const unionType = type;
481
- const nonUndefinedType = unionType.types.find((t) => !(t.flags & ts.TypeFlags.Undefined));
482
- if (!nonUndefinedType) {
483
- throw new Error(`Expected exactly one type to not be undefined: ${this.formatErrorContext(context)} has type '${this.checker.typeToString(type)}'`);
484
- }
485
- return this.analyzeType(context, nonUndefinedType, location, true, docString);
392
+ const optionalType = getOptionalType(type);
393
+ if (optionalType) {
394
+ return this.analyzeType(context, optionalType, location, true, docString);
486
395
  }
487
- else if (type.isUnion()) {
396
+ if (type.isUnion()) {
488
397
  throw new Error(`Union types are not supported for ${this.formatErrorContext(context)}: type '${this.checker.typeToString(type)}'`);
489
398
  }
490
- else if (type.isIntersection()) {
399
+ if (type.isIntersection()) {
491
400
  throw new Error(`Intersection types are not supported for ${this.formatErrorContext(context)}: type '${this.checker.typeToString(type)}'`);
492
401
  }
493
402
  throw new Error(`Unsupported type for ${this.formatErrorContext(context)}: type '${this.checker.typeToString(type)}'`);
@@ -498,7 +407,7 @@ Please ensure these components are properly imported to your package's entry poi
498
407
  typeArguments = type.aliasTypeArguments;
499
408
  }
500
409
  if (!typeArguments || typeArguments.length !== 1) {
501
- throw new Error(`Expected exactly one type argument in '${this.checker.typeToString(type)}': ${this.formatErrorContext(context)} has ${(typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) || 0} type arguments`);
410
+ throw new Error(`Expected exactly one type argument in '${this.checker.typeToString(type)}': ${this.formatErrorContext(context)} has ${typeArguments?.length || 0} type arguments`);
502
411
  }
503
412
  const innerType = typeArguments[0];
504
413
  return innerType;
@@ -536,13 +445,12 @@ Please ensure these components are properly imported to your package's entry poi
536
445
  * @throws Error if the resource type cannot be determined with detailed context information
537
446
  */
538
447
  getResourceType(context, type) {
539
- var _a;
540
448
  const symbol = type.getSymbol();
541
449
  if (!symbol) {
542
450
  throw new Error(`Cannot determine resource type: source (symbol) not found for type '${this.checker.typeToString(type)}' for ${this.formatErrorContext(context)}`);
543
451
  }
544
452
  // Try to find the declaration of the class
545
- const declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
453
+ const declaration = symbol.declarations?.[0];
546
454
  if (!declaration) {
547
455
  throw new Error(`Cannot determine resource type: source (declaration) not found for symbol '${symbol.name}' for ${this.formatErrorContext(context)}`);
548
456
  }
@@ -610,17 +518,22 @@ exports.Analyzer = Analyzer;
610
518
  function isOptional(symbol) {
611
519
  return (symbol.flags & ts.SymbolFlags.Optional) === ts.SymbolFlags.Optional;
612
520
  }
613
- function isOptionalType(type, checker) {
521
+ function getOptionalType(type) {
614
522
  if (!(type.flags & ts.TypeFlags.Union)) {
615
- return false;
523
+ return undefined;
616
524
  }
617
525
  const unionType = type;
618
526
  // We only support union types with two types, one of which must be undefined
619
527
  if (!unionType.types || unionType.types.length !== 2) {
620
- return false;
528
+ return undefined;
621
529
  }
622
530
  // Check if one of the types in the union is undefined
623
- return unionType.types.some((t) => t.flags & ts.TypeFlags.Undefined || t.flags & ts.TypeFlags.Void);
531
+ const undefinedType = unionType.types.find((t) => t.flags & ts.TypeFlags.Undefined || t.flags & ts.TypeFlags.Void); // Also check for void in some cases
532
+ if (!undefinedType) {
533
+ return undefined;
534
+ }
535
+ const nonUndefinedType = unionType.types.find((t) => !(t.flags & ts.TypeFlags.Undefined || t.flags & ts.TypeFlags.Void));
536
+ return nonUndefinedType;
624
537
  }
625
538
  // Checks if a type is a union of true | false | undefined, which represents an optional boolean.
626
539
  function isBooleanOptionalType(type, checker) {
@@ -670,16 +583,35 @@ function isBoolean(type) {
670
583
  function isAny(type) {
671
584
  return (type.flags & ts.TypeFlags.Any) === ts.TypeFlags.Any;
672
585
  }
673
- function isSimpleType(type) {
674
- return isNumber(type) || isString(type) || isBoolean(type);
586
+ function getSimplePropertyType(type) {
587
+ if (isNumber(type)) {
588
+ return "number";
589
+ }
590
+ else if (isString(type)) {
591
+ return "string";
592
+ }
593
+ else if (isBoolean(type)) {
594
+ return "boolean";
595
+ }
596
+ return undefined;
675
597
  }
676
- function isMapType(type, checker) {
598
+ function getMapType(type, checker) {
677
599
  const indexInfo = checker.getIndexInfoOfType(type, ts.IndexKind.String);
678
- return indexInfo !== undefined;
600
+ if (!indexInfo) {
601
+ return undefined;
602
+ }
603
+ return indexInfo.type;
679
604
  }
680
- function isArrayType(type) {
681
- var _a;
682
- return (type.flags & ts.TypeFlags.Object) === ts.TypeFlags.Object && ((_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.escapedName) === "Array";
605
+ function getArrayType(type) {
606
+ const isArray = (type.flags & ts.TypeFlags.Object) === ts.TypeFlags.Object && type.getSymbol()?.escapedName === "Array";
607
+ if (!isArray) {
608
+ return undefined;
609
+ }
610
+ const typeArguments = type.typeArguments;
611
+ if (!typeArguments || typeArguments.length !== 1) {
612
+ return undefined;
613
+ }
614
+ return typeArguments[0];
683
615
  }
684
616
  function isPromise(type) {
685
617
  if (!(type.flags & ts.TypeFlags.Object)) {
@@ -692,7 +624,6 @@ function isPromise(type) {
692
624
  return symbol.name === "Promise";
693
625
  }
694
626
  function isOutput(type) {
695
- var _a;
696
627
  // In sdk/nodejs/output.ts we define Output as:
697
628
  //
698
629
  // export type Output<T> = OutputInstance<T> & Lifted<T>;
@@ -712,25 +643,23 @@ function isOutput(type) {
712
643
  if (!symbol) {
713
644
  symbol = type.aliasSymbol;
714
645
  }
715
- const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "OutputInstance" || (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "Output";
716
- const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
717
- const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("output.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("output.d.ts"));
646
+ const matchesName = symbol?.escapedName === "OutputInstance" || symbol?.escapedName === "Output";
647
+ const sourceFile = symbol?.declarations?.[0].getSourceFile();
648
+ const matchesSourceFile = sourceFile?.fileName.endsWith("output.ts") || sourceFile?.fileName.endsWith("output.d.ts");
718
649
  return !!matchesName && !!matchesSourceFile;
719
650
  }
720
651
  function isAsset(type) {
721
- var _a;
722
652
  const symbol = type.getSymbol();
723
- const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "Asset";
724
- const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
725
- const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("asset.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("asset.d.ts"));
653
+ const matchesName = symbol?.escapedName === "Asset";
654
+ const sourceFile = symbol?.declarations?.[0].getSourceFile();
655
+ const matchesSourceFile = sourceFile?.fileName.endsWith("asset.ts") || sourceFile?.fileName.endsWith("asset.d.ts");
726
656
  return !!matchesName && !!matchesSourceFile;
727
657
  }
728
658
  function isArchive(type) {
729
- var _a;
730
659
  const symbol = type.getSymbol();
731
- const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "Archive";
732
- const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
733
- const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("archive.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("archive.d.ts"));
660
+ const matchesName = symbol?.escapedName === "Archive";
661
+ const sourceFile = symbol?.declarations?.[0].getSourceFile();
662
+ const matchesSourceFile = sourceFile?.fileName.endsWith("archive.ts") || sourceFile?.fileName.endsWith("archive.d.ts");
734
663
  return !!matchesName && !!matchesSourceFile;
735
664
  }
736
665
  function unwrapOutputIntersection(type) {
@@ -751,54 +680,42 @@ function unwrapOutputIntersection(type) {
751
680
  /**
752
681
  * An input type is a union of Output<T>, Promise<T>, and T.
753
682
  */
754
- function isInput(type) {
683
+ function getInputInnerType(type) {
755
684
  if (!type.isUnion()) {
756
- return false;
685
+ return undefined;
757
686
  }
758
687
  let hasOutput = false;
759
688
  let hasPromise = false;
760
689
  let hasOther = false;
690
+ let promiseType;
761
691
  for (const t of type.types) {
762
692
  if (isOutput(t)) {
763
693
  hasOutput = true;
764
694
  }
765
695
  else if (isPromise(t)) {
766
696
  hasPromise = true;
697
+ promiseType = t;
767
698
  }
768
699
  else {
769
700
  hasOther = true;
770
701
  }
771
702
  }
772
- return hasOutput && hasPromise && hasOther;
703
+ return hasOutput && hasPromise && hasOther ? promiseType : undefined;
773
704
  }
774
705
  function isResourceReference(type, checker) {
775
706
  if (!type.isClass()) {
776
707
  return false;
777
708
  }
778
709
  return checker.getBaseTypes(type).some((baseType) => {
779
- var _a;
780
710
  const symbol = baseType.getSymbol();
781
- const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "CustomResource" ||
782
- (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "ComponentResource" ||
783
- (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "Resource";
784
- const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
785
- const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.d.ts"));
711
+ const matchesName = symbol?.escapedName === "CustomResource" ||
712
+ symbol?.escapedName === "ComponentResource" ||
713
+ symbol?.escapedName === "Resource";
714
+ const sourceFile = symbol?.declarations?.[0].getSourceFile();
715
+ const matchesSourceFile = sourceFile?.fileName.endsWith("resource.ts") || sourceFile?.fileName.endsWith("resource.d.ts");
786
716
  return (matchesName && matchesSourceFile) || isResourceReference(baseType, checker);
787
717
  });
788
718
  }
789
- function tsTypeToPropertyType(type) {
790
- var _a;
791
- if (isNumber(type)) {
792
- return "number";
793
- }
794
- else if (isString(type)) {
795
- return "string";
796
- }
797
- else if (isBoolean(type)) {
798
- return "boolean";
799
- }
800
- throw new Error(`Unsupported type '${(_a = type.symbol) === null || _a === void 0 ? void 0 : _a.name}'`);
801
- }
802
719
  function symbolTableToSymbols(table) {
803
720
  const symbols = [];
804
721
  table.forEach((symbol) => {