@awsless/awsless 0.0.90 → 0.0.92

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
@@ -389,6 +389,9 @@ var Function = class extends Resource {
389
389
  assumedBy: "lambda.amazonaws.com"
390
390
  });
391
391
  role.addInlinePolicy(policy);
392
+ if (props.permissions) {
393
+ policy.addStatement(props.permissions);
394
+ }
392
395
  super("AWS::Lambda::Function", _logicalId, [role]);
393
396
  this._logicalId = _logicalId;
394
397
  this.props = props;
@@ -414,13 +417,16 @@ var Function = class extends Resource {
414
417
  retention
415
418
  });
416
419
  this.addChild(logGroup);
417
- this.addPermissions({
418
- actions: ["logs:CreateLogStream"],
419
- resources: [logGroup.arn]
420
- }, {
421
- actions: ["logs:PutLogEvents"],
422
- resources: [sub("${arn}:*", { arn: logGroup.arn })]
423
- });
420
+ this.addPermissions(
421
+ {
422
+ actions: ["logs:CreateLogStream"],
423
+ resources: [logGroup.arn]
424
+ },
425
+ {
426
+ actions: ["logs:PutLogEvents"],
427
+ resources: [sub("${arn}:*", { arn: logGroup.arn })]
428
+ }
429
+ );
424
430
  return this;
425
431
  }
