xmemory 3.8.2 → 3.8.3
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/cjs/client.d.ts +10 -0
- package/dist/cjs/client.js +24 -16
- package/dist/esm/client.d.ts +10 -0
- package/dist/esm/client.js +24 -16
- package/package.json +1 -1
package/dist/cjs/client.d.ts
CHANGED
|
@@ -62,6 +62,16 @@ export declare class XmemoryClient {
|
|
|
62
62
|
checkHealth(): Promise<void>;
|
|
63
63
|
private _fetch;
|
|
64
64
|
private _headers;
|
|
65
|
+
/**
|
|
66
|
+
* The request URL for `path`, honouring whatever the configured base carries.
|
|
67
|
+
*
|
|
68
|
+
* Composed through `URL` rather than concatenated. Concatenation put the API path
|
|
69
|
+
* inside the query of a base that had one (`https://host?tenant=x` requested `/`),
|
|
70
|
+
* and appended a second `?` for request parameters. A plain `new URL(path, base)`
|
|
71
|
+
* is not the fix either: it drops a base path prefix, so a gateway base like
|
|
72
|
+
* `https://gw.example/xmemory` would lose `/xmemory`.
|
|
73
|
+
*/
|
|
74
|
+
private _requestUrl;
|
|
65
75
|
/** Core request — returns the raw API wrapper `{ids, items, errors}`. */
|
|
66
76
|
private _request;
|
|
67
77
|
private _requestOne;
|
package/dist/cjs/client.js
CHANGED
|
@@ -158,24 +158,32 @@ class XmemoryClient {
|
|
|
158
158
|
h["Authorization"] = `Bearer ${this._apiKey}`;
|
|
159
159
|
return h;
|
|
160
160
|
}
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
161
|
+
/**
|
|
162
|
+
* The request URL for `path`, honouring whatever the configured base carries.
|
|
163
|
+
*
|
|
164
|
+
* Composed through `URL` rather than concatenated. Concatenation put the API path
|
|
165
|
+
* inside the query of a base that had one (`https://host?tenant=x` requested `/`),
|
|
166
|
+
* and appended a second `?` for request parameters. A plain `new URL(path, base)`
|
|
167
|
+
* is not the fix either: it drops a base path prefix, so a gateway base like
|
|
168
|
+
* `https://gw.example/xmemory` would lose `/xmemory`.
|
|
169
|
+
*/
|
|
170
|
+
_requestUrl(path, params) {
|
|
171
|
+
const url = new URL(this._baseUrl);
|
|
172
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}${path}`;
|
|
173
|
+
for (const [key, val] of Object.entries(params ?? {})) {
|
|
174
|
+
if (Array.isArray(val)) {
|
|
175
|
+
for (const v of val)
|
|
176
|
+
url.searchParams.append(key, v);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
url.searchParams.append(key, val);
|
|
174
180
|
}
|
|
175
|
-
const qs = sp.toString();
|
|
176
|
-
if (qs)
|
|
177
|
-
url += `?${qs}`;
|
|
178
181
|
}
|
|
182
|
+
return url.toString();
|
|
183
|
+
}
|
|
184
|
+
/** Core request — returns the raw API wrapper `{ids, items, errors}`. */
|
|
185
|
+
async _request(method, path, options) {
|
|
186
|
+
const url = this._requestUrl(path, options?.params);
|
|
179
187
|
const timeoutMs = options?.timeoutMs ?? this._timeoutMs;
|
|
180
188
|
const hasBody = !!(options?.body && method !== "GET");
|
|
181
189
|
const init = { method, headers: this._headers(hasBody) };
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -62,6 +62,16 @@ export declare class XmemoryClient {
|
|
|
62
62
|
checkHealth(): Promise<void>;
|
|
63
63
|
private _fetch;
|
|
64
64
|
private _headers;
|
|
65
|
+
/**
|
|
66
|
+
* The request URL for `path`, honouring whatever the configured base carries.
|
|
67
|
+
*
|
|
68
|
+
* Composed through `URL` rather than concatenated. Concatenation put the API path
|
|
69
|
+
* inside the query of a base that had one (`https://host?tenant=x` requested `/`),
|
|
70
|
+
* and appended a second `?` for request parameters. A plain `new URL(path, base)`
|
|
71
|
+
* is not the fix either: it drops a base path prefix, so a gateway base like
|
|
72
|
+
* `https://gw.example/xmemory` would lose `/xmemory`.
|
|
73
|
+
*/
|
|
74
|
+
private _requestUrl;
|
|
65
75
|
/** Core request — returns the raw API wrapper `{ids, items, errors}`. */
|
|
66
76
|
private _request;
|
|
67
77
|
private _requestOne;
|
package/dist/esm/client.js
CHANGED
|
@@ -154,24 +154,32 @@ export class XmemoryClient {
|
|
|
154
154
|
h["Authorization"] = `Bearer ${this._apiKey}`;
|
|
155
155
|
return h;
|
|
156
156
|
}
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
/**
|
|
158
|
+
* The request URL for `path`, honouring whatever the configured base carries.
|
|
159
|
+
*
|
|
160
|
+
* Composed through `URL` rather than concatenated. Concatenation put the API path
|
|
161
|
+
* inside the query of a base that had one (`https://host?tenant=x` requested `/`),
|
|
162
|
+
* and appended a second `?` for request parameters. A plain `new URL(path, base)`
|
|
163
|
+
* is not the fix either: it drops a base path prefix, so a gateway base like
|
|
164
|
+
* `https://gw.example/xmemory` would lose `/xmemory`.
|
|
165
|
+
*/
|
|
166
|
+
_requestUrl(path, params) {
|
|
167
|
+
const url = new URL(this._baseUrl);
|
|
168
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}${path}`;
|
|
169
|
+
for (const [key, val] of Object.entries(params ?? {})) {
|
|
170
|
+
if (Array.isArray(val)) {
|
|
171
|
+
for (const v of val)
|
|
172
|
+
url.searchParams.append(key, v);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
url.searchParams.append(key, val);
|
|
170
176
|
}
|
|
171
|
-
const qs = sp.toString();
|
|
172
|
-
if (qs)
|
|
173
|
-
url += `?${qs}`;
|
|
174
177
|
}
|
|
178
|
+
return url.toString();
|
|
179
|
+
}
|
|
180
|
+
/** Core request — returns the raw API wrapper `{ids, items, errors}`. */
|
|
181
|
+
async _request(method, path, options) {
|
|
182
|
+
const url = this._requestUrl(path, options?.params);
|
|
175
183
|
const timeoutMs = options?.timeoutMs ?? this._timeoutMs;
|
|
176
184
|
const hasBody = !!(options?.body && method !== "GET");
|
|
177
185
|
const init = { method, headers: this._headers(hasBody) };
|