kubernetesjs 0.6.0 → 0.6.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/client.d.ts CHANGED
@@ -2,6 +2,7 @@ export interface APIClientOptions {
2
2
  restEndpoint: string;
3
3
  }
4
4
  export interface APIClientRequestHeaders {
5
+ [key: string]: string | number | string[] | undefined;
5
6
  accept?: string | string[] | undefined;
6
7
  'accept-charset'?: string | string[] | undefined;
7
8
  'accept-encoding'?: string | string[] | undefined;
package/client.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.APIClient = void 0;
4
- const url_1 = require("url");
5
4
  class APIClient {
6
5
  baseUrl;
7
6
  defaultTimeout = 10000; // 10 seconds
@@ -9,6 +8,24 @@ class APIClient {
9
8
  this.baseUrl = options.restEndpoint;
10
9
  }
11
10
  buildFullPath(endpoint, query) {
11
+ // If baseUrl is a relative proxy path (e.g. '/api/k8s'), build manually
12
+ if (this.baseUrl.startsWith('/')) {
13
+ // Remove any trailing slash from baseUrl, ensure endpoint starts with '/'
14
+ const base = this.baseUrl.replace(/\/$/, '');
15
+ let url = `${base}${endpoint}`;
16
+ if (query) {
17
+ // Build query params as a simple record so URLSearchParams can accept it
18
+ const record = {};
19
+ Object.keys(query).forEach(key => {
20
+ record[key] = String(query[key]);
21
+ });
22
+ const params = new URLSearchParams(record).toString();
23
+ if (params)
24
+ url += `?${params}`;
25
+ }
26
+ return url;
27
+ }
28
+ // Otherwise, treat baseUrl as an absolute URL
12
29
  const url = new URL(endpoint, this.baseUrl);
13
30
  if (query) {
14
31
  Object.keys(query).forEach(key => url.searchParams.append(key, query[key]));
@@ -75,7 +92,7 @@ class APIClient {
75
92
  ...opts.headers,
76
93
  };
77
94
  const bodyContent = opts.isFormData
78
- ? new url_1.URLSearchParams(body).toString()
95
+ ? new URLSearchParams(body).toString()
79
96
  : JSON.stringify(body);
80
97
  return this.request({
81
98
  path: endpoint,
package/esm/client.js CHANGED
@@ -1,4 +1,3 @@
1
- import { URLSearchParams } from 'url';
2
1
  export class APIClient {
3
2
  baseUrl;
4
3
  defaultTimeout = 10000; // 10 seconds
@@ -6,6 +5,24 @@ export class APIClient {
6
5
  this.baseUrl = options.restEndpoint;
7
6
  }
8
7
  buildFullPath(endpoint, query) {
8
+ // If baseUrl is a relative proxy path (e.g. '/api/k8s'), build manually
9
+ if (this.baseUrl.startsWith('/')) {
10
+ // Remove any trailing slash from baseUrl, ensure endpoint starts with '/'
11
+ const base = this.baseUrl.replace(/\/$/, '');
12
+ let url = `${base}${endpoint}`;
13
+ if (query) {
14
+ // Build query params as a simple record so URLSearchParams can accept it
15
+ const record = {};
16
+ Object.keys(query).forEach(key => {
17
+ record[key] = String(query[key]);
18
+ });
19
+ const params = new URLSearchParams(record).toString();
20
+ if (params)
21
+ url += `?${params}`;
22
+ }
23
+ return url;
24
+ }
25
+ // Otherwise, treat baseUrl as an absolute URL
9
26
  const url = new URL(endpoint, this.baseUrl);
10
27
  if (query) {
11
28
  Object.keys(query).forEach(key => url.searchParams.append(key, query[key]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetesjs",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "Fully Typed Kubernetes",
6
6
  "keywords": [
@@ -50,7 +50,7 @@
50
50
  "test:deploy": "ts-node scripts/deploy.ts"
51
51
  },
52
52
  "devDependencies": {
53
- "schema-sdk": "^0.7.0"
53
+ "schema-sdk": "^0.11.3"
54
54
  },
55
- "gitHead": "5c56cb86a6b5cfbdcb34c1983c2da760e8e76f08"
55
+ "gitHead": "d7bd6e39e651200afad7a014784f756c53a1bacc"
56
56
  }