426
432
  warmUp(concurrency) {
@@ -460,10 +466,7 @@ var Function = class extends Resource {
460
466
  }
461
467
  get permissions() {
462
468
  return {
463
- actions: [
464
- "lambda:InvokeFunction",
465
- "lambda:InvokeAsync"
466
- ],
469
+ actions: ["lambda:InvokeFunction", "lambda:InvokeAsync"],
467
470
  resources: [
468
471
  formatArn({
469
472
  service: "lambda",
@@ -1560,12 +1563,12 @@ var schema = z6.object({
1560
1563
  }).array()
1561
1564
  });
1562
1565
  var typeGenCode = `
1563
- import { InvokeOptions } from '@awsless/lambda'
1566
+ import { InvokeOptions, InvokeResponse } from '@awsless/lambda'
1564
1567
 
1565
1568
  type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1566
1569
  readonly name: Name
1567
- readonly async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1568
- (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): ReturnType<Func>
1570
+ readonly async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => InvokeResponse<Func>
1571
+ (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): InvokeResponse<Func>
1569
1572
  }`;
1570
1573
  var functionPlugin = definePlugin({
1571
1574
  name: "function",
@@ -2474,6 +2477,8 @@ var isEmail = (value) => {
2474
2477
  };
2475
2478
 
2476
2479
  // src/plugins/topic.ts
2480
+ import { paramCase as paramCase4 } from "change-case";
2481
+ var TopicNameSchema = z12.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase4(value));
2477
2482
  var typeGenCode3 = `
2478
2483
  import { PublishOptions } from '@awsless/sns'
2479
2484
 
@@ -2491,7 +2496,7 @@ var topicPlugin = definePlugin({
2491
2496
  * topics: [ 'TOPIC_NAME' ]
2492
2497
  * }
2493
2498
  */
2494
- topics: z12.array(ResourceIdSchema).refine((topics) => {
2499
+ topics: z12.array(TopicNameSchema).refine((topics) => {
2495
2500
  return topics.length === new Set(topics).size;
2496
2501
  }, "Must be a list of unique topic names").optional(),
2497
2502
  /** Define the events to subscribe too in your stack.
@@ -2506,7 +2511,7 @@ var topicPlugin = definePlugin({
2506
2511
  * }
2507
2512
  * }
2508
2513
  */
2509
- subscribers: z12.record(ResourceIdSchema, z12.union([EmailSchema, FunctionSchema])).optional()
2514
+ subscribers: z12.record(TopicNameSchema, z12.union([EmailSchema, FunctionSchema])).optional()
2510
2515
  }).array().superRefine((stacks, ctx) => {
2511
2516
  const topics = [];
2512
2517
  for (const stack of stacks) {
@@ -2714,7 +2719,7 @@ var toArray = (value) => {
2714
2719
  };
2715
2720
 
2716
2721
  // src/plugins/graphql.ts
2717
- import { paramCase as paramCase4 } from "change-case";
2722
+ import { paramCase as paramCase5 } from "change-case";
2718
2723
 
2719
2724
  // src/formation/resource/appsync/graphql-api.ts
2720
2725
  var GraphQLApi = class extends Resource {
@@ -3276,7 +3281,7 @@ var graphqlPlugin = definePlugin({
3276
3281
  for (const [typeName, fields] of Object.entries(props.resolvers || {})) {
3277
3282
  for (const [fieldName, resolverProps] of Object.entries(fields || {})) {
3278
3283
  const props2 = isFunctionProps(resolverProps) ? { consumer: resolverProps } : resolverProps;
3279
- const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
3284
+ const entryId = paramCase5(`${id}-${typeName}-${fieldName}`);
3280
3285
  const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, props2.consumer);
3281
3286
  const resolver = props2.resolver ?? defaultProps?.resolver;
3282
3287
  let code = defaultResolver;
@@ -4964,7 +4969,7 @@ var Params = class {
4964
4969
  };
4965
4970
 
4966
4971
  // src/plugins/config.ts
4967
- import { paramCase as paramCase5 } from "change-case";
4972
+ import { paramCase as paramCase6 } from "change-case";
4968
4973
  var ConfigNameSchema = z23.string().regex(/[a-z0-9\-]/g, "Invalid config name");
4969
4974
  var configPlugin = definePlugin({
4970
4975
  name: "config",
@@ -5009,7 +5014,7 @@ var configPlugin = definePlugin({
5009
5014
  return formatArn({
5010
5015
  service: "ssm",
5011
5016
  resource: "parameter",
5012
- resourceName: configParameterPrefix(config) + "/" + paramCase5(name),
5017
+ resourceName: configParameterPrefix(config) + "/" + paramCase6(name),
5013
5018
  seperator: ""
5014
5019
  });
5015
5020
  })
@@ -7487,7 +7492,7 @@ var shouldDeployBootstrap = async (client, stack) => {
7487
7492
  // src/formation/client.ts
7488
7493
  import { CloudFormationClient, CreateStackCommand, DeleteStackCommand, DescribeStackEventsCommand, DescribeStacksCommand, GetTemplateCommand, OnFailure, TemplateStage, UpdateStackCommand, ValidateTemplateCommand, waitUntilStackCreateComplete, waitUntilStackDeleteComplete, waitUntilStackUpdateComplete } from "@aws-sdk/client-cloudformation";
7489
7494
  import { S3Client, PutObjectCommand, ObjectCannedACL, StorageClass } from "@aws-sdk/client-s3";
7490
- import { paramCase as paramCase6 } from "change-case";
7495
+ import { paramCase as paramCase7 } from "change-case";
7491
7496
  var StackClient = class {
7492
7497
  constructor(app, account, region, credentials) {
7493
7498
  this.app = app;
@@ -7520,7 +7525,7 @@ var StackClient = class {
7520
7525
  };
7521
7526
  }
7522
7527
  stackName(stackName) {
7523
- return paramCase6(`${this.app.name}-${stackName}`);
7528
+ return paramCase7(`${this.app.name}-${stackName}`);
7524
7529
  }
7525
7530
  tags(stack) {
7526
7531
  const tags = [];
package/dist/index.d.ts CHANGED
@@ -11072,6 +11072,7 @@ type FunctionProps$1 = {
11072
11072
  timeout?: Duration;
11073
11073
  ephemeralStorageSize?: Size;
11074
11074
  environment?: Record<string, string>;
11075
+ permissions?: Permission | Permission[];
11075
11076
  reserved?: number;
11076
11077
  vpc?: {
11077
11078
  securityGroupIds: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.90",
3
+ "version": "0.0.92",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@awsless/validate": "^0.0.6",
28
- "@awsless/lambda": "^0.0.12",
29
28
  "@awsless/redis": "^0.0.8",
29
+ "@awsless/lambda": "^0.0.13",
30
30
  "@awsless/sns": "^0.0.7",
31
31
  "@awsless/sqs": "^0.0.7",
32
32
  "@awsless/ssm": "^0.0.7"