@awsless/awsless 0.0.405 → 0.0.407

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
@@ -12549,7 +12549,7 @@ var restFeature = defineFeature({
12549
12549
 
12550
12550
  // src/feature/rpc/index.ts
12551
12551
  import { camelCase as camelCase6, constantCase as constantCase10, paramCase as paramCase6 } from "change-case";
12552
- import { Asset as Asset5, aws as aws17, Node as Node16, Output as Output3 } from "@awsless/formation";
12552
+ import { Asset as Asset5, aws as aws17, Node as Node16 } from "@awsless/formation";
12553
12553
  import { mebibytes as mebibytes2 } from "@awsless/size";
12554
12554
  import { dirname as dirname10, join as join9, relative as relative5 } from "path";
12555
12555
  import { fileURLToPath } from "node:url";
@@ -12746,22 +12746,23 @@ var rpcFeature = defineFeature({
12746
12746
  resourceType: "rpc",
12747
12747
  resourceName: id
12748
12748
  });
12749
- const { lambda, code } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
12749
+ const { lambda, policy, code } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
12750
12750
  bundleFile: join9(__dirname, "/prebuild/rpc/bundle.zip"),
12751
12751
  bundleHash: join9(__dirname, "/prebuild/rpc/HASH"),
12752
12752
  memorySize: mebibytes2(256),
12753
12753
  warm: 3
12754
12754
  });
12755
- const schema = {};
12756
- lambda.addEnvironment(
12757
- "SCHEMA",
12758
- new Output3([], (resolve2) => {
12759
- ctx.onReady(() => {
12760
- resolve2(JSON.stringify(schema));
12761
- });
12762
- })
12763
- );
12764
- ctx.shared.set(`rpc-${id}-schema`, schema);
12755
+ const table2 = new aws17.dynamodb.Table(group, "schema", {
12756
+ name,
12757
+ hash: "query"
12758
+ });
12759
+ lambda.addEnvironment("SCHEMA_TABLE", table2.name);
12760
+ policy.addStatement({
12761
+ effect: "allow",
12762
+ actions: ["dynamodb:GetItem"],
12763
+ resources: [table2.arn]
12764
+ });
12765
+ ctx.shared.set(`rpc-${id}-schema-table`, table2);
12765
12766
  if (props.auth) {
12766
12767
  const authGroup = new Node16(group, "auth", "authorizer");
12767
12768
  const auth2 = createLambdaFunction(authGroup, ctx, "rpc", `${id}-auth`, props.auth);
@@ -12844,16 +12845,27 @@ var rpcFeature = defineFeature({
12844
12845
  if (!defaultProps) {
12845
12846
  throw new FileError(ctx.stackConfig.file, `RPC definition is not defined on app level for "${id}"`);
12846
12847
  }
12847
- const schema = ctx.shared.get(`rpc-${id}-schema`);
12848
+ const table2 = ctx.shared.get(`rpc-${id}-schema-table`);
12848
12849
  const group = new Node16(ctx.stack, "rpc", id);
12849
12850
  for (const [name, props] of Object.entries(queries ?? {})) {
12850
12851
  const queryGroup = new Node16(group, "query", name);
12851
12852
  const entryId = paramCase6(`${id}-${shortId(name)}`);
12852
- const lambda = createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
12853
+ createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
12853
12854
  ...props,
12854
12855
  description: `${id} ${name}`
12855
12856
  });
12856
- schema[name] = lambda.name;
12857
+ new aws17.dynamodb.TableItem(queryGroup, "query", {
12858
+ table: table2,
12859
+ item: Asset5.fromJSON({
12860
+ query: name,
12861
+ function: formatLocalResourceName({
12862
+ appName: ctx.app.name,
12863
+ stackName: ctx.stack.name,
12864
+ resourceType: "rpc",
12865
+ resourceName: entryId
12866
+ })
12867
+ })
12868
+ });
12857
12869
  }
12858
12870
  }
12859
12871
  }
package/dist/client.js CHANGED
@@ -79,6 +79,7 @@ var createHttpClient = (fetcher) => {
79
79
  };
80
80
 
81
81
  // src/lib/client/pubsub.ts
82
+ import { parse, stringify } from "@awsless/json";
82
83
  import { createClient } from "@awsless/mqtt";
