superposition-provider 0.91.0 → 0.91.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/configuration-client.d.ts +3 -3
- package/dist/index.esm.js +165 -126
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +165 -126
- package/dist/index.js.map +1 -1
- package/dist/native-lib/libsuperposition_core-aarch64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-apple-darwin.dylib +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-pc-windows-msvc.dll +0 -0
- package/dist/native-lib/libsuperposition_core-x86_64-unknown-linux-gnu.so +0 -0
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -9100,7 +9100,7 @@ function requireModels_0 () {
|
|
|
9100
9100
|
if (hasRequiredModels_0) return models_0;
|
|
9101
9101
|
hasRequiredModels_0 = 1;
|
|
9102
9102
|
Object.defineProperty(models_0, "__esModule", { value: true });
|
|
9103
|
-
models_0.WorkspaceNotFound = models_0.WebhookNotFound = models_0.OrganisationNotFound = models_0.Stage = models_0.FunctionExecutionRequest = models_0.ExperimentSortOn = models_0.ExperimentGroupSortOn = models_0.TypeTemplatesNotFound = models_0.FunctionNotFound = models_0.WorkspaceStatus = models_0.Version = models_0.HttpMethod = models_0.OrgStatus = models_0.FunctionTypes = models_0.
|
|
9103
|
+
models_0.WorkspaceNotFound = models_0.WebhookNotFound = models_0.OrganisationNotFound = models_0.Stage = models_0.FunctionExecutionRequest = models_0.ExperimentSortOn = models_0.ExperimentGroupSortOn = models_0.TypeTemplatesNotFound = models_0.FunctionNotFound = models_0.WorkspaceStatus = models_0.Version = models_0.HttpMethod = models_0.OrgStatus = models_0.FunctionTypes = models_0.ContextFilterSortOn = models_0.SortBy = models_0.DimensionMatchStrategy = models_0.MergeStrategy = models_0.DimensionType = models_0.ExperimentStatusType = models_0.ExperimentType = models_0.ContextActionOut = models_0.ContextAction = models_0.ContextIdentifier = models_0.VariantType = models_0.ResourceNotFound = models_0.InternalServerError = models_0.GroupType = void 0;
|
|
9104
9104
|
const SuperpositionServiceException_1 = requireSuperpositionServiceException();
|
|
9105
9105
|
models_0.GroupType = {
|
|
9106
9106
|
SYSTEM_GENERATED: "SYSTEM_GENERATED",
|
|
@@ -9185,6 +9185,18 @@ function requireModels_0 () {
|
|
|
9185
9185
|
INPROGRESS: "INPROGRESS",
|
|
9186
9186
|
PAUSED: "PAUSED",
|
|
9187
9187
|
};
|
|
9188
|
+
var DimensionType;
|
|
9189
|
+
(function (DimensionType) {
|
|
9190
|
+
DimensionType.visit = (value, visitor) => {
|
|
9191
|
+
if (value.REGULAR !== undefined)
|
|
9192
|
+
return visitor.REGULAR(value.REGULAR);
|
|
9193
|
+
if (value.LOCAL_COHORT !== undefined)
|
|
9194
|
+
return visitor.LOCAL_COHORT(value.LOCAL_COHORT);
|
|
9195
|
+
if (value.REMOTE_COHORT !== undefined)
|
|
9196
|
+
return visitor.REMOTE_COHORT(value.REMOTE_COHORT);
|
|
9197
|
+
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
9198
|
+
};
|
|
9199
|
+
})(DimensionType || (models_0.DimensionType = DimensionType = {}));
|
|
9188
9200
|
models_0.MergeStrategy = {
|
|
9189
9201
|
MERGE: "MERGE",
|
|
9190
9202
|
REPLACE: "REPLACE",
|
|
@@ -9202,18 +9214,6 @@ function requireModels_0 () {
|
|
|
9202
9214
|
LastModifiedAt: "last_modified_at",
|
|
9203
9215
|
Weight: "weight",
|
|
9204
9216
|
};
|
|
9205
|
-
var DimensionType;
|
|
9206
|
-
(function (DimensionType) {
|
|
9207
|
-
DimensionType.visit = (value, visitor) => {
|
|
9208
|
-
if (value.REGULAR !== undefined)
|
|
9209
|
-
return visitor.REGULAR(value.REGULAR);
|
|
9210
|
-
if (value.LOCAL_COHORT !== undefined)
|
|
9211
|
-
return visitor.LOCAL_COHORT(value.LOCAL_COHORT);
|
|
9212
|
-
if (value.REMOTE_COHORT !== undefined)
|
|
9213
|
-
return visitor.REMOTE_COHORT(value.REMOTE_COHORT);
|
|
9214
|
-
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
9215
|
-
};
|
|
9216
|
-
})(DimensionType || (models_0.DimensionType = DimensionType = {}));
|
|
9217
9217
|
models_0.FunctionTypes = {
|
|
9218
9218
|
Autocomplete: "AUTOCOMPLETE",
|
|
9219
9219
|
Validation: "VALIDATION",
|
|
@@ -9465,7 +9465,7 @@ function requireAws_restJson1 () {
|
|
|
9465
9465
|
'description': [],
|
|
9466
9466
|
'function_name': [],
|
|
9467
9467
|
'key': [],
|
|
9468
|
-
'schema': _ =>
|
|
9468
|
+
'schema': _ => se_Object(_),
|
|
9469
9469
|
'value': _ => se_Document(_),
|
|
9470
9470
|
}));
|
|
9471
9471
|
b.m("POST")
|
|
@@ -9491,7 +9491,7 @@ function requireAws_restJson1 () {
|
|
|
9491
9491
|
'dimension_type': _ => (0, smithy_client_1._json)(_),
|
|
9492
9492
|
'function_name': [],
|
|
9493
9493
|
'position': [],
|
|
9494
|
-
'schema': _ =>
|
|
9494
|
+
'schema': _ => se_Object(_),
|
|
9495
9495
|
}));
|
|
9496
9496
|
b.m("POST")
|
|
9497
9497
|
.h(headers)
|
|
@@ -9604,7 +9604,7 @@ function requireAws_restJson1 () {
|
|
|
9604
9604
|
'change_reason': [],
|
|
9605
9605
|
'description': [],
|
|
9606
9606
|
'type_name': [],
|
|
9607
|
-
'type_schema': _ =>
|
|
9607
|
+
'type_schema': _ => se_Object(_),
|
|
9608
9608
|
}));
|
|
9609
9609
|
b.m("POST")
|
|
9610
9610
|
.h(headers)
|
|
@@ -10395,7 +10395,7 @@ function requireAws_restJson1 () {
|
|
|
10395
10395
|
'change_reason': [],
|
|
10396
10396
|
'description': [],
|
|
10397
10397
|
'function_name': [],
|
|
10398
|
-
'schema': _ =>
|
|
10398
|
+
'schema': _ => se_Object(_),
|
|
10399
10399
|
'value': _ => se_Document(_),
|
|
10400
10400
|
}));
|
|
10401
10401
|
b.m("PUT")
|
|
@@ -10420,7 +10420,7 @@ function requireAws_restJson1 () {
|
|
|
10420
10420
|
'description': [],
|
|
10421
10421
|
'function_name': [],
|
|
10422
10422
|
'position': [],
|
|
10423
|
-
'schema': _ =>
|
|
10423
|
+
'schema': _ => se_Object(_),
|
|
10424
10424
|
}));
|
|
10425
10425
|
b.m("PUT")
|
|
10426
10426
|
.h(headers)
|
|
@@ -10552,7 +10552,7 @@ function requireAws_restJson1 () {
|
|
|
10552
10552
|
body = JSON.stringify((0, smithy_client_1.take)(input, {
|
|
10553
10553
|
'change_reason': [],
|
|
10554
10554
|
'description': [],
|
|
10555
|
-
'type_schema': _ =>
|
|
10555
|
+
'type_schema': _ => se_Object(_),
|
|
10556
10556
|
}));
|
|
10557
10557
|
b.m("PUT")
|
|
10558
10558
|
.h(headers)
|
|
@@ -10757,7 +10757,7 @@ function requireAws_restJson1 () {
|
|
|
10757
10757
|
'key': smithy_client_1.expectString,
|
|
10758
10758
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10759
10759
|
'last_modified_by': smithy_client_1.expectString,
|
|
10760
|
-
'schema': _ =>
|
|
10760
|
+
'schema': _ => de_Object(_),
|
|
10761
10761
|
'value': _ => de_Document(_),
|
|
10762
10762
|
});
|
|
10763
10763
|
Object.assign(contents, doc);
|
|
@@ -10777,7 +10777,7 @@ function requireAws_restJson1 () {
|
|
|
10777
10777
|
'change_reason': smithy_client_1.expectString,
|
|
10778
10778
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10779
10779
|
'created_by': smithy_client_1.expectString,
|
|
10780
|
-
'dependency_graph':
|
|
10780
|
+
'dependency_graph': smithy_client_1._json,
|
|
10781
10781
|
'description': smithy_client_1.expectString,
|
|
10782
10782
|
'dimension': smithy_client_1.expectString,
|
|
10783
10783
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -10786,7 +10786,7 @@ function requireAws_restJson1 () {
|
|
|
10786
10786
|
'last_modified_by': smithy_client_1.expectString,
|
|
10787
10787
|
'mandatory': smithy_client_1.expectBoolean,
|
|
10788
10788
|
'position': smithy_client_1.expectInt32,
|
|
10789
|
-
'schema': _ =>
|
|
10789
|
+
'schema': _ => de_Object(_),
|
|
10790
10790
|
});
|
|
10791
10791
|
Object.assign(contents, doc);
|
|
10792
10792
|
return contents;
|
|
@@ -10924,7 +10924,7 @@ function requireAws_restJson1 () {
|
|
|
10924
10924
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10925
10925
|
'last_modified_by': smithy_client_1.expectString,
|
|
10926
10926
|
'type_name': smithy_client_1.expectString,
|
|
10927
|
-
'type_schema': _ =>
|
|
10927
|
+
'type_schema': _ => de_Object(_),
|
|
10928
10928
|
});
|
|
10929
10929
|
Object.assign(contents, doc);
|
|
10930
10930
|
return contents;
|
|
@@ -11077,7 +11077,7 @@ function requireAws_restJson1 () {
|
|
|
11077
11077
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11078
11078
|
'last_modified_by': smithy_client_1.expectString,
|
|
11079
11079
|
'type_name': smithy_client_1.expectString,
|
|
11080
|
-
'type_schema': _ =>
|
|
11080
|
+
'type_schema': _ => de_Object(_),
|
|
11081
11081
|
});
|
|
11082
11082
|
Object.assign(contents, doc);
|
|
11083
11083
|
return contents;
|
|
@@ -11217,7 +11217,7 @@ function requireAws_restJson1 () {
|
|
|
11217
11217
|
'change_reason': smithy_client_1.expectString,
|
|
11218
11218
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11219
11219
|
'created_by': smithy_client_1.expectString,
|
|
11220
|
-
'dependency_graph':
|
|
11220
|
+
'dependency_graph': smithy_client_1._json,
|
|
11221
11221
|
'description': smithy_client_1.expectString,
|
|
11222
11222
|
'dimension': smithy_client_1.expectString,
|
|
11223
11223
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -11226,7 +11226,7 @@ function requireAws_restJson1 () {
|
|
|
11226
11226
|
'last_modified_by': smithy_client_1.expectString,
|
|
11227
11227
|
'mandatory': smithy_client_1.expectBoolean,
|
|
11228
11228
|
'position': smithy_client_1.expectInt32,
|
|
11229
|
-
'schema': _ =>
|
|
11229
|
+
'schema': _ => de_Object(_),
|
|
11230
11230
|
});
|
|
11231
11231
|
Object.assign(contents, doc);
|
|
11232
11232
|
return contents;
|
|
@@ -11845,7 +11845,7 @@ function requireAws_restJson1 () {
|
|
|
11845
11845
|
'key': smithy_client_1.expectString,
|
|
11846
11846
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11847
11847
|
'last_modified_by': smithy_client_1.expectString,
|
|
11848
|
-
'schema': _ =>
|
|
11848
|
+
'schema': _ => de_Object(_),
|
|
11849
11849
|
'value': _ => de_Document(_),
|
|
11850
11850
|
});
|
|
11851
11851
|
Object.assign(contents, doc);
|
|
@@ -11865,7 +11865,7 @@ function requireAws_restJson1 () {
|
|
|
11865
11865
|
'change_reason': smithy_client_1.expectString,
|
|
11866
11866
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11867
11867
|
'created_by': smithy_client_1.expectString,
|
|
11868
|
-
'dependency_graph':
|
|
11868
|
+
'dependency_graph': smithy_client_1._json,
|
|
11869
11869
|
'description': smithy_client_1.expectString,
|
|
11870
11870
|
'dimension': smithy_client_1.expectString,
|
|
11871
11871
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -11874,7 +11874,7 @@ function requireAws_restJson1 () {
|
|
|
11874
11874
|
'last_modified_by': smithy_client_1.expectString,
|
|
11875
11875
|
'mandatory': smithy_client_1.expectBoolean,
|
|
11876
11876
|
'position': smithy_client_1.expectInt32,
|
|
11877
|
-
'schema': _ =>
|
|
11877
|
+
'schema': _ => de_Object(_),
|
|
11878
11878
|
});
|
|
11879
11879
|
Object.assign(contents, doc);
|
|
11880
11880
|
return contents;
|
|
@@ -12037,7 +12037,7 @@ function requireAws_restJson1 () {
|
|
|
12037
12037
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12038
12038
|
'last_modified_by': smithy_client_1.expectString,
|
|
12039
12039
|
'type_name': smithy_client_1.expectString,
|
|
12040
|
-
'type_schema': _ =>
|
|
12040
|
+
'type_schema': _ => de_Object(_),
|
|
12041
12041
|
});
|
|
12042
12042
|
Object.assign(contents, doc);
|
|
12043
12043
|
return contents;
|
|
@@ -12476,7 +12476,7 @@ function requireAws_restJson1 () {
|
|
|
12476
12476
|
'key': smithy_client_1.expectString,
|
|
12477
12477
|
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12478
12478
|
'last_modified_by': smithy_client_1.expectString,
|
|
12479
|
-
'schema': (_) =>
|
|
12479
|
+
'schema': (_) => de_Object(_),
|
|
12480
12480
|
'value': (_) => de_Document(_),
|
|
12481
12481
|
});
|
|
12482
12482
|
};
|
|
@@ -12485,7 +12485,7 @@ function requireAws_restJson1 () {
|
|
|
12485
12485
|
if (value === null) {
|
|
12486
12486
|
return acc;
|
|
12487
12487
|
}
|
|
12488
|
-
acc[key] =
|
|
12488
|
+
acc[key] = de_DimensionInfo(value);
|
|
12489
12489
|
return acc;
|
|
12490
12490
|
}, {});
|
|
12491
12491
|
};
|
|
@@ -12495,7 +12495,7 @@ function requireAws_restJson1 () {
|
|
|
12495
12495
|
'change_reason': smithy_client_1.expectString,
|
|
12496
12496
|
'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12497
12497
|
'created_by': smithy_client_1.expectString,
|
|
12498
|
-
'dependency_graph':
|
|
12498
|
+
'dependency_graph': smithy_client_1._json,
|
|
12499
12499
|
'description': smithy_client_1.expectString,
|
|
12500
12500
|
'dimension': smithy_client_1.expectString,
|
|
12501
12501
|
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -12504,7 +12504,7 @@ function requireAws_restJson1 () {
|
|
|
12504
12504
|
'last_modified_by': smithy_client_1.expectString,
|
|
12505
12505
|
'mandatory': smithy_client_1.expectBoolean,
|
|
12506
12506
|
'position': smithy_client_1.expectInt32,
|
|
12507
|
-
'schema': (_) =>
|
|
12507
|
+
'schema': (_) => de_Object(_),
|
|
12508
12508
|
});
|
|
12509
12509
|
};
|
|
12510
12510
|
const de_DimensionExtList = (output, context) => {
|
|
@@ -12513,6 +12513,14 @@ function requireAws_restJson1 () {
|
|
|
12513
12513
|
});
|
|
12514
12514
|
return retVal;
|
|
12515
12515
|
};
|
|
12516
|
+
const de_DimensionInfo = (output, context) => {
|
|
12517
|
+
return (0, smithy_client_1.take)(output, {
|
|
12518
|
+
'dependency_graph': smithy_client_1._json,
|
|
12519
|
+
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
12520
|
+
'position': smithy_client_1.expectInt32,
|
|
12521
|
+
'schema': (_) => de_Object(_),
|
|
12522
|
+
});
|
|
12523
|
+
};
|
|
12516
12524
|
const de_ExperimentGroupList = (output, context) => {
|
|
12517
12525
|
const retVal = (output || []).filter((e) => e != null).map((entry) => {
|
|
12518
12526
|
return de_ExperimentGroupResponse(entry);
|
|
@@ -12689,7 +12697,7 @@ function requireAws_restJson1 () {
|
|
|
12689
12697
|
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12690
12698
|
'last_modified_by': smithy_client_1.expectString,
|
|
12691
12699
|
'type_name': smithy_client_1.expectString,
|
|
12692
|
-
'type_schema': (_) =>
|
|
12700
|
+
'type_schema': (_) => de_Object(_),
|
|
12693
12701
|
});
|
|
12694
12702
|
};
|
|
12695
12703
|
const de_Variant = (output, context) => {
|
|
@@ -15335,7 +15343,8 @@ class ConfigurationClient {
|
|
|
15335
15343
|
this.config = config;
|
|
15336
15344
|
this.resolver = resolver;
|
|
15337
15345
|
this.options = options;
|
|
15338
|
-
if (this.options.refreshStrategy &&
|
|
15346
|
+
if (this.options.refreshStrategy &&
|
|
15347
|
+
"interval" in this.options.refreshStrategy) {
|
|
15339
15348
|
const strategy = this.options.refreshStrategy;
|
|
15340
15349
|
setInterval(async () => {
|
|
15341
15350
|
try {
|
|
@@ -15371,16 +15380,16 @@ class ConfigurationClient {
|
|
|
15371
15380
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15372
15381
|
experimentationArgs = {
|
|
15373
15382
|
experiments,
|
|
15374
|
-
targeting_key: targetingKey
|
|
15383
|
+
targeting_key: targetingKey,
|
|
15375
15384
|
};
|
|
15376
15385
|
}
|
|
15377
|
-
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, queryData,
|
|
15386
|
+
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, configData.dimensions || {}, queryData, "merge", filterPrefixes, experimentationArgs);
|
|
15378
15387
|
return result;
|
|
15379
15388
|
}
|
|
15380
15389
|
catch (error) {
|
|
15381
15390
|
if (this.defaults) {
|
|
15382
|
-
console.log(
|
|
15383
|
-
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, queryData,
|
|
15391
|
+
console.log("Falling back to defaults");
|
|
15392
|
+
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, this.defaults.dimensions || {}, queryData, "merge", filterPrefixes);
|
|
15384
15393
|
}
|
|
15385
15394
|
throw error;
|
|
15386
15395
|
}
|
|
@@ -15400,12 +15409,13 @@ class ConfigurationClient {
|
|
|
15400
15409
|
this.currentConfigData = {
|
|
15401
15410
|
default_configs: response.default_configs || {},
|
|
15402
15411
|
contexts: response.contexts || [],
|
|
15403
|
-
overrides: response.overrides || {}
|
|
15412
|
+
overrides: response.overrides || {},
|
|
15413
|
+
dimensions: response.dimensions || {},
|
|
15404
15414
|
};
|
|
15405
15415
|
return this.currentConfigData;
|
|
15406
15416
|
}
|
|
15407
15417
|
catch (error) {
|
|
15408
|
-
console.error(
|
|
15418
|
+
console.error("SuperpositionClient GetConfigCommand failed:", error);
|
|
15409
15419
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15410
15420
|
throw new Error(`Failed to fetch configuration: ${errorMessage}`);
|
|
15411
15421
|
}
|
|
@@ -15418,18 +15428,18 @@ class ConfigurationClient {
|
|
|
15418
15428
|
if (this.experimentationClient && targetingKey) {
|
|
15419
15429
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15420
15430
|
const identifier = this.experimentationOptions?.defaultIdentifier ||
|
|
15421
|
-
(targetingKey ? targetingKey :
|
|
15431
|
+
(targetingKey ? targetingKey : "default");
|
|
15422
15432
|
const variantIds = await this.getApplicableVariants(experiments, queryData, identifier);
|
|
15423
15433
|
if (variantIds.length > 0) {
|
|
15424
15434
|
queryData.variantIds = variantIds;
|
|
15425
15435
|
}
|
|
15426
15436
|
}
|
|
15427
|
-
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, queryData,
|
|
15437
|
+
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, configData.dimensions || {}, queryData, "merge");
|
|
15428
15438
|
return result;
|
|
15429
15439
|
}
|
|
15430
15440
|
catch (error) {
|
|
15431
15441
|
if (this.defaults) {
|
|
15432
|
-
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, context,
|
|
15442
|
+
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, this.defaults.dimensions || {}, context, "merge");
|
|
15433
15443
|
}
|
|
15434
15444
|
throw error;
|
|
15435
15445
|
}
|
|
@@ -15499,90 +15509,112 @@ class NativeResolver {
|
|
|
15499
15509
|
this.isAvailable = false;
|
|
15500
15510
|
try {
|
|
15501
15511
|
this.lib = koffi.load(libPath || this.getDefaultLibPath());
|
|
15502
|
-
// Define the core resolution functions with CORRECT
|
|
15503
|
-
this.lib.core_get_resolved_config = this.lib.func(
|
|
15504
|
-
this.lib.core_get_resolved_config_with_reasoning = this.lib.func(
|
|
15505
|
-
this.lib.core_free_string = this.lib.func(
|
|
15506
|
-
this.lib.core_last_error_message = this.lib.func(
|
|
15507
|
-
this.lib.core_last_error_length = this.lib.func(
|
|
15508
|
-
this.lib.core_get_applicable_variants = this.lib.func(
|
|
15509
|
-
this.lib.core_test_connection = this.lib.func(
|
|
15512
|
+
// Define the core resolution functions with CORRECT 8 parameters each
|
|
15513
|
+
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*)");
|
|
15514
|
+
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*)");
|
|
15515
|
+
this.lib.core_free_string = this.lib.func("void core_free_string(char*)");
|
|
15516
|
+
this.lib.core_last_error_message = this.lib.func("char* core_last_error_message()");
|
|
15517
|
+
this.lib.core_last_error_length = this.lib.func("int core_last_error_length()");
|
|
15518
|
+
this.lib.core_get_applicable_variants = this.lib.func("char* core_get_applicable_variants(const char*, const char*, const char*, const char*, const char*)");
|
|
15519
|
+
this.lib.core_test_connection = this.lib.func("int core_test_connection()");
|
|
15510
15520
|
this.isAvailable = true;
|
|
15511
15521
|
}
|
|
15512
15522
|
catch (error) {
|
|
15513
|
-
console.warn(
|
|
15523
|
+
console.warn("Native resolver library not available, falling back to JavaScript implementation:", error);
|
|
15514
15524
|
this.isAvailable = false;
|
|
15515
15525
|
}
|
|
15516
15526
|
}
|
|
15517
15527
|
isNativeAvailable() {
|
|
15518
15528
|
return this.isAvailable;
|
|
15519
15529
|
}
|
|
15520
|
-
resolveConfig(defaultConfigs, contexts, overrides, queryData, mergeStrategy =
|
|
15530
|
+
resolveConfig(defaultConfigs, contexts, overrides, dimensions, queryData, mergeStrategy = "merge", filterPrefixes, experimentation) {
|
|
15521
15531
|
if (!this.isAvailable) {
|
|
15522
|
-
throw new Error(
|
|
15532
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15523
15533
|
}
|
|
15524
15534
|
// Input validation
|
|
15525
15535
|
if (!contexts) {
|
|
15526
|
-
throw new Error(
|
|
15536
|
+
throw new Error("contexts parameter is required");
|
|
15527
15537
|
}
|
|
15528
15538
|
if (!overrides) {
|
|
15529
|
-
throw new Error(
|
|
15539
|
+
throw new Error("overrides parameter is required");
|
|
15540
|
+
}
|
|
15541
|
+
if (!dimensions) {
|
|
15542
|
+
throw new Error("dimensions parameter is required");
|
|
15530
15543
|
}
|
|
15531
15544
|
if (!queryData) {
|
|
15532
|
-
throw new Error(
|
|
15545
|
+
throw new Error("queryData parameter is required");
|
|
15533
15546
|
}
|
|
15534
15547
|
if (!mergeStrategy) {
|
|
15535
|
-
throw new Error(
|
|
15548
|
+
throw new Error("mergeStrategy parameter is required");
|
|
15536
15549
|
}
|
|
15537
15550
|
const defaultConfigsJson = JSON.stringify(defaultConfigs || {});
|
|
15538
15551
|
const contextsJson = JSON.stringify(contexts);
|
|
15539
15552
|
const overridesJson = JSON.stringify(overrides);
|
|
15553
|
+
const dimensionsJson = JSON.stringify(dimensions);
|
|
15540
15554
|
const queryDataJson = JSON.stringify(queryData);
|
|
15541
15555
|
const filterPrefixesJson = filterPrefixes && filterPrefixes.length > 0
|
|
15542
15556
|
? JSON.stringify(filterPrefixes)
|
|
15543
15557
|
: null;
|
|
15544
|
-
const experimentationJson = experimentation
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
console.log(
|
|
15548
|
-
console.log(
|
|
15549
|
-
console.log(
|
|
15550
|
-
console.log(
|
|
15551
|
-
console.log(
|
|
15552
|
-
console.log(
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
if (!
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15558
|
+
const experimentationJson = experimentation
|
|
15559
|
+
? JSON.stringify(experimentation)
|
|
15560
|
+
: null;
|
|
15561
|
+
console.log("🔧 Calling FFI with parameters:");
|
|
15562
|
+
console.log(" defaultConfigs:", defaultConfigs);
|
|
15563
|
+
console.log(" contexts length:", contextsJson.length);
|
|
15564
|
+
console.log(" overrides length:", overridesJson.length);
|
|
15565
|
+
console.log(" dimensions length:", dimensionsJson.length);
|
|
15566
|
+
console.log(" queryData :", queryDataJson);
|
|
15567
|
+
console.log(" mergeStrategy:", mergeStrategy);
|
|
15568
|
+
console.log(" filterPrefixes:", filterPrefixes);
|
|
15569
|
+
console.log(" experimentation:", experimentationJson);
|
|
15570
|
+
if (!defaultConfigsJson ||
|
|
15571
|
+
defaultConfigsJson === "null" ||
|
|
15572
|
+
defaultConfigsJson === "undefined") {
|
|
15573
|
+
throw new Error("defaultConfigs serialization failed");
|
|
15574
|
+
}
|
|
15575
|
+
if (!contextsJson ||
|
|
15576
|
+
contextsJson === "null" ||
|
|
15577
|
+
contextsJson === "undefined") {
|
|
15578
|
+
throw new Error("contexts serialization failed");
|
|
15579
|
+
}
|
|
15580
|
+
if (!overridesJson ||
|
|
15581
|
+
overridesJson === "null" ||
|
|
15582
|
+
overridesJson === "undefined") {
|
|
15583
|
+
throw new Error("overrides serialization failed");
|
|
15584
|
+
}
|
|
15585
|
+
if (!dimensionsJson ||
|
|
15586
|
+
dimensionsJson === "null" ||
|
|
15587
|
+
dimensionsJson === "undefined") {
|
|
15588
|
+
throw new Error("dimensions serialization failed");
|
|
15589
|
+
}
|
|
15590
|
+
if (!queryDataJson ||
|
|
15591
|
+
queryDataJson === "null" ||
|
|
15592
|
+
queryDataJson === "undefined") {
|
|
15593
|
+
throw new Error("queryData serialization failed");
|
|
15594
|
+
}
|
|
15595
|
+
const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson);
|
|
15596
|
+
console.log("🔧 FFI call completed, result:", result);
|
|
15567
15597
|
if (!result) {
|
|
15568
|
-
this.throwLastError(
|
|
15598
|
+
this.throwLastError("Failed to resolve config");
|
|
15569
15599
|
}
|
|
15570
|
-
const configStr = typeof result ===
|
|
15571
|
-
|
|
15600
|
+
const configStr = typeof result === "string"
|
|
15601
|
+
? result
|
|
15602
|
+
: this.lib.decode(result, "string");
|
|
15603
|
+
if (typeof result !== "string") {
|
|
15572
15604
|
this.lib.core_free_string(result);
|
|
15573
15605
|
}
|
|
15574
15606
|
try {
|
|
15575
15607
|
return JSON.parse(configStr);
|
|
15576
15608
|
}
|
|
15577
15609
|
catch (parseError) {
|
|
15578
|
-
console.error(
|
|
15579
|
-
console.error(
|
|
15610
|
+
console.error("Failed to parse config result:", parseError);
|
|
15611
|
+
console.error("Raw result string:", configStr);
|
|
15580
15612
|
throw new Error(`Failed to parse config evaluation result: ${parseError}`);
|
|
15581
15613
|
}
|
|
15582
15614
|
}
|
|
15583
|
-
resolveConfigWithReasoning(defaultConfigs, contexts, overrides, queryData, mergeStrategy =
|
|
15615
|
+
resolveConfigWithReasoning(defaultConfigs, contexts, overrides, dimensions, queryData, mergeStrategy = "merge", filterPrefixes, experimentation) {
|
|
15584
15616
|
if (!this.isAvailable) {
|
|
15585
|
-
throw new Error(
|
|
15617
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15586
15618
|
}
|
|
15587
15619
|
const filterPrefixesJson = filterPrefixes && filterPrefixes.length > 0
|
|
15588
15620
|
? JSON.stringify(filterPrefixes)
|
|
@@ -15590,56 +15622,61 @@ class NativeResolver {
|
|
|
15590
15622
|
const experimentationJson = experimentation
|
|
15591
15623
|
? JSON.stringify(experimentation)
|
|
15592
15624
|
: null;
|
|
15593
|
-
const result = this.lib.core_get_resolved_config_with_reasoning(JSON.stringify(defaultConfigs || {}), JSON.stringify(contexts), JSON.stringify(overrides), JSON.stringify(queryData), mergeStrategy, filterPrefixesJson, experimentationJson);
|
|
15625
|
+
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);
|
|
15594
15626
|
if (!result) {
|
|
15595
|
-
this.throwLastError(
|
|
15627
|
+
this.throwLastError("Failed to resolve config with reasoning");
|
|
15596
15628
|
}
|
|
15597
|
-
const configStr = typeof result ===
|
|
15598
|
-
|
|
15629
|
+
const configStr = typeof result === "string"
|
|
15630
|
+
? result
|
|
15631
|
+
: this.lib.decode(result, "string");
|
|
15632
|
+
if (typeof result !== "string") {
|
|
15599
15633
|
this.lib.core_free_string(result);
|
|
15600
15634
|
}
|
|
15601
15635
|
try {
|
|
15602
15636
|
return JSON.parse(configStr);
|
|
15603
15637
|
}
|
|
15604
15638
|
catch (parseError) {
|
|
15605
|
-
console.error(
|
|
15606
|
-
console.error(
|
|
15639
|
+
console.error("Failed to parse reasoning result:", parseError);
|
|
15640
|
+
console.error("Raw result string:", configStr);
|
|
15607
15641
|
throw new Error(`Failed to parse reasoning evaluation result: ${parseError}`);
|
|
15608
15642
|
}
|
|
15609
15643
|
}
|
|
15610
|
-
getApplicableVariants(experiments, userContext, identifier, filterPrefixes = []) {
|
|
15644
|
+
getApplicableVariants(experiments, dimensions, userContext, identifier, filterPrefixes = []) {
|
|
15611
15645
|
if (!this.isAvailable) {
|
|
15612
|
-
throw new Error(
|
|
15646
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15613
15647
|
}
|
|
15614
15648
|
if (!experiments) {
|
|
15615
|
-
throw new Error(
|
|
15649
|
+
throw new Error("experiments parameter is required");
|
|
15616
15650
|
}
|
|
15617
15651
|
if (!userContext) {
|
|
15618
|
-
throw new Error(
|
|
15652
|
+
throw new Error("userContext parameter is required");
|
|
15619
15653
|
}
|
|
15620
15654
|
const experimentsJson = JSON.stringify(experiments);
|
|
15621
15655
|
const userContextJson = JSON.stringify(userContext);
|
|
15656
|
+
const dimensionsJson = JSON.stringify(dimensions);
|
|
15622
15657
|
const filterPrefixesJson = filterPrefixes.length > 0 ? JSON.stringify(filterPrefixes) : null;
|
|
15623
|
-
console.log(
|
|
15624
|
-
console.log(
|
|
15625
|
-
console.log(
|
|
15626
|
-
console.log(
|
|
15627
|
-
console.log(
|
|
15628
|
-
const result = this.lib.core_get_applicable_variants(experimentsJson, userContextJson, identifier, filterPrefixesJson);
|
|
15629
|
-
console.log(
|
|
15658
|
+
console.log("🔧 Calling FFI getApplicableVariants with parameters:");
|
|
15659
|
+
console.log(" experiments:", experiments);
|
|
15660
|
+
console.log(" userContext:", userContext);
|
|
15661
|
+
console.log(" identifier:", identifier);
|
|
15662
|
+
console.log(" filterPrefixes:", filterPrefixes);
|
|
15663
|
+
const result = this.lib.core_get_applicable_variants(experimentsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
|
|
15664
|
+
console.log("FFI getApplicableVariants call completed, result:", result);
|
|
15630
15665
|
if (!result) {
|
|
15631
|
-
this.throwLastError(
|
|
15666
|
+
this.throwLastError("Failed to get applicable variants");
|
|
15632
15667
|
}
|
|
15633
|
-
const resultStr = typeof result ===
|
|
15634
|
-
|
|
15668
|
+
const resultStr = typeof result === "string"
|
|
15669
|
+
? result
|
|
15670
|
+
: this.lib.decode(result, "string");
|
|
15671
|
+
if (typeof result !== "string") {
|
|
15635
15672
|
this.lib.core_free_string(result);
|
|
15636
15673
|
}
|
|
15637
15674
|
try {
|
|
15638
15675
|
return JSON.parse(resultStr);
|
|
15639
15676
|
}
|
|
15640
15677
|
catch (parseError) {
|
|
15641
|
-
console.error(
|
|
15642
|
-
console.error(
|
|
15678
|
+
console.error("Failed to parse variants result:", parseError);
|
|
15679
|
+
console.error("Raw result string:", resultStr);
|
|
15643
15680
|
throw new Error(`Failed to parse variants evaluation result: ${parseError}`);
|
|
15644
15681
|
}
|
|
15645
15682
|
}
|
|
@@ -15654,45 +15691,45 @@ class NativeResolver {
|
|
|
15654
15691
|
let filename;
|
|
15655
15692
|
let extension;
|
|
15656
15693
|
// Determine file extension based on platform
|
|
15657
|
-
if (platform ===
|
|
15658
|
-
extension =
|
|
15694
|
+
if (platform === "win32" && arch === "x64") {
|
|
15695
|
+
extension = "x86_64-pc-windows-msvc.dll";
|
|
15659
15696
|
}
|
|
15660
|
-
else if (platform ===
|
|
15661
|
-
extension =
|
|
15697
|
+
else if (platform === "darwin" && arch === "arm64") {
|
|
15698
|
+
extension = "aarch64-apple-darwin.dylib";
|
|
15662
15699
|
}
|
|
15663
|
-
else if (platform ===
|
|
15664
|
-
extension =
|
|
15700
|
+
else if (platform === "darwin" && arch === "x64") {
|
|
15701
|
+
extension = "x86_64-apple-darwin.dylib";
|
|
15665
15702
|
}
|
|
15666
15703
|
else {
|
|
15667
|
-
extension =
|
|
15704
|
+
extension = "x86_64-unknown-linux-gnu.so";
|
|
15668
15705
|
}
|
|
15669
15706
|
filename = `libsuperposition_core-${extension}`;
|
|
15670
15707
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15671
|
-
const packageRootPath = path.resolve(dirname,
|
|
15708
|
+
const packageRootPath = path.resolve(dirname, "..", filename);
|
|
15672
15709
|
if (this.fileExists(packageRootPath)) {
|
|
15673
15710
|
console.log(`Using native library from package root: ${packageRootPath}`);
|
|
15674
15711
|
return packageRootPath;
|
|
15675
15712
|
}
|
|
15676
15713
|
// 1. First try to load from package's native-lib directory (GitHub artifacts)
|
|
15677
|
-
const packageNativeLibPath = path.resolve(dirname,
|
|
15714
|
+
const packageNativeLibPath = path.resolve(dirname, "native-lib", filename);
|
|
15678
15715
|
if (this.fileExists(packageNativeLibPath)) {
|
|
15679
15716
|
console.log(`Using native library from package: ${packageNativeLibPath}`);
|
|
15680
15717
|
return packageNativeLibPath;
|
|
15681
15718
|
}
|
|
15682
|
-
const packageNative2LibPath = path.resolve(dirname,
|
|
15719
|
+
const packageNative2LibPath = path.resolve(dirname, "..", "native-lib", filename);
|
|
15683
15720
|
if (this.fileExists(packageNative2LibPath)) {
|
|
15684
15721
|
console.log(`Using native library from package: ${packageNative2LibPath}`);
|
|
15685
15722
|
return packageNative2LibPath;
|
|
15686
15723
|
}
|
|
15687
15724
|
// 2. Try platform-specific subdirectory in native-lib
|
|
15688
15725
|
const platformDir = `${platform}-${arch}`;
|
|
15689
|
-
const platformSpecificPath = path.resolve(dirname,
|
|
15726
|
+
const platformSpecificPath = path.resolve(dirname, "..", "native-lib", platformDir, filename);
|
|
15690
15727
|
if (this.fileExists(platformSpecificPath)) {
|
|
15691
15728
|
console.log(`Using platform-specific native library: ${platformSpecificPath}`);
|
|
15692
15729
|
return platformSpecificPath;
|
|
15693
15730
|
}
|
|
15694
15731
|
// 3. Fall back to local build (relative to repository root)
|
|
15695
|
-
const localBuildPath = path.resolve(dirname,
|
|
15732
|
+
const localBuildPath = path.resolve(dirname, "..", "..", "..", "..", "target", "release", filename);
|
|
15696
15733
|
if (this.fileExists(localBuildPath)) {
|
|
15697
15734
|
console.log(`Using local build: ${localBuildPath}`);
|
|
15698
15735
|
return localBuildPath;
|
|
@@ -15717,8 +15754,10 @@ class NativeResolver {
|
|
|
15717
15754
|
const errorLength = this.lib.core_last_error_length();
|
|
15718
15755
|
if (errorLength > 0) {
|
|
15719
15756
|
const errorPtr = this.lib.core_last_error_message();
|
|
15720
|
-
const errorMsg = typeof errorPtr ===
|
|
15721
|
-
|
|
15757
|
+
const errorMsg = typeof errorPtr === "string"
|
|
15758
|
+
? errorPtr
|
|
15759
|
+
: this.lib.decode(errorPtr, "string");
|
|
15760
|
+
if (typeof errorPtr !== "string") {
|
|
15722
15761
|
this.lib.core_free_string(errorPtr);
|
|
15723
15762
|
}
|
|
15724
15763
|
throw new Error(`${prefix}: ${errorMsg}`);
|