Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hosting-export-byo-brand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/hosting': patch
---

Brand `ByoValue` with a literal-typed `byoBrand` property instead of a `unique symbol` computed key. The symbol brand referenced an unexported name in the generated API report, breaking the `check_api_changes` compile on `main`; a literal-typed discriminant is self-contained in the report. Runtime behavior of `byoSecret`/`byoConfig`/`isByoValue` is unchanged.
2 changes: 1 addition & 1 deletion packages/hosting/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const byoSecret: (secretNameOrArn: string) => ByoValue;

// @public
export type ByoValue = {
readonly [BYO_BRAND]: true;
readonly byoBrand: true;
readonly kind: 'secret' | 'config';
readonly ref: string;
};
Expand Down
16 changes: 9 additions & 7 deletions packages/hosting/src/byo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
// This module is CDK-free (just an inert marker); the CDK resolution happens in
// `factory.ts` where the construct scope exists.

/** Brand for BYO markers. `Symbol.for` so it survives across module copies. */
const BYO_BRAND = Symbol.for('@aws-amplify/hosting.byo');

/** Inert marker describing an existing store entry to wire into `environment`. */
export type ByoValue = {
readonly [BYO_BRAND]: true;
/**
* Discriminant identifying a BYO marker produced by {@link byoSecret} /
* {@link byoConfig}. A literal-typed property (rather than a `unique symbol`
* key) so the exported type is self-contained in the generated API report.
*/
readonly byoBrand: true;
/** `secret` → Secrets Manager, `config` → SSM Parameter Store. */
readonly kind: 'secret' | 'config';
/** The secret name/ARN (secret) or parameter name (config; ARNs not accepted). */
Expand All @@ -32,7 +34,7 @@ export type ByoValue = {
* ```
*/
export const byoSecret = (secretNameOrArn: string): ByoValue => ({
[BYO_BRAND]: true,
byoBrand: true,
kind: 'secret',
ref: secretNameOrArn,
});
Expand All @@ -45,7 +47,7 @@ export const byoSecret = (secretNameOrArn: string): ByoValue => ({
* @param parameterName - the parameter's name (e.g. `/my/app/flags`).
*/
export const byoConfig = (parameterName: string): ByoValue => ({
[BYO_BRAND]: true,
byoBrand: true,
kind: 'config',
ref: parameterName,
});
Expand All @@ -54,4 +56,4 @@ export const byoConfig = (parameterName: string): ByoValue => ({
export const isByoValue = (v: unknown): v is ByoValue =>
typeof v === 'object' &&
v !== null &&
(v as Record<symbol, unknown>)[BYO_BRAND] === true;
(v as Record<string, unknown>).byoBrand === true;
Loading