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
8 changes: 4 additions & 4 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cliVersion": "5.5.1",
"cliVersion": "5.7.7",
"generatorName": "fernapi/fern-typescript-sdk",
"generatorVersion": "3.66.1",
"generatorVersion": "3.69.0",
"generatorConfig": {
"namespaceExport": "Junction",
"noSerdeLayer": false,
Expand All @@ -13,10 +13,10 @@
"packageManager": "pnpm",
"testFramework": "vitest"
},
"originGitCommit": "05d79dd6ce370cbd029417f59eb71c056d94aa61",
"originGitCommit": "013d384eb55b3bae6134a907ce4c7f11837ba7d9",
"originGitCommitIsDirty": true,
"invokedBy": "ci",
"requestedVersion": "AUTO",
"ciProvider": "unknown",
"sdkVersion": "0.0.1"
"sdkVersion": "1.0.0"
}
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,19 @@ The SDK is instrumented with automatic retries with exponential backoff. A reque
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:
Which status codes are retried depends on the `retryStatusCodes` generator configuration:

**`legacy`** (current default): retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)

**`recommended`**: retries on
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)

Use the `maxRetries` request option to configure this behavior.

Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.0.0 - 2026-05-04
### Breaking Changes
* **`MealInDbBaseClientFacingSource`** now includes a required `calendarDate: string` field (YYYY-mm-dd format). Existing code that constructs or destructures this type must be updated to handle the new field.
* **`JunctionEnvironment`** URLs have changed from `tryvital.io` to `junction.com` for all four environments (`Production`, `ProductionEu`, `Sandbox`, `SandboxEu`). If you hard-coded or compared against the old URLs, update accordingly.
### Added
* **`AuthOption`** union type and **`auth`** property on `BaseClientOptions` allow per-client authentication overrides: pass `false` to disable auth, a function returning auth headers, an `AuthProvider` instance, or raw `HeaderAuthProvider.AuthOptions`.
* **`isAuthProvider`** type-guard helper is now exported from the core auth module.
* **`forwardCompatibleEnum_`** schema builder added for forward-compatible enum deserialization.
### Fixed
* **`Micros`**, **`SampleData`**, and **`LabResultsRaw`** serializers now correctly allow `null` values inside record fields, matching the actual API contract.

## 0.0.1 - 2026-05-01
* Initial SDK generation
* 🌿 Generated with Fern
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@junction-api/sdk",
"version": "0.0.1",
"version": "1.0.0",
"private": false,
"repository": {
"type": "git",
Expand Down
72 changes: 36 additions & 36 deletions pnpm-lock.yaml

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

29 changes: 27 additions & 2 deletions src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { mergeHeaders } from "./core/headers.js";
import * as core from "./core/index.js";
import type * as environments from "./environments.js";

export type AuthOption =
| false
| core.AuthProvider["getAuthRequest"]
| core.AuthProvider
| HeaderAuthProvider.AuthOptions;

export type BaseClientOptions = {
environment?: core.Supplier<environments.JunctionEnvironment | string>;
/** Specify a custom URL to connect the client to. */
Expand All @@ -19,6 +25,8 @@ export type BaseClientOptions = {
fetch?: typeof fetch;
/** Configure logging for the client. */
logging?: core.logging.LogConfig | core.logging.Logger;
/** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
auth?: AuthOption;
} & HeaderAuthProvider.AuthOptions;

export interface BaseRequestOptions {
Expand Down Expand Up @@ -51,8 +59,8 @@ export function normalizeClientOptions<T extends BaseClientOptions = BaseClientO
{
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@junction-api/sdk",
"X-Fern-SDK-Version": "0.0.1",
"User-Agent": "@junction-api/sdk/0.0.1",
"X-Fern-SDK-Version": "1.0.0",
"User-Agent": "@junction-api/sdk/1.0.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand All @@ -70,6 +78,23 @@ export function normalizeClientOptionsWithAuth<T extends BaseClientOptions = Bas
options: T,
): NormalizedClientOptionsWithAuth<T> {
const normalized = normalizeClientOptions(options) as NormalizedClientOptionsWithAuth<T>;

if (options.auth === false) {
normalized.authProvider = new core.NoOpAuthProvider();
return normalized;
}
if (options.auth != null) {
if (typeof options.auth === "function") {
normalized.authProvider = { getAuthRequest: options.auth };
return normalized;
}
if (core.isAuthProvider(options.auth)) {
normalized.authProvider = options.auth;
return normalized;
}
Object.assign(normalized, options.auth);
}

const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
normalized.authProvider ??= new HeaderAuthProvider(normalizedWithNoOpAuthProvider);
return normalized;
Expand Down
2 changes: 2 additions & 0 deletions src/api/types/MealInDbBaseClientFacingSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface MealInDbBaseClientFacingSource {
/** This value is identical to `id`. */
providerId: string;
timestamp: Date;
/** Date of the meal in the YYYY-mm-dd format. For providers that only expose a date, this is the calendar date as recorded by the user. */
calendarDate: string;
name: string;
energy?: Junction.Energy | null;
macros?: Junction.Macros | null;
Expand Down
9 changes: 9 additions & 0 deletions src/core/auth/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ import type { AuthRequest } from "./AuthRequest.js";
export interface AuthProvider {
getAuthRequest(arg?: { endpointMetadata?: EndpointMetadata }): Promise<AuthRequest>;
}

export function isAuthProvider(value: unknown): value is AuthProvider {
return (
typeof value === "object" &&
value !== null &&
"getAuthRequest" in value &&
typeof value.getAuthRequest === "function"
);
}
2 changes: 1 addition & 1 deletion src/core/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { AuthProvider } from "./AuthProvider.js";
export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
export type { AuthRequest } from "./AuthRequest.js";
export { BasicAuth } from "./BasicAuth.js";
export { BearerToken } from "./BearerToken.js";
Expand Down
Loading
Loading