@awsless/awsless 0.0.85 → 0.0.87

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 (28) hide show
  1. package/dist/bin.js +516 -170
  2. package/dist/features/cognito-client-secret/HASH +1 -0
  3. package/dist/features/cognito-client-secret/bundle.zip +0 -0
  4. package/dist/features/cognito-client-secret/index.js +61 -0
  5. package/dist/features/cognito-client-secret/index.mjs +59 -0
  6. package/dist/features/delete-bucket/HASH +1 -0
  7. package/dist/features/delete-bucket/bundle.zip +0 -0
  8. package/dist/features/delete-bucket/index.js +88 -0
  9. package/dist/features/{delete-bucket.js → delete-bucket/index.mjs} +2 -2
  10. package/dist/features/delete-hosted-zone/HASH +1 -0
  11. package/dist/features/delete-hosted-zone/bundle.zip +0 -0
  12. package/dist/features/delete-hosted-zone/index.js +130 -0
  13. package/dist/features/{delete-hosted-zone.js → delete-hosted-zone/index.mjs} +2 -2
  14. package/dist/features/global-exports/HASH +1 -0
  15. package/dist/features/global-exports/bundle.zip +0 -0
  16. package/dist/features/global-exports/index.js +63 -0
  17. package/dist/features/{global-exports.js → global-exports/index.mjs} +2 -2
  18. package/dist/features/invalidate-cache/HASH +1 -0
  19. package/dist/features/invalidate-cache/bundle.zip +0 -0
  20. package/dist/features/invalidate-cache/index.js +63 -0
  21. package/dist/features/{invalidate-cache.js → invalidate-cache/index.mjs} +2 -2
  22. package/dist/features/upload-bucket-asset/HASH +1 -0
  23. package/dist/features/upload-bucket-asset/bundle.zip +0 -0
  24. package/dist/features/upload-bucket-asset/index.js +22015 -0
  25. package/dist/features/{upload-bucket-asset.js → upload-bucket-asset/index.mjs} +2 -2
  26. package/dist/index.d.ts +93 -13
  27. package/dist/index.js +60 -16
  28. package/package.json +8 -4
package/dist/bin.js CHANGED
@@ -591,8 +591,8 @@ var Stack = class {
591
591
  return node;
592
592
  };
593
593
  for (const resource of this.resources) {
594
- const json2 = walk(resource.toJSON());
595
- Object.assign(resources, json2);
594
+ const json3 = walk(resource.toJSON());
595
+ Object.assign(resources, json3);
596
596
  }
