@uniformdev/canvas 18.18.1-alpha.12 → 18.19.0
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.d.ts +672 -28
- package/dist/index.esm.js +67 -3
- package/dist/index.js +67 -3
- package/dist/index.mjs +67 -3
- package/package.json +5 -4
package/dist/index.esm.js
CHANGED
@@ -16,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
19
23
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
20
24
|
mod
|
21
25
|
));
|
@@ -78,7 +82,7 @@ var require_retry_operation = __commonJS({
|
|
78
82
|
if (!err) {
|
79
83
|
return false;
|
80
84
|
}
|
81
|
-
var currentTime = new Date().getTime();
|
85
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
82
86
|
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
83
87
|
this._errors.push(err);
|
84
88
|
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
@@ -128,7 +132,7 @@ var require_retry_operation = __commonJS({
|
|
128
132
|
self._operationTimeoutCb();
|
129
133
|
}, self._operationTimeout);
|
130
134
|
}
|
131
|
-
this._operationStart = new Date().getTime();
|
135
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
132
136
|
this._fn(this._attempts);
|
133
137
|
};
|
134
138
|
RetryOperation.prototype.try = function(fn) {
|
@@ -268,10 +272,15 @@ import { ApiClient } from "@uniformdev/context/api";
|
|
268
272
|
var import_retry = __toESM(require_retry2(), 1);
|
269
273
|
var networkErrorMsgs = /* @__PURE__ */ new Set([
|
270
274
|
"Failed to fetch",
|
275
|
+
// Chrome
|
271
276
|
"NetworkError when attempting to fetch resource.",
|
277
|
+
// Firefox
|
272
278
|
"The Internet connection appears to be offline.",
|
279
|
+
// Safari
|
273
280
|
"Network request failed",
|
281
|
+
// `cross-fetch`
|
274
282
|
"fetch failed"
|
283
|
+
// Undici (Node.js)
|
275
284
|
]);
|
276
285
|
var AbortError = class extends Error {
|
277
286
|
constructor(message) {
|
@@ -452,6 +461,7 @@ var CanvasClient = class extends ApiClient {
|
|
452
461
|
super(options);
|
453
462
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
454
463
|
}
|
464
|
+
/** Fetches lists of Canvas compositions, optionally by type */
|
455
465
|
async getCompositionList(options) {
|
456
466
|
const { projectId } = this.options;
|
457
467
|
const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
|
@@ -460,12 +470,14 @@ var CanvasClient = class extends ApiClient {
|
|
460
470
|
getCompositionByNodePath(options) {
|
461
471
|
return this.getOneComposition(options);
|
462
472
|
}
|
473
|
+
/** @deprecated use getCompositionByNodePath instead */
|
463
474
|
unstable_getCompositionByNodePath(options) {
|
464
475
|
return this.getOneComposition(options);
|
465
476
|
}
|
466
477
|
getCompositionByNodeId(options) {
|
467
478
|
return this.getOneComposition(options);
|
468
479
|
}
|
480
|
+
/** @deprecated Use getCompositionByNodeId instead */
|
469
481
|
unstable_getCompositionByNodeId(options) {
|
470
482
|
return this.getOneComposition(options);
|
471
483
|
}
|
@@ -494,6 +506,7 @@ var CanvasClient = class extends ApiClient {
|
|
494
506
|
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
495
507
|
return this.apiClient(edgeUrl);
|
496
508
|
}
|
509
|
+
/** Updates or creates a Canvas component definition */
|
497
510
|
async updateComposition(body) {
|
498
511
|
const fetchUri = this.createUrl(CANVAS_URL);
|
499
512
|
await this.apiClient(fetchUri, {
|
@@ -502,6 +515,7 @@ var CanvasClient = class extends ApiClient {
|
|
502
515
|
expectNoContent: true
|
503
516
|
});
|
504
517
|
}
|
518
|
+
/** Deletes a Canvas component definition */
|
505
519
|
async removeComposition(body) {
|
506
520
|
const fetchUri = this.createUrl(CANVAS_URL);
|
507
521
|
const { projectId } = this.options;
|
@@ -511,11 +525,13 @@ var CanvasClient = class extends ApiClient {
|
|
511
525
|
expectNoContent: true
|
512
526
|
});
|
513
527
|
}
|
528
|
+
/** Fetches all Canvas component definitions */
|
514
529
|
async getComponentDefinitions(options) {
|
515
530
|
const { projectId } = this.options;
|
516
531
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
|
517
532
|
return await this.apiClient(fetchUri);
|
518
533
|
}
|
534
|
+
/** Updates or creates a Canvas component definition */
|
519
535
|
async updateComponentDefinition(body) {
|
520
536
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
521
537
|
await this.apiClient(fetchUri, {
|
@@ -524,6 +540,7 @@ var CanvasClient = class extends ApiClient {
|
|
524
540
|
expectNoContent: true
|
525
541
|
});
|
526
542
|
}
|
543
|
+
/** Deletes a Canvas component definition */
|
527
544
|
async removeComponentDefinition(body) {
|
528
545
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
529
546
|
await this.apiClient(fetchUri, {
|
@@ -547,16 +564,19 @@ var DataSourceClient = class extends ApiClient2 {
|
|
547
564
|
constructor(options) {
|
548
565
|
super(options);
|
549
566
|
}
|
567
|
+
/** Fetches all DataSources for a project */
|
550
568
|
async get(options) {
|
551
569
|
const { projectId } = this.options;
|
552
570
|
const fetchUri = this.createUrl(dataSourceUrl, { ...options, projectId });
|
553
571
|
return await this.apiClient(fetchUri);
|
554
572
|
}
|
573
|
+
/** Fetches all DataSources for a project */
|
555
574
|
async getList(options) {
|
556
575
|
const { projectId } = this.options;
|
557
576
|
const fetchUri = this.createUrl(dataSourcesUrl, { ...options, projectId });
|
558
577
|
return await this.apiClient(fetchUri);
|
559
578
|
}
|
579
|
+
/** Updates or creates (based on id) a DataSource */
|
560
580
|
async upsert(body) {
|
561
581
|
const fetchUri = this.createUrl(dataSourceUrl);
|
562
582
|
await this.apiClient(fetchUri, {
|
@@ -565,6 +585,7 @@ var DataSourceClient = class extends ApiClient2 {
|
|
565
585
|
expectNoContent: true
|
566
586
|
});
|
567
587
|
}
|
588
|
+
/** Deletes a DataSource */
|
568
589
|
async remove(body) {
|
569
590
|
const fetchUri = this.createUrl(dataSourceUrl);
|
570
591
|
await this.apiClient(fetchUri, {
|
@@ -582,11 +603,13 @@ var _DataTypeClient = class extends ApiClient3 {
|
|
582
603
|
constructor(options) {
|
583
604
|
super(options);
|
584
605
|
}
|
606
|
+
/** Fetches all DataTypes for a project */
|
585
607
|
async get(options) {
|
586
608
|
const { projectId } = this.options;
|
587
609
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url), { ...options, projectId });
|
588
610
|
return await this.apiClient(fetchUri);
|
589
611
|
}
|
612
|
+
/** Updates or creates (based on id) a DataType */
|
590
613
|
async upsert(body) {
|
591
614
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
592
615
|
await this.apiClient(fetchUri, {
|
@@ -595,6 +618,7 @@ var _DataTypeClient = class extends ApiClient3 {
|
|
595
618
|
expectNoContent: true
|
596
619
|
});
|
597
620
|
}
|
621
|
+
/** Deletes a DataType */
|
598
622
|
async remove(body) {
|
599
623
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
600
624
|
await this.apiClient(fetchUri, {
|
@@ -616,14 +640,17 @@ var BatchEntry = class {
|
|
616
640
|
this.args = args;
|
617
641
|
this._isCompleted = false;
|
618
642
|
}
|
643
|
+
/** Mark the batch entry as successfully completed. */
|
619
644
|
resolve(result) {
|
620
645
|
this._resolve(result);
|
621
646
|
this._isCompleted = true;
|
622
647
|
}
|
648
|
+
/** Mark the batch entry as failed. */
|
623
649
|
reject(reason) {
|
624
650
|
this._reject(reason);
|
625
651
|
this._isCompleted = true;
|
626
652
|
}
|
653
|
+
/** @return Whether the batch entry has been completed (resolved or rejected). */
|
627
654
|
get isCompleted() {
|
628
655
|
return this._isCompleted;
|
629
656
|
}
|
@@ -956,10 +983,12 @@ var ChildEnhancerBuilder = class {
|
|
956
983
|
this._paramMatches = Array();
|
957
984
|
this._dataMatches = /* @__PURE__ */ new Map();
|
958
985
|
}
|
986
|
+
/** Targets an enhancer to modify the value of any parameter */
|
959
987
|
parameter(enhancer) {
|
960
988
|
this._paramMatches.push({ enhancer: this._resolveParameterEnhancer(enhancer) });
|
961
989
|
return this;
|
962
990
|
}
|
991
|
+
/** Targets an enhancer to modify the value of any parameter with a specific name */
|
963
992
|
parameterName(name, enhancer) {
|
964
993
|
const names = Array.isArray(name) ? name : [name];
|
965
994
|
names.forEach(
|
@@ -967,6 +996,7 @@ var ChildEnhancerBuilder = class {
|
|
967
996
|
);
|
968
997
|
return this;
|
969
998
|
}
|
999
|
+
/** Targets an enhancer to modify the value of any parameter with a specific type */
|
970
1000
|
parameterType(type, enhancer) {
|
971
1001
|
const types = Array.isArray(type) ? type : [type];
|
972
1002
|
types.forEach(
|
@@ -974,6 +1004,10 @@ var ChildEnhancerBuilder = class {
|
|
974
1004
|
);
|
975
1005
|
return this;
|
976
1006
|
}
|
1007
|
+
/**
|
1008
|
+
* Targets an enhancer to set a specific object key on the component's `data` property.
|
1009
|
+
* Note: an exception will be thrown if the same key is registered more than once.
|
1010
|
+
*/
|
977
1011
|
data(name, enhancer) {
|
978
1012
|
if (this._dataMatches.has(name)) {
|
979
1013
|
throw new Error(`${name} enhancer data key has been used more than once. This will cause data loss.`);
|
@@ -981,12 +1015,20 @@ var ChildEnhancerBuilder = class {
|
|
981
1015
|
this._dataMatches.set(name, typeof enhancer === "function" ? { enhanceOne: enhancer } : enhancer);
|
982
1016
|
return this;
|
983
1017
|
}
|
1018
|
+
/**
|
1019
|
+
* Resolves the parameter enhancer for a given parameter, if one exists.
|
1020
|
+
* The first matching enhancer by registration order is returned, if more than one could match.
|
1021
|
+
*/
|
984
1022
|
resolveParameterEnhancer(parameterName, parameter) {
|
985
1023
|
var _a;
|
986
1024
|
return (_a = this._paramMatches.find(
|
987
1025
|
(m) => m.name && m.name === parameterName || m.type && m.type === parameter.type || !m.type && !m.name
|
988
1026
|
)) == null ? void 0 : _a.enhancer;
|
989
1027
|
}
|
1028
|
+
/**
|
1029
|
+
* Resolves component enhancer(s) for a given component.
|
1030
|
+
* Returns a Map where the key is the name of the data property and the value is the enhancer.
|
1031
|
+
*/
|
990
1032
|
resolveComponentEnhancers() {
|
991
1033
|
return this._dataMatches;
|
992
1034
|
}
|
@@ -1003,22 +1045,33 @@ var EnhancerBuilder = class {
|
|
1003
1045
|
this._componentIndex = {};
|
1004
1046
|
this._rootBuilder = new ChildEnhancerBuilder();
|
1005
1047
|
}
|
1048
|
+
/** Targets an enhancer to modify the value of any parameter */
|
1006
1049
|
parameter(enhancer) {
|
1007
1050
|
this._rootBuilder.parameter(enhancer);
|
1008
1051
|
return this;
|
1009
1052
|
}
|
1053
|
+
/** Targets an enhancer to modify the value of any parameter with a specific name */
|
1010
1054
|
parameterName(name, enhancer) {
|
1011
1055
|
this._rootBuilder.parameterName(name, enhancer);
|
1012
1056
|
return this;
|
1013
1057
|
}
|
1058
|
+
/** Targets an enhancer to modify the value of any parameter with a specific type */
|
1014
1059
|
parameterType(type, enhancer) {
|
1015
1060
|
this._rootBuilder.parameterType(type, enhancer);
|
1016
1061
|
return this;
|
1017
1062
|
}
|
1063
|
+
/**
|
1064
|
+
* Targets an enhancer to set a specific object key on the component's `data` property.
|
1065
|
+
* Note: an exception will be thrown if the same key is registered more than once.
|
1066
|
+
*/
|
1018
1067
|
data(name, enhancer) {
|
1019
1068
|
this._rootBuilder.data(name, enhancer);
|
1020
1069
|
return this;
|
1021
1070
|
}
|
1071
|
+
/**
|
1072
|
+
* Targets a subset of enhancers at a specific component type.
|
1073
|
+
* Global enhancers will still be run if no matching enhancer is registered for this component's properties.
|
1074
|
+
*/
|
1022
1075
|
component(name, builder) {
|
1023
1076
|
const names = Array.isArray(name) ? name : [name];
|
1024
1077
|
names.forEach((name2) => {
|
@@ -1027,6 +1080,10 @@ var EnhancerBuilder = class {
|
|
1027
1080
|
});
|
1028
1081
|
return this;
|
1029
1082
|
}
|
1083
|
+
/**
|
1084
|
+
* Resolves the parameter enhancer for a given parameter, if one exists.
|
1085
|
+
* The first matching enhancer by registration order is returned, if more than one could match.
|
1086
|
+
*/
|
1030
1087
|
resolveParameterEnhancer(component, parameterName, parameter) {
|
1031
1088
|
const eb = this._componentIndex[component.type];
|
1032
1089
|
if (eb) {
|
@@ -1037,6 +1094,10 @@ var EnhancerBuilder = class {
|
|
1037
1094
|
}
|
1038
1095
|
return this._rootBuilder.resolveParameterEnhancer(parameterName, parameter);
|
1039
1096
|
}
|
1097
|
+
/**
|
1098
|
+
* Resolves component enhancer(s) for a given component.
|
1099
|
+
* Returns a Map where the key is the name of the data property and the value is the enhancer.
|
1100
|
+
*/
|
1040
1101
|
resolveComponentEnhancers(component) {
|
1041
1102
|
let componentEnhancers = this._rootBuilder.resolveComponentEnhancers();
|
1042
1103
|
const eb = this._componentIndex[component.type];
|
@@ -1127,9 +1188,11 @@ var UniqueBatchEntries = class {
|
|
1127
1188
|
return acc;
|
1128
1189
|
}, {});
|
1129
1190
|
}
|
1191
|
+
/** Resolves all entries in a group key with the same result value. */
|
1130
1192
|
resolveKey(key, result) {
|
1131
1193
|
this.groups[key].forEach((task) => task.resolve(result));
|
1132
1194
|
}
|
1195
|
+
/** Resolves all remaining entries that have not been otherwise resolved with a specific value */
|
1133
1196
|
resolveRemaining(value) {
|
1134
1197
|
Object.keys(this.groups).forEach((key) => {
|
1135
1198
|
this.groups[key].forEach((task) => {
|
@@ -1302,7 +1365,7 @@ async function loadPusher() {
|
|
1302
1365
|
resolve(window.Pusher);
|
1303
1366
|
}
|
1304
1367
|
reject(
|
1305
|
-
`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${PUSHER_SRC}"
|
1368
|
+
`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${PUSHER_SRC}"></script> manually.`
|
1306
1369
|
);
|
1307
1370
|
}, 5e3);
|
1308
1371
|
const pusher = document.createElement("script");
|
@@ -1419,6 +1482,7 @@ function mapSlotToTestVariations(slot) {
|
|
1419
1482
|
return {
|
1420
1483
|
...v,
|
1421
1484
|
id
|
1485
|
+
//testDistribution: contextTag?.testDistribution,
|
1422
1486
|
};
|
1423
1487
|
});
|
1424
1488
|
}
|
package/dist/index.js
CHANGED
@@ -21,6 +21,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
21
21
|
return to;
|
22
22
|
};
|
23
23
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
28
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
29
|
mod
|
26
30
|
));
|
@@ -84,7 +88,7 @@ var require_retry_operation = __commonJS({
|
|
84
88
|
if (!err) {
|
85
89
|
return false;
|
86
90
|
}
|
87
|
-
var currentTime = new Date().getTime();
|
91
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
88
92
|
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
89
93
|
this._errors.push(err);
|
90
94
|
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
@@ -134,7 +138,7 @@ var require_retry_operation = __commonJS({
|
|
134
138
|
self._operationTimeoutCb();
|
135
139
|
}, self._operationTimeout);
|
136
140
|
}
|
137
|
-
this._operationStart = new Date().getTime();
|
141
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
138
142
|
this._fn(this._attempts);
|
139
143
|
};
|
140
144
|
RetryOperation.prototype.try = function(fn) {
|
@@ -339,10 +343,15 @@ var import_api = require("@uniformdev/context/api");
|
|
339
343
|
var import_retry = __toESM(require_retry2(), 1);
|
340
344
|
var networkErrorMsgs = /* @__PURE__ */ new Set([
|
341
345
|
"Failed to fetch",
|
346
|
+
// Chrome
|
342
347
|
"NetworkError when attempting to fetch resource.",
|
348
|
+
// Firefox
|
343
349
|
"The Internet connection appears to be offline.",
|
350
|
+
// Safari
|
344
351
|
"Network request failed",
|
352
|
+
// `cross-fetch`
|
345
353
|
"fetch failed"
|
354
|
+
// Undici (Node.js)
|
346
355
|
]);
|
347
356
|
var AbortError = class extends Error {
|
348
357
|
constructor(message) {
|
@@ -523,6 +532,7 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
523
532
|
super(options);
|
524
533
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
525
534
|
}
|
535
|
+
/** Fetches lists of Canvas compositions, optionally by type */
|
526
536
|
async getCompositionList(options) {
|
527
537
|
const { projectId } = this.options;
|
528
538
|
const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
|
@@ -531,12 +541,14 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
531
541
|
getCompositionByNodePath(options) {
|
532
542
|
return this.getOneComposition(options);
|
533
543
|
}
|
544
|
+
/** @deprecated use getCompositionByNodePath instead */
|
534
545
|
unstable_getCompositionByNodePath(options) {
|
535
546
|
return this.getOneComposition(options);
|
536
547
|
}
|
537
548
|
getCompositionByNodeId(options) {
|
538
549
|
return this.getOneComposition(options);
|
539
550
|
}
|
551
|
+
/** @deprecated Use getCompositionByNodeId instead */
|
540
552
|
unstable_getCompositionByNodeId(options) {
|
541
553
|
return this.getOneComposition(options);
|
542
554
|
}
|
@@ -565,6 +577,7 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
565
577
|
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
566
578
|
return this.apiClient(edgeUrl);
|
567
579
|
}
|
580
|
+
/** Updates or creates a Canvas component definition */
|
568
581
|
async updateComposition(body) {
|
569
582
|
const fetchUri = this.createUrl(CANVAS_URL);
|
570
583
|
await this.apiClient(fetchUri, {
|
@@ -573,6 +586,7 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
573
586
|
expectNoContent: true
|
574
587
|
});
|
575
588
|
}
|
589
|
+
/** Deletes a Canvas component definition */
|
576
590
|
async removeComposition(body) {
|
577
591
|
const fetchUri = this.createUrl(CANVAS_URL);
|
578
592
|
const { projectId } = this.options;
|
@@ -582,11 +596,13 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
582
596
|
expectNoContent: true
|
583
597
|
});
|
584
598
|
}
|
599
|
+
/** Fetches all Canvas component definitions */
|
585
600
|
async getComponentDefinitions(options) {
|
586
601
|
const { projectId } = this.options;
|
587
602
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
|
588
603
|
return await this.apiClient(fetchUri);
|
589
604
|
}
|
605
|
+
/** Updates or creates a Canvas component definition */
|
590
606
|
async updateComponentDefinition(body) {
|
591
607
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
592
608
|
await this.apiClient(fetchUri, {
|
@@ -595,6 +611,7 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
595
611
|
expectNoContent: true
|
596
612
|
});
|
597
613
|
}
|
614
|
+
/** Deletes a Canvas component definition */
|
598
615
|
async removeComponentDefinition(body) {
|
599
616
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions");
|
600
617
|
await this.apiClient(fetchUri, {
|
@@ -618,16 +635,19 @@ var DataSourceClient = class extends import_api2.ApiClient {
|
|
618
635
|
constructor(options) {
|
619
636
|
super(options);
|
620
637
|
}
|
638
|
+
/** Fetches all DataSources for a project */
|
621
639
|
async get(options) {
|
622
640
|
const { projectId } = this.options;
|
623
641
|
const fetchUri = this.createUrl(dataSourceUrl, { ...options, projectId });
|
624
642
|
return await this.apiClient(fetchUri);
|
625
643
|
}
|
644
|
+
/** Fetches all DataSources for a project */
|
626
645
|
async getList(options) {
|
627
646
|
const { projectId } = this.options;
|
628
647
|
const fetchUri = this.createUrl(dataSourcesUrl, { ...options, projectId });
|
629
648
|
return await this.apiClient(fetchUri);
|
630
649
|
}
|
650
|
+
/** Updates or creates (based on id) a DataSource */
|
631
651
|
async upsert(body) {
|
632
652
|
const fetchUri = this.createUrl(dataSourceUrl);
|
633
653
|
await this.apiClient(fetchUri, {
|
@@ -636,6 +656,7 @@ var DataSourceClient = class extends import_api2.ApiClient {
|
|
636
656
|
expectNoContent: true
|
637
657
|
});
|
638
658
|
}
|
659
|
+
/** Deletes a DataSource */
|
639
660
|
async remove(body) {
|
640
661
|
const fetchUri = this.createUrl(dataSourceUrl);
|
641
662
|
await this.apiClient(fetchUri, {
|
@@ -653,11 +674,13 @@ var _DataTypeClient = class extends import_api3.ApiClient {
|
|
653
674
|
constructor(options) {
|
654
675
|
super(options);
|
655
676
|
}
|
677
|
+
/** Fetches all DataTypes for a project */
|
656
678
|
async get(options) {
|
657
679
|
const { projectId } = this.options;
|
658
680
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url), { ...options, projectId });
|
659
681
|
return await this.apiClient(fetchUri);
|
660
682
|
}
|
683
|
+
/** Updates or creates (based on id) a DataType */
|
661
684
|
async upsert(body) {
|
662
685
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
663
686
|
await this.apiClient(fetchUri, {
|
@@ -666,6 +689,7 @@ var _DataTypeClient = class extends import_api3.ApiClient {
|
|
666
689
|
expectNoContent: true
|
667
690
|
});
|
668
691
|
}
|
692
|
+
/** Deletes a DataType */
|
669
693
|
async remove(body) {
|
670
694
|
const fetchUri = this.createUrl(__privateGet(_DataTypeClient, _url));
|
671
695
|
await this.apiClient(fetchUri, {
|
@@ -687,14 +711,17 @@ var BatchEntry = class {
|
|
687
711
|
this.args = args;
|
688
712
|
this._isCompleted = false;
|
689
713
|
}
|
714
|
+
/** Mark the batch entry as successfully completed. */
|
690
715
|
resolve(result) {
|
691
716
|
this._resolve(result);
|
692
717
|
this._isCompleted = true;
|
693
718
|
}
|
719
|
+
/** Mark the batch entry as failed. */
|
694
720
|
reject(reason) {
|
695
721
|
this._reject(reason);
|
696
722
|
this._isCompleted = true;
|
697
723
|
}
|
724
|
+
/** @return Whether the batch entry has been completed (resolved or rejected). */
|
698
725
|
get isCompleted() {
|
699
726
|
return this._isCompleted;
|
700
727
|
}
|
@@ -1027,10 +1054,12 @@ var ChildEnhancerBuilder = class {
|
|
1027
1054
|
this._paramMatches = Array();
|
1028
1055
|
this._dataMatches = /* @__PURE__ */ new Map();
|
1029
1056
|
}
|
1057
|
+
/** Targets an enhancer to modify the value of any parameter */
|
1030
1058
|
parameter(enhancer) {
|
1031
1059
|
this._paramMatches.push({ enhancer: this._resolveParameterEnhancer(enhancer) });
|
1032
1060
|
return this;
|
1033
1061
|
}
|
1062
|
+
/** Targets an enhancer to modify the value of any parameter with a specific name */
|
1034
1063
|
parameterName(name, enhancer) {
|
1035
1064
|
const names = Array.isArray(name) ? name : [name];
|
1036
1065
|
names.forEach(
|
@@ -1038,6 +1067,7 @@ var ChildEnhancerBuilder = class {
|
|
1038
1067
|
);
|
1039
1068
|
return this;
|
1040
1069
|
}
|
1070
|
+
/** Targets an enhancer to modify the value of any parameter with a specific type */
|
1041
1071
|
parameterType(type, enhancer) {
|
1042
1072
|
const types = Array.isArray(type) ? type : [type];
|
1043
1073
|
types.forEach(
|
@@ -1045,6 +1075,10 @@ var ChildEnhancerBuilder = class {
|
|
1045
1075
|
);
|
1046
1076
|
return this;
|
1047
1077
|
}
|
1078
|
+
/**
|
1079
|
+
* Targets an enhancer to set a specific object key on the component's `data` property.
|
1080
|
+
* Note: an exception will be thrown if the same key is registered more than once.
|
1081
|
+
*/
|
1048
1082
|
data(name, enhancer) {
|
1049
1083
|
if (this._dataMatches.has(name)) {
|
1050
1084
|
throw new Error(`${name} enhancer data key has been used more than once. This will cause data loss.`);
|
@@ -1052,12 +1086,20 @@ var ChildEnhancerBuilder = class {
|
|
1052
1086
|
this._dataMatches.set(name, typeof enhancer === "function" ? { enhanceOne: enhancer } : enhancer);
|
1053
1087
|
return this;
|
1054
1088
|
}
|
1089
|
+
/**
|
1090
|
+
* Resolves the parameter enhancer for a given parameter, if one exists.
|
1091
|
+
* The first matching enhancer by registration order is returned, if more than one could match.
|
1092
|
+
*/
|
1055
1093
|
resolveParameterEnhancer(parameterName, parameter) {
|
1056
1094
|
var _a;
|
1057
1095
|
return (_a = this._paramMatches.find(
|
1058
1096
|
(m) => m.name && m.name === parameterName || m.type && m.type === parameter.type || !m.type && !m.name
|
1059
1097
|
)) == null ? void 0 : _a.enhancer;
|
1060
1098
|
}
|
1099
|
+
/**
|
1100
|
+
* Resolves component enhancer(s) for a given component.
|
1101
|
+
* Returns a Map where the key is the name of the data property and the value is the enhancer.
|
1102
|
+
*/
|
1061
1103
|
resolveComponentEnhancers() {
|
1062
1104
|
return this._dataMatches;
|
1063
1105
|
}
|
@@ -1074,22 +1116,33 @@ var EnhancerBuilder = class {
|
|
1074
1116
|
this._componentIndex = {};
|
1075
1117
|
this._rootBuilder = new ChildEnhancerBuilder();
|
1076
1118
|
}
|
1119
|
+
/** Targets an enhancer to modify the value of any parameter */
|
1077
1120
|
parameter(enhancer) {
|
1078
1121
|
this._rootBuilder.parameter(enhancer);
|
1079
1122
|
return this;
|
1080
1123
|
}
|
1124
|
+
/** Targets an enhancer to modify the value of any parameter with a specific name */
|
1081
1125
|
parameterName(name, enhancer) {
|
1082
1126
|
this._rootBuilder.parameterName(name, enhancer);
|
1083
1127
|
return this;
|
1084
1128
|
}
|
1129
|
+
/** Targets an enhancer to modify the value of any parameter with a specific type */
|
1085
1130
|
parameterType(type, enhancer) {
|
1086
1131
|
this._rootBuilder.parameterType(type, enhancer);
|
1087
1132
|
return this;
|
1088
1133
|
}
|
1134
|
+
/**
|
1135
|
+
* Targets an enhancer to set a specific object key on the component's `data` property.
|
1136
|
+
* Note: an exception will be thrown if the same key is registered more than once.
|
1137
|
+
*/
|
1089
1138
|
data(name, enhancer) {
|
1090
1139
|
this._rootBuilder.data(name, enhancer);
|
1091
1140
|
return this;
|
1092
1141
|
}
|
1142
|
+
/**
|
1143
|
+
* Targets a subset of enhancers at a specific component type.
|
1144
|
+
* Global enhancers will still be run if no matching enhancer is registered for this component's properties.
|
1145
|
+
*/
|
1093
1146
|
component(name, builder) {
|
1094
1147
|
const names = Array.isArray(name) ? name : [name];
|
1095
1148
|
names.forEach((name2) => {
|
@@ -1098,6 +1151,10 @@ var EnhancerBuilder = class {
|
|
1098
1151
|
});
|
1099
1152
|
return this;
|
1100
1153
|
}
|
1154
|
+
/**
|
1155
|
+
* Resolves the parameter enhancer for a given parameter, if one exists.
|
1156
|
+
* The first matching enhancer by registration order is returned, if more than one could match.
|
1157
|
+
*/
|
1101
1158
|
resolveParameterEnhancer(component, parameterName, parameter) {
|
1102
1159
|
const eb = this._componentIndex[component.type];
|
1103
1160
|
if (eb) {
|
@@ -1108,6 +1165,10 @@ var EnhancerBuilder = class {
|
|
1108
1165
|
}
|
1109
1166
|
return this._rootBuilder.resolveParameterEnhancer(parameterName, parameter);
|
1110
1167
|
}
|
1168
|
+
/**
|
1169
|
+
* Resolves component enhancer(s) for a given component.
|
1170
|
+
* Returns a Map where the key is the name of the data property and the value is the enhancer.
|
1171
|
+
*/
|
1111
1172
|
resolveComponentEnhancers(component) {
|
1112
1173
|
let componentEnhancers = this._rootBuilder.resolveComponentEnhancers();
|
1113
1174
|
const eb = this._componentIndex[component.type];
|
@@ -1198,9 +1259,11 @@ var UniqueBatchEntries = class {
|
|
1198
1259
|
return acc;
|
1199
1260
|
}, {});
|
1200
1261
|
}
|
1262
|
+
/** Resolves all entries in a group key with the same result value. */
|
1201
1263
|
resolveKey(key, result) {
|
1202
1264
|
this.groups[key].forEach((task) => task.resolve(result));
|
1203
1265
|
}
|
1266
|
+
/** Resolves all remaining entries that have not been otherwise resolved with a specific value */
|
1204
1267
|
resolveRemaining(value) {
|
1205
1268
|
Object.keys(this.groups).forEach((key) => {
|
1206
1269
|
this.groups[key].forEach((task) => {
|
@@ -1373,7 +1436,7 @@ async function loadPusher() {
|
|
1373
1436
|
resolve(window.Pusher);
|
1374
1437
|
}
|
1375
1438
|
reject(
|
1376
|
-
`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${PUSHER_SRC}"
|
1439
|
+
`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${PUSHER_SRC}"></script> manually.`
|
1377
1440
|
);
|
1378
1441
|
}, 5e3);
|
1379
1442
|
const pusher = document.createElement("script");
|
@@ -1490,6 +1553,7 @@ function mapSlotToTestVariations(slot) {
|
|
1490
1553
|
return {
|
1491
1554
|
...v,
|
1492
1555
|
id
|
1556
|
+
//testDistribution: contextTag?.testDistribution,
|
1493
1557
|
};
|
1494
1558
|
});
|
1495
1559
|
}
|