@awsless/awsless 0.0.40 → 0.0.41

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.cjs CHANGED
@@ -1317,6 +1317,7 @@ import { InvokeOptions } from '@awsless/lambda'
1317
1317
  type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1318
1318
  name: Name
1319
1319
  (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): ReturnType<Func>
1320
+ async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1320
1321
  }`;
1321
1322
  var functionPlugin = definePlugin({
1322
1323
  name: "function",
@@ -1630,6 +1631,7 @@ var SqsEventSource = class extends Group {
1630
1631
  };
1631
1632
 
1632
1633
  // src/plugins/queue.ts
1634
+ var import_change_case6 = require("change-case");
1633
1635
  var RetentionPeriodSchema = DurationSchema.refine(durationMin(Duration.minutes(1)), "Minimum retention period is 1 minute").refine(durationMax(Duration.days(14)), "Maximum retention period is 14 days");
1634
1636
  var VisibilityTimeoutSchema = DurationSchema.refine(durationMax(Duration.hours(12)), "Maximum visibility timeout is 12 hours");
1635
1637
  var DeliveryDelaySchema = DurationSchema.refine(durationMax(Duration.minutes(15)), "Maximum delivery delay is 15 minutes");
@@ -1639,10 +1641,11 @@ var BatchSizeSchema = import_zod8.z.number().int().min(1, "Minimum batch size is
1639
1641
  var MaxConcurrencySchema = import_zod8.z.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000");
1640
1642
  var MaxBatchingWindow = DurationSchema.refine(durationMax(Duration.minutes(5)), "Maximum max batching window is 5 minutes");
1641
1643
  var typeGenCode2 = `
1642
- import { SendMessageOptions } from '@awsless/sqs'
1644
+ import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless/sqs'
1643
1645
 
