8000 feat(cloudflare): add CustomHostname resource for Cloudflare for SaaS by sam-goodwin · Pull Request #436 · sam-goodwin/alchemy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(cloudflare): add CustomHostname resource for Cloudflare for SaaS #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sam-goodwin
Copy link
Owner

Implements CustomHostname resource for Cloudflare's SSL for SaaS feature:

  • Complete TypeScript interfaces following Cloudflare API spec
  • Full CRUD lifecycle with proper error handling
  • Support for SSL verification methods (HTTP, TXT, email)
  • Advanced SSL settings and custom metadata
  • Comprehensive test suite (requires SSL for SaaS account)
  • Complete documentation with examples

Closes #435

Generated with Claude Code

Implements CustomHostname resource for Cloudflare's SSL for SaaS feature:

- Complete TypeScript interfaces following Cloudflare API spec
- Full CRUD lifecycle with proper error handling
- Support for SSL verification methods (HTTP, TXT, email)
- Advanced SSL settings and custom metadata
- Comprehensive test suite (requires SSL for SaaS account)
- Complete documentation with examples

Addresses issue #435

Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
Copy link
Owner Author
@sam-goodwin sam-goodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude

also make sure to run bun check prior to pushing code to type check

or bun i to install deps

@@ -0,0 +1,187 @@
# CustomHostname

Create and manage Custom Hostnames for Cloudflare for SaaS. Custom Hostnames allow you to provide SSL certificates for your customer's domains that point to your Cloudflare zone.
Copy link
Owner Author
10000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 23 to 30
method?: "http" | "txt" | "email";

/**
* SSL certificate type
* "dv" - Domain Validated
* @default "dv"
*/
type?: "dv";
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

union types should be defined once as a standlone type for easy re-use

Comment on lines 35 to 58
settings?: {
/**
* HTTP/2 settings
* "on" - Enable HTTP/2
* "off" - Disable HTTP/2
* @default "on"
*/
http2?: "on" | "off";

/**
* TLS 1.3 settings
* "on" - Enable TLS 1.3
* "off" - Disable TLS 1.3
* @default "on"
*/
tls_1_3?: "on" | "off";

/**
* Minimum TLS version
* @default "1.2"
*/
min_tls_version?: "1.0" | "1.1" | "1.2" | "1.3";

/**
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested object types should be extracted as an interface

Comment on lines 293 to 299
// Validate required properties
if (!props.hostname) {
throw new Error("Hostname (props.hostname) is required");
}
if (!props.zone) {
throw new Error("Zone (props.zone) is required");
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can just be enforced with types, no need for runtime checks

Comment on lines +559 to +562
function doesCustomHostnameNeedUpdate(
existing: CloudflareCustomHostname,
props: CustomHostnameProps,
): boolean {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function looks like it could be simplified with a programmatic deep equals check or some equivalent

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude i changed my mind, deepEquals didn't help. Revert to just checking each field explicitly

Copy link
Contributor
@claude claude bot Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @sam-goodwin's task —— View job


Claude finished @sam-goodwin's task —— View job


✅ Task Completed: Reverted deepEquals back to explicit field checking

  • Read current custom-hostname.ts file to understand the deepEquals implementation
  • Revert the comparison function to check each field explicitly
  • Commit the changes to the PR branch

Changes Made

Successfully reverted the doesCustomHostnameNeedUpdate function from using a generic deepEquals comparison back to explicit field-by-field checking:

  1. Removed deepEquals function: Completely removed the generic deep equality checking function

  2. Explicit field validation: Rewrote the comparison logic to check each field individually:

    • Hostname comparison
    • SSL method, type, bundle_method, and wildcard settings
    • SSL advanced settings (HTTP/2, TLS 1.3, min TLS version, ciphers)
    • Custom metadata key-value pairs
  3. Clearer logic flow: The explicit approach makes it easier to understand exactly which fields are being compared and provides better debugging when updates are needed.

The changes have been committed to the PR branch with commit b9befa9.


Copy link
Contributor
claude bot commented Jun 20, 2025

Claude finished @sam-goodwin's task —— View job


✅ All PR review feedback addressed

Successfully implemented all requested changes:

Completed Tasks

  • Install dependencies with bun i
  • Read and understand the current code structure
  • Address review comment: Add link to Cloudflare documentation
  • Address review comment: Extract union types as standalone types
  • Address review comment: Extract nested object types as interfaces
  • Address review comment: Remove runtime checks in favor of type enforcement
  • Address review comment: Simplify function with programmatic deep equals check
  • Run bun check for type checking
  • Commit changes to the branch

Changes Made

  1. Documentation Link: Added link to Cloudflare for SaaS domain support in the documentation.

  2. Union Type Extraction: Extracted all union types as standalone exported types:

    • SslValidationMethod for SSL validation methods
    • SslCertificateType for SSL certificate types
    • Http2Setting for HTTP/2 settings
    • Tls13Setting for TLS 1.3 settings
    • MinTlsVersion for minimum TLS version
    • SslBundleMethod for SSL bundle methods
  3. Interface Extraction: Extracted nested SSL settings as SslAdvancedSettings interface.

  4. Runtime Validation Removal: Removed runtime property validation for hostname and zone since they're already enforced by TypeScript as required properties.

  5. Function Simplification: Replaced the complex manual comparison function with a programmatic deep equals check that compares the expected and current payloads.

  6. Type Compatibility: Fixed type compatibility issues between CustomHostnameSsl and CustomHostnameSslSettings by using consistent union types.

All changes have been type-checked and formatted according to the project's standards. The commit has been pushed to the PR branch.

Copy link
github-actions bot commented Jun 20, 2025

🚀 Website Preview Deployed

Your website preview is ready!

Preview URL:

This preview was built from commit b9befa9


🤖 This comment will be updated automatically when you push new commits to this PR.

- Add link to Cloudflare for SaaS domain 
8000
support documentation
- Extract union types as standalone exported types for reuse
- Extract nested SSL settings object as SslAdvancedSettings interface
- Remove runtime property validation (enforced by TypeScript types)
- Simplify update detection with programmatic deep equals comparison
- Fix type compatibility between CustomHostnameSsl and CustomHostnameSslSettings

Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
Copy link
pkg-pr-new bot commented Jun 20, 2025

Open in StackBlitz

npm i https://pkg.pr.new/sam-goodwin/alchemy@436

commit: b9befa9

Revert the comparison function in doesCustomHostnameNeedUpdate to use
explicit field-by-field checking instead of deepEquals approach.
This provides clearer validation logic and easier debugging.

Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloudflare Custom Hostname Resource
1 participant
0