keycloak-api 0.0.0 → 0.2.0

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/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  function notEmpty(value) {
2
- return value !== null && value !== void 0;
2
+ return value !== null && value !== undefined;
3
3
  }
4
4
  function compactObject(obj) {
5
5
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
@@ -65,7 +65,24 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
65
65
  return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)] ?? "") + query;
66
66
  };
67
67
 
68
- class KeycloakApi {
68
+ class KeycloakAdminApi {
69
+ #baseUrl;
70
+ #token;
71
+ #fetch;
72
+ constructor(options) {
73
+ this.#baseUrl = options.baseUrl;
74
+ this.#token = options.token;
75
+ this.#fetch = options.fetch || fetch;
76
+ if (!this.#fetch) throw new Error("Fetch is required");
77
+ }
78
+ async request(endpoint, params) {
79
+ const [method = "", url = ""] = endpoint.split(" ");
80
+ const extraParams = params || {};
81
+ const result = await fetch$1({ ...extraParams, method, url, baseUrl: this.#baseUrl, token: this.#token, fetchImpl: this.#fetch });
82
+ return result;
83
+ }
84
+ }
85
+ class KeycloakAccountApi {
69
86
  #baseUrl;
70
87
  #token;
71
88
  #fetch;
@@ -83,4 +100,4 @@ class KeycloakApi {
83
100
  }
84
101
  }
85
102
 
86
- export { KeycloakApi };
103
+ export { KeycloakAccountApi, KeycloakAdminApi };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "keycloak-api",
3
- "version": "0.0.0",
4
- "description": "keycloak API client for Node.js",
3
+ "version": "0.2.0",
4
+ "description": "keycloak auto-generated type-safe API client",
5
5
  "author": "SferaDev",
6
6
  "license": "ISC",
7
7
  "bugs": {
@@ -24,18 +24,13 @@
24
24
  }
25
25
  }
26
26
  },
27
- "scripts": {
28
- "tsc": "tsc --noEmit",
29
- "build": "unbuild",
30
- "prepack": "unbuild",
31
- "generate": "openapi-codegen admin"
32
- },
33
27
  "repository": {
34
28
  "type": "git",
35
29
  "url": "git+https://github.com/SferaDev/openapi-clients.git"
36
30
  },
37
- "devDependencies": {
38
- "case": "^1.6.3",
39
- "openapi3-ts": "^4.4.0"
31
+ "scripts": {
32
+ "tsc": "tsc --noEmit",
33
+ "build": "unbuild",
34
+ "generate": "openapi-codegen admin && openapi-codegen account"
40
35
  }
41
- }
36
+ }