wirejs-deploy-amplify-basic 0.0.96-realtime → 0.0.97-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.
|
@@ -131,7 +131,7 @@ for (const resource of generated) {
|
|
|
131
131
|
|
|
132
132
|
function isRealtimeService(resource: any): resource is {
|
|
133
133
|
type: 'RealtimeService';
|
|
134
|
-
options:
|
|
134
|
+
options: { namespace: string; };
|
|
135
135
|
} {
|
|
136
136
|
return resource.type === 'RealtimeService';
|
|
137
137
|
}
|
|
@@ -143,7 +143,7 @@ if (generated.some(isRealtimeService)) {
|
|
|
143
143
|
publisher: backend.api,
|
|
144
144
|
namespaces: generated
|
|
145
145
|
.filter(isRealtimeService)
|
|
146
|
-
.map(r => r.options.
|
|
146
|
+
.map(r => r.options.namespace),
|
|
147
147
|
});
|
|
148
148
|
// TODO: is there a better way to ensure we grant access specifically
|
|
149
149
|
// to what `Secret` uses to store its creds without creating N places to
|
|
@@ -8,10 +8,14 @@ import { addResource } from '../resource-collector.js';
|
|
|
8
8
|
export const SECRET_ID = 'realtime-secret';
|
|
9
9
|
export class RealtimeService extends Resource {
|
|
10
10
|
#secret;
|
|
11
|
+
#namespace;
|
|
11
12
|
constructor(scope, id) {
|
|
12
13
|
super(scope, id);
|
|
13
14
|
this.#secret = new Secret(this, SECRET_ID);
|
|
14
|
-
|
|
15
|
+
this.#namespace = this.absoluteId
|
|
16
|
+
.replace(/[^a-zA-Z0-9]/g, '-')
|
|
17
|
+
.slice(0, 50);
|
|
18
|
+
addResource('RealtimeService', { namespace: this.#namespace });
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Ensures channel name will be supported by known, major cloud provers using
|
|
@@ -73,7 +77,7 @@ export class RealtimeService extends Resource {
|
|
|
73
77
|
body: JSON.stringify({
|
|
74
78
|
channel,
|
|
75
79
|
events: {
|
|
76
|
-
channel:
|
|
80
|
+
channel: `${this.#namespace}/${channel}`,
|
|
77
81
|
events: events.map(event => JSON.stringify(event))
|
|
78
82
|
},
|
|
79
83
|
}),
|
|
@@ -99,8 +103,8 @@ export class RealtimeService extends Resource {
|
|
|
99
103
|
.sign(new TextEncoder().encode(await this.#secret.read()));
|
|
100
104
|
return {
|
|
101
105
|
__wjstype: 'realtime',
|
|
102
|
-
url:
|
|
103
|
-
channel
|
|
106
|
+
url: this.address,
|
|
107
|
+
channel: `${this.#namespace}/${channel}`,
|
|
104
108
|
token: jwt
|
|
105
109
|
};
|
|
106
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.97-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.
|
|
44
|
+
"wirejs-resources": "^0.1.65-realtime"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@aws-amplify/backend": "^1.14.0",
|