@uniformdev/canvas 20.63.0 → 20.63.1-alpha.17
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.mts +309 -85
- package/dist/index.d.ts +309 -85
- package/dist/index.esm.js +295 -54
- package/dist/index.js +300 -54
- package/dist/index.mjs +295 -54
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -465,11 +465,13 @@ __export(src_exports, {
|
|
|
465
465
|
PreviewClient: () => PreviewClient,
|
|
466
466
|
ProjectClient: () => ProjectClient,
|
|
467
467
|
PromptClient: () => PromptClient,
|
|
468
|
+
REFERENCE_DATA_TYPE_ID: () => REFERENCE_DATA_TYPE_ID,
|
|
468
469
|
RelationshipClient: () => RelationshipClient,
|
|
469
470
|
ReleaseClient: () => ReleaseClient,
|
|
470
471
|
ReleaseContentsClient: () => ReleaseContentsClient,
|
|
471
472
|
RouteClient: () => RouteClient,
|
|
472
473
|
SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
|
|
474
|
+
SELECT_QUERY_PREFIX: () => SELECT_QUERY_PREFIX,
|
|
473
475
|
UncachedCanvasClient: () => UncachedCanvasClient,
|
|
474
476
|
UncachedCategoryClient: () => UncachedCategoryClient,
|
|
475
477
|
UncachedContentClient: () => UncachedContentClient,
|
|
@@ -551,10 +553,13 @@ __export(src_exports, {
|
|
|
551
553
|
localize: () => localize,
|
|
552
554
|
mapSlotToPersonalizedVariations: () => mapSlotToPersonalizedVariations,
|
|
553
555
|
mapSlotToTestVariations: () => mapSlotToTestVariations,
|
|
556
|
+
matchesProjectionPattern: () => matchesProjectionPattern,
|
|
554
557
|
mergeAssetConfigWithDefaults: () => mergeAssetConfigWithDefaults,
|
|
555
558
|
nullLimitPolicy: () => nullLimitPolicy,
|
|
556
559
|
parseComponentPlaceholderId: () => parseComponentPlaceholderId,
|
|
557
560
|
parseVariableExpression: () => parseVariableExpression,
|
|
561
|
+
projectionToQuery: () => projectionToQuery,
|
|
562
|
+
queryToProjection: () => queryToProjection,
|
|
558
563
|
version: () => version,
|
|
559
564
|
walkNodeTree: () => walkNodeTree,
|
|
560
565
|
walkPropertyValues: () => walkPropertyValues
|
|
@@ -766,6 +771,51 @@ function createLimitPolicy({
|
|
|
766
771
|
}
|
|
767
772
|
var nullLimitPolicy = async (func) => await func();
|
|
768
773
|
|
|
774
|
+
// src/projection/types.ts
|
|
775
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
776
|
+
|
|
777
|
+
// src/projection/projectionToQuery.ts
|
|
778
|
+
function appendCsv(out, key, values) {
|
|
779
|
+
if (values === void 0) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
out[key] = values.join(",");
|
|
783
|
+
}
|
|
784
|
+
function projectionToQuery(spec) {
|
|
785
|
+
const out = {};
|
|
786
|
+
if (!spec) {
|
|
787
|
+
return out;
|
|
788
|
+
}
|
|
789
|
+
const { fields, fieldTypes, slots } = spec;
|
|
790
|
+
const p = SELECT_QUERY_PREFIX;
|
|
791
|
+
if (fields) {
|
|
792
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
793
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
794
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
795
|
+
}
|
|
796
|
+
if (fieldTypes) {
|
|
797
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
798
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
799
|
+
}
|
|
800
|
+
if (slots) {
|
|
801
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
802
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
803
|
+
if (typeof slots.depth === "number") {
|
|
804
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
805
|
+
}
|
|
806
|
+
if (slots.named) {
|
|
807
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
808
|
+
for (const slotName of slotNames) {
|
|
809
|
+
const named = slots.named[slotName];
|
|
810
|
+
if (named && typeof named.depth === "number") {
|
|
811
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return out;
|
|
817
|
+
}
|
|
818
|
+
|
|
769
819
|
// src/CanvasClient.ts
|
|
770
820
|
var CANVAS_URL = "/api/v1/canvas";
|
|
771
821
|
var CanvasClient = class extends import_api2.ApiClient {
|
|
@@ -781,17 +831,24 @@ var CanvasClient = class extends import_api2.ApiClient {
|
|
|
781
831
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
782
832
|
async getCompositionList(params = {}) {
|
|
783
833
|
const { projectId } = this.options;
|
|
784
|
-
const { resolveData, filters, ...originParams } = params;
|
|
834
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
785
835
|
const rewrittenFilters = (0, import_api2.rewriteFiltersForApi)(filters);
|
|
836
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
786
837
|
if (!resolveData) {
|
|
787
|
-
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
838
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
839
|
+
...originParams,
|
|
840
|
+
projectId,
|
|
841
|
+
...rewrittenFilters,
|
|
842
|
+
...rewrittenSelect
|
|
843
|
+
});
|
|
788
844
|
return this.apiClient(fetchUri);
|
|
789
845
|
}
|
|
790
846
|
const edgeParams = {
|
|
791
847
|
...originParams,
|
|
792
848
|
projectId,
|
|
793
849
|
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
794
|
-
...rewrittenFilters
|
|
850
|
+
...rewrittenFilters,
|
|
851
|
+
...rewrittenSelect
|
|
795
852
|
};
|
|
796
853
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
797
854
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
@@ -951,15 +1008,21 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
|
|
|
951
1008
|
}
|
|
952
1009
|
getEntries(options) {
|
|
953
1010
|
const { projectId } = this.options;
|
|
954
|
-
const { skipDataResolution, filters, ...params } = options;
|
|
1011
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
955
1012
|
const rewrittenFilters = (0, import_api4.rewriteFiltersForApi)(filters);
|
|
1013
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
956
1014
|
if (skipDataResolution) {
|
|
957
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
1015
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
1016
|
+
...params,
|
|
1017
|
+
...rewrittenFilters,
|
|
1018
|
+
...rewrittenSelect,
|
|
1019
|
+
projectId
|
|
1020
|
+
});
|
|
958
1021
|
return this.apiClient(url);
|
|
959
1022
|
}
|
|
960
1023
|
const edgeUrl = this.createUrl(
|
|
961
1024
|
__privateGet(_ContentClient, _entriesUrl),
|
|
962
|
-
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
|
1025
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
963
1026
|
this.edgeApiHost
|
|
964
1027
|
);
|
|
965
1028
|
return this.apiClient(
|
|
@@ -1288,6 +1351,7 @@ var EDGE_CACHE_DISABLED = -1;
|
|
|
1288
1351
|
var ASSET_PARAMETER_TYPE = "asset";
|
|
1289
1352
|
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
|
1290
1353
|
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
|
1354
|
+
var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
|
|
1291
1355
|
|
|
1292
1356
|
// src/utils/guards.ts
|
|
1293
1357
|
function isRootEntryReference(root) {
|
|
@@ -1446,7 +1510,7 @@ function hasReferencedVariables(value) {
|
|
|
1446
1510
|
|
|
1447
1511
|
// src/enhancement/walkNodeTree.ts
|
|
1448
1512
|
function walkNodeTree(node, visitor, options) {
|
|
1449
|
-
var _a, _b;
|
|
1513
|
+
var _a, _b, _c;
|
|
1450
1514
|
const componentQueue = [
|
|
1451
1515
|
{
|
|
1452
1516
|
ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
|
|
@@ -1454,12 +1518,14 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1454
1518
|
}
|
|
1455
1519
|
];
|
|
1456
1520
|
const childContexts = /* @__PURE__ */ new Map();
|
|
1521
|
+
const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
|
|
1522
|
+
const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
|
|
1457
1523
|
do {
|
|
1458
|
-
const currentQueueEntry =
|
|
1524
|
+
const currentQueueEntry = takeNext();
|
|
1459
1525
|
if (!currentQueueEntry) continue;
|
|
1460
1526
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
|
1461
1527
|
let visitDescendants = true;
|
|
1462
|
-
let descendantContext = (
|
|
1528
|
+
let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
|
|
1463
1529
|
let visitorInfo;
|
|
1464
1530
|
if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
|
|
1465
1531
|
visitorInfo = {
|
|
@@ -1646,39 +1712,11 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1646
1712
|
continue;
|
|
1647
1713
|
}
|
|
1648
1714
|
const slots = "slots" in currentComponent.node && currentComponent.node.slots;
|
|
1649
|
-
|
|
1650
|
-
const slotKeys = Object.keys(slots);
|
|
1651
|
-
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
|
1652
|
-
const slotKey = slotKeys[slotIndex];
|
|
1653
|
-
const components = slots[slotKey];
|
|
1654
|
-
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
|
1655
|
-
const enqueueingComponent = components[componentIndex];
|
|
1656
|
-
const parentSlotIndexFn = () => {
|
|
1657
|
-
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1658
|
-
(x) => x === enqueueingComponent
|
|
1659
|
-
);
|
|
1660
|
-
return result;
|
|
1661
|
-
};
|
|
1662
|
-
componentQueue.push({
|
|
1663
|
-
ancestorsAndSelf: [
|
|
1664
|
-
{
|
|
1665
|
-
type: "slot",
|
|
1666
|
-
node: enqueueingComponent,
|
|
1667
|
-
parentSlot: slotKey,
|
|
1668
|
-
parentSlotIndexFn
|
|
1669
|
-
},
|
|
1670
|
-
...currentQueueEntry.ancestorsAndSelf
|
|
1671
|
-
],
|
|
1672
|
-
context: descendantContext
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1715
|
+
const childEntries = [];
|
|
1677
1716
|
const properties = getPropertiesValue(currentComponent.node);
|
|
1678
1717
|
if (properties) {
|
|
1679
1718
|
const propertyEntries = Object.entries(properties);
|
|
1680
|
-
for (
|
|
1681
|
-
const [propKey, propObject] = propertyEntries[propIndex];
|
|
1719
|
+
for (const [propKey, propObject] of propertyEntries) {
|
|
1682
1720
|
if (!isNestedNodeType(propObject.type)) {
|
|
1683
1721
|
continue;
|
|
1684
1722
|
}
|
|
@@ -1698,13 +1736,12 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1698
1736
|
continue;
|
|
1699
1737
|
}
|
|
1700
1738
|
}
|
|
1701
|
-
const blocks = (
|
|
1702
|
-
for (
|
|
1703
|
-
const enqueueingBlock = blocks[blockIndex];
|
|
1739
|
+
const blocks = (_c = propObject.value) != null ? _c : [];
|
|
1740
|
+
for (const enqueueingBlock of blocks) {
|
|
1704
1741
|
const blockIndexFn = () => {
|
|
1705
1742
|
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
|
1706
1743
|
};
|
|
1707
|
-
|
|
1744
|
+
childEntries.push({
|
|
1708
1745
|
ancestorsAndSelf: [
|
|
1709
1746
|
{
|
|
1710
1747
|
type: "block",
|
|
@@ -1719,6 +1756,36 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1719
1756
|
}
|
|
1720
1757
|
}
|
|
1721
1758
|
}
|
|
1759
|
+
if (slots) {
|
|
1760
|
+
const slotKeys = Object.keys(slots);
|
|
1761
|
+
for (const slotKey of slotKeys) {
|
|
1762
|
+
const components = slots[slotKey];
|
|
1763
|
+
for (const enqueueingComponent of components) {
|
|
1764
|
+
const parentSlotIndexFn = () => {
|
|
1765
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1766
|
+
(x) => x === enqueueingComponent
|
|
1767
|
+
);
|
|
1768
|
+
return result;
|
|
1769
|
+
};
|
|
1770
|
+
childEntries.push({
|
|
1771
|
+
ancestorsAndSelf: [
|
|
1772
|
+
{
|
|
1773
|
+
type: "slot",
|
|
1774
|
+
node: enqueueingComponent,
|
|
1775
|
+
parentSlot: slotKey,
|
|
1776
|
+
parentSlotIndexFn
|
|
1777
|
+
},
|
|
1778
|
+
...currentQueueEntry.ancestorsAndSelf
|
|
1779
|
+
],
|
|
1780
|
+
context: descendantContext
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
if (order === "dfs") {
|
|
1786
|
+
childEntries.reverse();
|
|
1787
|
+
}
|
|
1788
|
+
componentQueue.push(...childEntries);
|
|
1722
1789
|
} while (componentQueue.length > 0);
|
|
1723
1790
|
}
|
|
1724
1791
|
function isNestedNodeType(type) {
|
|
@@ -2584,8 +2651,7 @@ function extractLocales({ component }) {
|
|
|
2584
2651
|
return variations;
|
|
2585
2652
|
}
|
|
2586
2653
|
function localize(options) {
|
|
2587
|
-
const nodes = options
|
|
2588
|
-
const locale = options.locale;
|
|
2654
|
+
const { nodes, locale, keepLocalesFor } = options;
|
|
2589
2655
|
if (!locale) {
|
|
2590
2656
|
return;
|
|
2591
2657
|
}
|
|
@@ -2593,7 +2659,7 @@ function localize(options) {
|
|
|
2593
2659
|
walkNodeTree(nodes, (context) => {
|
|
2594
2660
|
const { type, node, actions } = context;
|
|
2595
2661
|
if (type !== "component") {
|
|
2596
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2662
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2597
2663
|
return;
|
|
2598
2664
|
}
|
|
2599
2665
|
const result = evaluateWalkTreeNodeVisibility({
|
|
@@ -2614,7 +2680,7 @@ function localize(options) {
|
|
|
2614
2680
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
|
2615
2681
|
replaceComponent.forEach((component) => {
|
|
2616
2682
|
removeLocaleProperty(component);
|
|
2617
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
|
2683
|
+
localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2618
2684
|
});
|
|
2619
2685
|
const [first, ...rest] = replaceComponent;
|
|
2620
2686
|
actions.replace(first);
|
|
@@ -2625,7 +2691,7 @@ function localize(options) {
|
|
|
2625
2691
|
actions.remove();
|
|
2626
2692
|
}
|
|
2627
2693
|
} else {
|
|
2628
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2694
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2629
2695
|
}
|
|
2630
2696
|
});
|
|
2631
2697
|
}
|
|
@@ -2644,7 +2710,7 @@ function removeLocaleProperty(component) {
|
|
|
2644
2710
|
}
|
|
2645
2711
|
}
|
|
2646
2712
|
}
|
|
2647
|
-
function localizeProperties(node, locale, rules) {
|
|
2713
|
+
function localizeProperties(node, locale, rules, keepLocalesFor) {
|
|
2648
2714
|
const properties = getPropertiesValue(node);
|
|
2649
2715
|
if (!properties) {
|
|
2650
2716
|
return void 0;
|
|
@@ -2663,10 +2729,16 @@ function localizeProperties(node, locale, rules) {
|
|
|
2663
2729
|
if (currentLocaleConditionalValues !== void 0) {
|
|
2664
2730
|
propertyValue.conditions = currentLocaleConditionalValues;
|
|
2665
2731
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2732
|
+
const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
|
|
2733
|
+
if (!preserveLocales) {
|
|
2734
|
+
delete propertyValue.locales;
|
|
2735
|
+
delete propertyValue.localesConditions;
|
|
2736
|
+
}
|
|
2668
2737
|
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
|
2669
|
-
|
|
2738
|
+
const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
|
|
2739
|
+
if (!hasLocales) {
|
|
2740
|
+
delete properties[propertyId];
|
|
2741
|
+
}
|
|
2670
2742
|
}
|
|
2671
2743
|
});
|
|
2672
2744
|
evaluateWalkTreePropertyCriteria({
|
|
@@ -3345,6 +3417,173 @@ __privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
|
3345
3417
|
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
3346
3418
|
var ProjectClient = _ProjectClient;
|
|
3347
3419
|
|
|
3420
|
+
// src/projection/matchesProjectionPattern.ts
|
|
3421
|
+
var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
|
|
3422
|
+
var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
|
|
3423
|
+
function isValidProjectionPattern(pattern) {
|
|
3424
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
3425
|
+
return false;
|
|
3426
|
+
}
|
|
3427
|
+
if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
|
|
3428
|
+
return false;
|
|
3429
|
+
}
|
|
3430
|
+
return true;
|
|
3431
|
+
}
|
|
3432
|
+
function compilePattern(pattern) {
|
|
3433
|
+
let regexSource = "^";
|
|
3434
|
+
for (const ch of pattern) {
|
|
3435
|
+
if (ch === "*") {
|
|
3436
|
+
regexSource += ".*";
|
|
3437
|
+
} else {
|
|
3438
|
+
regexSource += ch.replace(REGEX_METACHAR, "\\$&");
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
regexSource += "$";
|
|
3442
|
+
return new RegExp(regexSource);
|
|
3443
|
+
}
|
|
3444
|
+
var PATTERN_CACHE_MAX = 1024;
|
|
3445
|
+
var patternRegexCache = /* @__PURE__ */ new Map();
|
|
3446
|
+
function matchesProjectionPattern(pattern, value) {
|
|
3447
|
+
let re = patternRegexCache.get(pattern);
|
|
3448
|
+
if (re === void 0) {
|
|
3449
|
+
if (!isValidProjectionPattern(pattern)) {
|
|
3450
|
+
throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
|
|
3451
|
+
}
|
|
3452
|
+
re = compilePattern(pattern);
|
|
3453
|
+
if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
|
|
3454
|
+
const oldest = patternRegexCache.keys().next().value;
|
|
3455
|
+
if (oldest !== void 0) patternRegexCache.delete(oldest);
|
|
3456
|
+
}
|
|
3457
|
+
patternRegexCache.set(pattern, re);
|
|
3458
|
+
}
|
|
3459
|
+
return re.test(value);
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
// src/projection/queryToProjection.ts
|
|
3463
|
+
var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
|
|
3464
|
+
var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
|
|
3465
|
+
function toStringValue2(value) {
|
|
3466
|
+
if (Array.isArray(value)) {
|
|
3467
|
+
return value.join(",");
|
|
3468
|
+
}
|
|
3469
|
+
return value;
|
|
3470
|
+
}
|
|
3471
|
+
function parseCsv(value) {
|
|
3472
|
+
const str = toStringValue2(value);
|
|
3473
|
+
if (!str) {
|
|
3474
|
+
return [];
|
|
3475
|
+
}
|
|
3476
|
+
return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
3477
|
+
}
|
|
3478
|
+
function parseDepth(value, key) {
|
|
3479
|
+
const str = toStringValue2(value);
|
|
3480
|
+
if (str === void 0 || str === "") {
|
|
3481
|
+
throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
|
|
3482
|
+
}
|
|
3483
|
+
if (!/^\d+$/.test(str)) {
|
|
3484
|
+
throw new Error(
|
|
3485
|
+
`Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
|
|
3486
|
+
);
|
|
3487
|
+
}
|
|
3488
|
+
return Number(str);
|
|
3489
|
+
}
|
|
3490
|
+
function extractSelectKeys(source) {
|
|
3491
|
+
if (source instanceof URLSearchParams) {
|
|
3492
|
+
let out2;
|
|
3493
|
+
for (const [key, value] of source.entries()) {
|
|
3494
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3495
|
+
out2 != null ? out2 : out2 = {};
|
|
3496
|
+
out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
|
|
3497
|
+
}
|
|
3498
|
+
return out2;
|
|
3499
|
+
}
|
|
3500
|
+
let out;
|
|
3501
|
+
for (const key in source) {
|
|
3502
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3503
|
+
out != null ? out : out = {};
|
|
3504
|
+
out[key] = source[key];
|
|
3505
|
+
}
|
|
3506
|
+
return out;
|
|
3507
|
+
}
|
|
3508
|
+
function queryToProjection(source) {
|
|
3509
|
+
var _a, _b, _c, _d, _e;
|
|
3510
|
+
if (!source) {
|
|
3511
|
+
return void 0;
|
|
3512
|
+
}
|
|
3513
|
+
const query = extractSelectKeys(source);
|
|
3514
|
+
if (!query) {
|
|
3515
|
+
return void 0;
|
|
3516
|
+
}
|
|
3517
|
+
const spec = {};
|
|
3518
|
+
for (const [rawKey, value] of Object.entries(query)) {
|
|
3519
|
+
const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
|
|
3520
|
+
const namedMatch = SLOTS_NAMED_KEY.exec(key);
|
|
3521
|
+
if (namedMatch) {
|
|
3522
|
+
const [, slotName, operator2] = namedMatch;
|
|
3523
|
+
if (operator2 !== "depth") {
|
|
3524
|
+
throw new Error(
|
|
3525
|
+
`Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
|
|
3526
|
+
);
|
|
3527
|
+
}
|
|
3528
|
+
const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
|
|
3529
|
+
const named = (_b = slots.named) != null ? _b : slots.named = {};
|
|
3530
|
+
named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
|
|
3531
|
+
continue;
|
|
3532
|
+
}
|
|
3533
|
+
const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
|
|
3534
|
+
if (!topMatch) {
|
|
3535
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3536
|
+
}
|
|
3537
|
+
const [, bucket, operator] = topMatch;
|
|
3538
|
+
if (bucket === "fields") {
|
|
3539
|
+
const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
|
|
3540
|
+
switch (operator) {
|
|
3541
|
+
case "only":
|
|
3542
|
+
fields.only = parseCsv(value);
|
|
3543
|
+
break;
|
|
3544
|
+
case "except":
|
|
3545
|
+
fields.except = parseCsv(value);
|
|
3546
|
+
break;
|
|
3547
|
+
case "locales":
|
|
3548
|
+
fields.locales = parseCsv(value);
|
|
3549
|
+
break;
|
|
3550
|
+
default:
|
|
3551
|
+
throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
|
|
3552
|
+
}
|
|
3553
|
+
} else if (bucket === "fieldTypes") {
|
|
3554
|
+
const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
|
|
3555
|
+
switch (operator) {
|
|
3556
|
+
case "only":
|
|
3557
|
+
fieldTypes.only = parseCsv(value);
|
|
3558
|
+
break;
|
|
3559
|
+
case "except":
|
|
3560
|
+
fieldTypes.except = parseCsv(value);
|
|
3561
|
+
break;
|
|
3562
|
+
default:
|
|
3563
|
+
throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
|
|
3564
|
+
}
|
|
3565
|
+
} else if (bucket === "slots") {
|
|
3566
|
+
const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
|
|
3567
|
+
switch (operator) {
|
|
3568
|
+
case "only":
|
|
3569
|
+
slots.only = parseCsv(value);
|
|
3570
|
+
break;
|
|
3571
|
+
case "except":
|
|
3572
|
+
slots.except = parseCsv(value);
|
|
3573
|
+
break;
|
|
3574
|
+
case "depth":
|
|
3575
|
+
slots.depth = parseDepth(value, rawKey);
|
|
3576
|
+
break;
|
|
3577
|
+
default:
|
|
3578
|
+
throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
|
|
3579
|
+
}
|
|
3580
|
+
} else {
|
|
3581
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
return spec;
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3348
3587
|
// src/PromptClient.ts
|
|
3349
3588
|
var import_api13 = require("@uniformdev/context/api");
|
|
3350
3589
|
var PromptsUrl = "/api/v1/prompts";
|
|
@@ -3473,7 +3712,9 @@ var RouteClient = class extends import_api17.ApiClient {
|
|
|
3473
3712
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
3474
3713
|
async getRoute(options) {
|
|
3475
3714
|
const { projectId } = this.options;
|
|
3476
|
-
const
|
|
3715
|
+
const { select, ...rest } = options != null ? options : {};
|
|
3716
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
3717
|
+
const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
|
|
3477
3718
|
return await this.apiClient(
|
|
3478
3719
|
fetchUri,
|
|
3479
3720
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
@@ -3836,7 +4077,7 @@ function handleRichTextNodeBinding(object, options) {
|
|
|
3836
4077
|
var import_api19 = require("@uniformdev/context/api");
|
|
3837
4078
|
|
|
3838
4079
|
// src/.version.ts
|
|
3839
|
-
var version = "20.
|
|
4080
|
+
var version = "20.66.0";
|
|
3840
4081
|
|
|
3841
4082
|
// src/WorkflowClient.ts
|
|
3842
4083
|
var import_api18 = require("@uniformdev/context/api");
|
|
@@ -3952,11 +4193,13 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
3952
4193
|
PreviewClient,
|
|
3953
4194
|
ProjectClient,
|
|
3954
4195
|
PromptClient,
|
|
4196
|
+
REFERENCE_DATA_TYPE_ID,
|
|
3955
4197
|
RelationshipClient,
|
|
3956
4198
|
ReleaseClient,
|
|
3957
4199
|
ReleaseContentsClient,
|
|
3958
4200
|
RouteClient,
|
|
3959
4201
|
SECRET_QUERY_STRING_PARAM,
|
|
4202
|
+
SELECT_QUERY_PREFIX,
|
|
3960
4203
|
UncachedCanvasClient,
|
|
3961
4204
|
UncachedCategoryClient,
|
|
3962
4205
|
UncachedContentClient,
|
|
@@ -4038,10 +4281,13 @@ var CanvasClientError = import_api19.ApiClientError;
|
|
|
4038
4281
|
localize,
|
|
4039
4282
|
mapSlotToPersonalizedVariations,
|
|
4040
4283
|
mapSlotToTestVariations,
|
|
4284
|
+
matchesProjectionPattern,
|
|
4041
4285
|
mergeAssetConfigWithDefaults,
|
|
4042
4286
|
nullLimitPolicy,
|
|
4043
4287
|
parseComponentPlaceholderId,
|
|
4044
4288
|
parseVariableExpression,
|
|
4289
|
+
projectionToQuery,
|
|
4290
|
+
queryToProjection,
|
|
4045
4291
|
version,
|
|
4046
4292
|
walkNodeTree,
|
|
4047
4293
|
walkPropertyValues
|