8000 Replacing `R.union()` by RobinTail · Pull Request #2599 · RobinTail/express-zod-api · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replacing R.union() #2599

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

Merged
merged 3 commits into from
May 2, 2025
Merged

Replacing R.union() #2599

merged 3 commits into from
May 2, 2025

Conversation

RobinTail
Copy link
Owner
 ✓ bench/experiment.bench.ts > Experiment for key lookup 4612ms
     name               hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · set      4,577,119.53  0.0002  0.7375  0.0002  0.0002  0.0003  0.0003  0.0006  ±0.87%  2288560   fastest
   · R.union  2,958,612.29  0.0003  0.2822  0.0003  0.0003  0.0004  0.0006  0.0007  ±0.83%  1479307

 BENCH  Summary

  set - bench/experiment.bench.ts > Experiment for key lookup
    1.55x faster than R.union

@RobinTail RobinTail added the refactoring The better way to achieve the same result label May 2, 2025
@RobinTail RobinTail added this to the v24 milestone May 2, 2025
Copy link
coveralls-official bot commented May 2, 2025

Coverage Status

coverage: 100.0%. remained the same
when pulling 067c473 on no-r-union
into efd7d58 on make-v24.

@RobinTail RobinTail marked this pull request as ready for review May 2, 2025 13:34
Copy link
Owner Author
@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

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

ok

@RobinTail RobinTail merged commit 5a4d1c6 into make-v24 May 2, 2025
12 checks passed
@RobinTail RobinTail deleted the no-r-union branch May 2, 2025 13:39
RobinTail added a commit that referenced this pull request May 28, 2025
Related to #2550

## Dedication