597
597
  for (let [name, value] of this.exports.entries()) {
598
598
  Object.assign(outputs, {
@@ -892,7 +892,11 @@ import json from "@rollup/plugin-json";
892
892
  import commonjs from "@rollup/plugin-commonjs";
893
893
  import nodeResolve from "@rollup/plugin-node-resolve";
894
894
  import { dirname } from "path";
895
- var rollupBundle = ({ format: format2 = "esm", minify = true, handler = "default" } = {}) => {
895
+ var rollupBundle = ({
896
+ format: format2 = "esm",
897
+ minify = true,
898
+ handler = "default"
899
+ } = {}) => {
896
900
  return async (input) => {
897
901
  const bundle = await rollup({
898
902
  input,
@@ -977,6 +981,7 @@ var zipFiles = (files) => {
977
981
  };
978
982
 
979
983
  // src/formation/resource/lambda/code.ts
984
+ import { readFile } from "fs/promises";
980
985
  import { fileURLToPath } from "url";
981
986
  import { join } from "path";
982
987
  var Code = class {
@@ -993,21 +998,10 @@ var Code = class {
993
998
  // return new ZipFileCode(id, file, hash, handler)
994
999
  // }
995
1000
  static fromFeature(id) {
996
- const root2 = fileURLToPath(new URL(".", import.meta.url));
997
- const file = join(root2, `features/${id}.js`);
998
- return new FileCode(id, file, rollupBundle({
999
- minify: false,
1000
- handler: "handler"
1001
- }));
1001
+ return new FeatureCode(id);
1002
1002
  }
1003
1003
  static fromInlineFeature(id) {
1004
- const root2 = fileURLToPath(new URL(".", import.meta.url));
1005
- const file = join(root2, `features/${id}.js`);
1006
- return new InlineFileCode(id, file, rollupBundle({
1007
- format: "cjs",
1008
- minify: false,
1009
- handler: "handler"
1010
- }));
1004
+ return new InlineFeatureCode(id);
1011
1005
  }
1012
1006
  };
1013
1007
  var InlineCode = class {
@@ -1034,11 +1028,12 @@ var InlineFileCode = class extends Asset {
1034
1028
  handler;
1035
1029
  async build({ write }) {
1036
1030
  const bundler = this.bundler ?? rollupBundle();
1037
- const { hash, files: [file], handler } = await bundler(this.file);
1038
- await Promise.all([
1039
- write("HASH", hash),
1040
- write("file.js", file.code)
1041
- ]);
1031
+ const {
1032
+ hash,
1033
+ files: [file],
1034
+ handler
1035
+ } = await bundler(this.file);
1036
+ await Promise.all([write("HASH", hash), write("file.js", file.code)]);
1042
1037
  this.handler = handler;
1043
1038
  this.code = file.code.toString("utf8");
1044
1039
  return {
@@ -1082,11 +1077,7 @@ var FileCode = class extends Asset {
1082
1077
  };
1083
1078
  }
1084
1079
  async publish({ publish }) {
1085
- this.s3 = await publish(
1086
- `${this.id}.zip`,
1087
- this.bundle,
1088
- this.hash
1089
- );
1080
+ this.s3 = await publish(`${this.id}.zip`, this.bundle, this.hash);
1090
1081
  }
1091
1082
  toCodeJson() {
1092
1083
  return {
@@ -1099,6 +1090,49 @@ var FileCode = class extends Asset {
1099
1090
  };
1100
1091
  }
1101
1092
  };
1093
+ var FeatureCode = class extends Asset {
1094
+ s3;
1095
+ constructor(id) {
1096
+ super("function", id);
1097
+ }
1098
+ async publish({ publish }) {
1099
+ const root2 = fileURLToPath(new URL(".", import.meta.url));
1100
+ const path = join(root2, `features/${this.id}`);
1101
+ const bundle = await readFile(join(path, "bundle.zip"));
1102
+ const hash = await readFile(join(path, "HASH"));
1103
+ this.s3 = await publish(`${this.id}.zip`, bundle, hash.toString("utf8"));
1104
+ }
1105
+ toCodeJson() {
1106
+ return {
1107
+ Handler: "index.handler",
1108
+ Code: {
1109
+ S3Bucket: this.s3?.bucket ?? "",
1110
+ S3Key: this.s3?.key ?? "",
1111
+ S3ObjectVersion: this.s3?.version ?? ""
1112
+ }
1113
+ };
1114
+ }
1115
+ };
1116
+ var InlineFeatureCode = class extends Asset {
1117
+ code;
1118
+ constructor(id) {
1119
+ super("function", id);
1120
+ }
1121
+ async publish() {
1122
+ const root2 = fileURLToPath(new URL(".", import.meta.url));
1123
+ const path = join(root2, `features/${this.id}`);
1124
+ const file = await readFile(join(path, "index.js"));
1125
+ this.code = file.toString("utf8");
1126
+ }
1127
+ toCodeJson() {
1128
+ return {
1129
+ Handler: "index.handler",
1130
+ Code: {
1131
+ ZipFile: this.code ?? ""
1132
+ }
1133
+ };
1134
+ }
1135
+ };
1102
1136
 
1103
1137
  // src/formation/resource/lambda/event-invoke-config.ts
1104
1138
  var EventInvokeConfig = class extends Resource {
@@ -1321,16 +1355,23 @@ var TypeObject = class {
1321
1355
  };
1322
1356
 
1323
1357
  // src/plugins/function.ts
1324
- var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
1325
- var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
1326
- var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
1358
+ var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(
1359
+ sizeMax(Size.gigaBytes(10)),
1360
+ "Minimum memory size is 10 GB"
1361
+ );
1362
+ var TimeoutSchema = DurationSchema.refine(
1363
+ durationMin(Duration.seconds(10)),
1364
+ "Minimum timeout duration is 10 seconds"
1365
+ ).refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
1366
+ var EphemeralStorageSizeSchema = SizeSchema.refine(
1367
+ sizeMin(Size.megaBytes(512)),
1368
+ "Minimum ephemeral storage size is 512 MB"
1369
+ ).refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
1327
1370
  var ReservedConcurrentExecutionsSchema = z6.number().int().min(0);
1328
1371
  var EnvironmentSchema = z6.record(z6.string(), z6.string()).optional();
1329
1372
  var ArchitectureSchema = z6.enum(["x86_64", "arm64"]);
1330
1373
  var RetryAttemptsSchema = z6.number().int().min(0).max(2);
1331
- var RuntimeSchema = z6.enum([
1332
- "nodejs18.x"
1333
- ]);
1374
+ var RuntimeSchema = z6.enum(["nodejs18.x"]);
1334
1375
  var PermissionSchema = z6.object({
1335
1376
  effect: z6.enum(["allow", "deny"]).default("allow"),
1336
1377
  actions: z6.string().array(),
@@ -1392,12 +1433,12 @@ var FunctionSchema = z6.union([
1392
1433
  /** The size of the function's /tmp directory.
1393
1434
  * You can specify a size value from 512 MB to 10 GB.
1394
1435
  * @default 512 MB
1395
- */
1436
+ */
1396
1437
  ephemeralStorageSize: EphemeralStorageSizeSchema.optional(),
1397
1438
  /** The maximum number of times to retry when the function returns an error.
1398
1439
  * You can specify a number from 0 to 2.
1399
1440
  * @default 2
1400
- */
1441
+ */
1401
1442
  retryAttempts: RetryAttemptsSchema.optional(),
1402
1443
  /** The number of simultaneous executions to reserve for the function.
1403
1444
  * You can specify a number from 0.
@@ -1432,7 +1473,7 @@ var schema = z6.object({
1432
1473
  function: z6.object({
1433
1474
  /** The name of the exported method within your code that Lambda calls to run your function.
1434
1475
  * @default 'default'
1435
- */
1476
+ */
1436
1477
  handler: z6.string().default("default"),
1437
1478
  /** Minify the function code.
1438
1479
  * @default true
@@ -1474,12 +1515,12 @@ var schema = z6.object({
1474
1515
  /** The size of the function's /tmp directory.
1475
1516
  * You can specify a size value from 512 MB to 10 GB.
1476
1517
  * @default 512 MB
1477
- */
1518
+ */
1478
1519
  ephemeralStorageSize: EphemeralStorageSizeSchema.default("512 MB"),
1479
1520
  /** The maximum number of times to retry when the function returns an error.
1480
1521
  * You can specify a number from 0 to 2.
1481
1522
  * @default 2
1482
- */
1523
+ */
1483
1524
  retryAttempts: RetryAttemptsSchema.default(2),
1484
1525
  /** The number of simultaneous executions to reserve for the function.
1485
1526
  * You can specify a number from 0.
@@ -1515,10 +1556,7 @@ var schema = z6.object({
1515
1556
  * }
1516
1557
  * }
1517
1558
  */
1518
- functions: z6.record(
1519
- ResourceIdSchema,
1520
- FunctionSchema
1521
- ).optional()
1559
+ functions: z6.record(ResourceIdSchema, FunctionSchema).optional()
1522
1560
  }).array()
1523
1561
  });
1524
1562
  var typeGenCode = `
@@ -1571,15 +1609,19 @@ var functionPlugin = definePlugin({
1571
1609
  });
1572
1610
  var toLambdaFunction = (ctx, id, fileOrProps) => {
1573
1611
  const config = ctx.config;
1574
- const stack = ctx.stack;
1612
+ const stack = ctx.stack ?? ctx.bootstrap;
1575
1613
  const bootstrap2 = ctx.bootstrap;
1576
1614
  const props = typeof fileOrProps === "string" ? { ...config.defaults?.function, file: fileOrProps } : { ...config.defaults?.function, ...fileOrProps };
1577
1615
  const lambda = new Function(id, {
1578
1616
  name: `${config.name}-${stack.name}-${id}`,
1579
- code: Code.fromFile(id, props.file, rollupBundle({
1580
- handler: props.handler,
1581
- minify: props.minify
1582
- })),
1617
+ code: Code.fromFile(
1618
+ id,
1619
+ props.file,
1620
+ rollupBundle({
1621
+ handler: props.handler,
1622
+ minify: props.minify
1623
+ })
1624
+ ),
1583
1625
  ...props,
1584
1626
  vpc: void 0
1585
1627
  });
@@ -1598,13 +1640,8 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
1598
1640
  }
1599
1641
  if (props.vpc) {
1600
1642
  lambda.setVpc({
1601
- securityGroupIds: [
1602
- bootstrap2.import(`vpc-security-group-id`)
1603
- ],
1604
- subnetIds: [
1605
- bootstrap2.import(`public-subnet-1`),
1606
- bootstrap2.import(`public-subnet-2`)
1607
- ]
1643
+ securityGroupIds: [bootstrap2.import(`vpc-security-group-id`)],
1644
+ subnetIds: [bootstrap2.import(`public-subnet-1`), bootstrap2.import(`public-subnet-2`)]
1608
1645
  }).addPermissions({
1609
1646
  actions: [
1610
1647
  "ec2:CreateNetworkInterface",
@@ -1617,10 +1654,7 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
1617
1654
  });
1618
1655
  }
1619
1656
  lambda.addPermissions({
1620
- actions: [
1621
- "lambda:InvokeFunction",
1622
- "lambda:InvokeAsync"
1623
- ],
1657
+ actions: ["lambda:InvokeFunction", "lambda:InvokeAsync"],
1624
1658
  resources: ["*"]
1625
1659
  });
1626
1660
  return lambda;
@@ -2782,9 +2816,9 @@ var RecordSet = class extends Resource {
2782
2816
  properties() {
2783
2817
  return {
2784
2818
  HostedZoneId: this.props.hostedZoneId,
2785
- Name: this.name + ".",
2819
+ Name: typeof this.name === "string" ? this.name + "." : this.name,
2786
2820
  Type: this.props.type,
2787
- TTL: this.props.ttl,
2821
+ TTL: this.props.ttl?.toSeconds(),
2788
2822
  ...this.props.records ? {
2789
2823
  ResourceRecords: this.props.records
2790
2824
  } : {},
@@ -2800,7 +2834,7 @@ var RecordSet = class extends Resource {
2800
2834
 
2801
2835
  // src/formation/resource/appsync/graphql-schema.ts
2802
2836
  import { print } from "graphql";
2803
- import { readFile } from "fs/promises";
2837
+ import { readFile as readFile2 } from "fs/promises";
2804
2838
  import { mergeTypeDefs } from "@graphql-tools/merge";
2805
2839
  var GraphQLSchema = class extends Resource {
2806
2840
  constructor(logicalId, props) {
@@ -2825,7 +2859,7 @@ var Definition = class extends Asset {
2825
2859
  async build({ write }) {
2826
2860
  const files = [this.files].flat();
2827
2861
  const schemas = await Promise.all(files.map((file) => {
2828
- return readFile(file, "utf8");
2862
+ return readFile2(file, "utf8");
2829
2863
  }));
2830
2864
  const defs = mergeTypeDefs(schemas);
2831
2865
  const schema2 = print(defs);
@@ -2844,8 +2878,69 @@ var Definition = class extends Asset {
2844
2878
  }
2845
2879
  };
2846
2880
 
2881
+ // src/formation/resource/appsync/util/rollup.ts
2882
+ import { rollup as rollup2 } from "rollup";
2883
+ import { swc as swc2, minify as swcMinify2 } from "rollup-plugin-swc3";
2884
+ import json2 from "@rollup/plugin-json";
2885
+ import commonjs2 from "@rollup/plugin-commonjs";
2886
+ import nodeResolve2 from "@rollup/plugin-node-resolve";
2887
+ import { dirname as dirname2 } from "path";
2888
+ var rollupResolver = ({ minify = true } = {}) => {
2889
+ return async (input) => {
2890
+ const bundle = await rollup2({
2891
+ input,
2892
+ external: (importee) => {
2893
+ return importee.startsWith("@aws-sdk") || importee.startsWith("aws-sdk") || importee.startsWith("@aws-appsync/utils");
2894
+ },
2895
+ onwarn: (error) => {
2896
+ debugError(error.message);
2897
+ },
2898
+ treeshake: {
2899
+ moduleSideEffects: (id) => input === id
2900
+ },
2901
+ plugins: [
2902
+ // @ts-ignore
2903
+ commonjs2({ sourceMap: true }),
2904
+ // @ts-ignore
2905
+ nodeResolve2({ preferBuiltins: true }),
2906
+ swc2({
2907
+ // minify,
2908
+ // module: true,
2909
+ jsc: {
2910
+ baseUrl: dirname2(input),
2911
+ minify: { sourceMap: true }
2912
+ },
2913
+ sourceMaps: true
2914
+ }),
2915
+ minify ? swcMinify2({
2916
+ module: true,
2917
+ sourceMap: true,
2918
+ compress: true
2919
+ }) : void 0,
2920
+ // @ts-ignore
2921
+ json2()
2922
+ ]
2923
+ });
2924
+ const result = await bundle.generate({
2925
+ format: "esm",
2926
+ sourcemap: "hidden",
2927
+ exports: "auto",
2928
+ manualChunks: {},
2929
+ entryFileNames: `index.mjs`,
2930
+ chunkFileNames: `[name].mjs`
2931
+ });
2932
+ let code;
2933
+ for (const item of result.output) {
2934
+ if (item.type !== "chunk") {
2935
+ continue;
2936
+ }
2937
+ code = item.code;
2938
+ }
2939
+ return Buffer.from(code, "utf8");
2940
+ };
2941
+ };
2942
+
2847
2943
  // src/formation/resource/appsync/code.ts
2848
- import { readFile as readFile2 } from "fs/promises";
2849
2944
  var Code2 = class {
2850
2945
  static fromFile(id, file) {
2851
2946
  return new FileCode2(id, file);
@@ -2872,7 +2967,7 @@ var FileCode2 = class extends Asset {
2872
2967
  }
2873
2968
  code;
2874
2969
  async build() {
2875
- const code = await readFile2(this.file);
2970
+ const code = await rollupResolver({ minify: false })(this.file);
2876
2971
  this.code = code.toString("utf8");
2877
2972
  return {
2878
2973
  size: formatByteSize(code.byteLength)
@@ -2934,9 +3029,7 @@ var DataSource = class _DataSource extends Resource {
2934
3029
  import { snakeCase as snakeCase3 } from "change-case";
2935
3030
  var FunctionConfiguration = class extends Resource {
2936
3031
  constructor(logicalId, props) {
2937
- super("AWS::AppSync::FunctionConfiguration", logicalId, [
2938
- props.code
2939
- ]);
3032
+ super("AWS::AppSync::FunctionConfiguration", logicalId);
2940
3033
  this.props = props;
2941
3034
  this.name = snakeCase3(this.props.name || logicalId);
2942
3035
  }
@@ -3055,7 +3148,10 @@ var DomainNameApiAssociation = class extends Resource {
3055
3148
  };
3056
3149
 
3057
3150
  // src/plugins/graphql.ts
3058
- var defaultResolver = `
3151
+ import { basename } from "path";
3152
+ var defaultResolver = Code2.fromInline(
3153
+ "graphql-default-resolver",
3154
+ `
3059
3155
  export function request(ctx) {
3060
3156
  return {
3061
3157
  operation: 'Invoke',
@@ -3066,7 +3162,9 @@ export function request(ctx) {
3066
3162
  export function response(ctx) {
3067
3163
  return ctx.result
3068
3164
  }
3069
- `;
3165
+ `
3166
+ );
3167
+ var resolverCache = /* @__PURE__ */ new Map();
3070
3168
  var graphqlPlugin = definePlugin({
3071
3169
  name: "graphql",
3072
3170
  schema: z15.object({
@@ -3100,7 +3198,7 @@ var graphqlPlugin = definePlugin({
3100
3198
  FunctionSchema,
3101
3199
  z15.object({
3102
3200
  consumer: FunctionSchema,
3103
- resolver: LocalFileSchema
3201
+ resolver: LocalFileSchema.optional()
3104
3202
  })
3105
3203
  ])
3106
3204
  )
@@ -3171,19 +3269,30 @@ var graphqlPlugin = definePlugin({
3171
3269
  }
3172
3270
  },
3173
3271
  onStack(ctx) {
3174
- const { stack, stackConfig, bootstrap: bootstrap2 } = ctx;
3272
+ const { config, stack, stackConfig, bootstrap: bootstrap2 } = ctx;
3175
3273
  for (const [id, props] of Object.entries(stackConfig.graphql || {})) {
3176
3274
  const apiId = bootstrap2.import(`graphql-${id}`);
3275
+ const defaultProps = config.defaults.graphql?.[id];
3177
3276
  for (const [typeName, fields] of Object.entries(props.resolvers || {})) {
3178
3277
  for (const [fieldName, resolverProps] of Object.entries(fields || {})) {
3179
3278
  const props2 = isFunctionProps(resolverProps) ? { consumer: resolverProps } : resolverProps;
3180
3279
  const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
3181
3280
  const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, props2.consumer);
3281
+ const resolver = props2.resolver ?? defaultProps?.resolver;
3282
+ let code = defaultResolver;
3283
+ if (resolver) {
3284
+ if (!resolverCache.has(resolver)) {
3285
+ const fileCode = Code2.fromFile(basename(resolver), resolver);
3286
+ resolverCache.set(resolver, fileCode);
3287
+ stack.add(fileCode);
3288
+ }
3289
+ code = resolverCache.get(resolver);
3290
+ }
3182
3291
  const source = new AppsyncEventSource(entryId, lambda, {
3183
3292
  apiId,
3184
3293
  typeName,
3185
3294
  fieldName,
3186
- code: Code2.fromInline(entryId, props2.resolver || defaultResolver)
3295
+ code
3187
3296
  });
3188
3297
  stack.add(lambda, source);
3189
3298
  }
@@ -3247,9 +3356,9 @@ var RecordSetGroup = class extends Resource {
3247
3356
  return {
3248
3357
  HostedZoneId: this.props.hostedZoneId,
3249
3358
  RecordSets: this.props.records.map((props) => ({
3250
- Name: props.name + ".",
3359
+ Name: typeof props.name === "string" ? props.name + "." : props.name,
3251
3360
  Type: props.type,
3252
- TTL: props.ttl,
3361
+ TTL: props.ttl?.toSeconds(),
3253
3362
  ...props.records ? {
3254
3363
  ResourceRecords: props.records
3255
3364
  } : {},
@@ -3292,6 +3401,108 @@ var GlobalExports = class extends Group {
3292
3401
  }
3293
3402
  };
3294
3403
 
3404
+ // src/formation/resource/ses/configuration-set.ts
3405
+ var ConfigurationSet = class extends Resource {
3406
+ constructor(logicalId, props) {
3407
+ super("AWS::SES::ConfigurationSet", logicalId);
3408
+ this.props = props;
3409
+ this.name = formatName(this.props.name || logicalId);
3410
+ }
3411
+ name;
3412
+ properties() {
3413
+ return {
3414
+ Name: this.name,
3415
+ VdmOptions: {
3416
+ DashboardOptions: {
3417
+ EngagementMetrics: this.props.engagementMetrics ?? false ? "ENABLED" : "DISABLED"
3418
+ }
3419
+ },
3420
+ ReputationOptions: {
3421
+ ReputationMetricsEnabled: this.props.reputationMetrics ?? false
3422
+ },
3423
+ SendingOptions: {
3424
+ SendingEnabled: this.props.sending ?? true
3425
+ }
3426
+ };
3427
+ }
3428
+ };
3429
+
3430
+ // src/formation/resource/ses/email-identity.ts
3431
+ import { constantCase as constantCase7 } from "change-case";
3432
+ var EmailIdentity = class extends Resource {
3433
+ constructor(logicalId, props) {
3434
+ super("AWS::SES::EmailIdentity", logicalId);
3435
+ this.props = props;
3436
+ }
3437
+ getDnsToken(index) {
3438
+ return {
3439
+ name: getAtt(this.logicalId, "DkimDNSTokenName" + index),
3440
+ value: getAtt(this.logicalId, "DkimDNSTokenValue" + index)
3441
+ };
3442
+ }
3443
+ get fullDomain() {
3444
+ return `${this.props.subDomain}.${this.props.domain}`;
3445
+ }
3446
+ get dkimDnsToken1() {
3447
+ return this.getDnsToken(1);
3448
+ }
3449
+ get dkimDnsToken2() {
3450
+ return this.getDnsToken(2);
3451
+ }
3452
+ get dkimDnsToken3() {
3453
+ return this.getDnsToken(3);
3454
+ }
3455
+ get records() {
3456
+ const tokens = [this.dkimDnsToken1, this.dkimDnsToken2, this.dkimDnsToken3];
3457
+ const ttl = Duration.minutes(5);
3458
+ return [
3459
+ ...tokens.map((token) => ({
3460
+ name: token.name,
3461
+ type: "CNAME",
3462
+ ttl,
3463
+ records: [token.value]
3464
+ })),
3465
+ {
3466
+ name: this.fullDomain,
3467
+ type: "TXT",
3468
+ ttl,
3469
+ records: ['"v=spf1 include:amazonses.com -all"']
3470
+ },
3471
+ {
3472
+ name: this.fullDomain,
3473
+ type: "MX",
3474
+ ttl,
3475
+ records: [sub("10 feedback-smtp.${AWS::Region}.amazonses.com.")]
3476
+ }
3477
+ ];
3478
+ }
3479
+ properties() {
3480
+ return {
3481
+ EmailIdentity: this.props.domain,
3482
+ ...this.props.configurationSetName ? {
3483
+ ConfigurationSetAttributes: {
3484
+ ConfigurationSetName: this.props.configurationSetName
3485
+ }
3486
+ } : {},
3487
+ ...this.props.dkim ? {
3488
+ DkimAttributes: {
3489
+ SigningEnabled: true
3490
+ },
3491
+ DkimSigningAttributes: {
3492
+ NextSigningKeyLength: constantCase7(this.props.dkim)
3493
+ }
3494
+ } : {},
3495
+ FeedbackAttributes: {
3496
+ EmailForwardingEnabled: this.props.feedback ?? false
3497
+ },
3498
+ MailFromAttributes: {
3499
+ BehaviorOnMxFailure: this.props.rejectOnMxFailure ?? true ? "REJECT_MESSAGE" : "USE_DEFAULT_VALUE",
3500
+ MailFromDomain: this.fullDomain
3501
+ }
3502
+ };
3503
+ }
3504
+ };
3505
+
3295
3506
  // src/plugins/domain.ts
3296
3507
  var DomainNameSchema = z16.string().regex(/[a-z\-\_\.]/g, "Invalid domain name");
3297
3508
  var domainPlugin = definePlugin({
@@ -3344,7 +3555,7 @@ var domainPlugin = definePlugin({
3344
3555
  ).optional()
3345
3556
  }).default({})
3346
3557
  }),
3347
- onApp({ config, bootstrap: bootstrap2, usEastBootstrap }) {
3558
+ onApp({ config, bootstrap: bootstrap2, usEastBootstrap, bind }) {
3348
3559
  const domains = Object.entries(config.defaults.domains || {});
3349
3560
  if (domains.length === 0) {
3350
3561
  return;
@@ -3361,6 +3572,12 @@ var domainPlugin = definePlugin({
3361
3572
  region: usEastBootstrap.region
3362
3573
  });
3363
3574
  bootstrap2.add(usEastExports);
3575
+ const configurationSet = new ConfigurationSet("default", {
3576
+ name: config.name,
3577
+ engagementMetrics: true,
3578
+ reputationMetrics: true
3579
+ });
3580
+ bootstrap2.add(configurationSet);
3364
3581
  for (const [domain, records] of domains) {
3365
3582
  const hostedZone = new HostedZone(domain);
3366
3583
  const usEastCertificate = new Certificate(domain, {
@@ -3378,7 +3595,18 @@ var domainPlugin = definePlugin({
3378
3595
  hostedZoneId: usEastExports.import(`hosted-zone-${domain}-id`),
3379
3596
  alternativeNames: [`*.${domain}`]
3380
3597
  });
3381
- bootstrap2.add(certificate).export(`certificate-${domain}-arn`, certificate.arn).export(`hosted-zone-${domain}-id`, usEastExports.import(`hosted-zone-${domain}-id`)).export(`us-east-certificate-${domain}-arn`, usEastExports.import(`certificate-${domain}-arn`));
3598
+ const emailIdentity = new EmailIdentity(domain, {
3599
+ domain,
3600
+ subDomain: "mailer",
3601
+ configurationSetName: configurationSet.name,
3602
+ feedback: true,
3603
+ rejectOnMxFailure: true
3604
+ }).dependsOn(configurationSet);
3605
+ const emailRecordGroup = new RecordSetGroup(`${domain}-mail`, {
3606
+ hostedZoneId: usEastExports.import(`hosted-zone-${domain}-id`),
3607
+ records: emailIdentity.records
3608
+ }).dependsOn(emailIdentity);
3609
+ bootstrap2.add(certificate).add(emailIdentity).add(emailRecordGroup).export(`certificate-${domain}-arn`, certificate.arn).export(`hosted-zone-${domain}-id`, usEastExports.import(`hosted-zone-${domain}-id`)).export(`us-east-certificate-${domain}-arn`, usEastExports.import(`certificate-${domain}-arn`));
3382
3610
  if (records.length > 0) {
3383
3611
  const group = new RecordSetGroup(domain, {
3384
3612
  hostedZoneId: hostedZone.id,
@@ -3387,6 +3615,12 @@ var domainPlugin = definePlugin({
3387
3615
  usEastBootstrap.add(group);
3388
3616
  }
3389
3617
  }
3618
+ bind(
3619
+ (lambda) => lambda.addPermissions({
3620
+ actions: ["ses:*"],
3621
+ resources: ["*"]
3622
+ })
3623
+ );
3390
3624
  }
3391
3625
  });
3392
3626
 
@@ -3775,7 +4009,7 @@ var LoadBalancer = class extends Resource {
3775
4009
  };
3776
4010
 
3777
4011
  // src/formation/resource/elb/listener.ts
3778
- import { constantCase as constantCase7 } from "change-case";
4012
+ import { constantCase as constantCase8 } from "change-case";
3779
4013
  var Listener = class extends Resource {
3780
4014
  constructor(logicalId, props) {
3781
4015
  super("AWS::ElasticLoadBalancingV2::Listener", logicalId);
@@ -3791,7 +4025,7 @@ var Listener = class extends Resource {
3791
4025
  return {
3792
4026
  LoadBalancerArn: this.props.loadBalancerArn,
3793
4027
  Port: this.props.port,
3794
- Protocol: constantCase7(this.props.protocol),
4028
+ Protocol: constantCase8(this.props.protocol),
3795
4029
  Certificates: this.props.certificates.map((arn) => ({
3796
4030
  CertificateArn: arn
3797
4031
  })),
@@ -4274,7 +4508,7 @@ var SubnetGroup = class extends Resource {
4274
4508
  };
4275
4509
 
4276
4510
  // src/plugins/cache.ts
4277
- import { constantCase as constantCase8 } from "change-case";
4511
+ import { constantCase as constantCase9 } from "change-case";
4278
4512
  var TypeSchema = z20.enum([
4279
4513
  "t4g.small",
4280
4514
  "t4g.medium",
@@ -4294,6 +4528,17 @@ var PortSchema = z20.number().int().min(1).max(5e4);
4294
4528
  var ShardsSchema = z20.number().int().min(0).max(100);
4295
4529
  var ReplicasPerShardSchema = z20.number().int().min(0).max(5);
4296
4530
  var EngineSchema = z20.enum(["7.0", "6.2"]);
4531
+ var typeGenCode4 = `
4532
+ import { Cluster, CommandOptions } from '@awsless/redis'
4533
+
4534
+ type Callback<T> = (redis: Cluster) => T
4535
+
4536
+ type Command = {
4537
+ readonly host: string
4538
+ readonly port: number
4539
+ <T>(callback: Callback<T>): T
4540
+ <T>(options:Omit<CommandOptions, 'cluster'>, callback: Callback<T>): T
4541
+ }`;
4297
4542
  var cachePlugin = definePlugin({
4298
4543
  name: "cache",
4299
4544
  schema: z20.object({
@@ -4324,10 +4569,11 @@ var cachePlugin = definePlugin({
4324
4569
  }),
4325
4570
  onTypeGen({ config }) {
4326
4571
  const gen = new TypeGen("@awsless/awsless", "CacheResources");
4572
+ gen.addCode(typeGenCode4);
4327
4573
  for (const stack of config.stacks) {
4328
4574
  const list3 = new TypeObject();
4329
4575
  for (const name of Object.keys(stack.caches || {})) {
4330
- list3.addType(name, `{ readonly host: string, readonly port: number }`);
4576
+ list3.addType(name, `Command`);
4331
4577
  }
4332
4578
  gen.addType(stack.name, list3.toString());
4333
4579
  }
@@ -4357,8 +4603,8 @@ var cachePlugin = definePlugin({
4357
4603
  }).dependsOn(subnetGroup, securityGroup);
4358
4604
  stack.add(subnetGroup, securityGroup, cluster);
4359
4605
  bind((lambda) => {
4360
- lambda.addEnvironment(`CACHE_${constantCase8(stack.name)}_${constantCase8(id)}_HOST`, cluster.address).addEnvironment(
4361
- `CACHE_${constantCase8(stack.name)}_${constantCase8(id)}_PORT`,
4606
+ lambda.addEnvironment(`CACHE_${constantCase9(stack.name)}_${constantCase9(id)}_HOST`, cluster.address).addEnvironment(
4607
+ `CACHE_${constantCase9(stack.name)}_${constantCase9(id)}_PORT`,
4362
4608
  props.port.toString()
4363
4609
  );
4364
4610
  });
@@ -5233,6 +5479,14 @@ var sitePlugin = definePlugin({
5233
5479
  static: LocalDirectorySchema.optional(),
5234
5480
  /** Specifies the ssr file. */
5235
5481
  ssr: FunctionSchema.optional(),
5482
+ // ssr: z.union([
5483
+ // FunctionSchema.optional(),
5484
+ // z.object({
5485
+ // consumer: FunctionSchema.optional(),
5486
+ // responseStreaming: z.boolean().default(false),
5487
+ // build: z.string().optional(),
5488
+ // }),
5489
+ // ]),
5236
5490
  /** Customize the error responses for specific HTTP status codes. */
5237
5491
  errors: z25.object({
5238
5492
  /** Customize a `400 Bad Request` response */
@@ -5341,7 +5595,9 @@ var sitePlugin = definePlugin({
5341
5595
  urlAuthType: "none"
5342
5596
  // sourceArn: distribution.arn,
5343
5597
  }).dependsOn(lambda);
5344
- const url = lambda.addUrl();
5598
+ const url = lambda.addUrl({
5599
+ invokeMode: "buffered"
5600
+ });
5345
5601
  stack.add(url, lambda, permissions);
5346
5602
  origins.push(
5347
5603
  new Origin({
@@ -5528,7 +5784,7 @@ var featurePlugin = definePlugin({
5528
5784
  import { z as z26 } from "zod";
5529
5785
 
5530
5786
  // src/formation/resource/cognito/user-pool.ts
5531
- import { constantCase as constantCase9 } from "change-case";
5787
+ import { constantCase as constantCase10 } from "change-case";
5532
5788
 
5533
5789
  // src/formation/resource/cognito/user-pool-client.ts
5534
5790
  var UserPoolClient = class extends Resource {
@@ -5699,25 +5955,26 @@ var UserPool = class extends Resource {
5699
5955
  AliasAttributes: ["email"],
5700
5956
  // UsernameAttributes: [ 'email' ],
5701
5957
  AutoVerifiedAttributes: ["email"],
5702
- Schema: [{
5703
- AttributeDataType: "String",
5704
- Name: "email",
5705
- Required: true,
5706
- Mutable: false,
5707
- StringAttributeConstraints: {
5708
- MinLength: 5,
5709
- MaxLength: 100
5958
+ Schema: [
5959
+ {
5960
+ AttributeDataType: "String",
5961
+ Name: "email",
5962
+ Required: true,
5963
+ Mutable: false,
5964
+ StringAttributeConstraints: {
5965
+ MinLength: 5,
5966
+ MaxLength: 100
5967
+ }
5710
5968
  }
5711
- }]
5969
+ ]
5712
5970
  } : {},
5713
5971
  UsernameConfiguration: {
5714
5972
  CaseSensitive: this.props.username?.caseSensitive ?? false
5715
5973
  },
5716
5974
  ...this.attr("EmailConfiguration", this.props.email?.toJSON()),
5717
- // DeviceConfiguration: {
5718
- // ChallengeRequiredOnNewDevice: {},
5719
- // DeviceOnlyRememberedOnUserPrompt: {},
5720
- // },
5975
+ DeviceConfiguration: {
5976
+ DeviceOnlyRememberedOnUserPrompt: false
5977
+ },
5721
5978
  AdminCreateUserConfig: {
5722
5979
  AllowAdminCreateUserOnly: !(this.props.allowUserRegistration ?? true)
5723
5980
  },
@@ -5741,14 +5998,41 @@ var UserPool = class extends Resource {
5741
5998
  ...this.attr("UserMigration", this.props.triggers?.userMigration),
5742
5999
  ...this.attr("DefineAuthChallenge", this.props.triggers?.defineChallange),
5743
6000
  ...this.attr("CreateAuthChallenge", this.props.triggers?.createChallange),
5744
- ...this.attr("VerifyAuthChallengeResponse", this.props.triggers?.verifyChallange)
6001
+ ...this.attr("VerifyAuthChallengeResponse", this.props.triggers?.verifyChallange),
6002
+ ...this.props.triggers?.emailSender ? {
6003
+ CustomEmailSender: {
6004
+ LambdaArn: this.props.triggers.emailSender,
6005
+ LambdaVersion: "V1_0"
6006
+ }
6007
+ } : {}
5745
6008
  }
5746
6009
  };
5747
6010
  }
5748
6011
  };
6012
+ var UserPoolEmail = class _UserPoolEmail {
6013
+ constructor(props) {
6014
+ this.props = props;
6015
+ }
6016
+ static withSES(props) {
6017
+ return new _UserPoolEmail({
6018
+ type: "developer",
6019
+ replyTo: props.replyTo,
6020
+ from: props.fromName ? `${props.fromName} <${props.fromEmail}>` : props.fromEmail,
6021
+ sourceArn: props.sourceArn
6022
+ });
6023
+ }
6024
+ toJSON() {
6025
+ return {
6026
+ ...this.props.type ? { EmailSendingAccount: constantCase10(this.props.type) } : {},
6027
+ ...this.props.from ? { From: this.props.from } : {},
6028
+ ...this.props.replyTo ? { ReplyToEmailAddress: this.props.replyTo } : {},
6029
+ ...this.props.sourceArn ? { SourceArn: this.props.sourceArn } : {}
6030
+ };
6031
+ }
6032
+ };
5749
6033
 
5750
6034
  // src/plugins/auth.ts
5751
- import { constantCase as constantCase10 } from "change-case";
6035
+ import { constantCase as constantCase11 } from "change-case";
5752
6036
  var TriggersSchema = z26.object({
5753
6037
  /** A pre jwt token generation AWS Lambda trigger. */
5754
6038
  beforeToken: FunctionSchema.optional(),
@@ -5762,6 +6046,8 @@ var TriggersSchema = z26.object({
5762
6046
  afterRegister: FunctionSchema.optional(),
5763
6047
  /** A custom message AWS Lambda trigger. */
5764
6048
  customMessage: FunctionSchema.optional(),
6049
+ // /** A custom email sender AWS Lambda trigger */
6050
+ // emailSender: FunctionSchema.optional(),
5765
6051
  /** Defines the authentication challenge. */
5766
6052
  defineChallenge: FunctionSchema.optional(),
5767
6053
  /** Creates an authentication challenge. */
@@ -5795,6 +6081,16 @@ var authPlugin = definePlugin({
5795
6081
  * @default true
5796
6082
  */
5797
6083
  allowUserRegistration: z26.boolean().default(true),
6084
+ /** The email configuration for sending messages.
6085
+ */
6086
+ messaging: z26.object({
6087
+ // Specifies the sender's email address.
6088
+ fromEmail: EmailSchema,
6089
+ // Specifies the sender's name.
6090
+ fromName: z26.string().optional(),
6091
+ // The destination to which the receiver of the email should reply.
6092
+ replyTo: EmailSchema.optional()
6093
+ }).optional(),
5798
6094
  /** The username policy. */
5799
6095
  username: z26.object({
5800
6096
  /** Allow the user email to be used as username.
@@ -5811,9 +6107,9 @@ var authPlugin = definePlugin({
5811
6107
  /** The password policy. */
5812
6108
  password: z26.object({
5813
6109
  /** Required users to have at least the minimum password length.
5814
- * @default 8
6110
+ * @default 12
5815
6111
  */
5816
- minLength: z26.number().int().min(6).max(99).default(8),
6112
+ minLength: z26.number().int().min(6).max(99).default(12),
5817
6113
  /** Required users to use at least one uppercase letter in their password.
5818
6114
  * @default true
5819
6115
  */
@@ -5900,11 +6196,13 @@ var authPlugin = definePlugin({
5900
6196
  for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
5901
6197
  if (props.access) {
5902
6198
  const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
5903
- const clientId = bootstrap2.import(`auth-${id}-user-pool-id`);
5904
- const name = constantCase10(id);
6199
+ const clientId = bootstrap2.import(`auth-${id}-client-id`);
6200
+ const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
6201
+ const name = constantCase11(id);
5905
6202
  bind((lambda) => {
5906
6203
  lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
5907
6204
  lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
6205
+ lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
5908
6206
  lambda.addPermissions({
5909
6207
  actions: ["cognito:*"],
5910
6208
  resources: ["*"]
@@ -5915,6 +6213,18 @@ var authPlugin = definePlugin({
5915
6213
  },
5916
6214
  onApp(ctx) {
5917
6215
  const { config, bootstrap: bootstrap2 } = ctx;
6216
+ if (Object.keys(config.defaults.auth).length === 0) {
6217
+ return;
6218
+ }
6219
+ const clientSecretLambda = new Function(`auth-client-secret`, {
6220
+ name: `${config.name}-auth-client-secret`,
6221
+ code: Code.fromFeature("cognito-client-secret")
6222
+ });
6223
+ clientSecretLambda.addPermissions({
6224
+ actions: ["cognito-idp:DescribeUserPoolClient"],
6225
+ resources: ["*"]
6226
+ });
6227
+ bootstrap2.add(clientSecretLambda);
5918
6228
  for (const [id, props] of Object.entries(config.defaults.auth)) {
5919
6229
  const functions = /* @__PURE__ */ new Map();
5920
6230
  const triggers = {};
@@ -5935,12 +6245,26 @@ var authPlugin = definePlugin({
5935
6245
  triggers[trigger] = lambda.arn;
5936
6246
  }
5937
6247
  }
6248
+ let emailConfig;
6249
+ if (props.messaging) {
6250
+ const [_, ...parts] = props.messaging.fromEmail.split("@");
6251
+ const domainName = parts.join("@");
6252
+ emailConfig = UserPoolEmail.withSES({
6253
+ ...props.messaging,
6254
+ sourceArn: formatArn({
6255
+ service: "ses",
6256
+ resource: "identity",
6257
+ resourceName: domainName
6258
+ })
6259
+ });
6260
+ }
5938
6261
  const userPool = new UserPool(id, {
5939
6262
  name: `${config.name}-${id}`,
5940
6263
  allowUserRegistration: props.allowUserRegistration,
5941
6264
  username: props.username,
5942
6265
  password: props.password,
5943
- triggers
6266
+ triggers,
6267
+ email: emailConfig
5944
6268
  });
5945
6269
  const client = userPool.addClient({
5946
6270
  name: `${config.name}-${id}`,
@@ -5954,7 +6278,14 @@ var authPlugin = definePlugin({
5954
6278
  const domain = userPool.addDomain({
5955
6279
  domain: `${config.name}-${id}`
5956
6280
  });
5957
- bootstrap2.add(userPool).export(`auth-${id}-user-pool-arn`, userPool.arn).export(`auth-${id}-user-pool-id`, userPool.id).export(`auth-${id}-client-id`, client.id).export(`auth-${id}-domain`, domain.domain);
6281
+ const clientSecret = new CustomResource(`${id}-client-secret`, {
6282
+ serviceToken: clientSecretLambda.arn,
6283
+ properties: {
6284
+ userPoolId: userPool.id,
6285
+ clientId: client.id
6286
+ }
6287
+ }).dependsOn(client, userPool);
6288
+ bootstrap2.add(userPool).add(clientSecret).export(`auth-${id}-user-pool-arn`, userPool.arn).export(`auth-${id}-user-pool-id`, userPool.id).export(`auth-${id}-client-id`, client.id).export(`auth-${id}-client-secret`, clientSecret.getAtt("secret")).export(`auth-${id}-domain`, domain.domain);
5958
6289
  for (const [event, lambda] of functions) {
5959
6290
  const permission = new Permission(`auth-${id}-${event}`, {
5960
6291
  action: "lambda:InvokeFunction",
@@ -6035,10 +6366,7 @@ var getAllDepends = (filters) => {
6035
6366
  var toApp = async (config, filters) => {
6036
6367
  const app = new App(config.name);
6037
6368
  const stacks = [];
6038
- const plugins = [
6039
- ...defaultPlugins,
6040
- ...config.plugins || []
6041
- ];
6369
+ const plugins = [...defaultPlugins, ...config.plugins || []];
6042
6370
  debug("Plugins detected:", plugins.map((plugin) => style.info(plugin.name)).join(", "));
6043
6371
  const bootstrap2 = new Stack("bootstrap", config.region);
6044
6372
  const usEastBootstrap = new Stack("us-east-bootstrap", "us-east-1");
@@ -6074,6 +6402,7 @@ var toApp = async (config, filters) => {
6074
6402
  app.add(stack);
6075
6403
  stacks.push({ stack, config: stackConfig, bindings: bindings2 });
6076
6404
  }
6405
+ debug(app.stacks);
6077
6406
  for (const plugin of plugins) {
6078
6407
  for (const stack of app.stacks) {
6079
6408
  for (const resource of stack) {
@@ -6207,27 +6536,28 @@ var AppSchema = z30.object({
6207
6536
  });
6208
6537
 
6209
6538
  // src/util/import.ts
6210
- import { rollup as rollup2, watch } from "rollup";
6211
- import { swc as swc2 } from "rollup-plugin-swc3";
6539
+ import { rollup as rollup3, watch } from "rollup";
6540
+ import { swc as swc3 } from "rollup-plugin-swc3";
6212
6541
  import replace from "rollup-plugin-replace";
6213
6542
  import { EventIterator } from "event-iterator";
6214
- import { dirname as dirname2, join as join5 } from "path";
6543
+ import { dirname as dirname3, join as join5 } from "path";
6215
6544
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
6216
6545
  var importFile = async (path) => {
6217
- const bundle = await rollup2({
6546
+ const bundle = await rollup3({
6218
6547
  input: path,
6219
6548
  onwarn: (error) => {
6220
6549
  debugError(error.message);
6221
6550
  },
6222
6551
  plugins: [
6552
+ // @ts-ignore
6223
6553
  replace({
6224
- __dirname: (id) => `'${dirname2(id)}'`,
6225
- "defineStackConfig({": (id) => `defineStackConfig({ cwd: '${dirname2(id)}',`
6554
+ __dirname: (id) => `'${dirname3(id)}'`
6555
+ // 'defineStackConfig({': id => `defineStackConfig({ cwd: '${dirname(id)}',`,
6226
6556
  }),
6227
- swc2({
6557
+ swc3({
6228
6558
  minify: false,
6229
6559
  jsc: {
6230
- baseUrl: dirname2(path)
6560
+ baseUrl: dirname3(path)
6231
6561
  }
6232
6562
  })
6233
6563
  ]
@@ -6256,14 +6586,15 @@ var watchFile = (path) => {
6256
6586
  debugError(error.message);
6257
6587
  },
6258
6588
  plugins: [
6589
+ // @ts-ignore
6259
6590
  replace({
6260
- __dirname: (id) => `'${dirname2(id)}'`,
6261
- "defineStackConfig({": (id) => `defineStackConfig({ cwd: '${dirname2(id)}',`
6591
+ __dirname: (id) => `'${dirname3(id)}'`
6592
+ // 'defineStackConfig({': id => `defineStackConfig({ cwd: '${dirname(id)}',`,
6262
6593
  }),
6263
- swc2({
6594
+ swc3({
6264
6595
  minify: false,
6265
6596
  jsc: {
6266
- baseUrl: dirname2(path)
6597
+ baseUrl: dirname3(path)
6267
6598
  }
6268
6599
  })
6269
6600
  ]
@@ -6979,7 +7310,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
6979
7310
  };
6980
7311
 
6981
7312
  // src/cli/ui/complex/builder.ts
6982
- import { dirname as dirname3, join as join7 } from "path";
7313
+ import { dirname as dirname4, join as join7 } from "path";
6983
7314
  var assetBuilder = (app) => {
6984
7315
  return async (term) => {
6985
7316
  const assets = [];
@@ -7043,7 +7374,7 @@ var assetBuilder = (app) => {
7043
7374
  const data = await asset.build({
7044
7375
  async write(file, data2) {
7045
7376
  const fullpath = join7(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7046
- const basepath = dirname3(fullpath);
7377
+ const basepath = dirname4(fullpath);
7047
7378
  await mkdir3(basepath, { recursive: true });
7048
7379
  await writeFile3(fullpath, data2);
7049
7380
  }
@@ -7632,55 +7963,70 @@ var assetPublisher = (config, app) => {
7632
7963
  });
7633
7964
  return async (term) => {
7634
7965
  const done = term.out.write(loadingDialog("Publishing stack assets to AWS..."));
7635
- await Promise.all(app.stacks.map(async (stack) => {
7636
- await Promise.all([...stack.assets].map(async (asset) => {
7637
- await asset.publish?.({
7638
- async read(file) {
7639
- const path = join9(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7640
- const data = await readFile3(path);
7641
- return data;
7642
- },
7643
- async publish(name, data, hash) {
7644
- const key = `${app.name}/${stack.name}/${asset.type}/${name}`;
7645
- const bucket = assetBucketName(config.account, config.region);
7646
- let getResult;
7647
- try {
7648
- getResult = await client.send(new GetObjectCommand({
7649
- Bucket: bucket,
7650
- Key: key
7651
- }));
7652
- } catch (error) {
7653
- if (error instanceof Error && error.name === "NoSuchKey") {
7654
- } else {
7655
- throw error;
7656
- }
7657
- }
7658
- if (getResult?.Metadata?.hash === hash) {
7659
- return {
7660
- bucket,
7661
- key,
7662
- version: getResult.VersionId
7663
- };
7664
- }
7665
- const putResult = await client.send(new PutObjectCommand2({
7666
- Bucket: bucket,
7667
- Key: key,
7668
- Body: data,
7669
- ACL: ObjectCannedACL2.private,
7670
- StorageClass: StorageClass2.STANDARD,
7671
- Metadata: {
7672
- hash
7966
+ await Promise.all(
7967
+ app.stacks.map(async (stack) => {
7968
+ await Promise.all(
7969
+ [...stack.assets].map(async (asset) => {
7970
+ await asset.publish?.({
7971
+ async read(file) {
7972
+ const path = join9(
7973
+ directories.asset,
7974
+ asset.type,
7975
+ app.name,
7976
+ stack.name,
7977
+ asset.id,
7978
+ file
7979
+ );
7980
+ const data = await readFile3(path);
7981
+ return data;
7982
+ },
7983
+ async publish(name, data, hash) {
7984
+ const key = `${app.name}/${stack.name}/${asset.type}/${name}`;
7985
+ const bucket = assetBucketName(config.account, config.region);
7986
+ let getResult;
7987
+ try {
7988
+ getResult = await client.send(
7989
+ new GetObjectCommand({
7990
+ Bucket: bucket,
7991
+ Key: key
7992
+ })
7993
+ );
7994
+ } catch (error) {
7995
+ if (error instanceof Error && error.name === "NoSuchKey") {
7996
+ } else {
7997
+ throw error;
7998
+ }
7999
+ }
8000
+ if (getResult?.Metadata?.hash === hash) {
8001
+ return {
8002
+ bucket,
8003
+ key,
8004
+ version: getResult.VersionId
8005
+ };
8006
+ }
8007
+ const putResult = await client.send(
8008
+ new PutObjectCommand2({
8009
+ Bucket: bucket,
8010
+ Key: key,
8011
+ Body: data,
8012
+ ACL: ObjectCannedACL2.private,
8013
+ StorageClass: StorageClass2.STANDARD,
8014
+ Metadata: {
8015
+ hash
8016
+ }
8017
+ })
8018
+ );
8019
+ return {
8020
+ bucket,
8021
+ key,
8022
+ version: putResult.VersionId
8023
+ };
7673
8024
  }
7674
- }));
7675
- return {
7676
- bucket,
7677
- key,
7678
- version: putResult.VersionId
7679
- };
7680
- }
7681
- });
7682
- }));
7683
- }));
8025
+ });
8026
+ })
8027
+ );
8028
+ })
8029
+ );
7684
8030
  done("Done publishing stack assets to AWS");
7685
8031
  };
7686
8032
  };