1644
1646
  type Send<Name extends string> = {
1645
1647
  name: Name
1648
+ batch(items:BatchItem[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1646
1649
  (payload: unknown, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
1647
1650
  }`;
1648
1651
  var queuePlugin = definePlugin({
@@ -1776,6 +1779,7 @@ var queuePlugin = definePlugin({
1776
1779
  stack.add(queue2, lambda, source);
1777
1780
  bind((lambda2) => {
1778
1781
  lambda2.addPermissions(queue2.permissions);
1782
+ lambda2.addEnvironment(`QUEUE_${(0, import_change_case6.constantCase)(stack.name)}_${(0, import_change_case6.constantCase)(id)}_URL`, queue2.url);
1779
1783
  });
1780
1784
  }
1781
1785
  }
@@ -1785,7 +1789,7 @@ var queuePlugin = definePlugin({
1785
1789
  var import_zod9 = require("zod");
1786
1790
 
1787
1791
  // src/formation/resource/dynamodb/table.ts
1788
- var import_change_case6 = require("change-case");
1792
+ var import_change_case7 = require("change-case");
1789
1793
  var Table = class extends Resource {
1790
1794
  constructor(logicalId, props) {
1791
1795
  super("AWS::DynamoDB::Table", logicalId);
@@ -1858,7 +1862,7 @@ var Table = class extends Resource {
1858
1862
  return {
1859
1863
  TableName: this.name,
1860
1864
  BillingMode: "PAY_PER_REQUEST",
1861
- TableClass: (0, import_change_case6.constantCase)(this.props.class || "standard"),
1865
+ TableClass: (0, import_change_case7.constantCase)(this.props.class || "standard"),
1862
1866
  PointInTimeRecoverySpecification: {
1863
1867
  PointInTimeRecoveryEnabled: this.props.pointInTimeRecovery || false
1864
1868
  },
@@ -1869,7 +1873,7 @@ var Table = class extends Resource {
1869
1873
  AttributeDefinitions: this.attributeDefinitions(),
1870
1874
  ...this.props.stream ? {
1871
1875
  StreamSpecification: {
1872
- StreamViewType: (0, import_change_case6.constantCase)(this.props.stream)
1876
+ StreamViewType: (0, import_change_case7.constantCase)(this.props.stream)
1873
1877
  }
1874
1878
  } : {},
1875
1879
  ...this.props.timeToLiveAttribute ? {
@@ -1886,7 +1890,7 @@ var Table = class extends Resource {
1886
1890
  ...props.sort ? [{ KeyType: "RANGE", AttributeName: props.sort }] : []
1887
1891
  ],
1888
1892
  Projection: {
1889
- ProjectionType: (0, import_change_case6.constantCase)(props.projection || "all")
1893
+ ProjectionType: (0, import_change_case7.constantCase)(props.projection || "all")
1890
1894
  }
1891
1895
  }))
1892
1896
  } : {}
@@ -2071,7 +2075,7 @@ var tablePlugin = definePlugin({
2071
2075
  var import_zod10 = require("zod");
2072
2076
 
2073
2077
  // src/formation/resource/s3/bucket.ts
2074
- var import_change_case7 = require("change-case");
2078
+ var import_change_case8 = require("change-case");
2075
2079
  var Bucket = class extends Resource {
2076
2080
  constructor(logicalId, props = {}) {
2077
2081
  super("AWS::S3::Bucket", logicalId);
@@ -2106,7 +2110,7 @@ var Bucket = class extends Resource {
2106
2110
  properties() {
2107
2111
  return {
2108
2112
  BucketName: this.name,
2109
- AccessControl: (0, import_change_case7.pascalCase)(this.props.accessControl ?? "private"),
2113
+ AccessControl: (0, import_change_case8.pascalCase)(this.props.accessControl ?? "private"),
2110
2114
  ...this.props.versioned ? {
2111
2115
  VersioningConfiguration: {
2112
2116
  Status: "Enabled"
@@ -2317,12 +2321,12 @@ var extendPlugin = definePlugin({
2317
2321
  var import_zod13 = require("zod");
2318
2322
 
2319
2323
  // src/formation/resource/iot/topic-rule.ts
2320
- var import_change_case8 = require("change-case");
2324
+ var import_change_case9 = require("change-case");
2321
2325
  var TopicRule = class extends Resource {
2322
2326
  constructor(logicalId, props) {
2323
2327
  super("AWS::IoT::TopicRule", logicalId);
2324
2328
  this.props = props;
2325
- this.name = (0, import_change_case8.snakeCase)(this.props.name || logicalId);
2329
+ this.name = (0, import_change_case9.snakeCase)(this.props.name || logicalId);
2326
2330
  }
2327
2331
  name;
2328
2332
  get arn() {
@@ -2422,10 +2426,10 @@ var toArray = (value) => {
2422
2426
  };
2423
2427
 
2424
2428
  // src/plugins/graphql.ts
2425
- var import_change_case12 = require("change-case");
2429
+ var import_change_case13 = require("change-case");
2426
2430
 
2427
2431
  // src/formation/resource/appsync/graphql-api.ts
2428
- var import_change_case9 = require("change-case");
2432
+ var import_change_case10 = require("change-case");
2429
2433
  var GraphQLApi = class extends Resource {
2430
2434
  constructor(logicalId, props) {
2431
2435
  super("AWS::AppSync::GraphQLApi", logicalId);
@@ -2457,7 +2461,7 @@ var GraphQLApi = class extends Resource {
2457
2461
  properties() {
2458
2462
  return {
2459
2463
  Name: this.name,
2460
- AuthenticationType: (0, import_change_case9.constantCase)(this.props.authenticationType || "api-key"),
2464
+ AuthenticationType: (0, import_change_case10.constantCase)(this.props.authenticationType || "api-key"),
2461
2465
  AdditionalAuthenticationProviders: this.lambdaAuthProviders.map((provider) => ({
2462
2466
  AuthenticationType: "AWS_LAMBDA",
2463
2467
  LambdaAuthorizerConfig: {
@@ -2584,12 +2588,12 @@ var FileCode2 = class extends Asset {
2584
2588
  };
2585
2589
 
2586
2590
  // src/formation/resource/appsync/data-source.ts
2587
- var import_change_case10 = require("change-case");
2591
+ var import_change_case11 = require("change-case");
2588
2592
  var DataSource = class extends Resource {
2589
2593
  constructor(logicalId, props) {
2590
2594
  super("AWS::AppSync::DataSource", logicalId);
2591
2595
  this.props = props;
2592
- this.name = (0, import_change_case10.snakeCase)(this.props.name || logicalId);
2596
+ this.name = (0, import_change_case11.snakeCase)(this.props.name || logicalId);
2593
2597
  }
2594
2598
  static fromLambda(logicalId, apiId, props) {
2595
2599
  return new DataSource(logicalId, {
@@ -2629,14 +2633,14 @@ var DataSource = class extends Resource {
2629
2633
  };
2630
2634
 
2631
2635
  // src/formation/resource/appsync/function-configuration.ts
2632
- var import_change_case11 = require("change-case");
2636
+ var import_change_case12 = require("change-case");
2633
2637
  var FunctionConfiguration = class extends Resource {
2634
2638
  constructor(logicalId, props) {
2635
2639
  super("AWS::AppSync::FunctionConfiguration", logicalId, [
2636
2640
  props.code
2637
2641
  ]);
2638
2642
  this.props = props;
2639
- this.name = (0, import_change_case11.snakeCase)(this.props.name || logicalId);
2643
+ this.name = (0, import_change_case12.snakeCase)(this.props.name || logicalId);
2640
2644
  }
2641
2645
  name;
2642
2646
  get id() {
@@ -2855,7 +2859,7 @@ var graphqlPlugin = definePlugin({
2855
2859
  const apiId = bootstrap2.import(`graphql-${id}`);
2856
2860
  for (const [typeAndField, functionProps] of Object.entries(props.resolvers || {})) {
2857
2861
  const [typeName, fieldName] = typeAndField.split(/[\s]+/g);
2858
- const entryId = (0, import_change_case12.paramCase)(`${id}-${typeName}-${fieldName}`);
2862
+ const entryId = (0, import_change_case13.paramCase)(`${id}-${typeName}-${fieldName}`);
2859
2863
  const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, functionProps);
2860
2864
  const source = new AppsyncEventSource(entryId, lambda, {
2861
2865
  apiId,
@@ -3539,7 +3543,7 @@ var LoadBalancer = class extends Resource {
3539
3543
  };
3540
3544
 
3541
3545
  // src/formation/resource/elb/listener.ts
3542
- var import_change_case13 = require("change-case");
3546
+ var import_change_case14 = require("change-case");
3543
3547
  var Listener = class extends Resource {
3544
3548
  constructor(logicalId, props) {
3545
3549
  super("AWS::ElasticLoadBalancingV2::Listener", logicalId);
@@ -3555,7 +3559,7 @@ var Listener = class extends Resource {
3555
3559
  return {
3556
3560
  LoadBalancerArn: this.props.loadBalancerArn,
3557
3561
  Port: this.props.port,
3558
- Protocol: (0, import_change_case13.constantCase)(this.props.protocol),
3562
+ Protocol: (0, import_change_case14.constantCase)(this.props.protocol),
3559
3563
  Certificates: this.props.certificates.map((arn) => ({
3560
3564
  CertificateArn: arn
3561
3565
  })),
@@ -3994,6 +3998,7 @@ var SubnetGroup = class extends Resource {
3994
3998
  };
3995
3999
 
3996
4000
  // src/plugins/cache.ts
4001
+ var import_change_case15 = require("change-case");
3997
4002
  var TypeSchema = import_zod19.z.enum([
3998
4003
  "t4g.small",
3999
4004
  "t4g.medium",
@@ -4046,7 +4051,7 @@ var cachePlugin = definePlugin({
4046
4051
  for (const stack of config.stacks) {
4047
4052
  const list3 = new TypeObject();
4048
4053
  for (const name of Object.keys(stack.caches || {})) {
4049
- list3.addType(name, `{ host: string, port:number }`);
4054
+ list3.addType(name, `{ host: string, port: number }`);
4050
4055
  }
4051
4056
  gen.addType(stack.name, list3.toString());
4052
4057
  }
@@ -4079,7 +4084,7 @@ var cachePlugin = definePlugin({
4079
4084
  }).dependsOn(subnetGroup, securityGroup);
4080
4085
  stack.add(subnetGroup, securityGroup, cluster);
4081
4086
  bind((lambda) => {
4082
- lambda.addEnvironment(`CACHE_${stack.name}_${id}_HOST`, cluster.address).addEnvironment(`CACHE_${stack.name}_${id}_PORT`, props.port.toString());
4087
+ lambda.addEnvironment(`CACHE_${(0, import_change_case15.constantCase)(stack.name)}_${(0, import_change_case15.constantCase)(id)}_HOST`, cluster.address).addEnvironment(`CACHE_${(0, import_change_case15.constantCase)(stack.name)}_${(0, import_change_case15.constantCase)(id)}_PORT`, props.port.toString());
4083
4088
  });
4084
4089
  }
4085
4090
  }
@@ -5255,7 +5260,7 @@ var shouldDeployBootstrap = async (client, stack) => {
5255
5260
  // src/formation/client.ts
5256
5261
  var import_client_cloudformation = require("@aws-sdk/client-cloudformation");
5257
5262
  var import_client_s3 = require("@aws-sdk/client-s3");
5258
- var import_change_case14 = require("change-case");
5263
+ var import_change_case16 = require("change-case");
5259
5264
  var StackClient = class {
5260
5265
  constructor(app, account, region, credentials) {
5261
5266
  this.app = app;
@@ -5288,7 +5293,7 @@ var StackClient = class {
5288
5293
  };
5289
5294
  }
5290
5295
  stackName(stackName) {
5291
- return (0, import_change_case14.paramCase)(`${this.app.name}-${stackName}`);
5296
+ return (0, import_change_case16.paramCase)(`${this.app.name}-${stackName}`);
5292
5297
  }
5293
5298
  tags(stack) {
5294
5299
  const tags = [];
package/dist/bin.js CHANGED
@@ -1294,6 +1294,7 @@ import { InvokeOptions } from '@awsless/lambda'
1294
1294
  type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1295
1295
  name: Name
1296
1296
  (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): ReturnType<Func>
1297
+ async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1297
1298
  }`;
1298
1299
  var functionPlugin = definePlugin({
1299
1300
  name: "function",
@@ -1607,6 +1608,7 @@ var SqsEventSource = class extends Group {
1607
1608
  };
1608
1609
 
1609
1610
  // src/plugins/queue.ts
1611
+ import { constantCase as constantCase2 } from "change-case";
1610
1612
  var RetentionPeriodSchema = DurationSchema.refine(durationMin(Duration.minutes(1)), "Minimum retention period is 1 minute").refine(durationMax(Duration.days(14)), "Maximum retention period is 14 days");
1611
1613
  var VisibilityTimeoutSchema = DurationSchema.refine(durationMax(Duration.hours(12)), "Maximum visibility timeout is 12 hours");
1612
1614
  var DeliveryDelaySchema = DurationSchema.refine(durationMax(Duration.minutes(15)), "Maximum delivery delay is 15 minutes");
@@ -1616,10 +1618,11 @@ var BatchSizeSchema = z8.number().int().min(1, "Minimum batch size is 1").max(1e
1616
1618
  var MaxConcurrencySchema = z8.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000");
1617
1619
  var MaxBatchingWindow = DurationSchema.refine(durationMax(Duration.minutes(5)), "Maximum max batching window is 5 minutes");
1618
1620
  var typeGenCode2 = `
1619
- import { SendMessageOptions } from '@awsless/sqs'
1621
+ import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless/sqs'
1620
1622
 
1621
1623
  type Send<Name extends string> = {
1622
1624
  name: Name
1625
+ batch(items:BatchItem[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1623
1626
  (payload: unknown, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
1624
1627
  }`;
1625
1628
  var queuePlugin = definePlugin({
@@ -1753,6 +1756,7 @@ var queuePlugin = definePlugin({
1753
1756
  stack.add(queue2, lambda, source);
1754
1757
  bind((lambda2) => {
1755
1758
  lambda2.addPermissions(queue2.permissions);
1759
+ lambda2.addEnvironment(`QUEUE_${constantCase2(stack.name)}_${constantCase2(id)}_URL`, queue2.url);
1756
1760
  });
1757
1761
  }
1758
1762
  }
@@ -1762,7 +1766,7 @@ var queuePlugin = definePlugin({
1762
1766
  import { z as z9 } from "zod";
1763
1767
 
1764
1768
  // src/formation/resource/dynamodb/table.ts
1765
- import { constantCase as constantCase2 } from "change-case";
1769
+ import { constantCase as constantCase3 } from "change-case";
1766
1770
  var Table = class extends Resource {
1767
1771
  constructor(logicalId, props) {
1768
1772
  super("AWS::DynamoDB::Table", logicalId);
@@ -1835,7 +1839,7 @@ var Table = class extends Resource {
1835
1839
  return {
1836
1840
  TableName: this.name,
1837
1841
  BillingMode: "PAY_PER_REQUEST",
1838
- TableClass: constantCase2(this.props.class || "standard"),
1842
+ TableClass: constantCase3(this.props.class || "standard"),
1839
1843
  PointInTimeRecoverySpecification: {
1840
1844
  PointInTimeRecoveryEnabled: this.props.pointInTimeRecovery || false
1841
1845
  },
@@ -1846,7 +1850,7 @@ var Table = class extends Resource {
1846
1850
  AttributeDefinitions: this.attributeDefinitions(),
1847
1851
  ...this.props.stream ? {
1848
1852
  StreamSpecification: {
1849
- StreamViewType: constantCase2(this.props.stream)
1853
+ StreamViewType: constantCase3(this.props.stream)
1850
1854
  }
1851
1855
  } : {},
1852
1856
  ...this.props.timeToLiveAttribute ? {
@@ -1863,7 +1867,7 @@ var Table = class extends Resource {
1863
1867
  ...props.sort ? [{ KeyType: "RANGE", AttributeName: props.sort }] : []
1864
1868
  ],
1865
1869
  Projection: {
1866
- ProjectionType: constantCase2(props.projection || "all")
1870
+ ProjectionType: constantCase3(props.projection || "all")
1867
1871
  }
1868
1872
  }))
1869
1873
  } : {}
@@ -2402,7 +2406,7 @@ var toArray = (value) => {
2402
2406
  import { paramCase as paramCase3 } from "change-case";
2403
2407
 
2404
2408
  // src/formation/resource/appsync/graphql-api.ts
2405
- import { constantCase as constantCase3 } from "change-case";
2409
+ import { constantCase as constantCase4 } from "change-case";
2406
2410
  var GraphQLApi = class extends Resource {
2407
2411
  constructor(logicalId, props) {
2408
2412
  super("AWS::AppSync::GraphQLApi", logicalId);
@@ -2434,7 +2438,7 @@ var GraphQLApi = class extends Resource {
2434
2438
  properties() {
2435
2439
  return {
2436
2440
  Name: this.name,
2437
- AuthenticationType: constantCase3(this.props.authenticationType || "api-key"),
2441
+ AuthenticationType: constantCase4(this.props.authenticationType || "api-key"),
2438
2442
  AdditionalAuthenticationProviders: this.lambdaAuthProviders.map((provider) => ({
2439
2443
  AuthenticationType: "AWS_LAMBDA",
2440
2444
  LambdaAuthorizerConfig: {
@@ -3516,7 +3520,7 @@ var LoadBalancer = class extends Resource {
3516
3520
  };
3517
3521
 
3518
3522
  // src/formation/resource/elb/listener.ts
3519
- import { constantCase as constantCase4 } from "change-case";
3523
+ import { constantCase as constantCase5 } from "change-case";
3520
3524
  var Listener = class extends Resource {
3521
3525
  constructor(logicalId, props) {
3522
3526
  super("AWS::ElasticLoadBalancingV2::Listener", logicalId);
@@ -3532,7 +3536,7 @@ var Listener = class extends Resource {
3532
3536
  return {
3533
3537
  LoadBalancerArn: this.props.loadBalancerArn,
3534
3538
  Port: this.props.port,
3535
- Protocol: constantCase4(this.props.protocol),
3539
+ Protocol: constantCase5(this.props.protocol),
3536
3540
  Certificates: this.props.certificates.map((arn) => ({
3537
3541
  CertificateArn: arn
3538
3542
  })),
@@ -3971,6 +3975,7 @@ var SubnetGroup = class extends Resource {
3971
3975
  };
3972
3976
 
3973
3977
  // src/plugins/cache.ts
3978
+ import { constantCase as constantCase6 } from "change-case";
3974
3979
  var TypeSchema = z19.enum([
3975
3980
  "t4g.small",
3976
3981
  "t4g.medium",
@@ -4023,7 +4028,7 @@ var cachePlugin = definePlugin({
4023
4028
  for (const stack of config.stacks) {
4024
4029
  const list3 = new TypeObject();
4025
4030
  for (const name of Object.keys(stack.caches || {})) {
4026
- list3.addType(name, `{ host: string, port:number }`);
4031
+ list3.addType(name, `{ host: string, port: number }`);
4027
4032
  }
4028
4033
  gen.addType(stack.name, list3.toString());
4029
4034
  }
@@ -4056,7 +4061,7 @@ var cachePlugin = definePlugin({
4056
4061
  }).dependsOn(subnetGroup, securityGroup);
4057
4062
  stack.add(subnetGroup, securityGroup, cluster);
4058
4063
  bind((lambda) => {
4059
- lambda.addEnvironment(`CACHE_${stack.name}_${id}_HOST`, cluster.address).addEnvironment(`CACHE_${stack.name}_${id}_PORT`, props.port.toString());
4064
+ lambda.addEnvironment(`CACHE_${constantCase6(stack.name)}_${constantCase6(id)}_HOST`, cluster.address).addEnvironment(`CACHE_${constantCase6(stack.name)}_${constantCase6(id)}_PORT`, props.port.toString());
4060
4065
  });
4061
4066
  }
4062
4067
  }
package/dist/index.cjs CHANGED
@@ -93,6 +93,14 @@ var Function = createProxy((stackName) => {
93
93
  });
94
94
  };
95
95
  call.name = name;
96
+ call.async = (payload, options = {}) => {
97
+ return (0, import_lambda.invoke)({
98
+ ...options,
99
+ type: "Event",
100
+ name,
101
+ payload
102
+ });
103
+ };
96
104
  return call;
97
105
  });
98
106
  });
@@ -125,25 +133,38 @@ var Topic = createProxy((topic) => {
125
133
 
126
134
  // src/node/queue.ts
127
135
  var import_sqs = require("@awsless/sqs");
136
+ var import_change_case2 = require("change-case");
128
137
  var getQueueName = getLocalResourceName;
138
+ var getQueueUrl = (name, stack = STACK) => {
139
+ return process.env[`QUEUE_${(0, import_change_case2.constantCase)(stack)}_${(0, import_change_case2.constantCase)(name)}_URL`];
140
+ };
129
141
  var Queue = createProxy((stack) => {
130
142
  return createProxy((queue) => {
131
- const name = getQueueName(queue, stack);
132
- const send = (payload, options) => {
143
+ const url = getQueueUrl(queue, stack);
144
+ const send = (payload, options = {}) => {
133
145
  return (0, import_sqs.sendMessage)({
134
146
  ...options,
135
- queue: name,
147
+ queue: url,
136
148
  payload
137
149
  });
138
150
  };
139
- send.name = name;
151
+ send.url = url;
152
+ send.name = getQueueName(queue, stack);
153
+ send.batch = (items, options = {}) => {
154
+ return (0, import_sqs.sendMessageBatch)({
155
+ ...options,
156
+ queue: url,
157
+ items
158
+ });
159
+ };
140
160
  return send;
141
161
  });
142
162
  });
143
163
 
144
164
  // src/node/cache.ts
165
+ var import_change_case3 = require("change-case");
145
166
  var getCacheProps = (name, stack = STACK) => {
146
- const prefix = `CACHE_${stack}_${name}`;
167
+ const prefix = `CACHE_${(0, import_change_case3.constantCase)(stack)}_${(0, import_change_case3.constantCase)(name)}`;
147
168
  return {
148
169
  host: process.env[`${prefix}_HOST`],
149
170
  port: parseInt(process.env[`${prefix}_PORT`], 10)
package/dist/index.js CHANGED
@@ -47,6 +47,14 @@ var Function = createProxy((stackName) => {
47
47
  });
48
48
  };
49
49
  call.name = name;
50
+ call.async = (payload, options = {}) => {
51
+ return invoke({
52
+ ...options,
53
+ type: "Event",
54
+ name,
55
+ payload
56
+ });
57
+ };
50
58
  return call;
51
59
  });
52
60
  });
@@ -78,26 +86,39 @@ var Topic = createProxy((topic) => {
78
86
  });
79
87
 
80
88
  // src/node/queue.ts
81
- import { sendMessage } from "@awsless/sqs";
89
+ import { sendMessage, sendMessageBatch } from "@awsless/sqs";
90
+ import { constantCase } from "change-case";
82
91
  var getQueueName = getLocalResourceName;
92
+ var getQueueUrl = (name, stack = STACK) => {
93
+ return process.env[`QUEUE_${constantCase(stack)}_${constantCase(name)}_URL`];
94
+ };
83
95
  var Queue = createProxy((stack) => {
84
96
  return createProxy((queue) => {
85
- const name = getQueueName(queue, stack);
86
- const send = (payload, options) => {
97
+ const url = getQueueUrl(queue, stack);
98
+ const send = (payload, options = {}) => {
87
99
  return sendMessage({
88
100
  ...options,
89
- queue: name,
101
+ queue: url,
90
102
  payload
91
103
  });
92
104
  };
93
- send.name = name;
105
+ send.url = url;
106
+ send.name = getQueueName(queue, stack);
107
+ send.batch = (items, options = {}) => {
108
+ return sendMessageBatch({
109
+ ...options,
110
+ queue: url,
111
+ items
112
+ });
113
+ };
94
114
  return send;
95
115
  });
96
116
  });
97
117
 
98
118
  // src/node/cache.ts
119
+ import { constantCase as constantCase2 } from "change-case";
99
120
  var getCacheProps = (name, stack = STACK) => {
100
- const prefix = `CACHE_${stack}_${name}`;
121
+ const prefix = `CACHE_${constantCase2(stack)}_${constantCase2(name)}`;
101
122
  return {
102
123
  host: process.env[`${prefix}_HOST`],
103
124
  port: parseInt(process.env[`${prefix}_PORT`], 10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  }
26
26
  },
27
27
  "peerDependencies": {
28
- "@awsless/sqs": "^0.0.5",
29
28
  "@awsless/lambda": "^0.0.5",
29
+ "@awsless/sqs": "^0.0.5",
30
30
  "@awsless/sns": "^0.0.5"
31
31
  },
32
32
  "dependencies": {