83
84
  var createPubSubClient = (app, props) => {
84
85
  const mqtt = createClient(async () => {
@@ -104,11 +105,11 @@ var createPubSubClient = (app, props) => {
104
105
  return mqtt.topics.map(fromPubSubTopic);
105
106
  },
106
107
  publish(topic, event, payload, qos) {
107
- return mqtt.publish(getPubSubTopic(topic), JSON.stringify([event, payload]), qos);
108
+ return mqtt.publish(getPubSubTopic(topic), stringify([event, payload]), qos);
108
109
  },
109
110
  subscribe(topic, event, callback) {
110
111
  return mqtt.subscribe(getPubSubTopic(topic), (message) => {
111
- const [eventName, payload] = JSON.parse(message.toString("utf8"));
112
+ const [eventName, payload] = parse(message.toString("utf8"));
112
113
  if (event === eventName) {
113
114
  callback(payload);
114
115
  }
@@ -1 +1 @@
1
- 97510d9a094a9b2d465e3a910caf3aa9b08ebf0d
1
+ 775126f16ab12a3cc007fed5f2de3518b92ce405
Binary file
package/dist/server.js CHANGED
@@ -365,6 +365,7 @@ var Config = /* @__PURE__ */ new Proxy(
365
365
  // src/lib/server/pubsub.ts
366
366
  import { hours, toSeconds } from "@awsless/duration";
367
367
  import { publish as publish2, QoS } from "@awsless/iot";
368
+ import { stringify } from "@awsless/json";
368
369
  var getPubSubTopic = (name) => {
369
370
  return `${APP}/pubsub/${name}`;
370
371
  };
@@ -372,7 +373,7 @@ var PubSub = {
372
373
  async publish(topic, event, payload, opts = {}) {
373
374
  await publish2({
374
375
  topic: getPubSubTopic(topic),
375
- payload: Buffer.from(JSON.stringify([event, payload])),
376
+ payload: Buffer.from(stringify([event, payload])),
376
377
  ...opts
377
378
  });
378
379
  }
@@ -436,8 +437,9 @@ var pubsubAuthorizerResponse = (props) => {
436
437
  ]
437
438
  }
438
439
  ];
439
- if (JSON.stringify(policyDocuments).length > 2048) {
440
- throw new Error("IoT Policy is too large");
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}`);
441
443
  }
442
444
  return {
443
445
  isAuthenticated: props.authorized,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.405",
3
+ "version": "0.0.407",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,16 +28,17 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/lambda": "^0.0.27",
32
- "@awsless/open-search": "^0.0.15",
31
+ "@awsless/iot": "^0.0.2",
32
+ "@awsless/lambda": "^0.0.30",
33
+ "@awsless/s3": "^0.0.18",
33
34
  "@awsless/sns": "^0.0.7",
34
- "@awsless/redis": "^0.0.13",
35
35
  "@awsless/sqs": "^0.0.7",
36
- "@awsless/iot": "^0.0.2",
37
36
  "@awsless/validate": "^0.0.16",
37
+ "@awsless/json": "^0.0.6",
38
+ "@awsless/open-search": "^0.0.15",
38
39
  "@awsless/ssm": "^0.0.7",
39
40
  "@awsless/weak-cache": "^0.0.1",
40
- "@awsless/s3": "^0.0.18",
41
+ "@awsless/redis": "^0.0.13",
41
42
  "@awsless/mqtt": "^0.0.2"
42
43
  },
43
44
  "dependencies": {
@@ -113,12 +114,13 @@
113
114
  "zod": "^3.21.4",
114
115
  "zod-to-json-schema": "^3.22.3",
115
116
  "@awsless/code": "^0.0.10",
116
- "@awsless/size": "^0.0.1",
117
- "@awsless/validate": "^0.0.16",
118
117
  "@awsless/duration": "^0.0.1",
119
118
  "@awsless/formation": "^0.0.57",
119
+ "@awsless/graphql": "^0.0.9",
120
+ "@awsless/json": "^0.0.6",
121
+ "@awsless/validate": "^0.0.16",
120
122
  "@awsless/ts-file-cache": "^0.0.10",
121
- "@awsless/graphql": "^0.0.9"
123
+ "@awsless/size": "^0.0.1"
122
124
  },
123
125
  "devDependencies": {
124
126
  "@node-rs/bcrypt": "^1.10.5"