![image](https://github.com/user-attachments/assets/0bf05104-d126-4e4b-aa6f-354292ff8dd5)

Ashley Burton was a 37 years young black transgender woman, a
hairstylist and a makeup artist in Atlanta.
She was shot to death at her apartment complex April 11th 2023. 
Her body was found shortly after 4:30 a.m. in the breezeway of her
building.

> She ran out of the house, hollering and screaming, beating on doors.
> This got to be personal. You shot her in her house, then you followed
her outside and shot her.

— _her cousin Ivory Carter told Atlanta TV station WXIA_.

Burton and Carter grew up together in South Carolina.

> She was a sweetheart, she wasn’t nasty. She wasn’t disrespectful. She
just wanted to live her life.
> I’m tired of all these incidents with transgender women just being
pushed up under the rug. We are human beings.

— _Carter said_.

Patrick Burton, the victim’s brother, told Atlanta station WAGA that
“Ashley was very loved all the way across the board, like from South
Carolina to Atlanta.”

Darius Mills, 31, was arrested in June in connection with the crime. He
faces charges of murder, armed robbery, possession of a firearm by a
convicted felon, and possession of a firearm during the commission of a
felony.

https://www.advocate.com/crime/ashley-burton-trans-woman-death

Transgender women suffer [too
frequently](https://www.congress.gov/118/meeting/house/117016/documents/HMKP-118-JU00-20240321-SD015.pdf)
from transphobic violence and cruelty, being the less protected social
group. I'd like to raise an awareness of this problem. Humans should be
creators — not killers. But most importantly, I want every transgender
girl to have an opportunity to create applications quickly and, in
general, learn to write code easily in order to receive job offers and
leave dangerously transphobic territories for more favorable and
civilized ones, and live happily there. Protect transgender women.

## Modern impact


![image](https://github.com/user-attachments/assets/e8f1854d-8581-45f6-8825-9d8f329e8320)

The Trump administration's policies have significantly impacted
transgender individuals, particularly those who are most vulnerable, by
dismantling protections and fostering environments that increase the
risk of discrimination and violence. Here's an overview of how these
policies have affected the transgender community:

### 1. Executive Order 14168: Erasure of Transgender Recognition

On January 20, 2025, President Trump signed Executive Order 14168,
titled "Defending Women from Gender Ideology Extremism and Restoring
Biological Truth to the Federal Government." This order mandates federal
agencies to recognize only two sexes, male and female, determined at
birth, effectively erasing federal recognition of transgender
identities. It also prohibits the use of gender identity in federal
documentation and policies, impacting areas such as passports, housing,
and healthcare. ([Executive Order
14168](https://en.wikipedia.org/wiki/Executive_Order_14168?utm_source=chatgpt.com),
[Trump Administration Moves to Reject Transgender Identity, Rights |
Human Rights
Watch](https://www.hrw.org/news/2025/01/23/trump-administration-moves-reject-transgender-identity-rights?utm_source=chatgpt.com))

### 2. Healthcare Discrimination and Denial of Gender-Affirming Care

The administration rolled back protections under the Affordable Care Act
that previously prohibited discrimination based on gender identity. This
change allows healthcare providers and insurers to deny gender-affirming
treatments, such as hormone therapy and surgeries, which are vital for
the well-being of transgender individuals. ([Trump administration
reverses health protections for transgender people | Trump
administration | The
Guardian](https://www.theguardian.com/us-news/2020/jun/12/trump-transgender-lgbt-healthcare-protections?utm_source=chatgpt.com))

### 3. Restrictions on Access to Shelters

The Department of Housing and Urban Development (HUD) proposed revisions
to the Equal Access Rule, permitting federally funded shelters to deny
access to transgender individuals based on their sex assigned at birth.
This policy change increases the risk of homelessness and exposure to
violence for transgender people seeking safe shelter. ([The Dire
Consequences of the Trump Administration’s Attack on Transgender
People’s Access to Shelters - Center for American
Progress](https://www.americanprogress.org/article/dire-consequences-trump-administrations-attack-transgender-peoples-access-shelters/?utm_source=chatgpt.com))

### 4. Transgender Individuals in the Prison System

Under Executive Order 14168, the Bureau of Prisons is required to house
incarcerated individuals based on their sex assigned at birth, not their
gender identity. This policy has led to transgender women being placed
in men's prisons, where they face heightened risks of sexual assault and
abuse. Additionally, access to gender-affirming healthcare in prisons
has been curtailed. ([Executive Order
14168](https://en.wikipedia.org/wiki/Executive_Order_14168?utm_source=chatgpt.com),
[Trump Administration Moves to Reject Transgender Identity, Rights |
Human Rights
Watch](https://www.hrw.org/news/2025/01/23/trump-administration-moves-reject-transgender-identity-rights?utm_source=chatgpt.com))

### 5. Defunding of LGBTQ+ Support Services

The administration proposed terminating federal funding for specialized
services of the 988 Suicide & Crisis Lifeline that cater to LGBTQ+
youth. These services have been crucial in providing crisis support to
over 1.2 million individuals, and their removal could exacerbate mental
health challenges within the community. ([RFK Jr. Reportedly Wants to
Defund the National Suicide Hotline for LGBTQ+
Youth](https://www.them.us/story/rfk-jr-hhs-suicide-hotline-lgbtq-youth-rfk-jr-trump-administration?utm_source=chatgpt.com))

### 6. Increased Violence Against Transgender Individuals

The rollback of protections and the promotion of policies that
invalidate transgender identities have coincided with a rise in violence
against transgender people. In 2023, at least 29 transgender and
nonbinary individuals were reported killed in the U.S., with many cases
involving women of color. Advocacy groups suggest that the actual number
may be higher due to underreporting and misidentification. ([Trump
Administration Doubles Down on Trans Discrimination | Human Rights
Watch](https://www.hrw.org/news/2020/06/25/trump-administration-doubles-down-trans-discrimination?utm_source=chatgpt.com))

In summary, the Trump administration's policies have systematically
undermined the rights and safety of transgender individuals, leading to
increased discrimination, denial of essential services, and a rise in
violence against the community.

## Summary

Version 24 introduces initial support for Zod 4, requiring at least
version `3.25.1`, but due to the special versioning strategy of Zod all
imports must be changed to `zod/v4`. The framework simplifies the
`IOSchema` type to explicitly require schemas that resolve to objects.
`Documentation` generation now uses Zod 4’s native `toJSONSchema()`
method, with custom overrides to align with OpenAPI 3.1, and the
`numericRange` option has been removed. The `Depicter` type changed its
signature, and `brandHandling` is now implemented as a postprocessing
step. The `optionalPropStyle` option was removed from the `Integration`
constructor. Using the Zod's internal storage for examples: method
`.example()` changed its argument from `z.input<>` to `z.output<>` which
is breaking for transforming schemas, so that examples of its input side
must be set bef
8000
ore the transformation. The `getExamples()` helper
removed in favour of `.meta()?.examples`.

### Contains

- #2537 
  - #2549 
  - #2560 
    - #2561
  - #2573 
  - #2574 - decided to split and rethink
  - #2575 
  - #2578
  - #2579
  - #2580 
  - #2584
  - #2589
  - #2600 
  - #2604 
    - #2607 
- #2547 
  - #2553 
  - #2557 
    - #2593
  - #2559 
  - #2556 
  - #2572 
  - #2581 
  - #2582
  - #2583 
- Chores on registries:
  - #2562 
- need to start over keeping immutability in mind and preserving all
meta when adding new ones
  - #2563 - postponed
  - #2566 - idea rejected
  - #2564 
  - #2565 
  - #2567 
  - #2643
  - #2632 
  - #2644
- Chores on migration:
  - #2585 
  - #2586 
- #2595 
  - #2598
  - #2599 
- #2631
- #2633 
- #2637
- #2651 
- #2649 
  - #2652 
- #2656
- #2664 
  - 57d08c9
- #2665 
- #2666 
- #2668 
- #2670 

### External bugs

![bug on
buggy](https://github.com/user-attachments/assets/e4eefacc-2bb6-4db7-9e6a-2641c582f13a)

- colinhacks/zod#4234
- colinhacks/zod#4228
- colinhacks/zod#4159
- colinhacks/zod#4152
- colinhacks/zod#4224
- colinhacks/zod#4274
- colinhacks/zod#4275 — This one especially
freaks me out
- colinhacks/zod#4267
- colinhacks/zod#4309 - important
- colinhacks/zod#4317
- colinhacks/zod#4318
- colinhacks/zod#4320
- colinhacks/zod#4322

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced `ez.buffer()` schema for Node.js Buffer validation,
replacing `ez.file()`.
- Enhanced OpenAPI documentation generation using Zod 4’s native
`toJSONSchema()` with improved depiction helpers.
- Added JSON Schema flattening utilities for improved schema processing.
- Improved endpoint result handling with discriminated result types and
integrated output example registration.

- **Breaking Changes**
- Removed simultaneous support for Zod 3 and 4; all imports now use
`zod/v4`.
- Deprecated `ez.file()` schema removed; replaced by `z.string()`,
`z.base64()`, or `ez.buffer()`.
  - Simplified `IOSchema` to accept only object schemas.
- `.example()` now aliases `.meta({ examples })` with updated semantics
and example placement.
- Removed `numericRange` and `optionalPropStyle` options from
constructors.
- Branding refactored to use internal Zod checks instead of metadata
cloning.
- Endpoint request type detection updated to use brand-based schema
identification.
  - Refined type signatures and removed deprecated helpers and types.

- **Bug Fixes**
- Improved error handling and diagnostics for schema validation,
including cycle detection.
  - Fixed example metadata immutability and accumulation.
- Enhanced output example extraction and registration via Zod global
registry.

- **Documentation**
- Updated README and CHANGELOG with new features and migration guidance.
- Clarified and improved code samples, especially for date handling and
non-JSON responses.
- Strengthened OpenAPI schema generation with stricter validation,
examples, and additional properties control.

- **Style**
- Migrated all code and tests to use `zod/v4` imports and updated schema
definitions.
- Simplified schema walking and depiction using Zod v4 JSON schema
output and overrides.
  - Consolidated and cleaned middleware and factory type constraints.
- Refactored branding, metadata, and example handling for better
maintainability.

- **Tests**
- Added tests for buffer schema, deep schema checks, JSON schema
helpers, migration rules, and environment validations.
- Removed tests for deprecated features and schemas such as `ez.file()`.
- Enhanced coverage for error classes, diagnostics, branding
persistence, and example extraction.
- Updated snapshots and assertions to align with Zod v4 internals and
behaviors.

- **Chores**
- Updated CI workflows to target new branches and remove legacy
triggers.
  - Added `pretest` script for type checking before tests.
  - Updated security policy to support version 24.x.x.
  - Rewrote migration ESLint rule for v24 API and schema changes.
- Improved Vitest serializers for Zod errors and schemas with brand
metadata.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring The better way to achieve the same result
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0