@maximem/synap-js-sdk 0.4.1 → 0.4.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/bin/synap-js-sdk.js +3 -3
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1238,7 +1238,7 @@ function envPort() {
|
|
|
1238
1238
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1239
1239
|
}
|
|
1240
1240
|
function envTls() {
|
|
1241
|
-
const raw = getEnv("SYNAP_GRPC_USE_TLS");
|
|
1241
|
+
const raw = getEnv("SYNAP_GRPC_USE_TLS") ?? getEnv("SYNAP_GRPC_TLS");
|
|
1242
1242
|
if (raw === void 0 || raw === "") return void 0;
|
|
1243
1243
|
return !["0", "false", "no", "off"].includes(raw.trim().toLowerCase());
|
|
1244
1244
|
}
|
|
@@ -2168,6 +2168,7 @@ var SynapClient = class {
|
|
|
2168
2168
|
#fetchHooks;
|
|
2169
2169
|
constructor(options = {}) {
|
|
2170
2170
|
const credentials = resolveCredentials(options);
|
|
2171
|
+
const resolvedBaseUrl = resolveBaseUrl(options);
|
|
2171
2172
|
validateInstanceId(credentials.instanceId);
|
|
2172
2173
|
const registryKey = buildRegistryKey(credentials.instanceId, credentials.apiKey);
|
|
2173
2174
|
if (options._force_new !== true) {
|
|
@@ -2185,7 +2186,12 @@ var SynapClient = class {
|
|
|
2185
2186
|
this.#registryKeys = options._force_new === true ? [] : [registryKey];
|
|
2186
2187
|
this.#transport = new HttpTransport({
|
|
2187
2188
|
credentials,
|
|
2188
|
-
|
|
2189
|
+
// SYNAP_BASE_URL is honoured, as Python does (sdk.py) and as the 0.3.x
|
|
2190
|
+
// wrapper did. Ignoring it was a wrong-DESTINATION bug rather than a
|
|
2191
|
+
// missing convenience: anyone pointing at a self-hosted or staging
|
|
2192
|
+
// deployment through the environment would silently have started sending
|
|
2193
|
+
// their data to production on upgrade.
|
|
2194
|
+
...resolvedBaseUrl !== void 0 ? { baseUrl: resolvedBaseUrl } : {},
|
|
2189
2195
|
...options.timeouts !== void 0 ? { timeouts: options.timeouts } : {},
|
|
2190
2196
|
...options.retryPolicy !== void 0 ? { retryPolicy: options.retryPolicy } : {},
|
|
2191
2197
|
...options.keepAlive !== void 0 ? { keepAlive: options.keepAlive } : {},
|
|
@@ -2635,6 +2641,11 @@ function pick3(o2, snake, camel) {
|
|
|
2635
2641
|
const a = o2[snake];
|
|
2636
2642
|
return a !== void 0 ? a : o2[camel];
|
|
2637
2643
|
}
|
|
2644
|
+
function resolveBaseUrl(options) {
|
|
2645
|
+
if (options.baseUrl !== void 0) return options.baseUrl;
|
|
2646
|
+
const fromEnv = getEnv("SYNAP_BASE_URL")?.trim();
|
|
2647
|
+
return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
|
|
2648
|
+
}
|
|
2638
2649
|
function resolveCredentials(options) {
|
|
2639
2650
|
const apiKey = options.apiKey ?? getEnv("SYNAP_API_KEY");
|
|
2640
2651
|
if (!apiKey) {
|