@awsless/awsless 0.0.582 → 0.0.583

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
@@ -1155,7 +1155,24 @@ var RpcDefaultSchema = z22.record(
1155
1155
  geoRestrictions: z22.array(z22.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
1156
1156
  })
1157
1157
  ).describe(`Define the global RPC API's.`).optional();
1158
- var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1158
+ var PermissionsSchema2 = z22.union([
1159
+ //
1160
+ z22.string().transform((v) => [v]),
1161
+ z22.string().array()
1162
+ ]).default([]).describe(
1163
+ "Specifies a list of permissions that can be used inside your custom authorizer function to determine if the user has access to this specific RPC function."
1164
+ );
1165
+ var EntrySchema = z22.union([
1166
+ FunctionSchema.transform((props) => ({
1167
+ function: props,
1168
+ permissions: []
1169
+ })),
1170
+ z22.object({
1171
+ function: FunctionSchema,
1172
+ permissions: PermissionsSchema2
1173
+ })
1174
+ ]);
1175
+ var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), EntrySchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1159
1176
 
1160
1177
  // src/feature/instance/schema.ts
1161
1178
  import { days as days3, toDays as toDays2 } from "@awsless/duration";
@@ -1227,7 +1244,7 @@ var PermissionSchema2 = z23.object({
1227
1244
  actions: ActionsSchema2,
1228
1245
  resources: ResourcesSchema2
1229
1246
  });
1230
- var PermissionsSchema2 = z23.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
1247
+ var PermissionsSchema3 = z23.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
1231
1248
  var DescriptionSchema2 = z23.string().describe("A description of the instance.");
1232
1249
  var ImageSchema = z23.string().optional().describe("The URL of the container image to use.");
