@awsless/awsless 0.0.406 → 0.0.408

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
@@ -8153,7 +8153,8 @@ var RpcDefaultSchema = z18.record(
8153
8153
  z18.object({
8154
8154
  domain: ResourceIdSchema.describe("The domain id to link your RPC API with.").optional(),
8155
8155
  subDomain: z18.string().optional(),
8156
- auth: FunctionSchema.optional()
8156
+ auth: FunctionSchema.optional(),
8157
+ log: LogSchema.optional()
8157
8158
  })
8158
8159
  ).describe(`Define the global RPC API's.`).optional();
8159
8160
  var RpcSchema = z18.record(ResourceIdSchema, z18.record(z18.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
@@ -12302,7 +12303,7 @@ var pubsubFeature = defineFeature({
12302
12303
  });
12303
12304
  if (props.domain) {
12304
12305
  const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
12305
- new aws13.iot.DomainConfiguration(group, "domain", {
12306
+ const domain = new aws13.iot.DomainConfiguration(group, "domain", {
12306
12307
  name,
12307
12308
  domainName,
12308
12309
  certificates: [ctx.shared.get(`local-certificate-${props.domain}-arn`)],
@@ -12311,6 +12312,7 @@ var pubsubFeature = defineFeature({
12311
12312
  }
12312
12313
  // validationCertificate: ctx.shared.get(`global-certificate-${props.domain}-arn`),
12313
12314
  });
12315
+ domain.dependsOn(authorizer);
12314
12316
  new aws13.route53.RecordSet(group, "record", {
12315
12317
  hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
12316
12318
  name: domainName,
@@ -12548,7 +12550,7 @@ var restFeature = defineFeature({
12548
12550
 
12549
12551
  // src/feature/rpc/index.ts
12550
12552
  import { camelCase as camelCase6, constantCase as constantCase10, paramCase as paramCase6 } from "change-case";
12551
- import { Asset as Asset5, aws as aws17, Node as Node16, Output as Output3 } from "@awsless/formation";
12553
+ import { Asset as Asset5, aws as aws17, Node as Node16 } from "@awsless/formation";
12552
12554
  import { mebibytes as mebibytes2 } from "@awsless/size";
12553
12555
  import { dirname as dirname10, join as join9, relative as relative5 } from "path";
12554
12556
  import { fileURLToPath } from "node:url";
@@ -12745,22 +12747,24 @@ var rpcFeature = defineFeature({
12745
12747
  resourceType: "rpc",
12746
12748
  resourceName: id
12747
12749
  });
12748
- const { lambda, code } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
12750
+ const { lambda, policy, code } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
12749
12751
  bundleFile: join9(__dirname, "/prebuild/rpc/bundle.zip"),
12750
12752
  bundleHash: join9(__dirname, "/prebuild/rpc/HASH"),
12751
12753
  memorySize: mebibytes2(256),
12752
- warm: 3
12753
- });
12754
- const schema = {};
12755
- lambda.addEnvironment(
12756
- "SCHEMA",
12757
- new Output3([], (resolve2) => {
12758
- ctx.onReady(() => {
12759
- resolve2(JSON.stringify(schema));
12760
- });
12761
- })
12762
- );
12763
- ctx.shared.set(`rpc-${id}-schema`, schema);
12754
+ warm: 3,
12755
+ log: props.log
12756
+ });
12757
+ const table2 = new aws17.dynamodb.Table(group, "schema", {
12758
+ name,
12759
+ hash: "query"
12760
+ });
12761
+ lambda.addEnvironment("SCHEMA_TABLE", table2.name);
12762
+ policy.addStatement({
12763
+ effect: "allow",
12764
+ actions: ["dynamodb:GetItem"],
12765
+ resources: [table2.arn]
12766
+ });
12767
+ ctx.shared.set(`rpc-${id}-schema-table`, table2);
12764
12768
  if (props.auth) {
12765
12769
  const authGroup = new Node16(group, "auth", "authorizer");
12766
12770
  const auth2 = createLambdaFunction(authGroup, ctx, "rpc", `${id}-auth`, props.auth);
@@ -12843,16 +12847,27 @@ var rpcFeature = defineFeature({
12843
12847
  if (!defaultProps) {
12844
12848
  throw new FileError(ctx.stackConfig.file, `RPC definition is not defined on app level for "${id}"`);
12845
12849
  }
12846
- const schema = ctx.shared.get(`rpc-${id}-schema`);
12850
+ const table2 = ctx.shared.get(`rpc-${id}-schema-table`);
12847
12851
  const group = new Node16(ctx.stack, "rpc", id);
12848
12852
  for (const [name, props] of Object.entries(queries ?? {})) {
12849
12853
  const queryGroup = new Node16(group, "query", name);
12850
12854
  const entryId = paramCase6(`${id}-${shortId(name)}`);
12851
- const lambda = createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
12855
+ createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
12852
12856
  ...props,
12853
12857
  description: `${id} ${name}`
12854
12858
  });
12855
- schema[name] = lambda.name;
12859
+ new aws17.dynamodb.TableItem(queryGroup, "query", {
12860
+ table: table2,
12861
+ item: Asset5.fromJSON({
12862
+ query: name,
12863
+ function: formatLocalResourceName({
12864
+ appName: ctx.app.name,
12865
+ stackName: ctx.stack.name,
12866
+ resourceType: "rpc",
12867
+ resourceName: entryId
12868
+ })
12869
+ })
12870
+ });
12856
12871
  }
12857
12872
  }
12858
12873
  }
@@ -695,7 +695,8 @@ var RpcDefaultSchema = z21.record(
695
695
  z21.object({
696
696
  domain: ResourceIdSchema.describe("The domain id to link your RPC API with.").optional(),
697
697
  subDomain: z21.string().optional(),
698
- auth: FunctionSchema.optional()
698
+ auth: FunctionSchema.optional(),
699
+ log: LogSchema.optional()
699
700
  })
700
701
  ).describe(`Define the global RPC API's.`).optional();
701
702
  var RpcSchema = z21.record(ResourceIdSchema, z21.record(z21.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
@@ -1 +1 @@
1
- baa4f5591254516e6462b0b073ae7f4b638ea501
1
+ de29b2d6b84a97458f41f4432aad4541eaa1ea18
Binary file
package/dist/server.js CHANGED
@@ -417,30 +417,36 @@ var pubsubAuthorizerResponse = (props) => {
417
417
  // }
418
418
  );
419
419
  }
420
+ const policyDocuments = [
421
+ {
422
+ Version: "2012-10-17",
423
+ Statement: [
424
+ {
425
+ Action: "iot:Connect",
426
+ Effect: "Allow",
427
+ Resource: "*"
428
+ // Resource: `${prefix}:client/\${iot:ClientId}`,
429
+ },
430
+ {
431
+ Action: "iot:Receive",
432
+ Effect: "Allow",
433
+ Resource: "*"
434
+ // Resource: `${prefix}:client/\${iot:ClientId}`,
435
+ },
436
+ ...statements
437
+ ]
438
+ }
439
+ ];
440
+ const documentSize = JSON.stringify(policyDocuments).length;
441
+ if (documentSize > 2048) {
442
+ throw new Error(`IoT policy document size can't exceed 2048 characters. Current size is ${documentSize}`);
443
+ }
420
444
  return {
421
445
  isAuthenticated: props.authorized,
422
446
  principalId: props.principalId ?? Date.now().toString(),
423
447
  disconnectAfterInSeconds: Number(toSeconds(props.disconnectAfter ?? hours(1))),
424
448
  refreshAfterInSeconds: Number(toSeconds(props.disconnectAfter ?? hours(1))),
425
- policyDocuments: [
426
- {
427
- Version: "2012-10-17",
428
- Statement: [
429
- {
430
- Action: "iot:Connect",
431
- Effect: "Allow",
432
- Resource: "*"
433
- // Resource: `${prefix}:client/\${iot:ClientId}`,
434
- },
435
- {
436
- Action: "iot:Receive",
437
- Effect: "Allow",
438
- Resource: "*"
439
- },
440
- ...statements
441
- ]
442
- }
443
- ]
449
+ policyDocuments
444
450
  };
445
451
  };
446
452
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.406",
3
+ "version": "0.0.408",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,18 +28,18 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/lambda": "^0.0.29",
32
31
  "@awsless/iot": "^0.0.2",
33
- "@awsless/mqtt": "^0.0.2",
34
- "@awsless/sqs": "^0.0.7",
32
+ "@awsless/lambda": "^0.0.30",
33
+ "@awsless/sns": "^0.0.7",
35
34
  "@awsless/open-search": "^0.0.15",
36
35
  "@awsless/json": "^0.0.6",
36
+ "@awsless/ssm": "^0.0.7",
37
+ "@awsless/validate": "^0.0.16",
37
38
  "@awsless/redis": "^0.0.13",
38
39
  "@awsless/weak-cache": "^0.0.1",
39
- "@awsless/validate": "^0.0.16",
40
40
  "@awsless/s3": "^0.0.18",
41
- "@awsless/ssm": "^0.0.7",
42
- "@awsless/sns": "^0.0.7"
41
+ "@awsless/sqs": "^0.0.7",
42
+ "@awsless/mqtt": "^0.0.2"
43
43
  },
44
44
  "dependencies": {
45
45
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -113,14 +113,14 @@
113
113
  "zip-a-folder": "^3.1.6",
114
114
  "zod": "^3.21.4",
115
115
  "zod-to-json-schema": "^3.22.3",
116
+ "@awsless/code": "^0.0.10",
116
117
  "@awsless/duration": "^0.0.1",
117
- "@awsless/formation": "^0.0.57",
118
118
  "@awsless/size": "^0.0.1",
119
- "@awsless/json": "^0.0.6",
120
- "@awsless/validate": "^0.0.16",
121
- "@awsless/code": "^0.0.10",
119
+ "@awsless/formation": "^0.0.57",
122
120
  "@awsless/graphql": "^0.0.9",
123
- "@awsless/ts-file-cache": "^0.0.10"
121
+ "@awsless/ts-file-cache": "^0.0.10",
122
+ "@awsless/validate": "^0.0.16",
123
+ "@awsless/json": "^0.0.6"
124
124
  },
125
125
  "devDependencies": {
126
126
  "@node-rs/bcrypt": "^1.10.5"