@geekmidas/manifest 10.0.0-alpha.155 → 10.0.0-alpha.157
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/index.cjs +56 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +74 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +53 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1389,6 +1389,59 @@ function drawSecret(pick, format = {}) {
|
|
|
1389
1389
|
return chars.join("");
|
|
1390
1390
|
}
|
|
1391
1391
|
//#endregion
|
|
1392
|
+
//#region src/websocket.ts
|
|
1393
|
+
/**
|
|
1394
|
+
* The `apigateway://` string a `WebSocketApi`'s publisher reads on AWS.
|
|
1395
|
+
*
|
|
1396
|
+
* Here because two packages meet on it: `@geekmidas/cloud` composes it from
|
|
1397
|
+
* the API Gateway WebSocket API and the connection table it provisioned, and
|
|
1398
|
+
* `@geekmidas/constructs` parses it to reach them. One codec, so the two
|
|
1399
|
+
* cannot disagree about a parameter's name.
|
|
1400
|
+
*
|
|
1401
|
+
* On a server stage the same key is a `redis://` string — whichever replica
|
|
1402
|
+
* holds the socket delivers. On AWS the gateway holds every socket: a send is
|
|
1403
|
+
* a call to its management API, and a broadcast reads the ids it would fan out
|
|
1404
|
+
* to from the table.
|
|
1405
|
+
*/
|
|
1406
|
+
const API_GATEWAY_WEBSOCKET_SCHEME = "apigateway:";
|
|
1407
|
+
/**
|
|
1408
|
+
* `apigateway://<region>?endpoint=<management url>&table=<name>[&tableEndpoint=<url>]`
|
|
1409
|
+
*/
|
|
1410
|
+
function apiGatewayWebSocketUrl(target) {
|
|
1411
|
+
const query = new URLSearchParams({
|
|
1412
|
+
endpoint: target.endpoint,
|
|
1413
|
+
table: target.table,
|
|
1414
|
+
...target.tableEndpoint ? { tableEndpoint: target.tableEndpoint } : {}
|
|
1415
|
+
});
|
|
1416
|
+
return `${API_GATEWAY_WEBSOCKET_SCHEME}//${target.region}?${query}`;
|
|
1417
|
+
}
|
|
1418
|
+
/** An `apigateway://` string missing what a publisher needs to reach a socket. */
|
|
1419
|
+
var InvalidApiGatewayWebSocketUrl = class extends Error {
|
|
1420
|
+
missing;
|
|
1421
|
+
constructor(missing) {
|
|
1422
|
+
super(`An apigateway:// WebSocket publisher string needs its ${missing}. gkm composes it as <ID>_PUBLISHER_CONNECTION_STRING on an AWS stage — read it from there rather than writing one by hand.`);
|
|
1423
|
+
this.missing = missing;
|
|
1424
|
+
this.name = "InvalidApiGatewayWebSocketUrl";
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
/** What an `apigateway://` string names. */
|
|
1428
|
+
function parseApiGatewayWebSocketUrl(value) {
|
|
1429
|
+
const url = new URL(value);
|
|
1430
|
+
if (url.protocol !== "apigateway:" || !url.hostname) throw new InvalidApiGatewayWebSocketUrl("region");
|
|
1431
|
+
const endpoint = url.searchParams.get("endpoint");
|
|
1432
|
+
if (!endpoint) throw new InvalidApiGatewayWebSocketUrl("endpoint");
|
|
1433
|
+
const table = url.searchParams.get("table");
|
|
1434
|
+
if (!table) throw new InvalidApiGatewayWebSocketUrl("table");
|
|
1435
|
+
const tableEndpoint = url.searchParams.get("tableEndpoint");
|
|
1436
|
+
return {
|
|
1437
|
+
region: url.hostname,
|
|
1438
|
+
endpoint,
|
|
1439
|
+
table,
|
|
1440
|
+
...tableEndpoint ? { tableEndpoint } : {}
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
//#endregion
|
|
1444
|
+
exports.API_GATEWAY_WEBSOCKET_SCHEME = API_GATEWAY_WEBSOCKET_SCHEME;
|
|
1392
1445
|
exports.CLIENT_IP_HEADER = CLIENT_IP_HEADER;
|
|
1393
1446
|
exports.DATABASE_FOLDERS = DATABASE_FOLDERS;
|
|
1394
1447
|
exports.DEFAULT_DERIVED_DAYS = DEFAULT_DERIVED_DAYS;
|
|
@@ -1401,6 +1454,7 @@ exports.EDGE_TOKEN_KEY = EDGE_TOKEN_KEY;
|
|
|
1401
1454
|
exports.INBOX_EVENT = INBOX_EVENT;
|
|
1402
1455
|
exports.INBOX_MESSAGES_PREFIX = INBOX_MESSAGES_PREFIX;
|
|
1403
1456
|
exports.IllegalDerivation = IllegalDerivation;
|
|
1457
|
+
exports.InvalidApiGatewayWebSocketUrl = InvalidApiGatewayWebSocketUrl;
|
|
1404
1458
|
exports.InvalidConstructId = InvalidConstructId;
|
|
1405
1459
|
exports.KMS_SCHEME = KMS_SCHEME;
|
|
1406
1460
|
exports.MIGRATIONS_ROOT = MIGRATIONS_ROOT;
|
|
@@ -1412,6 +1466,7 @@ exports.SECRET_SYMBOLS = SECRET_SYMBOLS;
|
|
|
1412
1466
|
exports.TELEMETRY_KEYS = TELEMETRY_KEYS;
|
|
1413
1467
|
exports.UnknownParent = UnknownParent;
|
|
1414
1468
|
exports.WILDCARD_SUBDOMAIN = WILDCARD_SUBDOMAIN;
|
|
1469
|
+
exports.apiGatewayWebSocketUrl = apiGatewayWebSocketUrl;
|
|
1415
1470
|
exports.assertDerivations = assertDerivations;
|
|
1416
1471
|
exports.bucketExpiry = bucketExpiry;
|
|
1417
1472
|
exports.cacheTable = cacheTable;
|
|
@@ -1433,6 +1488,7 @@ exports.kmsUrl = kmsUrl;
|
|
|
1433
1488
|
exports.migrationFolder = migrationFolder;
|
|
1434
1489
|
exports.migrationTargets = migrationTargets;
|
|
1435
1490
|
exports.mobileOrigins = mobileOrigins;
|
|
1491
|
+
exports.parseApiGatewayWebSocketUrl = parseApiGatewayWebSocketUrl;
|
|
1436
1492
|
exports.provideKey = provideKey;
|
|
1437
1493
|
exports.providedKeyFor = providedKeyFor;
|
|
1438
1494
|
exports.provisionOrder = provisionOrder;
|