@kulkan/kulterra-api-client 1.1.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +14 -11
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
19
|
|
|
20
20
|
### Security
|
|
21
21
|
|
|
22
|
+
## [1.2.1] - 2026-04-04
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **`HttpClient.patch`** and **`HttpPatch`** type for JSON bodies (Axios-compatible).
|
|
27
|
+
- **User endpoints** (`src/endpoints/user.ts`): `patchUpdateRoleUserByAdmin`.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
22
31
|
## [1.1.0] - 2026-04-04
|
|
23
32
|
|
|
24
33
|
### Added
|
package/README.md
CHANGED
|
@@ -22,23 +22,26 @@ npm install @kulkan/kulterra-api-client @kulkan/kulterra-contracts
|
|
|
22
22
|
| `createApiClient(options)` | Factory returning `healthCheck` + **`auth`** namespace |
|
|
23
23
|
| `ApiClient` / `CreateApiClientOptions` | Typed client and `{ http: HttpClient }` options |
|
|
24
24
|
| `HttpClient` | **`get`** and **`post`** (minimal surface compatible with Axios) |
|
|
25
|
-
| `HttpGet` / `HttpPost`
|
|
25
|
+
| `HttpGet` / `HttpPost` / `HttpPatch` | Method signatures |
|
|
26
26
|
| Named auth helpers | `postRegister`, `postLogin`, `getGoogleOAuthStart`, `postGoogleOAuthCallback`, `postRefresh`, `postLogout`, `getMe` (see `src/endpoints/auth.ts`) |
|
|
27
|
+
| Named user helpers | `patchUpdateUserRoleByAdmin` (see `src/endpoints/user.ts`) |
|
|
27
28
|
|
|
28
29
|
### Endpoints implemented
|
|
29
30
|
|
|
30
|
-
| HTTP
|
|
31
|
-
|
|
|
32
|
-
| `GET`
|
|
33
|
-
| `POST`
|
|
34
|
-
| `POST`
|
|
35
|
-
| `GET`
|
|
36
|
-
| `POST`
|
|
37
|
-
| `POST`
|
|
38
|
-
| `POST`
|
|
39
|
-
| `GET`
|
|
31
|
+
| HTTP | Path | Client |
|
|
32
|
+
| ------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `GET` | `/api/v1/health-check` | `client.healthCheck()` |
|
|
34
|
+
| `POST` | `/api/v1/auth/register` | `client.auth.register(body)` or `postRegister(http, body)` |
|
|
35
|
+
| `POST` | `/api/v1/auth/login` | `client.auth.login(body)` or `postLogin(http, body)` |
|
|
36
|
+
| `GET` | `/api/v1/auth/oauth/google/start?redirectUri=...` | `client.auth.getGoogleOAuthStart(redirectUri)` or `getGoogleOAuthStart(http, redirectUri)` |
|
|
37
|
+
| `POST` | `/api/v1/auth/oauth/google/callback` | `client.auth.postGoogleOAuthCallback(body)` or `postGoogleOAuthCallback(http, body)` |
|
|
38
|
+
| `POST` | `/api/v1/auth/refresh` | `client.auth.refresh(body)` or `postRefresh(http, body)` |
|
|
39
|
+
| `POST` | `/api/v1/auth/logout` | `client.auth.logout(body)` or `postLogout(http, body)` |
|
|
40
|
+
| `GET` | `/api/v1/auth/me` | `client.auth.me(accessToken)` or `getMe(http, accessToken)` |
|
|
41
|
+
| `PATCH` | `/api/v1/users/:id/role` | `client.user.updateRoleUserByAdmin(http, {id}, body)` or `patchUpdateRoleUserByAdmin(http, { id }, body)` |
|
|
40
42
|
|
|
41
43
|
Responses follow **`IApiResponse<T>`** from contracts (`success`, `data`, etc.). Auth session payloads are **`AuthSessionResponse`** (`TokenPair` + `user`). **`logout`** returns **204** with no JSON body.
|
|
44
|
+
User session payloads are **`UserSessionResponse`_(not implemented yet)_. **`updateRoleUserByAdmin`** returns **204\*\* with no JSON body.
|
|
42
45
|
|
|
43
46
|
### Usage example (Axios)
|
|
44
47
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, AuthUserResponse, HealthCheck } from '@kulkan/kulterra-contracts';
|
|
1
|
+
import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, AuthUserResponse, updateUserRoleByAdminParams, UpdateUserRoleByAdminRequest, HealthCheck } from '@kulkan/kulterra-contracts';
|
|
2
2
|
|
|
3
3
|
type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
|
|
4
4
|
data: TResponse;
|
|
@@ -6,9 +6,13 @@ type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
|
|
|
6
6
|
type HttpPost = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
|
|
7
7
|
data: TResponse;
|
|
8
8
|
}>;
|
|
9
|
+
type HttpPatch = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
|
|
10
|
+
data: TResponse;
|
|
11
|
+
}>;
|
|
9
12
|
interface HttpClient {
|
|
10
13
|
readonly get: HttpGet;
|
|
11
14
|
readonly post: HttpPost;
|
|
15
|
+
readonly patch: HttpPatch;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
declare function postRegister(http: HttpClient, body: RegisterRequest): Promise<IApiResponse<AuthSessionResponse>>;
|
|
@@ -19,6 +23,8 @@ declare function postRefresh(http: HttpClient, body: RefreshRequest): Promise<IA
|
|
|
19
23
|
declare function postLogout(http: HttpClient, body: LogoutRequest): Promise<void>;
|
|
20
24
|
declare function getMe(http: HttpClient, accessToken: string): Promise<IApiResponse<AuthUserResponse>>;
|
|
21
25
|
|
|
26
|
+
declare function patchUpdateRoleUserByAdmin(http: HttpClient, { id }: updateUserRoleByAdminParams, body: UpdateUserRoleByAdminRequest): Promise<void>;
|
|
27
|
+
|
|
22
28
|
declare function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>>;
|
|
23
29
|
|
|
24
30
|
interface CreateApiClientOptions {
|
|
@@ -35,7 +41,10 @@ interface ApiClient {
|
|
|
35
41
|
readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;
|
|
36
42
|
readonly me: (accessToken: string) => ReturnType<typeof getMe>;
|
|
37
43
|
};
|
|
44
|
+
readonly user: {
|
|
45
|
+
readonly updateRoleUserByAdmin: ({ id }: Parameters<typeof patchUpdateRoleUserByAdmin>[1], body: Parameters<typeof patchUpdateRoleUserByAdmin>[2]) => ReturnType<typeof patchUpdateRoleUserByAdmin>;
|
|
46
|
+
};
|
|
38
47
|
}
|
|
39
48
|
declare function createApiClient(options: CreateApiClientOptions): ApiClient;
|
|
40
49
|
|
|
41
|
-
export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPost, createApiClient, getGoogleOAuthStart, getMe, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
|
50
|
+
export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPost, createApiClient, getGoogleOAuthStart, getMe, patchUpdateRoleUserByAdmin, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, AuthUserResponse, HealthCheck } from '@kulkan/kulterra-contracts';
|
|
1
|
+
import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, AuthUserResponse, updateUserRoleByAdminParams, UpdateUserRoleByAdminRequest, HealthCheck } from '@kulkan/kulterra-contracts';
|
|
2
2
|
|
|
3
3
|
type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
|
|
4
4
|
data: TResponse;
|
|
@@ -6,9 +6,13 @@ type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
|
|
|
6
6
|
type HttpPost = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
|
|
7
7
|
data: TResponse;
|
|
8
8
|
}>;
|
|
9
|
+
type HttpPatch = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
|
|
10
|
+
data: TResponse;
|
|
11
|
+
}>;
|
|
9
12
|
interface HttpClient {
|
|
10
13
|
readonly get: HttpGet;
|
|
11
14
|
readonly post: HttpPost;
|
|
15
|
+
readonly patch: HttpPatch;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
declare function postRegister(http: HttpClient, body: RegisterRequest): Promise<IApiResponse<AuthSessionResponse>>;
|
|
@@ -19,6 +23,8 @@ declare function postRefresh(http: HttpClient, body: RefreshRequest): Promise<IA
|
|
|
19
23
|
declare function postLogout(http: HttpClient, body: LogoutRequest): Promise<void>;
|
|
20
24
|
declare function getMe(http: HttpClient, accessToken: string): Promise<IApiResponse<AuthUserResponse>>;
|
|
21
25
|
|
|
26
|
+
declare function patchUpdateRoleUserByAdmin(http: HttpClient, { id }: updateUserRoleByAdminParams, body: UpdateUserRoleByAdminRequest): Promise<void>;
|
|
27
|
+
|
|
22
28
|
declare function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>>;
|
|
23
29
|
|
|
24
30
|
interface CreateApiClientOptions {
|
|
@@ -35,7 +41,10 @@ interface ApiClient {
|
|
|
35
41
|
readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;
|
|
36
42
|
readonly me: (accessToken: string) => ReturnType<typeof getMe>;
|
|
37
43
|
};
|
|
44
|
+
readonly user: {
|
|
45
|
+
readonly updateRoleUserByAdmin: ({ id }: Parameters<typeof patchUpdateRoleUserByAdmin>[1], body: Parameters<typeof patchUpdateRoleUserByAdmin>[2]) => ReturnType<typeof patchUpdateRoleUserByAdmin>;
|
|
46
|
+
};
|
|
38
47
|
}
|
|
39
48
|
declare function createApiClient(options: CreateApiClientOptions): ApiClient;
|
|
40
49
|
|
|
41
|
-
export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPost, createApiClient, getGoogleOAuthStart, getMe, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
|
50
|
+
export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPost, createApiClient, getGoogleOAuthStart, getMe, patchUpdateRoleUserByAdmin, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,12 @@ async function getMe(http, accessToken) {
|
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// src/endpoints/user.ts
|
|
51
|
+
var AUTH_BASE2 = "/api/v1/users";
|
|
52
|
+
async function patchUpdateRoleUserByAdmin(http, { id }, body) {
|
|
53
|
+
await http.patch(`${AUTH_BASE2}/${id}/role`, body);
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
// src/endpoints/health-check.ts
|
|
51
57
|
var HEALTH_CHECK_PATH = "/api/v1/health-check";
|
|
52
58
|
async function fetchHealthCheck(http) {
|
|
@@ -67,6 +73,9 @@ function createApiClient(options) {
|
|
|
67
73
|
refresh: (body) => postRefresh(http, body),
|
|
68
74
|
logout: (body) => postLogout(http, body),
|
|
69
75
|
me: (accessToken) => getMe(http, accessToken)
|
|
76
|
+
},
|
|
77
|
+
user: {
|
|
78
|
+
updateRoleUserByAdmin: ({ id }, body) => patchUpdateRoleUserByAdmin(http, { id }, body)
|
|
70
79
|
}
|
|
71
80
|
};
|
|
72
81
|
}
|
|
@@ -74,6 +83,7 @@ function createApiClient(options) {
|
|
|
74
83
|
exports.createApiClient = createApiClient;
|
|
75
84
|
exports.getGoogleOAuthStart = getGoogleOAuthStart;
|
|
76
85
|
exports.getMe = getMe;
|
|
86
|
+
exports.patchUpdateRoleUserByAdmin = patchUpdateRoleUserByAdmin;
|
|
77
87
|
exports.postGoogleOAuthCallback = postGoogleOAuthCallback;
|
|
78
88
|
exports.postLogin = postLogin;
|
|
79
89
|
exports.postLogout = postLogout;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"mappings":";;;AAcA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,mBAAA,CACpB,MACA,WAAA,EACiD;AACjD,EAAA,MAAM,CAAA,GAAI,IAAI,eAAA,CAAgB,EAAE,aAAa,CAAA;AAC7C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,GAAA;AAAA,IAC1B,CAAA,EAAG,SAAS,CAAA,oBAAA,EAAuB,CAAA,CAAE,UAAU,CAAA;AAAA,GACjD;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,uBAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,sBAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,WAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,QAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,UAAA,CAAW,MAAkB,IAAA,EAAoC;AACrF,EAAA,MAAM,IAAA,CAAK,IAAA,CAA+B,CAAA,EAAG,SAAS,WAAW,IAAI,CAAA;AACvE;AAKA,eAAsB,KAAA,CACpB,MACA,WAAA,EACyC;AACzC,EAAA,MAAM,EAAE,MAAK,GAAI,MAAM,KAAK,GAAA,CAAoC,CAAA,EAAG,SAAS,CAAA,GAAA,CAAA,EAAO;AAAA,IACjF,OAAA,EAAS,EAAE,aAAA,EAAe,CAAA,OAAA,EAAU,WAAW,CAAA,CAAA;AAAG,GACnD,CAAA;AACD,EAAA,OAAO,IAAA;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":["AUTH_BASE"],"mappings":";;;AAcA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IAC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UserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n} from '@kulkan/kulterra-contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n","import type {\n UpdateUserRoleByAdminRequest,\n updateUserRoleByAdminParams,\n} from '@kulkan/kulterra-contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/users' as const;\n\n/**\n * PATCH /api/v1/users/:id/role — 204 No Content (no JSON body).\n */\nexport async function patchUpdateRoleUserByAdmin(\n http: HttpClient,\n { id }: updateUserRoleByAdminParams,\n body: UpdateUserRoleByAdminRequest,\n): Promise<void> {\n await http.patch<undefined, UpdateUserRoleByAdminRequest>(`${AUTH_BASE}/${id}/role`, body);\n}\n","import type { IApiResponse, HealthCheck } from '@kulkan/kulterra-contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport { patchUpdateRoleUserByAdmin } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * Both `get` and `post` are required for auth flows.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly user: {\n readonly updateRoleUserByAdmin: (\n { id }: Parameters<typeof patchUpdateRoleUserByAdmin>[1],\n body: Parameters<typeof patchUpdateRoleUserByAdmin>[2],\n ) => ReturnType<typeof patchUpdateRoleUserByAdmin>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n user: {\n updateRoleUserByAdmin: ({ id }, body) => patchUpdateRoleUserByAdmin(http, { id }, body),\n },\n };\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -45,6 +45,12 @@ async function getMe(http, accessToken) {
|
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// src/endpoints/user.ts
|
|
49
|
+
var AUTH_BASE2 = "/api/v1/users";
|
|
50
|
+
async function patchUpdateRoleUserByAdmin(http, { id }, body) {
|
|
51
|
+
await http.patch(`${AUTH_BASE2}/${id}/role`, body);
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
// src/endpoints/health-check.ts
|
|
49
55
|
var HEALTH_CHECK_PATH = "/api/v1/health-check";
|
|
50
56
|
async function fetchHealthCheck(http) {
|
|
@@ -65,10 +71,13 @@ function createApiClient(options) {
|
|
|
65
71
|
refresh: (body) => postRefresh(http, body),
|
|
66
72
|
logout: (body) => postLogout(http, body),
|
|
67
73
|
me: (accessToken) => getMe(http, accessToken)
|
|
74
|
+
},
|
|
75
|
+
user: {
|
|
76
|
+
updateRoleUserByAdmin: ({ id }, body) => patchUpdateRoleUserByAdmin(http, { id }, body)
|
|
68
77
|
}
|
|
69
78
|
};
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
export { createApiClient, getGoogleOAuthStart, getMe, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
|
81
|
+
export { createApiClient, getGoogleOAuthStart, getMe, patchUpdateRoleUserByAdmin, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister };
|
|
73
82
|
//# sourceMappingURL=index.mjs.map
|
|
74
83
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"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,CAA+B,CAAA,EAAG,SAAS,WAAW,IAAI,CAAA;AACvE;AAKA,eAAsB,KAAA,CACpB,MACA,WAAA,EACyC;AACzC,EAAA,MAAM,EAAE,MAAK,GAAI,MAAM,KAAK,GAAA,CAAoC,CAAA,EAAG,SAAS,CAAA,GAAA,CAAA,EAAO;AAAA,IACjF,OAAA,EAAS,EAAE,aAAA,EAAe,CAAA,OAAA,EAAU,WAAW,CAAA,CAAA;AAAG,GACnD,CAAA;AACD,EAAA,OAAO,IAAA;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":["AUTH_BASE"],"mappings":";AAcA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,mBAAA,CACpB,MACA,WAAA,EACiD;AACjD,EAAA,MAAM,CAAA,GAAI,IAAI,eAAA,CAAgB,EAAE,aAAa,CAAA;AAC7C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,GAAA;AAAA,IAC1B,CAAA,EAAG,SAAS,CAAA,oBAAA,EAAuB,CAAA,CAAE,UAAU,CAAA;AAAA,GACjD;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,uBAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,M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AEjB,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,MAAM,gBAAA,CAAiB,IAAI,CAAA;AAAA,IACxC,IAAA,EAAM;AAAA,MACJ,QAAA,EAAU,CAAC,IAAA,KAAS,YAAA,CAAa,MAAM,IAAI,CAAA;AAAA,MAC3C,KAAA,EAAO,CAAC,IAAA,KAAS,SAAA,CAAU,MAAM,IAAI,CAAA;AAAA,MACrC,mBAAA,EAAqB,CAAC,WAAA,KAAgB,mBAAA,CAAoB,MAAM,WAAW,CAAA;AAAA,MAC3E,uBAAA,EAAyB,CAAC,IAAA,KAAS,uBAAA,CAAwB,MAAM,IAAI,CAAA;AAAA,MACrE,OAAA,EAAS,CAAC,IAAA,KAAS,WAAA,CAAY,MAAM,IAAI,CAAA;AAAA,MACzC,MAAA,EAAQ,CAAC,IAAA,KAAS,UAAA,CAAW,MAAM,IAAI,CAAA;AAAA,MACvC,EAAA,EAAI,CAAC,WAAA,KAAgB,KAAA,CAAM,MAAM,WAAW;AAAA,KAC9C;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,qBAAA,EAAuB,CAAC,EAAE,EAAA,EAAG,EAAG,IAAA,KAAS,0BAAA,CAA2B,IAAA,EAAM,EAAE,EAAA,EAAG,EAAG,IAAI;AAAA;AACxF,GACF;AACF","file":"index.mjs","sourcesContent":["import type {\n AuthSessionResponse,\n AuthUserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n} from '@kulkan/kulterra-contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n","import type {\n UpdateUserRoleByAdminRequest,\n updateUserRoleByAdminParams,\n} from '@kulkan/kulterra-contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/users' as const;\n\n/**\n * PATCH /api/v1/users/:id/role — 204 No Content (no JSON body).\n */\nexport async function patchUpdateRoleUserByAdmin(\n http: HttpClient,\n { id }: updateUserRoleByAdminParams,\n body: UpdateUserRoleByAdminRequest,\n): Promise<void> {\n await http.patch<undefined, UpdateUserRoleByAdminRequest>(`${AUTH_BASE}/${id}/role`, body);\n}\n","import type { IApiResponse, HealthCheck } from '@kulkan/kulterra-contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport { patchUpdateRoleUserByAdmin } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * Both `get` and `post` are required for auth flows.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly user: {\n readonly updateRoleUserByAdmin: (\n { id }: Parameters<typeof patchUpdateRoleUserByAdmin>[1],\n body: Parameters<typeof patchUpdateRoleUserByAdmin>[2],\n ) => ReturnType<typeof patchUpdateRoleUserByAdmin>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n user: {\n updateRoleUserByAdmin: ({ id }, body) => patchUpdateRoleUserByAdmin(http, { id }, body),\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kulkan/kulterra-api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Client used to interact with KulTerra project API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"author": "",
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@kulkan/kulterra-contracts": "1.1.
|
|
41
|
+
"@kulkan/kulterra-contracts": "1.1.15",
|
|
42
42
|
"@eslint/js": "^10.0.1",
|
|
43
43
|
"@types/express": "^5.0.5",
|
|
44
44
|
"@types/node": "^24.10.0",
|