wirejs-deploy-amplify-basic 0.0.103-realtime → 0.0.105-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.71-realtime"
6
+ "wirejs-resources": "^0.1.73-realtime"
7
7
  }
8
8
  }
@@ -48,9 +48,10 @@ export function subscribe(url, channel, token, authHost, subscriber) {
48
48
  ws.onmessage = event => {
49
49
  const data = JSON.parse(event.data);
50
50
  if (data.type === 'data') {
51
+ const eventData = JSON.parse(data.event);
51
52
  for (const subscriber of subscribers.get(data.id) || []) {
52
53
  try {
53
- subscriber.onmessage(data.event);
54
+ subscriber.onmessage(eventData);
54
55
  }
55
56
  catch (error) {
56
57
  console.error('Error in subscriber onmessage:', error);
@@ -91,7 +92,7 @@ export function subscribe(url, channel, token, authHost, subscriber) {
91
92
  authorization
92
93
  }));
93
94
  channelSubs.set(fullChannelName, subscriptionId);
94
- subscribers.set(subscriptionId, []);
95
+ subscribers.set(subscriptionId, [subscriber]);
95
96
  };
96
97
  if (ws.readyState === WebSocket.OPEN) {
97
98
  subscribe();
@@ -100,7 +101,9 @@ export function subscribe(url, channel, token, authHost, subscriber) {
100
101
  ws.addEventListener('open', subscribe);
101
102
  }
102
103
  }
103
- subscribers.get(fullChannelName).push(subscriber);
104
+ else {
105
+ subscribers.get(fullChannelName).push(subscriber);
106
+ }
104
107
  }
105
108
  export function unsubscribe(url, channel, subscriber) {
106
109
  const fullChannelName = `${url}#${channel}`;
@@ -77,20 +77,19 @@ export class RealtimeService extends Resource {
77
77
  });
78
78
  const request = new HttpRequest({
79
79
  method: 'POST',
80
- protocol: 'https:',
81
- // hostname: `${process.env.REALTIME_DOMAIN}.appsync-api.${process.env.AWS_REGION}.amazonaws.com`,
82
80
  hostname: process.env.REALTIME_HTTP_DOMAIN,
83
81
  path: '/event',
84
82
  headers: {
85
- 'Content-Type': 'application/json',
83
+ accept: 'application/json, text/javascript',
84
+ 'content-encoding': 'amz-1.0',
85
+ 'content-type': 'application/json; charset=UTF-8',
86
86
  'x-amz-date': new Date().toISOString(),
87
+ host: process.env.REALTIME_HTTP_DOMAIN,
87
88
  },
88
89
  body: JSON.stringify({
89
- channel,
90
- events: {
91
- channel: `${this.#namespace}/${channel}`,
92
- events: events.map(event => JSON.stringify(event))
93
- },
90
+ id: crypto.randomUUID(),
91
+ channel: `${this.#namespace}/${channel}`,
92
+ events: events.map(event => JSON.stringify(event))
94
93
  }),
95
94
  });
96
95
  const signedRequest = await signer.sign(request);
@@ -99,6 +98,8 @@ export class RealtimeService extends Resource {
99
98
  headers: signedRequest.headers,
100
99
  body: signedRequest.body,
101
100
  });
101
+ await response.text();
102
+ console.log('Response from publish:', response.status, response.statusText);
102
103
  if (!response.ok) {
103
104
  throw new Error(`Failed to publish to channel: ${response.statusText}`);
104
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-deploy-amplify-basic",
3
- "version": "0.0.103-realtime",
3
+ "version": "0.0.105-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.71-realtime"
44
+ "wirejs-resources": "^0.1.73-realtime"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@aws-amplify/backend": "^1.14.0",