@awsless/awsless 0.0.76 → 0.0.78

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.
package/dist/bin.js CHANGED
@@ -212,6 +212,7 @@ var LogGroup = class extends Resource {
212
212
  };
213
213
 
214
214
  // src/formation/resource/iam/inline-policy.ts
215
+ import { capitalCase } from "change-case";
215
216
  var InlinePolicy = class {
216
217
  name;
217
218
  statements;
@@ -229,7 +230,7 @@ var InlinePolicy = class {
229
230
  PolicyDocument: {
230
231
  Version: "2012-10-17",
231
232
  Statement: this.statements.map((statement) => ({
232
- Effect: statement.effect || "Allow",
233
+ Effect: capitalCase(statement.effect || "allow"),
233
234
  Action: statement.actions,
234
235
  Resource: statement.resources
235
236
  }))
@@ -1330,6 +1331,12 @@ var RetryAttemptsSchema = z6.number().int().min(0).max(2);
1330
1331
  var RuntimeSchema = z6.enum([
1331
1332
  "nodejs18.x"
1332
1333
  ]);
1334
+ var PermissionSchema = z6.object({
1335
+ effect: z6.enum(["allow", "deny"]).default("allow"),
1336
+ actions: z6.string().array(),
1337
+ resources: z6.string().array()
1338
+ });
1339
+ var PermissionsSchema = z6.union([PermissionSchema, PermissionSchema.array()]);
1333
1340
  var LogSchema = z6.union([
1334
1341
  z6.boolean(),
1335
1342
  DurationSchema.refine(durationMin(Duration.days(1)), "Minimum log retention is 1 day")
@@ -1404,8 +1411,17 @@ var FunctionSchema = z6.union([
1404
1411
  * }
1405
1412
  * }
1406
1413
  */
1407
- environment: EnvironmentSchema.optional()
1408
- // onFailure: ResourceIdSchema.optional(),
1414
+ environment: EnvironmentSchema.optional(),
1415
+ /** Add IAM permissions to your function.
1416
+ * @example
1417
+ * {
1418
+ * permissions: {
1419
+ * actions: [ 's3:PutObject' ],
1420
+ * resources: [ '*' ]
1421
+ * }
1422
+ * }
1423
+ */
1424
+ permissions: PermissionsSchema.optional()
1409
1425
  })
1410
1426
  ]);
1411
1427
  var isFunctionProps = (input) => {
@@ -1477,8 +1493,17 @@ var schema = z6.object({
1477
1493
  * }
1478
1494
  * }
1479
1495
  */
1480
- environment: EnvironmentSchema.optional()
1481
- // onFailure: ResourceIdSchema.optional(),
1496
+ environment: EnvironmentSchema.optional(),
1497
+ /** Add IAM permissions to your function.
1498
+ * @example
1499
+ * {
1500
+ * permissions: {
1501
+ * actions: [ 's3:PutObject' ],
1502
+ * resources: [ '*' ]
1503
+ * }
1504
+ * }
1505
+ */
1506
+ permissions: PermissionsSchema.optional()
1482
1507
  }).default({})
1483
1508
  }).default({}),
