Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: netlify/functions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.1
Choose a base ref
...
head repository: netlify/functions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.2
Choose a head ref
  • 7 commits
  • 6 files changed
  • 3 contributors

Commits on Mar 4, 2025

  1. chore(deps): update dependency typescript to v5 (#555)

    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [typescript](https://www.typescriptlang.org/)
    ([source](https://redirect.github.com/microsoft/TypeScript)) | [`^4.4.4`
    -> `^5.0.0`](https://renovatebot.com/diffs/npm/typescript/4.9.5/5.7.3) |
    [![age](https://developer.mend.io/api/mc/badges/age/npm/typescript/5.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typescript/5.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typescript/4.9.5/5.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typescript/4.9.5/5.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>microsoft/TypeScript (typescript)</summary>
    
    ###
    [`v5.7.3`](https://redirect.github.com/microsoft/TypeScript/compare/v5.7.2...a5e123d9e0690fcea92878ea8a0a382922009fc9)
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.7.2...v5.7.3)
    
    ###
    [`v5.7.2`](https://redirect.github.com/microsoft/TypeScript/compare/v5.6.3...d701d908d534e68cfab24b6df15539014ac348a3)
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.6.3...v5.7.2)
    
    ###
    [`v5.6.3`](https://redirect.github.com/microsoft/TypeScript/compare/v5.6.2...d48a5cf89a62a62d6c6ed53ffa18f070d9458b85)
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.6.2...v5.6.3)
    
    ###
    [`v5.6.2`](https://redirect.github.com/microsoft/TypeScript/compare/v5.5.4...a7e3374f13327483fbe94e32806d65785b0b6cda)
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.5.4...v5.6.2)
    
    ###
    [`v5.5.4`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.5.4):
    TypeScript 5.5.4
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.5.3...v5.5.4)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for TypeScript v5.5.4
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.4%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.3%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.2%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.1%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    (soon!)
    
    ###
    [`v5.5.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.5.3):
    TypeScript 5.5.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.5.2...v5.5.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for TypeScript v5.5.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.3%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.2%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.1%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.5.2`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.5.2):
    TypeScript 5.5
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.4.5...v5.5.2)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for TypeScript v5.5.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.2%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.1%22+is%3Aclosed+).
    - [fixed issues query for TypeScript v5.5.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    
    ###
    [`v5.4.5`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.4.5):
    TypeScript 5.4.5
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.4.4...v5.4.5)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.4.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.4
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.4%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.5
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.5%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.4.4`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.4.4):
    TypeScript 5.4.4
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.4.3...v5.4.4)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.4.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.4
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.4%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.4.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.4.3):
    TypeScript 5.4.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.4.2...v5.4.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.4.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.4.2`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.4.2):
    TypeScript 5.4
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.3.3...v5.4.2)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.4.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.4.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.3.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.3.3):
    TypeScript 5.3.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.3.2...v5.3.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.3.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.3.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.3.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.3.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.3%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.3.2`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.3.2):
    TypeScript 5.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.2.2...v5.3.2)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.3.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.3.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.3.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.3.2%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.2.2`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.2.2):
    TypeScript 5.2
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.1.6...v5.2.2)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.2.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.2.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.2.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.2.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.2.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.2.2%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.1.6`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.1.6):
    TypeScript 5.1.6
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.1.5...v5.1.6)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript v5.1.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.3%22+is%3Aclosed+).
    - (5.1.4 [intentionally
    skipped](https://redirect.github.com/microsoft/TypeScript/issues/53031#issuecomment-1610038922))
    - [fixed issues query for Typescript v5.1.5
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.5%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.6
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.6%22+is%3Aclosed+).
    
    Downloads are available on
    [npm](https://www.npmjs.com/package/typescript)
    
    ###
    [`v5.1.5`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.1.5):
    TypeScript 5.1.5
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.1.3...v5.1.5)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript v5.1.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.1.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.3%22+is%3Aclosed+).
    - (5.1.4 [intentionally
    skipped](https://redirect.github.com/microsoft/TypeScript/issues/53031#issuecomment-1610038922))
    - [fixed issues query for Typescript v5.1.5
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.5%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.1.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.1.3):
    TypeScript 5.1.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.0.4...v5.1.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript 5.1.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.1.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.1.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.1.3%22+is%3Aclosed+).
    
    Downloads are available on:
    
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.0.4`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.0.4):
    TypeScript 5.0.4
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.0.3...v5.0.4)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript v5.0.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.3%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.4
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.4%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.0.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.0.3):
    TypeScript 5.0.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.0.2...v5.0.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript v5.0.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.0.3%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    ###
    [`v5.0.2`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.0.2):
    TypeScript 5.0
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v4.9.5...v5.0.2)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/).
    
    For the complete list of fixed issues, check out the
    
    - [fixed issues query for Typescript v5.0.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript v5.0.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=is%3Aissue+milestone%3A%22TypeScript+5.0.2%22+is%3Aclosed+).
    
    Downloads are available on:
    
    -   [npm](https://www.npmjs.com/package/typescript)
    - [NuGet
    package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "* 0-3 * * 1" (UTC), Automerge - At
    any time (no schedule defined).
    
    🚦 **Automerge**: Disabled by config. Please merge this manually once you
    are satisfied.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    🔕 **Ignore**: Close this PR and you won't be reminded about this update
    again.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR was generated by [Mend Renovate](https://mend.io/renovate/).
    View the [repository job
    log](https://developer.mend.io/github/netlify/functions).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44MC4wIiwidXBkYXRlZEluVmVyIjoiMzkuOTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIiwiamF2YXNjcmlwdCJdfQ==-->
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bb1fb1c View commit details
  2. fix: if the purge api call fails, include the api response body in th…

    …e thrown error's message (#571)
    JakeChampion authored Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e01516d View commit details

Commits on Mar 10, 2025

  1. chore(deps): update dependency publint to v0.3.8 (#577)

    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [publint](https://publint.dev)
    ([source](https://redirect.github.com/publint/publint/tree/HEAD/packages/publint))
    | [`0.3.7` ->
    `0.3.8`](https://renovatebot.com/diffs/npm/publint/0.3.7/0.3.8) |
    [![age](https://developer.mend.io/api/mc/badges/age/npm/publint/0.3.8?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/publint/0.3.8?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/publint/0.3.7/0.3.8?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/publint/0.3.7/0.3.8?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>publint/publint (publint)</summary>
    
    ###
    [`v0.3.8`](https://redirect.github.com/publint/publint/blob/HEAD/packages/publint/CHANGELOG.md#038)
    
    [Compare
    Source](https://redirect.github.com/publint/publint/compare/publint@0.3.7...publint@0.3.8)
    
    ##### Patch Changes
    
    - Support passing a tarball path to the publint CLI. This allows to
    easily lint any tarball files at hand.
    ([#&#8203;166](https://redirect.github.com/publint/publint/pull/166))
    
        ```bash
        npx publint ./mylib-1.0.0.tgz
        ```
    
    - The `publint` API now returns a `pkg` object as a convenience to pass
    it to `formatMessage`
    ([#&#8203;166](https://redirect.github.com/publint/publint/pull/166))
    
    - Updated dependencies
    \[[`02d169b`](https://redirect.github.com/publint/publint/commit/02d169b1c1bb4739427b261dbc6cccdea37abdca)]:
    -
    [@&#8203;publint/pack](https://redirect.github.com/publint/pack)[@&#8203;0](https://redirect.github.com/0).1.2
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "* 0-3 * * 1" (UTC), Automerge - At
    any time (no schedule defined).
    
    🚦 **Automerge**: Enabled.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    🔕 **Ignore**: Close this PR and you won't be reminded about this update
    again.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR was generated by [Mend Renovate](https://mend.io/renovate/).
    View the [repository job
    log](https://developer.mend.io/github/netlify/functions).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODUuNCIsInVwZGF0ZWRJblZlciI6IjM5LjE4NS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJqYXZhc2NyaXB0Il19-->
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d540cc6 View commit details
  2. chore(deps): update dependency typescript to v5.8.2 (#578)

    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [typescript](https://www.typescriptlang.org/)
    ([source](https://redirect.github.com/microsoft/TypeScript)) | [`5.7.2`
    -> `5.8.2`](https://renovatebot.com/diffs/npm/typescript/5.7.2/5.8.2) |
    [![age](https://developer.mend.io/api/mc/badges/age/npm/typescript/5.8.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typescript/5.8.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typescript/5.7.2/5.8.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typescript/5.7.2/5.8.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>microsoft/TypeScript (typescript)</summary>
    
    ###
    [`v5.8.2`](https://redirect.github.com/microsoft/TypeScript/compare/v5.7.3...beb69e4cdd61b1a0fd9ae21ae58bd4bd409d7217)
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.7.3...v5.8.2)
    
    ###
    [`v5.7.3`](https://redirect.github.com/microsoft/TypeScript/releases/tag/v5.7.3):
    TypeScript 5.7.3
    
    [Compare
    Source](https://redirect.github.com/microsoft/TypeScript/compare/v5.7.2...v5.7.3)
    
    For release notes, check out the [release
    announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/).
    
    - [fixed issues query for Typescript 5.7.0
    (Beta)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.7.0%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.7.1
    (RC)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.7.1%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.7.2
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.7.2%22+is%3Aclosed+).
    - [fixed issues query for Typescript 5.7.3
    (Stable)](https://redirect.github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.7.2%22+is%3Aclosed+).
    
    Downloads are available on
    [npm](https://www.npmjs.com/package/typescript)
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "* 0-3 * * 1" (UTC), Automerge - At
    any time (no schedule defined).
    
    🚦 **Automerge**: Enabled.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    🔕 **Ignore**: Close this PR and you won't be reminded about this update
    again.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR was generated by [Mend Renovate](https://mend.io/renovate/).
    View the [repository job
    log](https://developer.mend.io/github/netlify/functions).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODUuNCIsInVwZGF0ZWRJblZlciI6IjM5LjE4NS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJqYXZhc2NyaXB0Il19-->
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2d92037 View commit details

Commits on Mar 17, 2025

  1. chore(deps): update dependency publint to v0.3.9 (#580)

    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [publint](https://publint.dev)
    ([source](https://redirect.github.com/publint/publint/tree/HEAD/packages/publint))
    | [`0.3.8` ->
    `0.3.9`](https://renovatebot.com/diffs/npm/publint/0.3.8/0.3.9) |
    [![age](https://developer.mend.io/api/mc/badges/age/npm/publint/0.3.9?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/publint/0.3.9?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/publint/0.3.8/0.3.9?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/publint/0.3.8/0.3.9?slim=true)](https://docs.renovatebot.com/merge-confidence/)
    |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>publint/publint (publint)</summary>
    
    ###
    [`v0.3.9`](https://redirect.github.com/publint/publint/blob/HEAD/packages/publint/CHANGELOG.md#039)
    
    [Compare
    Source](https://redirect.github.com/publint/publint/compare/publint@0.3.8...publint@0.3.9)
    
    ##### Patch Changes
    
    - Support the `formatMessage` utility in the browser. It has a new
    `color: 'html'` option to highlight important parts with `<strong>` tags
    instead of ANSI colors. It also has a new `reference: boolean` option so
    the messages are worded in reference of the message location.
    ([`e1cfef0`](https://redirect.github.com/publint/publint/commit/e1cfef0b9b49c1eb55c9679308d761b7ce211fc2))
    
    - If `formatMessage` is passed a `package.json` object with missing
    keys, the message part that references the value will now fallback to
    `"undefined"` instead of completely erroring out.
    ([`45962d1`](https://redirect.github.com/publint/publint/commit/45962d1e39250569aa877eb3568725bee7d5b434))
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: Branch creation - "* 0-3 * * 1" (UTC), Automerge - At
    any time (no schedule defined).
    
    🚦 **Automerge**: Enabled.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
    rebase/retry checkbox.
    
    🔕 **Ignore**: Close this PR and you won't be reminded about this update
    again.
    
    ---
    
    - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
    this box
    
    ---
    
    This PR was generated by [Mend Renovate](https://mend.io/renovate/).
    View the [repository job
    log](https://developer.mend.io/github/netlify/functions).
    
    <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDAuMCIsInVwZGF0ZWRJblZlciI6IjM5LjIwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJqYXZhc2NyaXB0Il19-->
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    aad5814 View commit details
  2. fix: only purge alias by default if the purgeCache function is called…

    … within a deployed function (#576)
    
    linear ticket: https://linear.app/netlify/issue/RUN-1417/
    
    This patch will ensure that when `purgeCache` is called within a
    deployed function, the purge will happen for the deployment which
    contains the function. I.E. If it's the production deployment, it purges
    production. If it's a branch deployment, it purges the branch. If it's a
    deploy-preview, it purges the deploy-preview.
    JakeChampion authored Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    964b0a2 View commit details
  3. chore(main): release 3.0.2 (#575)

    🤖 I have created a release *beep* *boop*
    ---
    
    
    ## [3.0.2](v3.0.1...v3.0.2)
    (2025-03-17)
    
    
    ### Bug Fixes
    
    * if the purge api call fails, include the api response body in the
    thrown error's message
    ([#571](#571))
    ([e01516d](e01516d))
    * only purge alias by default if the purgeCache function is called
    within a deployed function
    ([#576](#576))
    ([964b0a2](964b0a2))
    
    ---
    This PR was generated with [Release
    Please](https://github.com/googleapis/release-please). See
    [documentation](https://github.com/googleapis/release-please#release-please).
    
    Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
    token-generator-app[bot] authored Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c4f9866 View commit details
Showing with 210 additions and 40 deletions.
  1. +1 −0 .eslintrc.js
  2. +8 −0 CHANGELOG.md
  3. +24 −24 package-lock.json
  4. +2 −2 package.json
  5. +146 −4 src/lib/purge_cache.test.ts
  6. +29 −10 src/lib/purge_cache.ts
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ module.exports = {
extends: '@netlify/eslint-config-node',
rules: {
'max-statements': 'off',
'max-lines': 'off',
},
overrides: [
...overrides,
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [3.0.2](https://github.com/netlify/functions/compare/v3.0.1...v3.0.2) (2025-03-17)


### Bug Fixes

* if the purge api call fails, include the api response body in the thrown error's message ([#571](https://github.com/netlify/functions/issues/571)) ([e01516d](https://github.com/netlify/functions/commit/e01516df909fc0e9ba9c553655cb7df8b5b27e51))
* only purge alias by default if the purgeCache function is called within a deployed function ([#576](https://github.com/netlify/functions/issues/576)) ([964b0a2](https://github.com/netlify/functions/commit/964b0a27ee092f9cc5fd6726adb15439e3b9e74e))

## [3.0.1](https://github.com/netlify/functions/compare/v3.0.0...v3.0.1) (2025-03-04)


48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
}
}
},
"version": "3.0.1",
"version": "3.0.2",
"description": "JavaScript utilities for Netlify Functions",
"files": [
"dist/**/*.js",
@@ -88,7 +88,7 @@
"semver": "^7.5.4",
"tsd": "^0.31.0",
"tsup": "^8.0.2",
"typescript": "^4.4.4",
"typescript": "^5.0.0",
"vitest": "^2.1.8"
},
"engines": {
150 changes: 146 additions & 4 deletions src/lib/purge_cache.test.ts
Original file line number Diff line number Diff line change
@@ -58,9 +58,111 @@ test('Calls the purge API endpoint and returns `undefined` if the operation was
expect(mockAPI.fulfilled).toBeTruthy()
})

test('Throws if the API response does not have a successful status code', async () => {
test('Does not default the deploy_alias field to process.env.NETLIFY_BRANCH if supplied in the options', async () => {
const mockSiteID = '123456789'
const mockToken = '1q2w3e4r5t6y7u8i9o0p'

process.env.NETLIFY_PURGE_API_TOKEN = mockToken
process.env.SITE_ID = mockSiteID
process.env.NETLIFY_BRANCH = 'main'

const mockAPI = new MockFetch().post({
body: (payload: string) => {
const data = JSON.parse(payload)

expect(data.site_id).toBe(mockSiteID)
expect(data.deploy_alias).toBe('test')
},
headers: { Authorization: `Bearer ${mockToken}` },
method: 'post',
response: new Response(null, { status: 202 }),
url: `https://api.netlify.com/api/v1/purge`,
})
// eslint-disable-next-line unicorn/consistent-function-scoping
const myFunction = async () => {
await purgeCache({ deployAlias: 'test' })
}

globalThis.fetch = mockAPI.fetcher

const response = await invokeLambda(myFunction)

expect(response).toBeUndefined()
expect(mockAPI.fulfilled).toBeTruthy()
})

test('Defaults the deploy_alias field to process.env.NETLIFY_BRANCH if not running locally', async () => {
const mockSiteID = '123456789'
const mockToken = '1q2w3e4r5t6y7u8i9o0p'

process.env.NETLIFY_PURGE_API_TOKEN = mockToken
process.env.SITE_ID = mockSiteID
process.env.NETLIFY_BRANCH = 'main'

const mockAPI = new MockFetch().post({
body: (payload: string) => {
const data = JSON.parse(payload)

expect(data.site_id).toBe(mockSiteID)
expect(data.deploy_alias).toBe(process.env.NETLIFY_BRANCH)
},
headers: { Authorization: `Bearer ${mockToken}` },
method: 'post',
response: new Response(null, { status: 202 }),
url: `https://api.netlify.com/api/v1/purge`,
})
// eslint-disable-next-line unicorn/consistent-function-scoping
const myFunction = async () => {
await purgeCache()
}

globalThis.fetch = mockAPI.fetcher

const response = await invokeLambda(myFunction)

expect(response).toBeUndefined()
expect(mockAPI.fulfilled).toBeTruthy()
})

test('Does not default the deploy_alias field to process.env.NETLIFY_BRANCH when running locally', async () => {
const mockSiteID = '123456789'
const mockToken = '1q2w3e4r5t6y7u8i9o0p'

process.env.NETLIFY_PURGE_API_TOKEN = mockToken
process.env.SITE_ID = mockSiteID
process.env.NETLIFY_LOCAL = 'true'
process.env.NETLIFY_BRANCH = 'main'

const mockAPI = new MockFetch().post({
body: (payload: string) => {
const data = JSON.parse(payload)

expect(data.site_id).toBe(mockSiteID)
expect(data.deploy_alias).toBeUndefined()
},
headers: { Authorization: `Bearer ${mockToken}` },
method: 'post',
response: new Response(null, { status: 202 }),
url: `https://api.netlify.com/api/v1/purge`,
})
// eslint-disable-next-line unicorn/consistent-function-scoping
const myFunction = async () => {
await purgeCache()
}

globalThis.fetch = mockAPI.fetcher

const response = await invokeLambda(myFunction)

expect(response).toBeUndefined()
expect(mockAPI.fulfilled).toBeTruthy()
})

test('Throws an error if the API response does not have a successful status code, using the response body as part of the error message', async () => {
if (!hasFetchAPI) {
console.warn('Skipping test requires the fetch API')

return
}

const mockSiteID = '123456789'
@@ -77,7 +179,7 @@ test('Throws if the API response does not have a successful status code', async
},
headers: { Authorization: `Bearer ${mockToken}` },
method: 'post',
response: new Response(null, { status: 500 }),
response: new Response('site not found', { status: 404 }),
url: `https://api.netlify.com/api/v1/purge`,
})
// eslint-disable-next-line unicorn/consistent-function-scoping
@@ -90,14 +192,54 @@ test('Throws if the API response does not have a successful status code', async
try {
await invokeLambda(myFunction)

throw new Error('Invocation should have failed')
expect.fail('Invocation should have failed')
} catch (error) {
expect((error as NodeJS.ErrnoException).message).toBe(
'Cache purge API call returned an unexpected status code: 500',
'Cache purge API call was unsuccessful.\nStatus: 404\nBody: site not found',
)
}
})

test('Throws if the API response does not have a successful status code, does not include the response body if it is not text', async () => {
if (!hasFetchAPI) {
console.warn('Skipping test requires the fetch API')

return
}

const mockSiteID = '123456789'
const mockToken = '1q2w3e4r5t6y7u8i9o0p'

process.env.NETLIFY_PURGE_API_TOKEN = mockToken
process.env.SITE_ID = mockSiteID

const mockAPI = new MockFetch().post({
body: (payload: string) => {
const data = JSON.parse(payload)

expect(data.site_id).toBe(mockSiteID)
},
headers: { Authorization: `Bearer ${mockToken}` },
method: 'post',
response: new Response(null, { status: 500 }),
url: `https://api.netlify.com/api/v1/purge`,
})
// eslint-disable-next-line unicorn/consistent-function-scoping
const myFunction = async () => {
await purgeCache()
}

globalThis.fetch = mockAPI.fetcher

try {
await invokeLambda(myFunction)

throw new Error('Invocation should have failed')
} catch (error) {
expect((error as NodeJS.ErrnoException).message).toBe('Cache purge API call was unsuccessful.\nStatus: 500')
}
})

test('Ignores purgeCache if in local dev with no token or site', async () => {
if (!hasFetchAPI) {
console.warn('Skipping test requires the fetch API')
Loading