Skip to content

Commit 2ce1415

Browse files
authored
Merge pull request #3 from fern-demo/fern-bot/2025-08-05T01-05Z
🌿 Fern Regeneration -- August 5, 2025
2 parents 622e548 + 48f33aa commit 2ce1415

File tree

32 files changed

+388
-258
lines changed

32 files changed

+388
-258
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,30 @@ jobs:
2828

2929
- name: Compile
3030
run: yarn && yarn test
31+
32+
publish:
33+
needs: [ compile, test ]
34+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout repo
38+
uses: actions/checkout@v4
39+
- name: Set up node
40+
uses: actions/setup-node@v3
41+
- name: Install dependencies
42+
run: yarn install
43+
- name: Build
44+
run: yarn build
45+
46+
- name: Publish to npm
47+
run: |
48+
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
49+
if [[ ${GITHUB_REF} == *alpha* ]]; then
50+
npm publish --access public --tag alpha
51+
elif [[ ${GITHUB_REF} == *beta* ]]; then
52+
npm publish --access public --tag beta
53+
else
54+
npm publish --access public
55+
fi
56+
env:
57+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# PhenoML TypeScript Library
1+
# Phenoml TypeScript Library
22

33
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ffern-demo%2Fphenoml-ts-sdk)
44
[![npm shield](https://img.shields.io/npm/v/phenoml)](https://www.npmjs.com/package/phenoml)
55

6-
The PhenoML TypeScript library provides convenient access to the PhenoML API from TypeScript.
6+
The Phenoml TypeScript library provides convenient access to the Phenoml API from TypeScript.
77

88
## Installation
99

@@ -22,7 +22,7 @@ Instantiate and use the client with the following:
2222
```typescript
2323
import { phenomlClient } from "phenoml";
2424

25-
const client = new phenomlClient({ token: "YOUR_TOKEN" });
25+
const client = new phenomlClient({ username: "YOUR_USERNAME", password: "YOUR_PASSWORD" });
2626
await client.agent.create({
2727
name: "name",
2828
prompts: ["prompt_123", "prompt_456"],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phenoml",
3-
"version": "0.0.11",
3+
"version": "0.0.1",
44
"private": false,
55
"repository": "github:fern-demo/phenoml-ts-sdk",
66
"type": "commonjs",

reference.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,9 @@ await client.agent.prompts.loadDefaults();
943943
</dl>
944944
</details>
945945

946-
## Authtoken
946+
## Authtoken Auth
947947

948-
<details><summary><code>client.authtoken.<a href="/src/api/resources/authtoken/client/Client.ts">generateToken</a>() -> phenoml.AuthtokenGenerateTokenResponse</code></summary>
948+
<details><summary><code>client.authtoken.auth.<a href="/src/api/resources/authtoken/resources/auth/client/Client.ts">generateToken</a>({ ...params }) -> phenoml.AuthGenerateTokenResponse</code></summary>
949949
<dl>
950950
<dd>
951951

@@ -957,7 +957,7 @@ await client.agent.prompts.loadDefaults();
957957
<dl>
958958
<dd>
959959

960-
Generates a JWT token using Basic Authentication with username or email and password.
960+
Obtain an access token using client credentials
961961

962962
</dd>
963963
</dl>
@@ -973,7 +973,10 @@ Generates a JWT token using Basic Authentication with username or email and pass
973973
<dd>
974974

975975
```typescript
976-
await client.authtoken.generateToken();
976+
await client.authtoken.auth.generateToken({
977+
username: "username",
978+
password: "password",
979+
});
977980
```
978981

979982
</dd>
@@ -989,7 +992,15 @@ await client.authtoken.generateToken();
989992
<dl>
990993
<dd>
991994

992-
**requestOptions:** `Authtoken.RequestOptions`
995+
**request:** `phenoml.authtoken.AuthGenerateTokenRequest`
996+
997+
</dd>
998+
</dl>
999+
1000+
<dl>
1001+
<dd>
1002+
1003+
**requestOptions:** `Auth.RequestOptions`
9931004

9941005
</dd>
9951006
</dl>

src/Client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export declare namespace phenomlClient {
1717
environment?: core.Supplier<environments.phenomlEnvironment | string>;
1818
/** Specify a custom URL to connect the client to. */
1919
baseUrl?: core.Supplier<string>;
20-
token: core.Supplier<core.BearerToken>;
20+
username: core.Supplier<string>;
21+
password: core.Supplier<string>;
2122
/** Additional headers to include in requests. */
2223
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
2324
fetcher?: core.FetchFunction;
@@ -53,7 +54,8 @@ export class phenomlClient {
5354
{
5455
"X-Fern-Language": "JavaScript",
5556
"X-Fern-SDK-Name": "phenoml",
56-
"X-Fern-SDK-Version": "0.0.11",
57+
"X-Fern-SDK-Version": "0.0.1",
58+
"User-Agent": "phenoml/0.0.1",
5759
"X-Fern-Runtime": core.RUNTIME.type,
5860
"X-Fern-Runtime-Version": core.RUNTIME.version,
5961
},

src/api/resources/agent/client/Client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export declare namespace Agent {
1414
environment?: core.Supplier<environments.phenomlEnvironment | string>;
1515
/** Specify a custom URL to connect the client to. */
1616
baseUrl?: core.Supplier<string>;
17-
token: core.Supplier<core.BearerToken>;
17+
username: core.Supplier<string>;
18+
password: core.Supplier<string>;
1819
/** Additional headers to include in requests. */
1920
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
2021
fetcher?: core.FetchFunction;
@@ -676,7 +677,10 @@ export class Agent {
676677
}
677678
}
678679

679-
protected async _getAuthorizationHeader(): Promise<string> {
680-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
680+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
681+
return core.BasicAuth.toAuthorizationHeader({
682+
username: await core.Supplier.get(this._options.username),
683+
password: await core.Supplier.get(this._options.password),
684+
});
681685
}
682686
}

src/api/resources/agent/resources/prompts/client/Client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export declare namespace Prompts {
1313
environment?: core.Supplier<environments.phenomlEnvironment | string>;
1414
/** Specify a custom URL to connect the client to. */
1515
baseUrl?: core.Supplier<string>;
16-
token: core.Supplier<core.BearerToken>;
16+
username: core.Supplier<string>;
17+
password: core.Supplier<string>;
1718
/** Additional headers to include in requests. */
1819
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
1920
fetcher?: core.FetchFunction;
@@ -645,7 +646,10 @@ export class Prompts {
645646
}
646647
}
647648

648-
protected async _getAuthorizationHeader(): Promise<string> {
649-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
649+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
650+
return core.BasicAuth.toAuthorizationHeader({
651+
username: await core.Supplier.get(this._options.username),
652+
password: await core.Supplier.get(this._options.password),
653+
});
650654
}
651655
}

src/api/resources/authtoken/client/Client.ts

Lines changed: 6 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,123 +4,30 @@
44

55
import * as environments from "../../../../environments.js";
66
import * as core from "../../../../core/index.js";
7-
import * as phenoml from "../../../index.js";
8-
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
9-
import * as errors from "../../../../errors/index.js";
7+
import { Auth } from "../resources/auth/client/Client.js";
108

119
export declare namespace Authtoken {
1210
export interface Options {
1311
environment?: core.Supplier<environments.phenomlEnvironment | string>;
1412
/** Specify a custom URL to connect the client to. */
1513
baseUrl?: core.Supplier<string>;
16-
token: core.Supplier<core.BearerToken>;
14+
username: core.Supplier<string>;
15+
password: core.Supplier<string>;
1716
/** Additional headers to include in requests. */
1817
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
1918
fetcher?: core.FetchFunction;
2019
}
21-
22-
export interface RequestOptions {
23-
/** The maximum time to wait for a response in seconds. */
24-
timeoutInSeconds?: number;
25-
/** The number of times to retry the request. Defaults to 2. */
26-
maxRetries?: number;
27-
/** A hook to abort the request. */
28-
abortSignal?: AbortSignal;
29-
/** Additional query string parameters to include in the request. */
30-
queryParams?: Record<string, unknown>;
31-
/** Additional headers to include in the request. */
32-
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
33-
}
3420
}
3521

3622
export class Authtoken {
3723
protected readonly _options: Authtoken.Options;
24+
protected _auth: Auth | undefined;
3825

3926
constructor(_options: Authtoken.Options) {
4027
this._options = _options;
4128
}
4229

43-
/**
44-
* Generates a JWT token using Basic Authentication with username or email and password.
45-
*
46-
* @param {Authtoken.RequestOptions} requestOptions - Request-specific configuration.
47-
*
48-
* @throws {@link phenoml.authtoken.BadRequestError}
49-
* @throws {@link phenoml.authtoken.UnauthorizedError}
50-
*
51-
* @example
52-
* await client.authtoken.generateToken()
53-
*/
54-
public generateToken(
55-
requestOptions?: Authtoken.RequestOptions,
56-
): core.HttpResponsePromise<phenoml.authtoken.AuthtokenGenerateTokenResponse> {
57-
return core.HttpResponsePromise.fromPromise(this.__generateToken(requestOptions));
58-
}
59-
60-
private async __generateToken(
61-
requestOptions?: Authtoken.RequestOptions,
62-
): Promise<core.WithRawResponse<phenoml.authtoken.AuthtokenGenerateTokenResponse>> {
63-
const _response = await (this._options.fetcher ?? core.fetcher)({
64-
url: core.url.join(
65-
(await core.Supplier.get(this._options.baseUrl)) ??
66-
(await core.Supplier.get(this._options.environment)) ??
67-
environments.phenomlEnvironment.Default,
68-
"auth/token",
69-
),
70-
method: "POST",
71-
headers: mergeHeaders(
72-
this._options?.headers,
73-
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
74-
requestOptions?.headers,
75-
),
76-
queryParameters: requestOptions?.queryParams,
77-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
78-
maxRetries: requestOptions?.maxRetries,
79-
abortSignal: requestOptions?.abortSignal,
80-
});
81-
if (_response.ok) {
82-
return {
83-
data: _response.body as phenoml.authtoken.AuthtokenGenerateTokenResponse,
84-
rawResponse: _response.rawResponse,
85-
};
86-
}
87-
88-
if (_response.error.reason === "status-code") {
89-
switch (_response.error.statusCode) {
90-
case 400:
91-
throw new phenoml.authtoken.BadRequestError(_response.error.body as unknown, _response.rawResponse);
92-
case 401:
93-
throw new phenoml.authtoken.UnauthorizedError(
94-
_response.error.body as unknown,
95-
_response.rawResponse,
96-
);
97-
default:
98-
throw new errors.phenomlError({
99-
statusCode: _response.error.statusCode,
100-
body: _response.error.body,
101-
rawResponse: _response.rawResponse,
102-
});
103-
}
104-
}
105-
106-
switch (_response.error.reason) {
107-
case "non-json":
108-
throw new errors.phenomlError({
109-
statusCode: _response.error.statusCode,
110-
body: _response.error.rawBody,
111-
rawResponse: _response.rawResponse,
112-
});
113-
case "timeout":
114-
throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /auth/token.");
115-
case "unknown":
116-
throw new errors.phenomlError({
117-
message: _response.error.errorMessage,
118-
rawResponse: _response.rawResponse,
119-
});
120-
}
121-
}
122-
123-
protected async _getAuthorizationHeader(): Promise<string> {
124-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
30+
public get auth(): Auth {
31+
return (this._auth ??= new Auth(this._options));
12532
}
12633
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./resources/index.js";
12
export * from "./types/index.js";
23
export * from "./errors/index.js";
34
export * from "./client/index.js";

0 commit comments

Comments
 (0)