1233
1250
  var validLogRetentionDays2 = [
@@ -1269,7 +1286,7 @@ var ISchema = z23.object({
1269
1286
  memorySize: MemorySizeSchema2.optional(),
1270
1287
  architecture: ArchitectureSchema3.optional(),
1271
1288
  environment: EnvironmentSchema2.optional(),
1272
- permissions: PermissionsSchema2.optional(),
1289
+ permissions: PermissionsSchema3.optional(),
1273
1290
  healthCheck: HealthCheckSchema.optional()
1274
1291
  // restartPolicy: RestartPolicySchema.optional(),
1275
1292
  });
@@ -1286,7 +1303,7 @@ var InstanceDefaultSchema = z23.object({
1286
1303
  memorySize: MemorySizeSchema2.default("512 MB"),
1287
1304
  architecture: ArchitectureSchema3.default("arm64"),
1288
1305
  environment: EnvironmentSchema2.optional(),
1289
- permissions: PermissionsSchema2.optional(),
1306
+ permissions: PermissionsSchema3.optional(),
1290
1307
  healthCheck: HealthCheckSchema.optional(),
1291
1308
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
1292
1309
  log: LogSchema2.default(true).transform((log26) => ({
@@ -2492,7 +2509,6 @@ var authFeature = defineFeature({
2492
2509
  resourceType: "auth",
2493
2510
  resourceName: id
2494
2511
  });
2495
- props.username;
2496
2512
  const userPool = new $.aws.cognito.UserPool(
2497
2513
  group,
2498
2514
  "user-pool",
@@ -4531,8 +4547,8 @@ var rpcFeature = defineFeature({
4531
4547
  const schema = new TypeObject(2);
4532
4548
  for (const stack of ctx.stackConfigs) {
4533
4549
  for (const [name, props] of Object.entries(stack.rpc?.[id] ?? {})) {
4534
- if ("file" in props.code) {
4535
- const relFile = relative5(directories.types, props.code.file);
4550
+ if ("file" in props.function.code) {
4551
+ const relFile = relative5(directories.types, props.function.code.file);
4536
4552
  const varName = camelCase5(`${stack.name}-${name}`);
4537
4553
  types2.addImport(varName, relFile);
4538
4554
  schema.addType(name, `Handle<typeof ${varName}>`);
@@ -4561,7 +4577,7 @@ var rpcFeature = defineFeature({
4561
4577
  } else {
4562
4578
  list3.add(name);
4563
4579
  }
4564
- const timeout = toSeconds5(props.timeout ?? ctx.appConfig.defaults.function.timeout);
4580
+ const timeout = toSeconds5(props.function.timeout ?? ctx.appConfig.defaults.function.timeout);
4565
4581
  const maxTimeout = toSeconds5(ctx.appConfig.defaults.rpc[id].timeout) * 0.8;
4566
4582
  if (timeout > maxTimeout) {
4567
4583
  throw new FileError(
@@ -4787,7 +4803,7 @@ var rpcFeature = defineFeature({
4787
4803
  const queryGroup = new Group13(group, "query", name);
4788
4804
  const entryId = kebabCase6(`${id}-${shortId(name)}`);
4789
4805
  createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
4790
- ...props,
4806
+ ...props.function,
4791
4807
  description: `${id} ${name}`
4792
4808
  });
4793
4809
  new $13.aws.dynamodb.TableItem(queryGroup, "query", {
@@ -4803,6 +4819,11 @@ var rpcFeature = defineFeature({
4803
4819
  resourceType: "rpc",
4804
4820
  resourceName: entryId
4805
4821
  })
4822
+ },
4823
+ permissions: {
4824
+ L: props.permissions.map((permission) => ({
4825
+ S: permission
4826
+ }))
4806
4827
  }
4807
4828
  })
4808
4829
  });
@@ -550,7 +550,24 @@ var RpcDefaultSchema = z19.record(
550
550
  geoRestrictions: z19.array(z19.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
551
551
  })
552
552
  ).describe(`Define the global RPC API's.`).optional();
553
- var RpcSchema = z19.record(ResourceIdSchema, z19.record(z19.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
553
+ var PermissionsSchema2 = z19.union([
554
+ //
555
+ z19.string().transform((v) => [v]),
556
+ z19.string().array()
557
+ ]).default([]).describe(
558
+ "Specifies a list of permissions that can be used inside your custom authorizer function to determine if the user has access to this specific RPC function."
559
+ );
560
+ var EntrySchema = z19.union([
561
+ FunctionSchema.transform((props) => ({
562
+ function: props,
563
+ permissions: []
564
+ })),
565
+ z19.object({
566
+ function: FunctionSchema,
567
+ permissions: PermissionsSchema2
568
+ })
569
+ ]);
570
+ var RpcSchema = z19.record(ResourceIdSchema, z19.record(z19.string(), EntrySchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
554
571
 
555
572
  // src/feature/instance/schema.ts
556
573
  import { days as days3, toDays as toDays2 } from "@awsless/duration";
@@ -622,7 +639,7 @@ var PermissionSchema2 = z20.object({
622
639
  actions: ActionsSchema2,
623
640
  resources: ResourcesSchema2
624
641
  });
625
- var PermissionsSchema2 = z20.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
642
+ var PermissionsSchema3 = z20.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
626
643
  var DescriptionSchema2 = z20.string().describe("A description of the instance.");
627
644
  var ImageSchema = z20.string().optional().describe("The URL of the container image to use.");
628
645
  var validLogRetentionDays2 = [
@@ -664,7 +681,7 @@ var ISchema = z20.object({
664
681
  memorySize: MemorySizeSchema2.optional(),
665
682
  architecture: ArchitectureSchema3.optional(),
666
683
  environment: EnvironmentSchema2.optional(),
667
- permissions: PermissionsSchema2.optional(),
684
+ permissions: PermissionsSchema3.optional(),
668
685
  healthCheck: HealthCheckSchema.optional()
669
686
  // restartPolicy: RestartPolicySchema.optional(),
670
687
  });
@@ -681,7 +698,7 @@ var InstanceDefaultSchema = z20.object({
681
698
  memorySize: MemorySizeSchema2.default("512 MB"),
682
699
  architecture: ArchitectureSchema3.default("arm64"),
683
700
  environment: EnvironmentSchema2.optional(),
684
- permissions: PermissionsSchema2.optional(),
701
+ permissions: PermissionsSchema3.optional(),
685
702
  healthCheck: HealthCheckSchema.optional(),
686
703
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
687
704
  log: LogSchema2.default(true).transform((log) => ({
Binary file
Binary file
@@ -1 +1 @@
1
- f5dbbf3d9b5e37eda3a77bbec4453130ace93efd
1
+ f25c05904c0f9349537dd7cb51577a1befa4c1af
Binary file
package/dist/server.d.ts CHANGED
@@ -131,6 +131,7 @@ type RpcAuthorizerResponse = {
131
131
  authorized: true;
132
132
  context?: unknown;
133
133
  lockKey?: string;
134
+ permissions?: string[];
134
135
  ttl: Duration;
135
136
  };
136
137