wirejs-deploy-amplify-basic 0.0.105-realtime → 0.0.106-realtime

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.
@@ -3,6 +3,6 @@
3
3
  "dependencies": {
4
4
  "jsdom": "^25.0.1",
5
5
  "wirejs-dom": "^1.0.41",
6
- "wirejs-resources": "^0.1.73-realtime"
6
+ "wirejs-resources": "^0.1.74-realtime"
7
7
  }
8
8
  }
@@ -8,6 +8,6 @@ export declare class RealtimeService<T = any> extends Resource {
8
8
  * The address the client will need to connect to.
9
9
  */
10
10
  get address(): string;
11
- publish(channel: string, data: T | T[]): Promise<void>;
11
+ publish(channel: string, data: T | T[]): Promise<any>;
12
12
  getStream(channel: string): Promise<any>;
13
13
  }
@@ -54,27 +54,31 @@ export class RealtimeService extends Resource {
54
54
  }
55
55
  async publish(channel, data) {
56
56
  this.#validateChannelName(channel);
57
- console.log('Publishing to channels:', channel);
57
+ console.log('Publishing to channel:', channel);
58
58
  const events = Array.isArray(data) ? data : [data];
59
59
  // AppSync allows batches of no more than 5. Hence, if we have more than 5,
60
60
  // we need to perform batching on our end.
61
61
  if (events.length > 5) {
62
+ console.log(`More than 5 events received. Batching...`);
63
+ let results = [];
62
64
  let i = 0;
63
65
  while (i < events.length) {
64
66
  const batch = events.slice(i, i + 5);
65
- await this.publish(channel, batch);
67
+ results.push(await this.publish(channel, batch));
66
68
  i += 5;
67
69
  }
68
- return;
70
+ return results;
69
71
  }
70
72
  // TODO: Utility for making SigV4 requests a little more concise.
71
73
  const credentials = await defaultProvider()();
72
- const signer = new SignatureV4({
74
+ const signerConfig = {
73
75
  service: 'appsync',
74
76
  region: process.env.AWS_REGION || 'us-east-1',
75
77
  credentials,
76
78
  sha256: Sha256,
77
- });
79
+ };
80
+ console.log('Signer config:', signerConfig);
81
+ const signer = new SignatureV4(signerConfig);
78
82
  const request = new HttpRequest({
79
83
  method: 'POST',
80
84
  hostname: process.env.REALTIME_HTTP_DOMAIN,
@@ -92,17 +96,20 @@ export class RealtimeService extends Resource {
92
96
  events: events.map(event => JSON.stringify(event))
93
97
  }),
94
98
  });
99
+ console.log('Signing request:', request);
95
100
  const signedRequest = await signer.sign(request);
96
101
  const response = await fetch(`https://${signedRequest.hostname}${signedRequest.path}`, {
97
102
  method: signedRequest.method,
98
103
  headers: signedRequest.headers,
99
104
  body: signedRequest.body,
100
105
  });
101
- await response.text();
102
- console.log('Response from publish:', response.status, response.statusText);
106
+ console.log('Response status:', response.status);
103
107
  if (!response.ok) {
104
108
  throw new Error(`Failed to publish to channel: ${response.statusText}`);
105
109
  }
110
+ const result = await response.json();
111
+ console.log('Response from publish:', result);
112
+ return result;
106
113
  }
107
114
  async getStream(channel) {
108
115
  this.#validateChannelName(channel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-deploy-amplify-basic",
3
- "version": "0.0.105-realtime",
3
+ "version": "0.0.106-realtime",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "recursive-copy": "^2.0.14",
42
42
  "rimraf": "^6.0.1",
43
43
  "wirejs-dom": "^1.0.41",
44
- "wirejs-resources": "^0.1.73-realtime"
44
+ "wirejs-resources": "^0.1.74-realtime"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@aws-amplify/backend": "^1.14.0",