sst 2.18.2 → 2.18.3

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.
@@ -160,6 +160,7 @@ export declare class App extends CDKApp {
160
160
  private removeGovCloudUnsupportedResourceProperties;
161
161
  private ensureUniqueConstructIds;
162
162
  private codegenTypes;
163
+ private foreachConstruct;
163
164
  stack<T extends FunctionalStack<any>>(fn: T, props?: StackProps & {
164
165
  id?: string;
165
166
  }): ReturnType<T> extends Promise<any> ? Promise<void> : App;
package/constructs/App.js CHANGED
@@ -427,43 +427,53 @@ export class App extends CDKApp {
427
427
  ` }`,
428
428
  `}`,
429
429
  ].join("\n"));
430
- class CodegenTypes {
431
- visit(c) {
432
- if (!isSSTConstruct(c)) {
433
- return;
434
- }
435
- if (c instanceof Function && c._doNotAllowOthersToBind) {
436
- return;
437
- }
438
- const binding = bindType(c);
439
- if (!binding) {
440
- return;
441
- }
442
- const className = c.constructor.name;
443
- const id = c.id;
444
- // Case 1: variable does not have properties, ie. Secrets and Parameters
445
- fs.appendFileSync(`${typesPath}/index.ts`, (binding.variables[0] === "."
446
- ? [
447
- `import "sst/node/${binding.clientPackage}";`,
448
- `declare module "sst/node/${binding.clientPackage}" {`,
449
- ` export interface ${className}Resources {`,
450
- ` "${id}": string;`,
451
- ` }`,
452
- `}`,
453
- ]
454
- : [
455
- `import "sst/node/${binding.clientPackage}";`,
456
- `declare module "sst/node/${binding.clientPackage}" {`,
457
- ` export interface ${className}Resources {`,
458
- ` "${id}": {`,
459
- ...binding.variables.map((p) => ` ${p}: string;`),
460
- ` }`,
461
- ` }`,
462
- `}`,
463
- ]).join("\n"));
430
+ this.foreachConstruct((c) => {
431
+ if (!isSSTConstruct(c)) {
432
+ return;
433
+ }
434
+ if (c instanceof Function && c._doNotAllowOthersToBind) {
435
+ return;
436
+ }
437
+ const binding = bindType(c);
438
+ if (!binding) {
439
+ return;
440
+ }
441
+ const className = c.constructor.name;
442
+ const id = c.id;
443
+ // Case 1: variable does not have properties, ie. Secrets and Parameters
444
+ fs.appendFileSync(`${typesPath}/index.ts`, (binding.variables[0] === "."
445
+ ? [
446
+ `import "sst/node/${binding.clientPackage}";`,
447
+ `declare module "sst/node/${binding.clientPackage}" {`,
448
+ ` export interface ${className}Resources {`,
449
+ ` "${id}": string;`,
450
+ ` }`,
451
+ `}`,
452
+ ]
453
+ : [
454
+ `import "sst/node/${binding.clientPackage}";`,
455
+ `declare module "sst/node/${binding.clientPackage}" {`,
456
+ ` export interface ${className}Resources {`,
457
+ ` "${id}": {`,
458
+ ...binding.variables.map((p) => ` ${p}: string;`),
459
+ ` }`,
460
+ ` }`,
461
+ `}`,
462
+ ]).join("\n"));
463
+ });
464
+ }
465
+ foreachConstruct(fn) {
466
+ const loop = (parent) => {
467
+ for (const child of parent.node.children) {
468
+ fn(child);
469
+ loop(child);
470
+ }
471
+ };
472
+ for (const child of this.node.children) {
473
+ if (child instanceof Stack) {
474
+ loop(child);
464
475
  }
465
476
  }
466
- Aspects.of(this).add(new CodegenTypes());
467
477
  }
468
478
  // Functional Stack
469
479
  // This is a magical global to avoid having to pass app everywhere.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.18.2",
4
+ "version": "2.18.3",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },