@geekmidas/manifest 10.0.0-alpha.168 → 10.0.0-alpha.169
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 +91 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +90 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +84 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1137,6 +1137,14 @@ function bucketExpiry(manifest, bucketId) {
|
|
|
1137
1137
|
return Object.keys(expire).length > 0 ? expire : void 0;
|
|
1138
1138
|
}
|
|
1139
1139
|
//#endregion
|
|
1140
|
+
//#region src/email.ts
|
|
1141
|
+
/** The local part mail is sent from when the construct names none. */
|
|
1142
|
+
const DEFAULT_SENDER = "noreply";
|
|
1143
|
+
/** `<local part>@<domain>` — `info@shop.example.com`, else `noreply@…`. */
|
|
1144
|
+
function senderAddress(email, domain) {
|
|
1145
|
+
return `${email.from ?? "noreply"}@${domain}`;
|
|
1146
|
+
}
|
|
1147
|
+
//#endregion
|
|
1140
1148
|
//#region src/encryption.ts
|
|
1141
1149
|
/**
|
|
1142
1150
|
* The `kms://` URL an `Encryption` construct reads on AWS.
|
|
@@ -1233,6 +1241,81 @@ const EDGE_TOKEN_HEADER = "x-gkm-edge-token";
|
|
|
1233
1241
|
/** Where a stack's processes read the token {@link EDGE_TOKEN_HEADER} carries. */
|
|
1234
1242
|
const EDGE_TOKEN_KEY = "GKM_EDGE_TOKEN";
|
|
1235
1243
|
//#endregion
|
|
1244
|
+
//#region src/hosts.ts
|
|
1245
|
+
/** Whether a declaration answers on a host of its own: a surface or a site. */
|
|
1246
|
+
function isHostedDeclaration(declaration) {
|
|
1247
|
+
return declaration?.kind === "rest-api" || declaration?.kind === "websocket-api" || declaration?.kind === "site";
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* The one derivation of a construct's labels: its primary label, its
|
|
1251
|
+
* aliases and its redirects, in declared order.
|
|
1252
|
+
*/
|
|
1253
|
+
function hostLabels(source) {
|
|
1254
|
+
return {
|
|
1255
|
+
primary: source.subdomain ?? kebabCase(source.id),
|
|
1256
|
+
aliases: [...source.aliases ?? []],
|
|
1257
|
+
redirects: [...source.redirects ?? []]
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
/** One label of a DNS name: lowercase letters, digits and inner hyphens. */
|
|
1261
|
+
const LABEL$1 = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
1262
|
+
/** An alias or redirect that cannot be a label of its own under the domain. */
|
|
1263
|
+
var InvalidHostLabel = class extends Error {
|
|
1264
|
+
id;
|
|
1265
|
+
label;
|
|
1266
|
+
field;
|
|
1267
|
+
constructor(id, label, field) {
|
|
1268
|
+
super(`'${id}' lists '${label}' in ${field}, which is not a host label it can add: each entry is one lowercase label under the stage's domain ('rest', 'www') — no '*', no dots — listed once, and not the construct's own label. Fix or remove the entry.`);
|
|
1269
|
+
this.id = id;
|
|
1270
|
+
this.label = label;
|
|
1271
|
+
this.field = field;
|
|
1272
|
+
this.name = "InvalidHostLabel";
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
/** A wildcard site with aliases or redirects. */
|
|
1276
|
+
var WildcardSiteCannotHaveAliases = class extends Error {
|
|
1277
|
+
id;
|
|
1278
|
+
constructor(id) {
|
|
1279
|
+
super(`'${id}' answers on every subdomain, so it has no single host for an alias to repeat or a redirect to point at. Drop \`aliases\` and \`redirects\`, or give the site a subdomain of its own.`);
|
|
1280
|
+
this.id = id;
|
|
1281
|
+
this.name = "WildcardSiteCannotHaveAliases";
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
/** One label listed as both an alias and a redirect. */
|
|
1285
|
+
var HostLabelBothAliasAndRedirect = class extends Error {
|
|
1286
|
+
id;
|
|
1287
|
+
label;
|
|
1288
|
+
constructor(id, label) {
|
|
1289
|
+
super(`'${id}' lists '${label}' in both aliases and redirects, but a host either serves the site or sends the browser elsewhere. Keep it in one of the two.`);
|
|
1290
|
+
this.id = id;
|
|
1291
|
+
this.label = label;
|
|
1292
|
+
this.name = "HostLabelBothAliasAndRedirect";
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
/**
|
|
1296
|
+
* What a construct's aliases and redirects have to be, checked where it is
|
|
1297
|
+
* constructed.
|
|
1298
|
+
*
|
|
1299
|
+
* @throws {WildcardSiteCannotHaveAliases} on a wildcard site with either
|
|
1300
|
+
* @throws {HostLabelBothAliasAndRedirect} when a label is in both lists
|
|
1301
|
+
* @throws {InvalidHostLabel} for `'*'`, a dot, a repeat, or its own label
|
|
1302
|
+
*/
|
|
1303
|
+
function assertHostLabels(source) {
|
|
1304
|
+
const { primary, aliases, redirects } = hostLabels(source);
|
|
1305
|
+
if (aliases.length === 0 && redirects.length === 0) return;
|
|
1306
|
+
if (primary === "*") throw new WildcardSiteCannotHaveAliases(source.id);
|
|
1307
|
+
for (const label of aliases) if (redirects.includes(label)) throw new HostLabelBothAliasAndRedirect(source.id, label);
|
|
1308
|
+
const seen = /* @__PURE__ */ new Set([primary]);
|
|
1309
|
+
const check = (labels, field) => {
|
|
1310
|
+
for (const label of labels) {
|
|
1311
|
+
if (!LABEL$1.test(label) || seen.has(label)) throw new InvalidHostLabel(source.id, label, field);
|
|
1312
|
+
seen.add(label);
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
check(aliases, "aliases");
|
|
1316
|
+
check(redirects, "redirects");
|
|
1317
|
+
}
|
|
1318
|
+
//#endregion
|
|
1236
1319
|
//#region src/inbox.ts
|
|
1237
1320
|
/** The event type a received message is announced as on its inbox's topic. */
|
|
1238
1321
|
const INBOX_EVENT = "email.received";
|
|
@@ -1542,18 +1625,21 @@ exports.CLIENT_IP_HEADER = CLIENT_IP_HEADER;
|
|
|
1542
1625
|
exports.DATABASE_FOLDERS = DATABASE_FOLDERS;
|
|
1543
1626
|
exports.DEFAULT_DERIVED_DAYS = DEFAULT_DERIVED_DAYS;
|
|
1544
1627
|
exports.DEFAULT_POSTGRES_VERSION = DEFAULT_POSTGRES_VERSION;
|
|
1628
|
+
exports.DEFAULT_SENDER = DEFAULT_SENDER;
|
|
1545
1629
|
exports.DEFAULT_STAGE_URL = DEFAULT_STAGE_URL;
|
|
1546
1630
|
exports.DERIVED_PREFIX = DERIVED_PREFIX;
|
|
1547
1631
|
exports.DERIVES_FROM = DERIVES_FROM;
|
|
1548
1632
|
exports.EDGE_TOKEN_HEADER = EDGE_TOKEN_HEADER;
|
|
1549
1633
|
exports.EDGE_TOKEN_KEY = EDGE_TOKEN_KEY;
|
|
1550
1634
|
exports.FILE_SERVER_SUFFIX = FILE_SERVER_SUFFIX;
|
|
1635
|
+
exports.HostLabelBothAliasAndRedirect = HostLabelBothAliasAndRedirect;
|
|
1551
1636
|
exports.IMAGE_ORIGINS_KEY = IMAGE_ORIGINS_KEY;
|
|
1552
1637
|
exports.INBOX_EVENT = INBOX_EVENT;
|
|
1553
1638
|
exports.INBOX_MESSAGES_PREFIX = INBOX_MESSAGES_PREFIX;
|
|
1554
1639
|
exports.IllegalDerivation = IllegalDerivation;
|
|
1555
1640
|
exports.InvalidApiGatewayWebSocketUrl = InvalidApiGatewayWebSocketUrl;
|
|
1556
1641
|
exports.InvalidConstructId = InvalidConstructId;
|
|
1642
|
+
exports.InvalidHostLabel = InvalidHostLabel;
|
|
1557
1643
|
exports.KMS_SCHEME = KMS_SCHEME;
|
|
1558
1644
|
exports.MIGRATIONS_ROOT = MIGRATIONS_ROOT;
|
|
1559
1645
|
exports.NoUrlForStage = NoUrlForStage;
|
|
@@ -1564,8 +1650,10 @@ exports.SECRET_SYMBOLS = SECRET_SYMBOLS;
|
|
|
1564
1650
|
exports.TELEMETRY_KEYS = TELEMETRY_KEYS;
|
|
1565
1651
|
exports.UnknownParent = UnknownParent;
|
|
1566
1652
|
exports.WILDCARD_SUBDOMAIN = WILDCARD_SUBDOMAIN;
|
|
1653
|
+
exports.WildcardSiteCannotHaveAliases = WildcardSiteCannotHaveAliases;
|
|
1567
1654
|
exports.apiGatewayWebSocketUrl = apiGatewayWebSocketUrl;
|
|
1568
1655
|
exports.assertDerivations = assertDerivations;
|
|
1656
|
+
exports.assertHostLabels = assertHostLabels;
|
|
1569
1657
|
exports.bucketExpiry = bucketExpiry;
|
|
1570
1658
|
exports.cacheTable = cacheTable;
|
|
1571
1659
|
exports.canonicalId = canonicalId;
|
|
@@ -1579,10 +1667,12 @@ exports.environmentCase = environmentCase;
|
|
|
1579
1667
|
exports.externalApiUrl = externalApiUrl;
|
|
1580
1668
|
exports.fileServerName = fileServerName;
|
|
1581
1669
|
exports.fileServerSurfaceId = fileServerSurfaceId;
|
|
1670
|
+
exports.hostLabels = hostLabels;
|
|
1582
1671
|
exports.imageOriginSources = imageOriginSources;
|
|
1583
1672
|
exports.imageOrigins = imageOrigins;
|
|
1584
1673
|
exports.inboxRecipient = inboxRecipient;
|
|
1585
1674
|
exports.isDerived = isDerived;
|
|
1675
|
+
exports.isHostedDeclaration = isHostedDeclaration;
|
|
1586
1676
|
exports.isPublicDeclaration = isPublicDeclaration;
|
|
1587
1677
|
exports.isWebOrigin = isWebOrigin;
|
|
1588
1678
|
exports.isWildcardSite = isWildcardSite;
|
|
@@ -1600,6 +1690,7 @@ exports.receiptRecipients = receiptRecipients;
|
|
|
1600
1690
|
exports.schemeBase = schemeBase;
|
|
1601
1691
|
exports.scopedName = scopedName;
|
|
1602
1692
|
exports.seedFolder = seedFolder;
|
|
1693
|
+
exports.senderAddress = senderAddress;
|
|
1603
1694
|
exports.serviceKey = serviceKey;
|
|
1604
1695
|
exports.trustsOrigin = trustsOrigin;
|
|
1605
1696
|
exports.wildcardDomainOf = wildcardDomainOf;
|