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.js
CHANGED
|
@@ -9103,7 +9103,7 @@ function requireModels_0 () {
|
|
|
9103
9103
|
if (hasRequiredModels_0) return models_0;
|
|
9104
9104
|
hasRequiredModels_0 = 1;
|
|
9105
9105
|
Object.defineProperty(models_0, "__esModule", { value: true });
|
|
9106
|
-
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.
|
|
9106
|
+
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;
|
|
9107
9107
|
const SuperpositionServiceException_1 = requireSuperpositionServiceException();
|
|
9108
9108
|
models_0.GroupType = {
|
|
9109
9109
|
SYSTEM_GENERATED: "SYSTEM_GENERATED",
|
|
@@ -9188,6 +9188,18 @@ function requireModels_0 () {
|
|
|
9188
9188
|
INPROGRESS: "INPROGRESS",
|
|
9189
9189
|
PAUSED: "PAUSED",
|
|
9190
9190
|
};
|
|
9191
|
+
var DimensionType;
|
|
9192
|
+
(function (DimensionType) {
|
|
9193
|
+
DimensionType.visit = (value, visitor) => {
|
|
9194
|
+
if (value.REGULAR !== undefined)
|
|
9195
|
+
return visitor.REGULAR(value.REGULAR);
|
|
9196
|
+
if (value.LOCAL_COHORT !== undefined)
|
|
9197
|
+
return visitor.LOCAL_COHORT(value.LOCAL_COHORT);
|
|
9198
|
+
if (value.REMOTE_COHORT !== undefined)
|
|
9199
|
+
return visitor.REMOTE_COHORT(value.REMOTE_COHORT);
|
|
9200
|
+
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
9201
|
+
};
|
|
9202
|
+
})(DimensionType || (models_0.DimensionType = DimensionType = {}));
|
|
9191
9203
|
models_0.MergeStrategy = {
|
|
9192
9204
|
MERGE: "MERGE",
|
|
9193
9205
|
REPLACE: "REPLACE",
|
|
@@ -9205,18 +9217,6 @@ function requireModels_0 () {
|
|
|
9205
9217
|
LastModifiedAt: "last_modified_at",
|
|
9206
9218
|
Weight: "weight",
|
|
9207
9219
|
};
|
|
9208
|
-
var DimensionType;
|
|
9209
|
-
(function (DimensionType) {
|
|
9210
|
-
DimensionType.visit = (value, visitor) => {
|
|
9211
|
-
if (value.REGULAR !== undefined)
|
|
9212
|
-
return visitor.REGULAR(value.REGULAR);
|
|
9213
|
-
if (value.LOCAL_COHORT !== undefined)
|
|
9214
|
-
return visitor.LOCAL_COHORT(value.LOCAL_COHORT);
|
|
9215
|
-
if (value.REMOTE_COHORT !== undefined)
|
|
9216
|
-
return visitor.REMOTE_COHORT(value.REMOTE_COHORT);
|
|
9217
|
-
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
9218
|
-
};
|
|
9219
|
-
})(DimensionType || (models_0.DimensionType = DimensionType = {}));
|
|
9220
9220
|
models_0.FunctionTypes = {
|
|
9221
9221
|
Autocomplete: "AUTOCOMPLETE",
|
|
9222
9222
|
Validation: "VALIDATION",
|
|
@@ -9468,7 +9468,7 @@ function requireAws_restJson1 () {
|
|
|
9468
9468
|
'description': [],
|
|
9469
9469
|
'function_name': [],
|
|
9470
9470
|
'key': [],
|
|
9471
|
-
'schema': _ =>
|
|
9471
|
+
'schema': _ => se_Object(_),
|
|
9472
9472
|
'value': _ => se_Document(_),
|
|
9473
9473
|
}));
|
|
9474
9474
|
b.m("POST")
|
|
@@ -9494,7 +9494,7 @@ function requireAws_restJson1 () {
|
|
|
9494
9494
|
'dimension_type': _ => (0, smithy_client_1._json)(_),
|
|
9495
9495
|
'function_name': [],
|
|
9496
9496
|
'position': [],
|
|
9497
|
-
'schema': _ =>
|
|
9497
|
+
'schema': _ => se_Object(_),
|
|
9498
9498
|
}));
|
|
9499
9499
|
b.m("POST")
|
|
9500
9500
|
.h(headers)
|
|
@@ -9607,7 +9607,7 @@ function requireAws_restJson1 () {
|
|
|
9607
9607
|
'change_reason': [],
|
|
9608
9608
|
'description': [],
|
|
9609
9609
|
'type_name': [],
|
|
9610
|
-
'type_schema': _ =>
|
|
9610
|
+
'type_schema': _ => se_Object(_),
|
|
9611
9611
|
}));
|
|
9612
9612
|
b.m("POST")
|
|
9613
9613
|
.h(headers)
|
|
@@ -10398,7 +10398,7 @@ function requireAws_restJson1 () {
|
|
|
10398
10398
|
'change_reason': [],
|
|
10399
10399
|
'description': [],
|
|
10400
10400
|
'function_name': [],
|
|
10401
|
-
'schema': _ =>
|
|
10401
|
+
'schema': _ => se_Object(_),
|
|
10402
10402
|
'value': _ => se_Document(_),
|
|
10403
10403
|
}));
|
|
10404
10404
|
b.m("PUT")
|
|
@@ -10423,7 +10423,7 @@ function requireAws_restJson1 () {
|
|
|
10423
10423
|
'description': [],
|
|
10424
10424
|
'function_name': [],
|
|
10425
10425
|
'position': [],
|
|
10426
|
-
'schema': _ =>
|
|
10426
|
+
'schema': _ => se_Object(_),
|
|
10427
10427
|
}));
|
|
10428
10428
|
b.m("PUT")
|
|
10429
10429
|
.h(headers)
|
|
@@ -10555,7 +10555,7 @@ function requireAws_restJson1 () {
|
|
|
10555
10555
|
body = JSON.stringify((0, smithy_client_1.take)(input, {
|
|
10556
10556
|
'change_reason': [],
|
|
10557
10557
|
'description': [],
|
|
10558
|
-
'type_schema': _ =>
|
|
10558
|
+
'type_schema': _ => se_Object(_),
|
|
10559
10559
|
}));
|
|
10560
10560
|
b.m("PUT")
|
|
10561
10561
|
.h(headers)
|
|
@@ -10760,7 +10760,7 @@ function requireAws_restJson1 () {
|
|
|
10760
10760
|
'key': smithy_client_1.expectString,
|
|
10761
10761
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10762
10762
|
'last_modified_by': smithy_client_1.expectString,
|
|
10763
|
-
'schema': _ =>
|
|
10763
|
+
'schema': _ => de_Object(_),
|
|
10764
10764
|
'value': _ => de_Document(_),
|
|
10765
10765
|
});
|
|
10766
10766
|
Object.assign(contents, doc);
|
|
@@ -10780,7 +10780,7 @@ function requireAws_restJson1 () {
|
|
|
10780
10780
|
'change_reason': smithy_client_1.expectString,
|
|
10781
10781
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10782
10782
|
'created_by': smithy_client_1.expectString,
|
|
10783
|
-
'dependency_graph':
|
|
10783
|
+
'dependency_graph': smithy_client_1._json,
|
|
10784
10784
|
'description': smithy_client_1.expectString,
|
|
10785
10785
|
'dimension': smithy_client_1.expectString,
|
|
10786
10786
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -10789,7 +10789,7 @@ function requireAws_restJson1 () {
|
|
|
10789
10789
|
'last_modified_by': smithy_client_1.expectString,
|
|
10790
10790
|
'mandatory': smithy_client_1.expectBoolean,
|
|
10791
10791
|
'position': smithy_client_1.expectInt32,
|
|
10792
|
-
'schema': _ =>
|
|
10792
|
+
'schema': _ => de_Object(_),
|
|
10793
10793
|
});
|
|
10794
10794
|
Object.assign(contents, doc);
|
|
10795
10795
|
return contents;
|
|
@@ -10927,7 +10927,7 @@ function requireAws_restJson1 () {
|
|
|
10927
10927
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
10928
10928
|
'last_modified_by': smithy_client_1.expectString,
|
|
10929
10929
|
'type_name': smithy_client_1.expectString,
|
|
10930
|
-
'type_schema': _ =>
|
|
10930
|
+
'type_schema': _ => de_Object(_),
|
|
10931
10931
|
});
|
|
10932
10932
|
Object.assign(contents, doc);
|
|
10933
10933
|
return contents;
|
|
@@ -11080,7 +11080,7 @@ function requireAws_restJson1 () {
|
|
|
11080
11080
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11081
11081
|
'last_modified_by': smithy_client_1.expectString,
|
|
11082
11082
|
'type_name': smithy_client_1.expectString,
|
|
11083
|
-
'type_schema': _ =>
|
|
11083
|
+
'type_schema': _ => de_Object(_),
|
|
11084
11084
|
});
|
|
11085
11085
|
Object.assign(contents, doc);
|
|
11086
11086
|
return contents;
|
|
@@ -11220,7 +11220,7 @@ function requireAws_restJson1 () {
|
|
|
11220
11220
|
'change_reason': smithy_client_1.expectString,
|
|
11221
11221
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11222
11222
|
'created_by': smithy_client_1.expectString,
|
|
11223
|
-
'dependency_graph':
|
|
11223
|
+
'dependency_graph': smithy_client_1._json,
|
|
11224
11224
|
'description': smithy_client_1.expectString,
|
|
11225
11225
|
'dimension': smithy_client_1.expectString,
|
|
11226
11226
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -11229,7 +11229,7 @@ function requireAws_restJson1 () {
|
|
|
11229
11229
|
'last_modified_by': smithy_client_1.expectString,
|
|
11230
11230
|
'mandatory': smithy_client_1.expectBoolean,
|
|
11231
11231
|
'position': smithy_client_1.expectInt32,
|
|
11232
|
-
'schema': _ =>
|
|
11232
|
+
'schema': _ => de_Object(_),
|
|
11233
11233
|
});
|
|
11234
11234
|
Object.assign(contents, doc);
|
|
11235
11235
|
return contents;
|
|
@@ -11848,7 +11848,7 @@ function requireAws_restJson1 () {
|
|
|
11848
11848
|
'key': smithy_client_1.expectString,
|
|
11849
11849
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11850
11850
|
'last_modified_by': smithy_client_1.expectString,
|
|
11851
|
-
'schema': _ =>
|
|
11851
|
+
'schema': _ => de_Object(_),
|
|
11852
11852
|
'value': _ => de_Document(_),
|
|
11853
11853
|
});
|
|
11854
11854
|
Object.assign(contents, doc);
|
|
@@ -11868,7 +11868,7 @@ function requireAws_restJson1 () {
|
|
|
11868
11868
|
'change_reason': smithy_client_1.expectString,
|
|
11869
11869
|
'created_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
11870
11870
|
'created_by': smithy_client_1.expectString,
|
|
11871
|
-
'dependency_graph':
|
|
11871
|
+
'dependency_graph': smithy_client_1._json,
|
|
11872
11872
|
'description': smithy_client_1.expectString,
|
|
11873
11873
|
'dimension': smithy_client_1.expectString,
|
|
11874
11874
|
'dimension_type': _ => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -11877,7 +11877,7 @@ function requireAws_restJson1 () {
|
|
|
11877
11877
|
'last_modified_by': smithy_client_1.expectString,
|
|
11878
11878
|
'mandatory': smithy_client_1.expectBoolean,
|
|
11879
11879
|
'position': smithy_client_1.expectInt32,
|
|
11880
|
-
'schema': _ =>
|
|
11880
|
+
'schema': _ => de_Object(_),
|
|
11881
11881
|
});
|
|
11882
11882
|
Object.assign(contents, doc);
|
|
11883
11883
|
return contents;
|
|
@@ -12040,7 +12040,7 @@ function requireAws_restJson1 () {
|
|
|
12040
12040
|
'last_modified_at': _ => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12041
12041
|
'last_modified_by': smithy_client_1.expectString,
|
|
12042
12042
|
'type_name': smithy_client_1.expectString,
|
|
12043
|
-
'type_schema': _ =>
|
|
12043
|
+
'type_schema': _ => de_Object(_),
|
|
12044
12044
|
});
|
|
12045
12045
|
Object.assign(contents, doc);
|
|
12046
12046
|
return contents;
|
|
@@ -12479,7 +12479,7 @@ function requireAws_restJson1 () {
|
|
|
12479
12479
|
'key': smithy_client_1.expectString,
|
|
12480
12480
|
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12481
12481
|
'last_modified_by': smithy_client_1.expectString,
|
|
12482
|
-
'schema': (_) =>
|
|
12482
|
+
'schema': (_) => de_Object(_),
|
|
12483
12483
|
'value': (_) => de_Document(_),
|
|
12484
12484
|
});
|
|
12485
12485
|
};
|
|
@@ -12488,7 +12488,7 @@ function requireAws_restJson1 () {
|
|
|
12488
12488
|
if (value === null) {
|
|
12489
12489
|
return acc;
|
|
12490
12490
|
}
|
|
12491
|
-
acc[key] =
|
|
12491
|
+
acc[key] = de_DimensionInfo(value);
|
|
12492
12492
|
return acc;
|
|
12493
12493
|
}, {});
|
|
12494
12494
|
};
|
|
@@ -12498,7 +12498,7 @@ function requireAws_restJson1 () {
|
|
|
12498
12498
|
'change_reason': smithy_client_1.expectString,
|
|
12499
12499
|
'created_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12500
12500
|
'created_by': smithy_client_1.expectString,
|
|
12501
|
-
'dependency_graph':
|
|
12501
|
+
'dependency_graph': smithy_client_1._json,
|
|
12502
12502
|
'description': smithy_client_1.expectString,
|
|
12503
12503
|
'dimension': smithy_client_1.expectString,
|
|
12504
12504
|
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
@@ -12507,7 +12507,7 @@ function requireAws_restJson1 () {
|
|
|
12507
12507
|
'last_modified_by': smithy_client_1.expectString,
|
|
12508
12508
|
'mandatory': smithy_client_1.expectBoolean,
|
|
12509
12509
|
'position': smithy_client_1.expectInt32,
|
|
12510
|
-
'schema': (_) =>
|
|
12510
|
+
'schema': (_) => de_Object(_),
|
|
12511
12511
|
});
|
|
12512
12512
|
};
|
|
12513
12513
|
const de_DimensionExtList = (output, context) => {
|
|
@@ -12516,6 +12516,14 @@ function requireAws_restJson1 () {
|
|
|
12516
12516
|
});
|
|
12517
12517
|
return retVal;
|
|
12518
12518
|
};
|
|
12519
|
+
const de_DimensionInfo = (output, context) => {
|
|
12520
|
+
return (0, smithy_client_1.take)(output, {
|
|
12521
|
+
'dependency_graph': smithy_client_1._json,
|
|
12522
|
+
'dimension_type': (_) => (0, smithy_client_1._json)((0, core_1.awsExpectUnion)(_)),
|
|
12523
|
+
'position': smithy_client_1.expectInt32,
|
|
12524
|
+
'schema': (_) => de_Object(_),
|
|
12525
|
+
});
|
|
12526
|
+
};
|
|
12519
12527
|
const de_ExperimentGroupList = (output, context) => {
|
|
12520
12528
|
const retVal = (output || []).filter((e) => e != null).map((entry) => {
|
|
12521
12529
|
return de_ExperimentGroupResponse(entry);
|
|
@@ -12692,7 +12700,7 @@ function requireAws_restJson1 () {
|
|
|
12692
12700
|
'last_modified_at': (_) => (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseRfc3339DateTimeWithOffset)(_)),
|
|
12693
12701
|
'last_modified_by': smithy_client_1.expectString,
|
|
12694
12702
|
'type_name': smithy_client_1.expectString,
|
|
12695
|
-
'type_schema': (_) =>
|
|
12703
|
+
'type_schema': (_) => de_Object(_),
|
|
12696
12704
|
});
|
|
12697
12705
|
};
|
|
12698
12706
|
const de_Variant = (output, context) => {
|
|
@@ -15338,7 +15346,8 @@ class ConfigurationClient {
|
|
|
15338
15346
|
this.config = config;
|
|
15339
15347
|
this.resolver = resolver;
|
|
15340
15348
|
this.options = options;
|
|
15341
|
-
if (this.options.refreshStrategy &&
|
|
15349
|
+
if (this.options.refreshStrategy &&
|
|
15350
|
+
"interval" in this.options.refreshStrategy) {
|
|
15342
15351
|
const strategy = this.options.refreshStrategy;
|
|
15343
15352
|
setInterval(async () => {
|
|
15344
15353
|
try {
|
|
@@ -15374,16 +15383,16 @@ class ConfigurationClient {
|
|
|
15374
15383
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15375
15384
|
experimentationArgs = {
|
|
15376
15385
|
experiments,
|
|
15377
|
-
targeting_key: targetingKey
|
|
15386
|
+
targeting_key: targetingKey,
|
|
15378
15387
|
};
|
|
15379
15388
|
}
|
|
15380
|
-
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, queryData,
|
|
15389
|
+
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, configData.dimensions || {}, queryData, "merge", filterPrefixes, experimentationArgs);
|
|
15381
15390
|
return result;
|
|
15382
15391
|
}
|
|
15383
15392
|
catch (error) {
|
|
15384
15393
|
if (this.defaults) {
|
|
15385
|
-
console.log(
|
|
15386
|
-
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, queryData,
|
|
15394
|
+
console.log("Falling back to defaults");
|
|
15395
|
+
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, this.defaults.dimensions || {}, queryData, "merge", filterPrefixes);
|
|
15387
15396
|
}
|
|
15388
15397
|
throw error;
|
|
15389
15398
|
}
|
|
@@ -15403,12 +15412,13 @@ class ConfigurationClient {
|
|
|
15403
15412
|
this.currentConfigData = {
|
|
15404
15413
|
default_configs: response.default_configs || {},
|
|
15405
15414
|
contexts: response.contexts || [],
|
|
15406
|
-
overrides: response.overrides || {}
|
|
15415
|
+
overrides: response.overrides || {},
|
|
15416
|
+
dimensions: response.dimensions || {},
|
|
15407
15417
|
};
|
|
15408
15418
|
return this.currentConfigData;
|
|
15409
15419
|
}
|
|
15410
15420
|
catch (error) {
|
|
15411
|
-
console.error(
|
|
15421
|
+
console.error("SuperpositionClient GetConfigCommand failed:", error);
|
|
15412
15422
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15413
15423
|
throw new Error(`Failed to fetch configuration: ${errorMessage}`);
|
|
15414
15424
|
}
|
|
@@ -15421,18 +15431,18 @@ class ConfigurationClient {
|
|
|
15421
15431
|
if (this.experimentationClient && targetingKey) {
|
|
15422
15432
|
const experiments = await this.experimentationClient.getExperiments();
|
|
15423
15433
|
const identifier = this.experimentationOptions?.defaultIdentifier ||
|
|
15424
|
-
(targetingKey ? targetingKey :
|
|
15434
|
+
(targetingKey ? targetingKey : "default");
|
|
15425
15435
|
const variantIds = await this.getApplicableVariants(experiments, queryData, identifier);
|
|
15426
15436
|
if (variantIds.length > 0) {
|
|
15427
15437
|
queryData.variantIds = variantIds;
|
|
15428
15438
|
}
|
|
15429
15439
|
}
|
|
15430
|
-
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, queryData,
|
|
15440
|
+
const result = this.resolver.resolveConfig(configData.default_configs || {}, configData.contexts || [], configData.overrides || {}, configData.dimensions || {}, queryData, "merge");
|
|
15431
15441
|
return result;
|
|
15432
15442
|
}
|
|
15433
15443
|
catch (error) {
|
|
15434
15444
|
if (this.defaults) {
|
|
15435
|
-
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, context,
|
|
15445
|
+
return this.resolver.resolveConfig(this.defaults.default_configs || {}, this.defaults.contexts || [], this.defaults.overrides || {}, this.defaults.dimensions || {}, context, "merge");
|
|
15436
15446
|
}
|
|
15437
15447
|
throw error;
|
|
15438
15448
|
}
|
|
@@ -15502,90 +15512,112 @@ class NativeResolver {
|
|
|
15502
15512
|
this.isAvailable = false;
|
|
15503
15513
|
try {
|
|
15504
15514
|
this.lib = koffi.load(libPath || this.getDefaultLibPath());
|
|
15505
|
-
// Define the core resolution functions with CORRECT
|
|
15506
|
-
this.lib.core_get_resolved_config = this.lib.func(
|
|
15507
|
-
this.lib.core_get_resolved_config_with_reasoning = this.lib.func(
|
|
15508
|
-
this.lib.core_free_string = this.lib.func(
|
|
15509
|
-
this.lib.core_last_error_message = this.lib.func(
|
|
15510
|
-
this.lib.core_last_error_length = this.lib.func(
|
|
15511
|
-
this.lib.core_get_applicable_variants = this.lib.func(
|
|
15512
|
-
this.lib.core_test_connection = this.lib.func(
|
|
15515
|
+
// Define the core resolution functions with CORRECT 8 parameters each
|
|
15516
|
+
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*)");
|
|
15517
|
+
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*)");
|
|
15518
|
+
this.lib.core_free_string = this.lib.func("void core_free_string(char*)");
|
|
15519
|
+
this.lib.core_last_error_message = this.lib.func("char* core_last_error_message()");
|
|
15520
|
+
this.lib.core_last_error_length = this.lib.func("int core_last_error_length()");
|
|
15521
|
+
this.lib.core_get_applicable_variants = this.lib.func("char* core_get_applicable_variants(const char*, const char*, const char*, const char*, const char*)");
|
|
15522
|
+
this.lib.core_test_connection = this.lib.func("int core_test_connection()");
|
|
15513
15523
|
this.isAvailable = true;
|
|
15514
15524
|
}
|
|
15515
15525
|
catch (error) {
|
|
15516
|
-
console.warn(
|
|
15526
|
+
console.warn("Native resolver library not available, falling back to JavaScript implementation:", error);
|
|
15517
15527
|
this.isAvailable = false;
|
|
15518
15528
|
}
|
|
15519
15529
|
}
|
|
15520
15530
|
isNativeAvailable() {
|
|
15521
15531
|
return this.isAvailable;
|
|
15522
15532
|
}
|
|
15523
|
-
resolveConfig(defaultConfigs, contexts, overrides, queryData, mergeStrategy =
|
|
15533
|
+
resolveConfig(defaultConfigs, contexts, overrides, dimensions, queryData, mergeStrategy = "merge", filterPrefixes, experimentation) {
|
|
15524
15534
|
if (!this.isAvailable) {
|
|
15525
|
-
throw new Error(
|
|
15535
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15526
15536
|
}
|
|
15527
15537
|
// Input validation
|
|
15528
15538
|
if (!contexts) {
|
|
15529
|
-
throw new Error(
|
|
15539
|
+
throw new Error("contexts parameter is required");
|
|
15530
15540
|
}
|
|
15531
15541
|
if (!overrides) {
|
|
15532
|
-
throw new Error(
|
|
15542
|
+
throw new Error("overrides parameter is required");
|
|
15543
|
+
}
|
|
15544
|
+
if (!dimensions) {
|
|
15545
|
+
throw new Error("dimensions parameter is required");
|
|
15533
15546
|
}
|
|
15534
15547
|
if (!queryData) {
|
|
15535
|
-
throw new Error(
|
|
15548
|
+
throw new Error("queryData parameter is required");
|
|
15536
15549
|
}
|
|
15537
15550
|
if (!mergeStrategy) {
|
|
15538
|
-
throw new Error(
|
|
15551
|
+
throw new Error("mergeStrategy parameter is required");
|
|
15539
15552
|
}
|
|
15540
15553
|
const defaultConfigsJson = JSON.stringify(defaultConfigs || {});
|
|
15541
15554
|
const contextsJson = JSON.stringify(contexts);
|
|
15542
15555
|
const overridesJson = JSON.stringify(overrides);
|
|
15556
|
+
const dimensionsJson = JSON.stringify(dimensions);
|
|
15543
15557
|
const queryDataJson = JSON.stringify(queryData);
|
|
15544
15558
|
const filterPrefixesJson = filterPrefixes && filterPrefixes.length > 0
|
|
15545
15559
|
? JSON.stringify(filterPrefixes)
|
|
15546
15560
|
: null;
|
|
15547
|
-
const experimentationJson = experimentation
|
|
15548
|
-
|
|
15549
|
-
|
|
15550
|
-
console.log(
|
|
15551
|
-
console.log(
|
|
15552
|
-
console.log(
|
|
15553
|
-
console.log(
|
|
15554
|
-
console.log(
|
|
15555
|
-
console.log(
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
if (!
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15567
|
-
|
|
15568
|
-
|
|
15569
|
-
|
|
15561
|
+
const experimentationJson = experimentation
|
|
15562
|
+
? JSON.stringify(experimentation)
|
|
15563
|
+
: null;
|
|
15564
|
+
console.log("🔧 Calling FFI with parameters:");
|
|
15565
|
+
console.log(" defaultConfigs:", defaultConfigs);
|
|
15566
|
+
console.log(" contexts length:", contextsJson.length);
|
|
15567
|
+
console.log(" overrides length:", overridesJson.length);
|
|
15568
|
+
console.log(" dimensions length:", dimensionsJson.length);
|
|
15569
|
+
console.log(" queryData :", queryDataJson);
|
|
15570
|
+
console.log(" mergeStrategy:", mergeStrategy);
|
|
15571
|
+
console.log(" filterPrefixes:", filterPrefixes);
|
|
15572
|
+
console.log(" experimentation:", experimentationJson);
|
|
15573
|
+
if (!defaultConfigsJson ||
|
|
15574
|
+
defaultConfigsJson === "null" ||
|
|
15575
|
+
defaultConfigsJson === "undefined") {
|
|
15576
|
+
throw new Error("defaultConfigs serialization failed");
|
|
15577
|
+
}
|
|
15578
|
+
if (!contextsJson ||
|
|
15579
|
+
contextsJson === "null" ||
|
|
15580
|
+
contextsJson === "undefined") {
|
|
15581
|
+
throw new Error("contexts serialization failed");
|
|
15582
|
+
}
|
|
15583
|
+
if (!overridesJson ||
|
|
15584
|
+
overridesJson === "null" ||
|
|
15585
|
+
overridesJson === "undefined") {
|
|
15586
|
+
throw new Error("overrides serialization failed");
|
|
15587
|
+
}
|
|
15588
|
+
if (!dimensionsJson ||
|
|
15589
|
+
dimensionsJson === "null" ||
|
|
15590
|
+
dimensionsJson === "undefined") {
|
|
15591
|
+
throw new Error("dimensions serialization failed");
|
|
15592
|
+
}
|
|
15593
|
+
if (!queryDataJson ||
|
|
15594
|
+
queryDataJson === "null" ||
|
|
15595
|
+
queryDataJson === "undefined") {
|
|
15596
|
+
throw new Error("queryData serialization failed");
|
|
15597
|
+
}
|
|
15598
|
+
const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson);
|
|
15599
|
+
console.log("🔧 FFI call completed, result:", result);
|
|
15570
15600
|
if (!result) {
|
|
15571
|
-
this.throwLastError(
|
|
15601
|
+
this.throwLastError("Failed to resolve config");
|
|
15572
15602
|
}
|
|
15573
|
-
const configStr = typeof result ===
|
|
15574
|
-
|
|
15603
|
+
const configStr = typeof result === "string"
|
|
15604
|
+
? result
|
|
15605
|
+
: this.lib.decode(result, "string");
|
|
15606
|
+
if (typeof result !== "string") {
|
|
15575
15607
|
this.lib.core_free_string(result);
|
|
15576
15608
|
}
|
|
15577
15609
|
try {
|
|
15578
15610
|
return JSON.parse(configStr);
|
|
15579
15611
|
}
|
|
15580
15612
|
catch (parseError) {
|
|
15581
|
-
console.error(
|
|
15582
|
-
console.error(
|
|
15613
|
+
console.error("Failed to parse config result:", parseError);
|
|
15614
|
+
console.error("Raw result string:", configStr);
|
|
15583
15615
|
throw new Error(`Failed to parse config evaluation result: ${parseError}`);
|
|
15584
15616
|
}
|
|
15585
15617
|
}
|
|
15586
|
-
resolveConfigWithReasoning(defaultConfigs, contexts, overrides, queryData, mergeStrategy =
|
|
15618
|
+
resolveConfigWithReasoning(defaultConfigs, contexts, overrides, dimensions, queryData, mergeStrategy = "merge", filterPrefixes, experimentation) {
|
|
15587
15619
|
if (!this.isAvailable) {
|
|
15588
|
-
throw new Error(
|
|
15620
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15589
15621
|
}
|
|
15590
15622
|
const filterPrefixesJson = filterPrefixes && filterPrefixes.length > 0
|
|
15591
15623
|
? JSON.stringify(filterPrefixes)
|
|
@@ -15593,56 +15625,61 @@ class NativeResolver {
|
|
|
15593
15625
|
const experimentationJson = experimentation
|
|
15594
15626
|
? JSON.stringify(experimentation)
|
|
15595
15627
|
: null;
|
|
15596
|
-
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);
|
|
15628
|
+
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);
|
|
15597
15629
|
if (!result) {
|
|
15598
|
-
this.throwLastError(
|
|
15630
|
+
this.throwLastError("Failed to resolve config with reasoning");
|
|
15599
15631
|
}
|
|
15600
|
-
const configStr = typeof result ===
|
|
15601
|
-
|
|
15632
|
+
const configStr = typeof result === "string"
|
|
15633
|
+
? result
|
|
15634
|
+
: this.lib.decode(result, "string");
|
|
15635
|
+
if (typeof result !== "string") {
|
|
15602
15636
|
this.lib.core_free_string(result);
|
|
15603
15637
|
}
|
|
15604
15638
|
try {
|
|
15605
15639
|
return JSON.parse(configStr);
|
|
15606
15640
|
}
|
|
15607
15641
|
catch (parseError) {
|
|
15608
|
-
console.error(
|
|
15609
|
-
console.error(
|
|
15642
|
+
console.error("Failed to parse reasoning result:", parseError);
|
|
15643
|
+
console.error("Raw result string:", configStr);
|
|
15610
15644
|
throw new Error(`Failed to parse reasoning evaluation result: ${parseError}`);
|
|
15611
15645
|
}
|
|
15612
15646
|
}
|
|
15613
|
-
getApplicableVariants(experiments, userContext, identifier, filterPrefixes = []) {
|
|
15647
|
+
getApplicableVariants(experiments, dimensions, userContext, identifier, filterPrefixes = []) {
|
|
15614
15648
|
if (!this.isAvailable) {
|
|
15615
|
-
throw new Error(
|
|
15649
|
+
throw new Error("Native resolver is not available. Please ensure the native library is built and accessible.");
|
|
15616
15650
|
}
|
|
15617
15651
|
if (!experiments) {
|
|
15618
|
-
throw new Error(
|
|
15652
|
+
throw new Error("experiments parameter is required");
|
|
15619
15653
|
}
|
|
15620
15654
|
if (!userContext) {
|
|
15621
|
-
throw new Error(
|
|
15655
|
+
throw new Error("userContext parameter is required");
|
|
15622
15656
|
}
|
|
15623
15657
|
const experimentsJson = JSON.stringify(experiments);
|
|
15624
15658
|
const userContextJson = JSON.stringify(userContext);
|
|
15659
|
+
const dimensionsJson = JSON.stringify(dimensions);
|
|
15625
15660
|
const filterPrefixesJson = filterPrefixes.length > 0 ? JSON.stringify(filterPrefixes) : null;
|
|
15626
|
-
console.log(
|
|
15627
|
-
console.log(
|
|
15628
|
-
console.log(
|
|
15629
|
-
console.log(
|
|
15630
|
-
console.log(
|
|
15631
|
-
const result = this.lib.core_get_applicable_variants(experimentsJson, userContextJson, identifier, filterPrefixesJson);
|
|
15632
|
-
console.log(
|
|
15661
|
+
console.log("🔧 Calling FFI getApplicableVariants with parameters:");
|
|
15662
|
+
console.log(" experiments:", experiments);
|
|
15663
|
+
console.log(" userContext:", userContext);
|
|
15664
|
+
console.log(" identifier:", identifier);
|
|
15665
|
+
console.log(" filterPrefixes:", filterPrefixes);
|
|
15666
|
+
const result = this.lib.core_get_applicable_variants(experimentsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
|
|
15667
|
+
console.log("FFI getApplicableVariants call completed, result:", result);
|
|
15633
15668
|
if (!result) {
|
|
15634
|
-
this.throwLastError(
|
|
15669
|
+
this.throwLastError("Failed to get applicable variants");
|
|
15635
15670
|
}
|
|
15636
|
-
const resultStr = typeof result ===
|
|
15637
|
-
|
|
15671
|
+
const resultStr = typeof result === "string"
|
|
15672
|
+
? result
|
|
15673
|
+
: this.lib.decode(result, "string");
|
|
15674
|
+
if (typeof result !== "string") {
|
|
15638
15675
|
this.lib.core_free_string(result);
|
|
15639
15676
|
}
|
|
15640
15677
|
try {
|
|
15641
15678
|
return JSON.parse(resultStr);
|
|
15642
15679
|
}
|
|
15643
15680
|
catch (parseError) {
|
|
15644
|
-
console.error(
|
|
15645
|
-
console.error(
|
|
15681
|
+
console.error("Failed to parse variants result:", parseError);
|
|
15682
|
+
console.error("Raw result string:", resultStr);
|
|
15646
15683
|
throw new Error(`Failed to parse variants evaluation result: ${parseError}`);
|
|
15647
15684
|
}
|
|
15648
15685
|
}
|
|
@@ -15657,45 +15694,45 @@ class NativeResolver {
|
|
|
15657
15694
|
let filename;
|
|
15658
15695
|
let extension;
|
|
15659
15696
|
// Determine file extension based on platform
|
|
15660
|
-
if (platform ===
|
|
15661
|
-
extension =
|
|
15697
|
+
if (platform === "win32" && arch === "x64") {
|
|
15698
|
+
extension = "x86_64-pc-windows-msvc.dll";
|
|
15662
15699
|
}
|
|
15663
|
-
else if (platform ===
|
|
15664
|
-
extension =
|
|
15700
|
+
else if (platform === "darwin" && arch === "arm64") {
|
|
15701
|
+
extension = "aarch64-apple-darwin.dylib";
|
|
15665
15702
|
}
|
|
15666
|
-
else if (platform ===
|
|
15667
|
-
extension =
|
|
15703
|
+
else if (platform === "darwin" && arch === "x64") {
|
|
15704
|
+
extension = "x86_64-apple-darwin.dylib";
|
|
15668
15705
|
}
|
|
15669
15706
|
else {
|
|
15670
|
-
extension =
|
|
15707
|
+
extension = "x86_64-unknown-linux-gnu.so";
|
|
15671
15708
|
}
|
|
15672
15709
|
filename = `libsuperposition_core-${extension}`;
|
|
15673
15710
|
const dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))));
|
|
15674
|
-
const packageRootPath = path.resolve(dirname,
|
|
15711
|
+
const packageRootPath = path.resolve(dirname, "..", filename);
|
|
15675
15712
|
if (this.fileExists(packageRootPath)) {
|
|
15676
15713
|
console.log(`Using native library from package root: ${packageRootPath}`);
|
|
15677
15714
|
return packageRootPath;
|
|
15678
15715
|
}
|
|
15679
15716
|
// 1. First try to load from package's native-lib directory (GitHub artifacts)
|
|
15680
|
-
const packageNativeLibPath = path.resolve(dirname,
|
|
15717
|
+
const packageNativeLibPath = path.resolve(dirname, "native-lib", filename);
|
|
15681
15718
|
if (this.fileExists(packageNativeLibPath)) {
|
|
15682
15719
|
console.log(`Using native library from package: ${packageNativeLibPath}`);
|
|
15683
15720
|
return packageNativeLibPath;
|
|
15684
15721
|
}
|
|
15685
|
-
const packageNative2LibPath = path.resolve(dirname,
|
|
15722
|
+
const packageNative2LibPath = path.resolve(dirname, "..", "native-lib", filename);
|
|
15686
15723
|
if (this.fileExists(packageNative2LibPath)) {
|
|
15687
15724
|
console.log(`Using native library from package: ${packageNative2LibPath}`);
|
|
15688
15725
|
return packageNative2LibPath;
|
|
15689
15726
|
}
|
|
15690
15727
|
// 2. Try platform-specific subdirectory in native-lib
|
|
15691
15728
|
const platformDir = `${platform}-${arch}`;
|
|
15692
|
-
const platformSpecificPath = path.resolve(dirname,
|
|
15729
|
+
const platformSpecificPath = path.resolve(dirname, "..", "native-lib", platformDir, filename);
|
|
15693
15730
|
if (this.fileExists(platformSpecificPath)) {
|
|
15694
15731
|
console.log(`Using platform-specific native library: ${platformSpecificPath}`);
|
|
15695
15732
|
return platformSpecificPath;
|
|
15696
15733
|
}
|
|
15697
15734
|
// 3. Fall back to local build (relative to repository root)
|
|
15698
|
-
const localBuildPath = path.resolve(dirname,
|
|
15735
|
+
const localBuildPath = path.resolve(dirname, "..", "..", "..", "..", "target", "release", filename);
|
|
15699
15736
|
if (this.fileExists(localBuildPath)) {
|
|
15700
15737
|
console.log(`Using local build: ${localBuildPath}`);
|
|
15701
15738
|
return localBuildPath;
|
|
@@ -15720,8 +15757,10 @@ class NativeResolver {
|
|
|
15720
15757
|
const errorLength = this.lib.core_last_error_length();
|
|
15721
15758
|
if (errorLength > 0) {
|
|
15722
15759
|
const errorPtr = this.lib.core_last_error_message();
|
|
15723
|
-
const errorMsg = typeof errorPtr ===
|
|
15724
|
-
|
|
15760
|
+
const errorMsg = typeof errorPtr === "string"
|
|
15761
|
+
? errorPtr
|
|
15762
|
+
: this.lib.decode(errorPtr, "string");
|
|
15763
|
+
if (typeof errorPtr !== "string") {
|
|
15725
15764
|
this.lib.core_free_string(errorPtr);
|
|
15726
15765
|
}
|
|
15727
15766
|
throw new Error(`${prefix}: ${errorMsg}`);
|