superposition-provider 0.93.2 → 0.94.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/dist/index.js CHANGED
@@ -15909,11 +15909,9 @@ class NativeResolver {
15909
15909
  try {
15910
15910
  this.lib = koffi.load(libPath || this.getDefaultLibPath());
15911
15911
  // Define the core resolution functions with CORRECT 8 parameters each
15912
- this.lib.core_get_resolved_config = this.lib.func("char* core_get_resolved_config(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15913
- this.lib.core_get_resolved_config_with_reasoning = this.lib.func("char* core_get_resolved_config_with_reasoning(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15912
+ this.lib.core_get_resolved_config = this.lib.func("char* core_get_resolved_config(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15913
+ this.lib.core_get_resolved_config_with_reasoning = this.lib.func("char* core_get_resolved_config_with_reasoning(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15914
15914
  this.lib.core_free_string = this.lib.func("void core_free_string(char*)");
15915
- this.lib.core_last_error_message = this.lib.func("char* core_last_error_message()");
15916
- this.lib.core_last_error_length = this.lib.func("int core_last_error_length()");
15917
15915
  this.lib.core_get_applicable_variants = this.lib.func("char* core_get_applicable_variants(const char*, const char*, const char*, const char*, const char*)");
15918
15916
  this.lib.core_test_connection = this.lib.func("int core_test_connection()");
15919
15917
  this.isAvailable = true;
@@ -15993,10 +15991,12 @@ class NativeResolver {
15993
15991
  queryDataJson === "undefined") {
15994
15992
  throw new Error("queryData serialization failed");
15995
15993
  }
15996
- const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson);
15994
+ const ebuf = buffer.Buffer.alloc(256);
15995
+ const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson, ebuf);
15997
15996
  console.log("🔧 FFI call completed, result:", result);
15998
- if (!result) {
15999
- this.throwLastError("Failed to resolve config");
15997
+ const err = ebuf.toString('utf8').split('\0')[0];
15998
+ if (err.length !== 0) {
15999
+ this.throwFFIError(err);
16000
16000
  }
16001
16001
  const configStr = typeof result === "string"
16002
16002
  ? result
@@ -16023,9 +16023,11 @@ class NativeResolver {
16023
16023
  const experimentationJson = experimentation
16024
16024
  ? JSON.stringify(experimentation)
16025
16025
  : null;
16026
- const result = this.lib.core_get_resolved_config_with_reasoning(JSON.stringify(defaultConfigs || {}), JSON.stringify(contexts), JSON.stringify(overrides), JSON.stringify(dimensions), JSON.stringify(queryData), mergeStrategy, filterPrefixesJson, experimentationJson);
16027
- if (!result) {
16028
- this.throwLastError("Failed to resolve config with reasoning");
16026
+ const ebuf = buffer.Buffer.alloc(256);
16027
+ const result = this.lib.core_get_resolved_config_with_reasoning(JSON.stringify(defaultConfigs || {}), JSON.stringify(contexts), JSON.stringify(overrides), JSON.stringify(dimensions), JSON.stringify(queryData), mergeStrategy, filterPrefixesJson, experimentationJson, ebuf);
16028
+ const err = ebuf.toString('utf8').split('\0')[0];
16029
+ if (err.length !== 0) {
16030
+ this.throwFFIError(err);
16029
16031
  }
16030
16032
  const configStr = typeof result === "string"
16031
16033
  ? result
@@ -16063,10 +16065,12 @@ class NativeResolver {
16063
16065
  console.log(" userContext:", userContext);
16064
16066
  console.log(" identifier:", identifier);
16065
16067
  console.log(" filterPrefixes:", filterPrefixes);
16068
+ const ebuf = buffer.Buffer.alloc(256);
16066
16069
  const result = this.lib.core_get_applicable_variants(experimentsJson, experimentGroupsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
16067
16070
  console.log("FFI getApplicableVariants call completed, result:", result);
16068
- if (!result) {
16069
- this.throwLastError("Failed to get applicable variants");
16071
+ const err = ebuf.toString('utf8').split('\0')[0];
16072
+ if (err.length !== 0) {
16073
+ this.throwFFIError(err);
16070
16074
  }
16071
16075
  const resultStr = typeof result === "string"
16072
16076
  ? result
@@ -16150,22 +16154,8 @@ class NativeResolver {
16150
16154
  return false;
16151
16155
  }
16152
16156
  }
16153
- throwLastError(prefix) {
16154
- if (!this.isAvailable) {
16155
- throw new Error(`${prefix}: Native resolver not available`);
16156
- }
16157
- const errorLength = this.lib.core_last_error_length();
16158
- if (errorLength > 0) {
16159
- const errorPtr = this.lib.core_last_error_message();
16160
- const errorMsg = typeof errorPtr === "string"
16161
- ? errorPtr
16162
- : this.lib.decode(errorPtr, "string");
16163
- if (typeof errorPtr !== "string") {
16164
- this.lib.core_free_string(errorPtr);
16165
- }
16166
- throw new Error(`${prefix}: ${errorMsg}`);
16167
- }
16168
- throw new Error(`${prefix}: Unknown error`);
16157
+ throwFFIError(err) {
16158
+ throw new Error("ffi: " + err);
16169
16159
  }
16170
16160
  }
16171
16161