1484
1509
  stacks: z6.object({
@@ -1500,9 +1525,9 @@ var typeGenCode = `
1500
1525
  import { InvokeOptions } from '@awsless/lambda'
1501
1526
 
1502
1527
  type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1503
- name: Name
1528
+ readonly name: Name
1529
+ readonly async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1504
1530
  (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): ReturnType<Func>
1505
- async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1506
1531
  }`;
1507
1532
  var functionPlugin = definePlugin({
1508
1533
  name: "function",
@@ -1558,6 +1583,12 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
1558
1583
  ...props,
1559
1584
  vpc: void 0
1560
1585
  });
1586
+ if (config.defaults?.function?.permissions) {
1587
+ lambda.addPermissions(config.defaults?.function?.permissions);
1588
+ }
1589
+ if (typeof fileOrProps === "object" && fileOrProps.permissions) {
1590
+ lambda.addPermissions(fileOrProps.permissions);
1591
+ }
1561
1592
  lambda.addEnvironment("APP", config.name).addEnvironment("STAGE", config.stage).addEnvironment("STACK", stack.name);
1562
1593
  if (props.log) {
1563
1594
  lambda.enableLogs(props.log instanceof Duration ? props.log : void 0);
@@ -1769,8 +1800,8 @@ import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless
1769
1800
  type Payload<Func extends (...args: any[]) => any> = Parameters<Func>[0]['Records'][number]['body']
1770
1801
 
1771
1802
  type Send<Name extends string, Func extends (...args: any[]) => any> = {
1772
- name: Name
1773
- batch(items:BatchItem<Payload<Func>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1803
+ readonly name: Name
1804
+ readonly batch(items:BatchItem<Payload<Func>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1774
1805
  (payload: Payload<Func>, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
1775
1806
  }`;
1776
1807
  var queuePlugin = definePlugin({
@@ -2166,7 +2197,7 @@ var tablePlugin = definePlugin({
2166
2197
  const list3 = new TypeObject();
2167
2198
  for (const name of Object.keys(stack.tables || {})) {
2168
2199
  const tableName = formatName(`${config.name}-${stack.name}-${name}`);
2169
- list3.addType(name, `{ name: '${tableName}' }`);
2200
+ list3.addType(name, `{ readonly name: '${tableName}' }`);
2170
2201
  }
2171
2202
  types2.addType(stack.name, list3.toString());
2172
2203
  }
@@ -2298,7 +2329,7 @@ var storePlugin = definePlugin({
2298
2329
  const list3 = new TypeObject();
2299
2330
  for (const name of stack.stores || []) {
2300
2331
  const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2301
- list3.addType(name, `{ name: '${storeName}' }`);
2332
+ list3.addType(name, `{ readonly name: '${storeName}' }`);
2302
2333
  }
2303
2334
  types2.addType(stack.name, list3.toString());
2304
2335
  }
@@ -2397,8 +2428,8 @@ var typeGenCode3 = `
2397
2428
  import { PublishOptions } from '@awsless/sns'
2398
2429
 
2399
2430
  type Publish<Name extends string> = {
2400
- name: Name
2401
- (payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
2431
+ readonly name: Name
2432
+ readonly (payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
2402
2433
  }`;
2403
2434
  var topicPlugin = definePlugin({
2404
2435
  name: "topic",
@@ -2620,16 +2651,17 @@ var toArray = (value) => {
2620
2651
  import { paramCase as paramCase4 } from "change-case";
2621
2652
 
2622
2653
  // src/formation/resource/appsync/graphql-api.ts
2623
- import { constantCase as constantCase7 } from "change-case";
2624
2654
  var GraphQLApi = class extends Resource {
2655
+ // private lambdaAuthProviders: { arn: string, ttl: Duration }[] = []
2625
2656
  constructor(logicalId, props) {
2626
2657
  super("AWS::AppSync::GraphQLApi", logicalId);
2627
2658
  this.props = props;
2628
2659
  this.name = formatName(this.props.name || logicalId);
2660
+ this.defaultAuthorization = props.defaultAuthorization;
2629
2661
  this.tag("name", this.name);
2630
2662
  }
2631
2663
  name;
2632
- lambdaAuthProviders = [];
2664
+ defaultAuthorization;
2633
2665
  get arn() {
2634
2666
  return ref(this.logicalId);
2635
2667
  }
@@ -2642,24 +2674,67 @@ var GraphQLApi = class extends Resource {
2642
2674
  get dns() {
2643
2675
  return getAtt(this.logicalId, "GraphQLDns");
2644
2676
  }
2645
- addLambdaAuthProvider(lambdaAuthorizerArn, resultTTL = Duration.seconds(0)) {
2646
- this.lambdaAuthProviders.push({
2647
- arn: lambdaAuthorizerArn,
2648
- ttl: resultTTL
2649
- });
2677
+ setDefaultAuthorization(auth) {
2678
+ this.defaultAuthorization = auth;
2650
2679
  return this;
2651
2680
  }
2681
+ // addLambdaAuthProvider(lambdaAuthorizerArn: string, resultTTL: Duration = Duration.seconds(0)) {
2682
+ // this.lambdaAuthProviders.push({
2683
+ // arn: lambdaAuthorizerArn,
2684
+ // ttl: resultTTL,
2685
+ // })
2686
+ // return this
2687
+ // }
2688
+ // addCognitoAuthProvider(lambdaAuthorizerArn: string, resultTTL: Duration = Duration.seconds(0)) {
2689
+ // this.lambdaAuthProviders.push({
2690
+ // arn: lambdaAuthorizerArn,
2691
+ // ttl: resultTTL,
2692
+ // })
2693
+ // return this
2694
+ // }
2652
2695
  properties() {
2653
2696
  return {
2654
2697
  Name: this.name,
2655
- AuthenticationType: constantCase7(this.props.authenticationType || "api-key"),
2656
- AdditionalAuthenticationProviders: this.lambdaAuthProviders.map((provider) => ({
2657
- AuthenticationType: "AWS_LAMBDA",
2658
- LambdaAuthorizerConfig: {
2659
- AuthorizerUri: provider.arn,
2660
- AuthorizerResultTtlInSeconds: provider.ttl.toSeconds()
2661
- }
2662
- }))
2698
+ ...this.defaultAuthorization?.toJSON() ?? {}
2699
+ // AuthenticationType: constantCase(this.props.authenticationType || 'api-key'),
2700
+ // AdditionalAuthenticationProviders: this.lambdaAuthProviders.map(provider => ({
2701
+ // AuthenticationType: 'AWS_LAMBDA',
2702
+ // LambdaAuthorizerConfig: {
2703
+ // AuthorizerUri: provider.arn,
2704
+ // AuthorizerResultTtlInSeconds: provider.ttl.toSeconds(),
2705
+ // }
2706
+ // }))
2707
+ };
2708
+ }
2709
+ };
2710
+ var GraphQLAuthorization = class {
2711
+ static withCognito(props) {
2712
+ return new GraphQLCognitoAuthorization(props);
2713
+ }
2714
+ static withApiKey() {
2715
+ return new GraphQLApiKeyAuthorization();
2716
+ }
2717
+ };
2718
+ var GraphQLCognitoAuthorization = class {
2719
+ constructor(props) {
2720
+ this.props = props;
2721
+ }
2722
+ toJSON() {
2723
+ return {
2724
+ AuthenticationType: "AMAZON_COGNITO_USER_POOLS",
2725
+ UserPoolConfig: {
2726
+ UserPoolId: this.props.userPoolId,
2727
+ ...this.props.region ? { AwsRegion: this.props.region } : {},
2728
+ ...this.props.defaultAction ? { DefaultAction: this.props.defaultAction } : {},
2729
+ ...this.props.appIdClientRegex ? { AppIdClientRegex: this.props.appIdClientRegex } : {}
2730
+ }
2731
+ };
2732
+ }
2733
+ };
2734
+ var GraphQLApiKeyAuthorization = class {
2735
+ toJSON() {
2736
+ return {
2737
+ AuthenticationType: "API_KEY"
2663
2738
  };
2664
2739
  }
2665
2740
  };
@@ -2967,10 +3042,11 @@ var graphqlPlugin = definePlugin({
2967
3042
  graphql: z14.record(ResourceIdSchema, z14.object({
2968
3043
  domain: z14.string().optional(),
2969
3044
  subDomain: z14.string().optional(),
2970
- authorization: z14.object({
2971
- authorizer: FunctionSchema,
2972
- ttl: DurationSchema.default("1 hour")
2973
- }).optional(),
3045
+ auth: ResourceIdSchema.optional(),
3046
+ // authorization: z.object({
3047
+ // authorizer: FunctionSchema,
3048
+ // ttl: DurationSchema.default('1 hour'),
3049
+ // }).optional(),
2974
3050
  resolver: LocalFileSchema.optional()
2975
3051
  })).optional()
2976
3052
  }).default({}),
@@ -3014,7 +3090,7 @@ var graphqlPlugin = definePlugin({
3014
3090
  }
3015
3091
  const api = new GraphQLApi(id, {
3016
3092
  name: `${config.name}-${id}`,
3017
- authenticationType: "api-key"
3093
+ defaultAuthorization: GraphQLAuthorization.withApiKey()
3018
3094
  });
3019
3095
  const schema2 = new GraphQLSchema(id, {
3020
3096
  apiId: api.id,
@@ -3025,10 +3101,12 @@ var graphqlPlugin = definePlugin({
3025
3101
  if (!props) {
3026
3102
  continue;
3027
3103
  }
3028
- if (props.authorization) {
3029
- const lambda = toLambdaFunction(ctx, `${id}-authorizer`, props.authorization.authorizer);
3030
- api.addLambdaAuthProvider(lambda.arn, props.authorization.ttl);
3031
- bootstrap2.add(lambda);
3104
+ if (props.auth) {
3105
+ api.setDefaultAuthorization(GraphQLAuthorization.withCognito({
3106
+ userPoolId: bootstrap2.import(`auth-${props.auth}-user-pool-id`),
3107
+ region: bootstrap2.region,
3108
+ defaultAction: "ALLOW"
3109
+ }));
3032
3110
  }
3033
3111
  if (props.domain) {
3034
3112
  const domainName = props.subDomain ? `${props.subDomain}.${props.domain}` : props.domain;
@@ -3183,36 +3261,38 @@ var DomainNameSchema = z15.string().regex(/[a-z\-\_\.]/g, "Invalid domain name")
3183
3261
  var domainPlugin = definePlugin({
3184
3262
  name: "domain",
3185
3263
  schema: z15.object({
3186
- /** Define the domains for your application.
3187
- * @example
3188
- * {
3189
- * domains: {
3190
- * 'example.com': [{
3191
- * name: 'www',
3192
- * type: 'TXT',
3193
- * ttl: '60 seconds',
3194
- * records: [ 'value' ]
3195
- * }]
3196
- * }
3197
- * }
3198
- */
3199
- domains: z15.record(DomainNameSchema, z15.object({
3200
- /** Enter a fully qualified domain name, for example, www.example.com.
3201
- * You can optionally include a trailing dot.
3202
- * If you omit the trailing dot, Amazon Route 53 assumes that the domain name that you specify is fully qualified.
3203
- * This means that Route 53 treats www.example.com (without a trailing dot) and www.example.com. (with a trailing dot) as identical.
3264
+ defaults: z15.object({
3265
+ /** Define the domains for your application.
3266
+ * @example
3267
+ * {
3268
+ * domains: {
3269
+ * 'example.com': [{
3270
+ * name: 'www',
3271
+ * type: 'TXT',
3272
+ * ttl: '60 seconds',
3273
+ * records: [ 'value' ]
3274
+ * }]
3275
+ * }
3276
+ * }
3204
3277
  */
3205
- name: DomainNameSchema.optional(),
3206
- /** The DNS record type. */
3207
- type: z15.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]),
3208
- /** The resource record cache time to live (TTL). */
3209
- ttl: DurationSchema,
3210
- /** One or more values that correspond with the value that you specified for the Type property. */
3211
- records: z15.string().array()
3212
- }).array()).optional()
3278
+ domains: z15.record(DomainNameSchema, z15.object({
3279
+ /** Enter a fully qualified domain name, for example, www.example.com.
3280
+ * You can optionally include a trailing dot.
3281
+ * If you omit the trailing dot, Amazon Route 53 assumes that the domain name that you specify is fully qualified.
3282
+ * This means that Route 53 treats www.example.com (without a trailing dot) and www.example.com. (with a trailing dot) as identical.
3283
+ */
3284
+ name: DomainNameSchema.optional(),
3285
+ /** The DNS record type. */
3286
+ type: z15.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]),
3287
+ /** The resource record cache time to live (TTL). */
3288
+ ttl: DurationSchema,
3289
+ /** One or more values that correspond with the value that you specified for the Type property. */
3290
+ records: z15.string().array()
3291
+ }).array()).optional()
3292
+ }).default({})
3213
3293
  }),
3214
3294
  onApp({ config, bootstrap: bootstrap2, usEastBootstrap }) {
3215
- const domains = Object.entries(config.domains || {});
3295
+ const domains = Object.entries(config.defaults.domains || {});
3216
3296
  if (domains.length === 0) {
3217
3297
  return;
3218
3298
  }
@@ -3660,7 +3740,7 @@ var LoadBalancer = class extends Resource {
3660
3740
  };
3661
3741
 
3662
3742
  // src/formation/resource/elb/listener.ts
3663
- import { constantCase as constantCase8 } from "change-case";
3743
+ import { constantCase as constantCase7 } from "change-case";
3664
3744
  var Listener = class extends Resource {
3665
3745
  constructor(logicalId, props) {
3666
3746
  super("AWS::ElasticLoadBalancingV2::Listener", logicalId);
@@ -3676,11 +3756,16 @@ var Listener = class extends Resource {
3676
3756
  return {
3677
3757
  LoadBalancerArn: this.props.loadBalancerArn,
3678
3758
  Port: this.props.port,
3679
- Protocol: constantCase8(this.props.protocol),
3759
+ Protocol: constantCase7(this.props.protocol),
3680
3760
  Certificates: this.props.certificates.map((arn) => ({
3681
3761
  CertificateArn: arn
3682
3762
  })),
3683
- ...this.attr("DefaultActions", this.props.defaultActions?.map((action) => action.toJSON()))
3763
+ ...this.attr("DefaultActions", this.props.defaultActions?.map((action, i) => {
3764
+ return {
3765
+ Order: i + 1,
3766
+ ...action.toJSON()
3767
+ };
3768
+ }))
3684
3769
  };
3685
3770
  }
3686
3771
  };
@@ -3688,6 +3773,12 @@ var ListenerAction = class _ListenerAction {
3688
3773
  constructor(props) {
3689
3774
  this.props = props;
3690
3775
  }
3776
+ static authCognito(props) {
3777
+ return new _ListenerAction({
3778
+ type: "authenticate-cognito",
3779
+ ...props
3780
+ });
3781
+ }
3691
3782
  static fixedResponse(statusCode, props = {}) {
3692
3783
  return new _ListenerAction({
3693
3784
  type: "fixed-response",
@@ -3729,6 +3820,17 @@ var ListenerAction = class _ListenerAction {
3729
3820
  TargetGroupArn: target
3730
3821
  }))
3731
3822
  }
3823
+ } : {},
3824
+ ...this.props.type === "authenticate-cognito" ? {
3825
+ AuthenticateCognitoConfig: {
3826
+ OnUnauthenticatedRequest: this.props.onUnauthenticated ?? "deny",
3827
+ Scope: this.props.scope ?? "openid",
3828
+ SessionCookieName: this.props.session?.cookieName ?? "AWSELBAuthSessionCookie",
3829
+ SessionTimeout: this.props.session?.timeout?.toSeconds() ?? 604800,
3830
+ UserPoolArn: this.props.userPool.arn,
3831
+ UserPoolClientId: this.props.userPool.clientId,
3832
+ UserPoolDomain: this.props.userPool.domain
3833
+ }
3732
3834
  } : {}
3733
3835
  };
3734
3836
  }
@@ -3751,7 +3853,13 @@ var ListenerRule = class extends Resource {
3751
3853
  ListenerArn: this.props.listenerArn,
3752
3854
  Priority: this.props.priority,
3753
3855
  Conditions: this.props.conditions.map((condition) => condition.toJSON()),
3754
- Actions: this.props.actions.map((action) => action.toJSON())
3856
+ // Actions: this.props.actions.map(action => action.toJSON()),
3857
+ Actions: this.props.actions?.map((action, i) => {
3858
+ return {
3859
+ Order: i + 1,
3860
+ ...action.toJSON()
3861
+ };
3862
+ })
3755
3863
  };
3756
3864
  }
3757
3865
  };
@@ -3830,11 +3938,16 @@ var ElbEventSource = class extends Group {
3830
3938
  type: "lambda",
3831
3939
  targets: [lambda.arn]
3832
3940
  }).dependsOn(lambda, permission);
3941
+ const actions = [];
3942
+ if (props.auth?.cognito) {
3943
+ actions.push(ListenerAction.authCognito(props.auth.cognito));
3944
+ }
3833
3945
  const rule = new ListenerRule(id, {
3834
3946
  listenerArn: props.listenerArn,
3835
3947
  priority: props.priority,
3836
3948
  conditions: props.conditions,
3837
3949
  actions: [
3950
+ ...actions,
3838
3951
  ListenerAction.forward([target.arn])
3839
3952
  ]
3840
3953
  }).dependsOn(target);
@@ -3880,7 +3993,8 @@ var httpPlugin = definePlugin({
3880
3993
  z17.object({
3881
3994
  /** The domain to link your api with. */
3882
3995
  domain: z17.string(),
3883
- subDomain: z17.string().optional()
3996
+ subDomain: z17.string().optional(),
3997
+ auth: ResourceIdSchema.optional()
3884
3998
  })
3885
3999
  ).optional()
3886
4000
  }).default({}),
@@ -3953,18 +4067,28 @@ var httpPlugin = definePlugin({
3953
4067
  }
3954
4068
  },
3955
4069
  onStack(ctx) {
3956
- const { stack, stackConfig, bootstrap: bootstrap2 } = ctx;
4070
+ const { config, stack, stackConfig, bootstrap: bootstrap2 } = ctx;
3957
4071
  for (const [id, routes] of Object.entries(stackConfig.http || {})) {
3958
- for (const [route, props] of Object.entries(routes)) {
4072
+ const props = config.defaults.http[id];
4073
+ for (const [route, routeProps] of Object.entries(routes)) {
3959
4074
  const { method, path } = parseRoute(route);
3960
- const lambda = toLambdaFunction(ctx, `http-${id}`, props);
4075
+ const lambda = toLambdaFunction(ctx, `http-${id}`, routeProps);
3961
4076
  const source = new ElbEventSource(`http-${id}-${route}`, lambda, {
3962
4077
  listenerArn: bootstrap2.import(`http-${id}-listener-arn`),
3963
4078
  priority: generatePriority(stackConfig.name, route),
3964
4079
  conditions: [
3965
4080
  ListenerCondition.httpRequestMethods([method]),
3966
4081
  ListenerCondition.pathPatterns([path])
3967
- ]
4082
+ ],
4083
+ auth: props.auth ? {
4084
+ cognito: {
4085
+ userPool: {
4086
+ arn: bootstrap2.import(`auth-${props.auth}-user-pool-arn`),
4087
+ clientId: bootstrap2.import(`auth-${props.auth}-client-id`),
4088
+ domain: bootstrap2.import(`auth-${props.auth}-domain`)
4089
+ }
4090
+ }
4091
+ } : void 0
3968
4092
  });
3969
4093
  stack.add(lambda, source);
3970
4094
  }
@@ -4028,7 +4152,7 @@ var searchPlugin = definePlugin({
4028
4152
  const list3 = new TypeObject();
4029
4153
  for (const id of stack.searchs || []) {
4030
4154
  const name = formatName(`${config.name}-${stack.name}-${id}`);
4031
- list3.addType(name, `{ name: '${name}' }`);
4155
+ list3.addType(name, `{ readonly name: '${name}' }`);
4032
4156
  }
4033
4157
  gen.addType(stack.name, list3.toString());
4034
4158
  }
@@ -4115,7 +4239,7 @@ var SubnetGroup = class extends Resource {
4115
4239
  };
4116
4240
 
4117
4241
  // src/plugins/cache.ts
4118
- import { constantCase as constantCase9 } from "change-case";
4242
+ import { constantCase as constantCase8 } from "change-case";
4119
4243
  var TypeSchema = z19.enum([
4120
4244
  "t4g.small",
4121
4245
  "t4g.medium",
@@ -4168,7 +4292,7 @@ var cachePlugin = definePlugin({
4168
4292
  for (const stack of config.stacks) {
4169
4293
  const list3 = new TypeObject();
4170
4294
  for (const name of Object.keys(stack.caches || {})) {
4171
- list3.addType(name, `{ host: string, port: number }`);
4295
+ list3.addType(name, `{ readonly host: string, readonly port: number }`);
4172
4296
  }
4173
4297
  gen.addType(stack.name, list3.toString());
4174
4298
  }
@@ -4201,7 +4325,7 @@ var cachePlugin = definePlugin({
4201
4325
  }).dependsOn(subnetGroup, securityGroup);
4202
4326
  stack.add(subnetGroup, securityGroup, cluster);
4203
4327
  bind((lambda) => {
4204
- lambda.addEnvironment(`CACHE_${constantCase9(stack.name)}_${constantCase9(id)}_HOST`, cluster.address).addEnvironment(`CACHE_${constantCase9(stack.name)}_${constantCase9(id)}_PORT`, props.port.toString());
4328
+ lambda.addEnvironment(`CACHE_${constantCase8(stack.name)}_${constantCase8(id)}_HOST`, cluster.address).addEnvironment(`CACHE_${constantCase8(stack.name)}_${constantCase8(id)}_PORT`, props.port.toString());
4205
4329
  });
4206
4330
  }
4207
4331
  }
@@ -4891,7 +5015,7 @@ var Files = class extends Asset {
4891
5015
  };
4892
5016
 
4893
5017
  // src/formation/resource/s3/bucket-policy.ts
4894
- import { capitalCase } from "change-case";
5018
+ import { capitalCase as capitalCase2 } from "change-case";
4895
5019
  var BucketPolicy = class extends Resource {
4896
5020
  constructor(logicalId, props) {
4897
5021
  super("AWS::S3::BucketPolicy", logicalId);
@@ -4903,7 +5027,7 @@ var BucketPolicy = class extends Resource {
4903
5027
  PolicyDocument: {
4904
5028
  Version: this.props.version ?? "2012-10-17",
4905
5029
  Statement: this.props.statements.map((statement) => ({
4906
- Effect: capitalCase(statement.effect ?? "allow"),
5030
+ Effect: capitalCase2(statement.effect ?? "allow"),
4907
5031
  ...statement.principal ? {
4908
5032
  Principal: {
4909
5033
  Service: statement.principal
@@ -5374,6 +5498,399 @@ var featurePlugin = definePlugin({
5374
5498
  }
5375
5499
  });
5376
5500
 
5501
+ // src/plugins/auth.ts
5502
+ import { z as z25 } from "zod";
5503
+
5504
+ // src/formation/resource/cognito/user-pool.ts
5505
+ import { constantCase as constantCase9 } from "change-case";
5506
+
5507
+ // src/formation/resource/cognito/user-pool-client.ts
5508
+ var UserPoolClient = class extends Resource {
5509
+ constructor(logicalId, props) {
5510
+ super("AWS::Cognito::UserPoolClient", logicalId);
5511
+ this.props = props;
5512
+ this.name = formatName(this.props.name || logicalId);
5513
+ }
5514
+ name;
5515
+ get id() {
5516
+ return ref(this.logicalId);
5517
+ }
5518
+ formatAuthFlows() {
5519
+ const authFlows = [];
5520
+ if (this.props.authFlows?.userPassword) {
5521
+ authFlows.push("ALLOW_USER_PASSWORD_AUTH");
5522
+ }
5523
+ if (this.props.authFlows?.adminUserPassword) {
5524
+ authFlows.push("ALLOW_ADMIN_USER_PASSWORD_AUTH");
5525
+ }
5526
+ if (this.props.authFlows?.custom) {
5527
+ authFlows.push("ALLOW_CUSTOM_AUTH");
5528
+ }
5529
+ if (this.props.authFlows?.userSrp) {
5530
+ authFlows.push("ALLOW_USER_SRP_AUTH");
5531
+ }
5532
+ authFlows.push("ALLOW_REFRESH_TOKEN_AUTH");
5533
+ return authFlows;
5534
+ }
5535
+ formatIdentityProviders() {
5536
+ const supported = this.props.supportedIdentityProviders ?? [];
5537
+ const providers = [];
5538
+ if (supported.length === 0) {
5539
+ return void 0;
5540
+ }
5541
+ if (supported.includes("amazon")) {
5542
+ providers.push("LoginWithAmazon");
5543
+ }
5544
+ if (supported.includes("apple")) {
5545
+ providers.push("SignInWithApple");
5546
+ }
5547
+ if (supported.includes("cognito")) {
5548
+ providers.push("COGNITO");
5549
+ }
5550
+ if (supported.includes("facebook")) {
5551
+ providers.push("Facebook");
5552
+ }
5553
+ if (supported.includes("google")) {
5554
+ providers.push("Google");
5555
+ }
5556
+ return providers;
5557
+ }
5558
+ properties() {
5559
+ return {
5560
+ ClientName: this.name,
5561
+ UserPoolId: this.props.userPoolId,
5562
+ ExplicitAuthFlows: this.formatAuthFlows(),
5563
+ EnableTokenRevocation: this.props.enableTokenRevocation ?? false,
5564
+ GenerateSecret: this.props.generateSecret ?? false,
5565
+ PreventUserExistenceErrors: this.props.preventUserExistenceErrors ?? true ? "ENABLED" : "LEGACY",
5566
+ ...this.attr("SupportedIdentityProviders", this.formatIdentityProviders()),
5567
+ AllowedOAuthFlows: ["code"],
5568
+ AllowedOAuthScopes: ["openid"],
5569
+ AllowedOAuthFlowsUserPoolClient: true,
5570
+ CallbackURLs: ["https://example.com"],
5571
+ LogoutURLs: ["https://example.com"],
5572
+ // DefaultRedirectURI: String
5573
+ // EnablePropagateAdditionalUserContextData
5574
+ ...this.attr("ReadAttributes", this.props.readAttributes),
5575
+ ...this.attr("WriteAttributes", this.props.writeAttributes),
5576
+ ...this.attr("AuthSessionValidity", this.props.validity?.authSession?.toMinutes()),
5577
+ ...this.attr("AccessTokenValidity", this.props.validity?.accessToken?.toHours()),
5578
+ ...this.attr("IdTokenValidity", this.props.validity?.idToken?.toHours()),
5579
+ ...this.attr("RefreshTokenValidity", this.props.validity?.refreshToken?.toDays()),
5580
+ TokenValidityUnits: {
5581
+ ...this.attr("AccessToken", this.props.validity?.accessToken && "hours"),
5582
+ ...this.attr("IdToken", this.props.validity?.idToken && "hours"),
5583
+ ...this.attr("RefreshToken", this.props.validity?.refreshToken && "days")
5584
+ }
5585
+ };
5586
+ }
5587
+ };
5588
+
5589
+ // src/formation/resource/cognito/user-pool-domain.ts
5590
+ var UserPoolDomain = class extends Resource {
5591
+ constructor(logicalId, props) {
5592
+ super("AWS::Cognito::UserPoolDomain", logicalId);
5593
+ this.props = props;
5594
+ }
5595
+ get domain() {
5596
+ return ref(this.logicalId);
5597
+ }
5598
+ get cloudFrontDistribution() {
5599
+ return getAtt(this.logicalId, "CloudFrontDistribution");
5600
+ }
5601
+ properties() {
5602
+ return {
5603
+ UserPoolId: this.props.userPoolId,
5604
+ Domain: formatName(this.props.domain)
5605
+ };
5606
+ }
5607
+ };
5608
+
5609
+ // src/formation/resource/cognito/user-pool.ts
5610
+ var UserPool = class extends Resource {
5611
+ constructor(logicalId, props) {
5612
+ super("AWS::Cognito::UserPool", logicalId);
5613
+ this.props = props;
5614
+ this.name = formatName(this.props.name || logicalId);
5615
+ }
5616
+ name;
5617
+ get id() {
5618
+ return ref(this.logicalId);
5619
+ }
5620
+ get arn() {
5621
+ return getAtt(this.logicalId, "Arn");
5622
+ }
5623
+ get providerName() {
5624
+ return getAtt(this.logicalId, "ProviderName");
5625
+ }
5626
+ get providerUrl() {
5627
+ return getAtt(this.logicalId, "ProviderURL");
5628
+ }
5629
+ addDomain(props) {
5630
+ const domain = new UserPoolDomain(this.logicalId, {
5631
+ ...props,
5632
+ userPoolId: this.id
5633
+ }).dependsOn(this);
5634
+ this.addChild(domain);
5635
+ return domain;
5636
+ }
5637
+ addClient(props = {}) {
5638
+ const client = new UserPoolClient(this.logicalId, {
5639
+ ...props,
5640
+ userPoolId: this.id
5641
+ }).dependsOn(this);
5642
+ this.addChild(client);
5643
+ return client;
5644
+ }
5645
+ // get permissions() {
5646
+ // const permissions = [{
5647
+ // actions: [
5648
+ // 'dynamodb:DescribeTable',
5649
+ // 'dynamodb:PutItem',
5650
+ // 'dynamodb:GetItem',
5651
+ // 'dynamodb:DeleteItem',
5652
+ // 'dynamodb:TransactWrite',
5653
+ // 'dynamodb:BatchWriteItem',
5654
+ // 'dynamodb:BatchGetItem',
5655
+ // 'dynamodb:ConditionCheckItem',
5656
+ // 'dynamodb:Query',
5657
+ // 'dynamodb:Scan',
5658
+ // ],
5659
+ // resources: [
5660
+ // formatArn({
5661
+ // service: 'dynamodb',
5662
+ // resource: 'table',
5663
+ // resourceName: this.name,
5664
+ // }),
5665
+ // ],
5666
+ // }]
5667
+ // }
5668
+ properties() {
5669
+ return {
5670
+ UserPoolName: this.name,
5671
+ // UserPoolTags: [],
5672
+ ...this.props.username?.emailAlias ? {
5673
+ AliasAttributes: ["email"],
5674
+ // UsernameAttributes: [ 'email' ],
5675
+ AutoVerifiedAttributes: ["email"],
5676
+ Schema: [{
5677
+ AttributeDataType: "String",
5678
+ Name: "email",
5679
+ Required: true,
5680
+ Mutable: false,
5681
+ StringAttributeConstraints: {
5682
+ MinLength: 5,
5683
+ MaxLength: 100
5684
+ }
5685
+ }]
5686
+ } : {},
5687
+ UsernameConfiguration: {
5688
+ CaseSensitive: this.props.username?.caseSensitive ?? false
5689
+ },
5690
+ ...this.attr("EmailConfiguration", this.props.email?.toJSON()),
5691
+ // DeviceConfiguration: {
5692
+ // ChallengeRequiredOnNewDevice: {},
5693
+ // DeviceOnlyRememberedOnUserPrompt: {},
5694
+ // },
5695
+ AdminCreateUserConfig: {
5696
+ AllowAdminCreateUserOnly: !(this.props.allowUserRegistration ?? true)
5697
+ },
5698
+ Policies: {
5699
+ PasswordPolicy: {
5700
+ MinimumLength: this.props.password?.minLength ?? 8,
5701
+ RequireUppercase: this.props.password?.uppercase ?? false,
5702
+ RequireLowercase: this.props.password?.lowercase ?? false,
5703
+ RequireNumbers: this.props.password?.numbers ?? false,
5704
+ RequireSymbols: this.props.password?.symbols ?? false,
5705
+ TemporaryPasswordValidityDays: this.props.password?.temporaryPasswordValidity?.toDays() ?? 7
5706
+ }
5707
+ },
5708
+ LambdaConfig: {
5709
+ ...this.attr("PreAuthentication", this.props.events?.preLogin),
5710
+ ...this.attr("PostAuthentication", this.props.events?.postLogin),
5711
+ ...this.attr("PostConfirmation", this.props.events?.postRegister),
5712
+ ...this.attr("PreSignUp", this.props.events?.preRegister),
5713
+ ...this.attr("PreTokenGeneration", this.props.events?.preToken),
5714
+ ...this.attr("CustomMessage", this.props.events?.customMessage),
5715
+ ...this.attr("UserMigration", this.props.events?.userMigration),
5716
+ ...this.attr("DefineAuthChallenge", this.props.events?.defineChallange),
5717
+ ...this.attr("CreateAuthChallenge", this.props.events?.createChallange),
5718
+ ...this.attr("VerifyAuthChallengeResponse", this.props.events?.verifyChallange)
5719
+ }
5720
+ };
5721
+ }
5722
+ };
5723
+
5724
+ // src/plugins/auth.ts
5725
+ var authPlugin = definePlugin({
5726
+ name: "auth",
5727
+ schema: z25.object({
5728
+ defaults: z25.object({
5729
+ /** Define the authenticatable users in your app.
5730
+ * @example
5731
+ * {
5732
+ * auth: {
5733
+ * AUTH_NAME: {
5734
+ * password: {
5735
+ * minLength: 10,
5736
+ * },
5737
+ * validity: {
5738
+ * refreshToken: '30 days',
5739
+ * }
5740
+ * }
5741
+ * }
5742
+ * }
5743
+ */
5744
+ auth: z25.record(
5745
+ ResourceIdSchema,
5746
+ z25.object({
5747
+ /** Specifies whether users can create an user account or if only the administrator can.
5748
+ * @default true
5749
+ */
5750
+ allowUserRegistration: z25.boolean().default(true),
5751
+ /** The username policy. */
5752
+ username: z25.object({
5753
+ /** Allow the user email to be used as username.
5754
+ * @default true
5755
+ */
5756
+ emailAlias: z25.boolean().default(true),
5757
+ /** Specifies whether username case sensitivity will be enabled.
5758
+ * When usernames and email addresses are case insensitive,
5759
+ * users can sign in as the same user when they enter a different capitalization of their user name.
5760
+ * @default false
5761
+ */
5762
+ caseSensitive: z25.boolean().default(false)
5763
+ }).default({}),
5764
+ /** The password policy. */
5765
+ password: z25.object({
5766
+ /** Required users to have at least the minimum password length.
5767
+ * @default 8
5768
+ */
5769
+ minLength: z25.number().int().min(6).max(99).default(8),
5770
+ /** Required users to use at least one uppercase letter in their password.
5771
+ * @default true
5772
+ */
5773
+ uppercase: z25.boolean().default(true),
5774
+ /** Required users to use at least one lowercase letter in their password.
5775
+ * @default true
5776
+ */
5777
+ lowercase: z25.boolean().default(true),
5778
+ /** Required users to use at least one number in their password.
5779
+ * @default true
5780
+ */
5781
+ numbers: z25.boolean().default(true),
5782
+ /** Required users to use at least one symbol in their password.
5783
+ * @default true
5784
+ */
5785
+ symbols: z25.boolean().default(true),
5786
+ /** The duration a temporary password is valid.
5787
+ * If the user doesn't sign in during this time, an administrator must reset their password.
5788
+ * @default '7 days'
5789
+ */
5790
+ temporaryPasswordValidity: DurationSchema.default("7 days")
5791
+ }).default({}),
5792
+ /** Specifies the validity duration for every JWT token. */
5793
+ validity: z25.object({
5794
+ /** The ID token time limit.
5795
+ * After this limit expires, your user can't use their ID token.
5796
+ * @default '1 hour'
5797
+ */
5798
+ idToken: DurationSchema.default("1 hour"),
5799
+ /** The access token time limit.
5800
+ * After this limit expires, your user can't use their access token.
5801
+ * @default '1 hour'
5802
+ */
5803
+ accessToken: DurationSchema.default("1 hour"),
5804
+ /** The refresh token time limit.
5805
+ * After this limit expires, your user can't use their refresh token.
5806
+ * @default '365 days'
5807
+ */
5808
+ refreshToken: DurationSchema.default("365 days")
5809
+ }).default({}),
5810
+ /** Specifies the configuration for AWS Lambda triggers. */
5811
+ events: z25.object({
5812
+ /** A pre jwt token generation AWS Lambda trigger. */
5813
+ preToken: FunctionSchema.optional(),
5814
+ /** A pre user login AWS Lambda trigger. */
5815
+ preLogin: FunctionSchema.optional(),
5816
+ /** A post user login AWS Lambda trigger. */
5817
+ postLogin: FunctionSchema.optional(),
5818
+ /** A pre user register AWS Lambda trigger. */
5819
+ preRegister: FunctionSchema.optional(),
5820
+ /** A post user register AWS Lambda trigger. */
5821
+ postRegister: FunctionSchema.optional(),
5822
+ /** A custom message AWS Lambda trigger. */
5823
+ customMessage: FunctionSchema.optional(),
5824
+ /** Defines the authentication challenge. */
5825
+ defineChallenge: FunctionSchema.optional(),
5826
+ /** Creates an authentication challenge. */
5827
+ createChallenge: FunctionSchema.optional(),
5828
+ /** Verifies the authentication challenge response. */
5829
+ verifyChallenge: FunctionSchema.optional()
5830
+ }).optional()
5831
+ })
5832
+ ).default({})
5833
+ }).default({})
5834
+ }),
5835
+ onTypeGen({ config }) {
5836
+ const gen = new TypeGen("@awsless/awsless", "AuthResources");
5837
+ for (const name of Object.keys(config.defaults.auth)) {
5838
+ gen.addType(name, `{ readonly name: '${formatName(`${config.name}-${name}`)}' }`);
5839
+ }
5840
+ return gen.toString();
5841
+ },
5842
+ onApp(ctx) {
5843
+ const { config, bootstrap: bootstrap2, bind } = ctx;
5844
+ for (const [id, props] of Object.entries(config.defaults.auth)) {
5845
+ const functions = /* @__PURE__ */ new Map();
5846
+ const events = {};
5847
+ for (const [event, fnProps] of Object.entries(props.events ?? {})) {
5848
+ const lambda = toLambdaFunction(ctx, `auth-${id}-${event}`, fnProps);
5849
+ functions.set(event, lambda);
5850
+ events[event] = lambda.arn;
5851
+ }
5852
+ const userPool = new UserPool(id, {
5853
+ name: `${config.name}-${id}`,
5854
+ allowUserRegistration: props.allowUserRegistration,
5855
+ username: props.username,
5856
+ password: props.password,
5857
+ events
5858
+ });
5859
+ const client = userPool.addClient({
5860
+ name: `${config.name}-${id}`,
5861
+ validity: props.validity,
5862
+ generateSecret: true,
5863
+ supportedIdentityProviders: ["cognito"],
5864
+ authFlows: {
5865
+ userSrp: true
5866
+ }
5867
+ });
5868
+ const domain = userPool.addDomain({
5869
+ domain: `${config.name}-${id}`
5870
+ });
5871
+ 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);
5872
+ for (const [event, lambda] of functions) {
5873
+ const permission = new Permission(`auth-${id}-${event}`, {
5874
+ action: "lambda:InvokeFunction",
5875
+ principal: "cognito-idp.amazonaws.com",
5876
+ functionArn: lambda.arn,
5877
+ sourceArn: userPool.arn
5878
+ }).dependsOn(lambda);
5879
+ bootstrap2.add(
5880
+ lambda,
5881
+ permission
5882
+ );
5883
+ }
5884
+ }
5885
+ bind((lambda) => {
5886
+ lambda.addPermissions({
5887
+ actions: ["cognito:*"],
5888
+ resources: ["*"]
5889
+ });
5890
+ });
5891
+ }
5892
+ });
5893
+
5377
5894
  // src/plugins/index.ts
5378
5895
  var defaultPlugins = [
5379
5896
  extendPlugin,
@@ -5390,6 +5907,7 @@ var defaultPlugins = [
5390
5907
  topicPlugin,
5391
5908
  pubsubPlugin,
5392
5909
  searchPlugin,
5910
+ authPlugin,
5393
5911
  graphqlPlugin,
5394
5912
  httpPlugin,
5395
5913
  restPlugin,
@@ -5546,17 +6064,17 @@ var getCredentials = (profile) => {
5546
6064
  };
5547
6065
 
5548
6066
  // src/schema/app.ts
5549
- import { z as z28 } from "zod";
6067
+ import { z as z29 } from "zod";
5550
6068
 
5551
6069
  // src/schema/stack.ts
5552
- import { z as z25 } from "zod";
5553
- var StackSchema = z25.object({
6070
+ import { z as z26 } from "zod";
6071
+ var StackSchema = z26.object({
5554
6072
  name: ResourceIdSchema,
5555
- depends: z25.array(z25.lazy(() => StackSchema)).optional()
6073
+ depends: z26.array(z26.lazy(() => StackSchema)).optional()
5556
6074
  });
5557
6075
 
5558
6076
  // src/schema/region.ts
5559
- import { z as z26 } from "zod";
6077
+ import { z as z27 } from "zod";
5560
6078
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
5561
6079
  var AF = ["af-south-1"];
5562
6080
  var AP = ["ap-east-1", "ap-south-2", "ap-southeast-3", "ap-southeast-4", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1"];
@@ -5573,41 +6091,41 @@ var regions = [
5573
6091
  ...ME,
5574
6092
  ...SA
5575
6093
  ];
5576
- var RegionSchema = z26.enum(regions);
6094
+ var RegionSchema = z27.enum(regions);
5577
6095
 
5578
6096
  // src/schema/plugin.ts
5579
- import { z as z27 } from "zod";
5580
- var PluginSchema = z27.object({
5581
- name: z27.string(),
5582
- schema: z27.custom().optional(),
6097
+ import { z as z28 } from "zod";
6098
+ var PluginSchema = z28.object({
6099
+ name: z28.string(),
6100
+ schema: z28.custom().optional(),
5583
6101
  // depends: z.array(z.lazy(() => PluginSchema)).optional(),
5584
- onApp: z27.function().returns(z27.void()).optional(),
5585
- onStack: z27.function().returns(z27.any()).optional(),
5586
- onResource: z27.function().returns(z27.any()).optional()
6102
+ onApp: z28.function().returns(z28.void()).optional(),
6103
+ onStack: z28.function().returns(z28.any()).optional(),
6104
+ onResource: z28.function().returns(z28.any()).optional()
5587
6105
  // bind: z.function().optional(),
5588
6106
  });
5589
6107
 
5590
6108
  // src/schema/app.ts
5591
- var AppSchema = z28.object({
6109
+ var AppSchema = z29.object({
5592
6110
  /** App name */
5593
6111
  name: ResourceIdSchema,
5594
6112
  /** The AWS region to deploy to. */
5595
6113
  region: RegionSchema,
5596
6114
  /** The AWS profile to deploy to. */
5597
- profile: z28.string(),
6115
+ profile: z29.string(),
5598
6116
  /** The deployment stage.
5599
6117
  * @default 'prod'
5600
6118
  */
5601
- stage: z28.string().regex(/^[a-z]+$/).default("prod"),
6119
+ stage: z29.string().regex(/^[a-z]+$/).default("prod"),
5602
6120
  /** Default properties. */
5603
- defaults: z28.object({}).default({}),
6121
+ defaults: z29.object({}).default({}),
5604
6122
  /** The application stacks. */
5605
- stacks: z28.array(StackSchema).min(1).refine((stacks) => {
6123
+ stacks: z29.array(StackSchema).min(1).refine((stacks) => {
5606
6124
  const unique = new Set(stacks.map((stack) => stack.name));
5607
6125
  return unique.size === stacks.length;
5608
6126
  }, "Must be an array of unique stacks"),
5609
6127
  /** Custom plugins. */
5610
- plugins: z28.array(PluginSchema).optional()
6128
+ plugins: z29.array(PluginSchema).optional()
5611
6129
  });
5612
6130
 
5613
6131
  // src/util/import.ts
@@ -5704,7 +6222,7 @@ var watchFile = (path) => {
5704
6222
  };
5705
6223
 
5706
6224
  // src/config.ts
5707
- import { z as z29 } from "zod";
6225
+ import { z as z30 } from "zod";
5708
6226
  var ConfigError = class extends Error {
5709
6227
  constructor(error, data) {
5710
6228
  super(error.message);
@@ -5737,7 +6255,7 @@ var importConfig = async (options) => {
5737
6255
  try {
5738
6256
  config = await schema2.parseAsync(appConfig);
5739
6257
  } catch (error) {
5740
- if (error instanceof z29.ZodError) {
6258
+ if (error instanceof z30.ZodError) {
5741
6259
  throw new ConfigError(error, appConfig);
5742
6260
  }
5743
6261
  throw error;
@@ -5778,7 +6296,7 @@ var watchConfig = async function* (options) {
5778
6296
  try {
5779
6297
  config = await schema2.parseAsync(appConfig);
5780
6298
  } catch (error) {
5781
- if (error instanceof z29.ZodError) {
6299
+ if (error instanceof z30.ZodError) {
5782
6300
  throw new ConfigError(error, appConfig);
5783
6301
  }
5784
6302
  throw error;