@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.
@@ -3,7 +3,7 @@
3
3
  * Compatibility shim.
4
4
  *
5
5
  * `npx synap-js-sdk setup` used to build a Python virtualenv and install the
6
- * Python SDK into it. Since 1.0 the SDK is native TypeScript, so there is
6
+ * Python SDK into it. Since 0.4 the SDK is native TypeScript, so there is
7
7
  * nothing to set up.
8
8
  *
9
9
  * The command is kept, and kept exiting 0, because it appears in published
@@ -17,7 +17,7 @@
17
17
  const [, , command] = process.argv;
18
18
 
19
19
  const NOTE = `
20
- @maximem/synap-js-sdk 1.x is a native TypeScript SDK. It does not use Python,
20
+ @maximem/synap-js-sdk 0.4+ is a native TypeScript SDK. It does not use Python,
21
21
  so there is no setup step and this command does nothing.
22
22
 
23
23
  If you are upgrading from 0.3.x:
@@ -37,7 +37,7 @@ switch (command) {
37
37
  break;
38
38
  case '--version':
39
39
  case '-v':
40
- console.log(process.env['npm_package_version'] ?? '1.x');
40
+ console.log(process.env['npm_package_version'] ?? '0.4+');
41
41
  break;
42
42
  default:
43
43
  console.log(`Unknown command: ${command}\n\n${NOTE}`);
package/dist/index.cjs 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 = _chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_GRPC_USE_TLS");
1241
+ const raw = _nullishCoalesce(_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_GRPC_USE_TLS"), () => ( _chunkZKOJDUN4cjs.getEnv.call(void 0, "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
- ...options.baseUrl !== void 0 ? { baseUrl: options.baseUrl } : {},
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 = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()]);
2647
+ return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
2648
+ }
2638
2649
  function resolveCredentials(options) {
2639
2650
  const apiKey = _nullishCoalesce(options.apiKey, () => ( _chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_API_KEY")));
2640
2651
  if (!apiKey) {