@awsless/awsless 0.0.635 → 0.0.637

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
@@ -1656,7 +1656,27 @@ var RpcDefaultSchema = z24.record(
1656
1656
  timeout: TimeoutSchema2.default("1 minutes")
1657
1657
  })
1658
1658
  ).describe(`Define the global RPC API's.`).optional();
1659
- var RpcSchema = z24.record(ResourceIdSchema, z24.record(z24.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1659
+ var RpcSchema = z24.record(
1660
+ ResourceIdSchema,
1661
+ z24.record(
1662
+ z24.string(),
1663
+ z24.union([
1664
+ FunctionSchema.transform((f) => ({
1665
+ function: f,
1666
+ lock: false
1667
+ })),
1668
+ z24.object({
1669
+ function: FunctionSchema,
1670
+ lock: z24.boolean().describe(
1671
+ [
1672
+ "Specify if the function should be locked on the `lockKey` returned from the auth function.",
1673
+ "An example would be returning the user ID as `lockKey`."
1674
+ ].join("\n")
1675
+ )
1676
+ })
1677
+ ])
1678
+ ).describe("The queries for your global RPC API.")
1679
+ ).describe("Define the schema in your stack for your global RPC API.").optional();
1660
1680
 
1661
1681
  // src/feature/instance/schema.ts
1662
1682
  import { days as days4, toDays as toDays2 } from "@awsless/duration";
@@ -3923,7 +3943,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3923
3943
  var createAsyncLambdaFunction = (group, ctx, ns, id, local) => {
3924
3944
  const result = createLambdaFunction(group, ctx, ns, id, { ...local, warm: 0 });
3925
3945
  const props = deepmerge(ctx.appConfig.defaults.function, local);
3926
- result.setEnvironment("LOG_VIEWABLE_ERROR", "1");
3946
+ result.setEnvironment("THROW_EXPECTED_ERRORS", "1");
3927
3947
  const onFailure = getGlobalOnFailure(ctx);
3928
3948
  new aws4.lambda.FunctionEventInvokeConfig(
3929
3949
  group,
@@ -4683,7 +4703,7 @@ var queueFeature = defineFeature({
4683
4703
  });
4684
4704
  if (typeof local === "object") {
4685
4705
  const lambdaConsumer = createLambdaFunction(group, ctx, `queue`, id, local.consumer);
4686
- lambdaConsumer.setEnvironment("LOG_VIEWABLE_ERROR", "1");
4706
+ lambdaConsumer.setEnvironment("THROW_EXPECTED_ERRORS", "1");
4687
4707
  new aws11.lambda.EventSourceMapping(
4688
4708
  group,
4689
4709
  "event",
@@ -5047,8 +5067,8 @@ var rpcFeature = defineFeature({
5047
5067
  const schema = new TypeObject(2);
5048
5068
  for (const stack of ctx.stackConfigs) {
5049
5069
  for (const [name, props] of Object.entries(stack.rpc?.[id] ?? {})) {
5050
- if ("file" in props.code) {
5051
- const relFile = relative6(directories.types, props.code.file);
5070
+ if ("file" in props.function.code) {
5071
+ const relFile = relative6(directories.types, props.function.code.file);
5052
5072
  const varName = camelCase6(`${id}-${stack.name}-${name}`);
5053
5073
  types2.addImport(varName, relFile);
5054
5074
  schema.addType(name, `Handle<typeof ${varName}>`);
@@ -5077,7 +5097,7 @@ var rpcFeature = defineFeature({
5077
5097
  } else {
5078
5098
  list3.add(name);
5079
5099
  }
5080
- const timeout = toSeconds6(props.timeout ?? ctx.appConfig.defaults.function.timeout);
5100
+ const timeout = toSeconds6(props.function.timeout ?? ctx.appConfig.defaults.function.timeout);
5081
5101
  const maxTimeout = toSeconds6(ctx.appConfig.defaults.rpc[id].timeout) * 0.8;
5082
5102
  if (timeout > maxTimeout) {
5083
5103
  throw new FileError(
@@ -5217,7 +5237,7 @@ var rpcFeature = defineFeature({
5217
5237
  const queryGroup = new Group13(group, "query", name);
5218
5238
  const entryId = kebabCase6(`${id}-${shortId(name)}`);
5219
5239
  createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
5220
- ...props,
5240
+ ...props.function,
5221
5241
  description: `${id} ${name}`
5222
5242
  });
5223
5243
  new aws14.dynamodb.TableItem(queryGroup, "query", {
@@ -5228,6 +5248,9 @@ var rpcFeature = defineFeature({
5228
5248
  query: {
5229
5249
  S: name
5230
5250
  },
5251
+ lock: {
5252
+ BOOL: props.lock
5253
+ },
5231
5254
  function: {
5232
5255
  S: formatLocalResourceName({
5233
5256
  appName: ctx.app.name,
@@ -5895,7 +5918,7 @@ var tableFeature = defineFeature({
5895
5918
  );
5896
5919
  if (props.stream) {
5897
5920
  const result = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
5898
- result.setEnvironment("LOG_VIEWABLE_ERROR", "1");
5921
+ result.setEnvironment("THROW_EXPECTED_ERRORS", "1");
5899
5922
  const onFailure = getGlobalOnFailure(ctx);
5900
5923
  new aws18.lambda.EventSourceMapping(
5901
5924
  group,
@@ -718,7 +718,27 @@ var RpcDefaultSchema = z20.record(
718
718
  timeout: TimeoutSchema2.default("1 minutes")
719
719
  })
720
720
  ).describe(`Define the global RPC API's.`).optional();
721
- var RpcSchema = z20.record(ResourceIdSchema, z20.record(z20.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
721
+ var RpcSchema = z20.record(
722
+ ResourceIdSchema,
723
+ z20.record(
724
+ z20.string(),
725
+ z20.union([
726
+ FunctionSchema.transform((f) => ({
727
+ function: f,
728
+ lock: false
729
+ })),
730
+ z20.object({
731
+ function: FunctionSchema,
732
+ lock: z20.boolean().describe(
733
+ [
734
+ "Specify if the function should be locked on the `lockKey` returned from the auth function.",
735
+ "An example would be returning the user ID as `lockKey`."
736
+ ].join("\n")
737
+ )
738
+ })
739
+ ])
740
+ ).describe("The queries for your global RPC API.")
741
+ ).describe("Define the schema in your stack for your global RPC API.").optional();
722
742
 
723
743
  // src/feature/instance/schema.ts
724
744
  import { days as days4, toDays as toDays2 } from "@awsless/duration";
Binary file
Binary file
@@ -1 +1 @@
1
- 0a9ac239bd887ff2a80174c8e335813a8349852a
1
+ 6fed4f7f5bc384717991b23b9380720e9807a367
Binary file