@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.mjs
CHANGED
|
@@ -584,6 +584,51 @@ function createLimitPolicy({
|
|
|
584
584
|
}
|
|
585
585
|
var nullLimitPolicy = async (func) => await func();
|
|
586
586
|
|
|
587
|
+
// src/projection/types.ts
|
|
588
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
589
|
+
|
|
590
|
+
// src/projection/projectionToQuery.ts
|
|
591
|
+
function appendCsv(out, key, values) {
|
|
592
|
+
if (values === void 0) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
out[key] = values.join(",");
|
|
596
|
+
}
|
|
597
|
+
function projectionToQuery(spec) {
|
|
598
|
+
const out = {};
|
|
599
|
+
if (!spec) {
|
|
600
|
+
return out;
|
|
601
|
+
}
|
|
602
|
+
const { fields, fieldTypes, slots } = spec;
|
|
603
|
+
const p = SELECT_QUERY_PREFIX;
|
|
604
|
+
if (fields) {
|
|
605
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
606
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
607
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
608
|
+
}
|
|
609
|
+
if (fieldTypes) {
|
|
610
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
611
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
612
|
+
}
|
|
613
|
+
if (slots) {
|
|
614
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
615
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
616
|
+
if (typeof slots.depth === "number") {
|
|
617
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
618
|
+
}
|
|
619
|
+
if (slots.named) {
|
|
620
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
621
|
+
for (const slotName of slotNames) {
|
|
622
|
+
const named = slots.named[slotName];
|
|
623
|
+
if (named && typeof named.depth === "number") {
|
|
624
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return out;
|
|
630
|
+
}
|
|
631
|
+
|
|
587
632
|
// src/CanvasClient.ts
|
|
588
633
|
var CANVAS_URL = "/api/v1/canvas";
|
|
589
634
|
var CanvasClient = class extends ApiClient {
|
|
@@ -599,17 +644,24 @@ var CanvasClient = class extends ApiClient {
|
|
|
599
644
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
600
645
|
async getCompositionList(params = {}) {
|
|
601
646
|
const { projectId } = this.options;
|
|
602
|
-
const { resolveData, filters, ...originParams } = params;
|
|
647
|
+
const { resolveData, filters, select, ...originParams } = params;
|
|
603
648
|
const rewrittenFilters = rewriteFiltersForApi(filters);
|
|
649
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
604
650
|
if (!resolveData) {
|
|
605
|
-
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
651
|
+
const fetchUri = this.createUrl(CANVAS_URL, {
|
|
652
|
+
...originParams,
|
|
653
|
+
projectId,
|
|
654
|
+
...rewrittenFilters,
|
|
655
|
+
...rewrittenSelect
|
|
656
|
+
});
|
|
606
657
|
return this.apiClient(fetchUri);
|
|
607
658
|
}
|
|
608
659
|
const edgeParams = {
|
|
609
660
|
...originParams,
|
|
610
661
|
projectId,
|
|
611
662
|
diagnostics: typeof params.diagnostics === "boolean" ? params.diagnostics : params.diagnostics === "no-data" ? "no-data" : void 0,
|
|
612
|
-
...rewrittenFilters
|
|
663
|
+
...rewrittenFilters,
|
|
664
|
+
...rewrittenSelect
|
|
613
665
|
};
|
|
614
666
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
|
615
667
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
|
@@ -769,15 +821,21 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
|
|
|
769
821
|
}
|
|
770
822
|
getEntries(options) {
|
|
771
823
|
const { projectId } = this.options;
|
|
772
|
-
const { skipDataResolution, filters, ...params } = options;
|
|
824
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
773
825
|
const rewrittenFilters = rewriteFiltersForApi2(filters);
|
|
826
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
774
827
|
if (skipDataResolution) {
|
|
775
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
828
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), {
|
|
829
|
+
...params,
|
|
830
|
+
...rewrittenFilters,
|
|
831
|
+
...rewrittenSelect,
|
|
832
|
+
projectId
|
|
833
|
+
});
|
|
776
834
|
return this.apiClient(url);
|
|
777
835
|
}
|
|
778
836
|
const edgeUrl = this.createUrl(
|
|
779
837
|
__privateGet(_ContentClient, _entriesUrl),
|
|
780
|
-
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
|
838
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
781
839
|
this.edgeApiHost
|
|
782
840
|
);
|
|
783
841
|
return this.apiClient(
|
|
@@ -1106,6 +1164,7 @@ var EDGE_CACHE_DISABLED = -1;
|
|
|
1106
1164
|
var ASSET_PARAMETER_TYPE = "asset";
|
|
1107
1165
|
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
|
1108
1166
|
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
|
1167
|
+
var REFERENCE_DATA_TYPE_ID = "uniformContentInternalReference";
|
|
1109
1168
|
|
|
1110
1169
|
// src/utils/guards.ts
|
|
1111
1170
|
function isRootEntryReference(root) {
|
|
@@ -1264,7 +1323,7 @@ function hasReferencedVariables(value) {
|
|
|
1264
1323
|
|
|
1265
1324
|
// src/enhancement/walkNodeTree.ts
|
|
1266
1325
|
function walkNodeTree(node, visitor, options) {
|
|
1267
|
-
var _a, _b;
|
|
1326
|
+
var _a, _b, _c;
|
|
1268
1327
|
const componentQueue = [
|
|
1269
1328
|
{
|
|
1270
1329
|
ancestorsAndSelf: Array.isArray(node) ? node : [{ node, type: "root" }],
|
|
@@ -1272,12 +1331,14 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1272
1331
|
}
|
|
1273
1332
|
];
|
|
1274
1333
|
const childContexts = /* @__PURE__ */ new Map();
|
|
1334
|
+
const order = (_a = options == null ? void 0 : options.order) != null ? _a : "dfs";
|
|
1335
|
+
const takeNext = () => order === "bfs" ? componentQueue.shift() : componentQueue.pop();
|
|
1275
1336
|
do {
|
|
1276
|
-
const currentQueueEntry =
|
|
1337
|
+
const currentQueueEntry = takeNext();
|
|
1277
1338
|
if (!currentQueueEntry) continue;
|
|
1278
1339
|
const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
|
|
1279
1340
|
let visitDescendants = true;
|
|
1280
|
-
let descendantContext = (
|
|
1341
|
+
let descendantContext = (_b = childContexts.get(currentComponent.node)) != null ? _b : currentQueueEntry.context;
|
|
1281
1342
|
let visitorInfo;
|
|
1282
1343
|
if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
|
|
1283
1344
|
visitorInfo = {
|
|
@@ -1464,39 +1525,11 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1464
1525
|
continue;
|
|
1465
1526
|
}
|
|
1466
1527
|
const slots = "slots" in currentComponent.node && currentComponent.node.slots;
|
|
1467
|
-
|
|
1468
|
-
const slotKeys = Object.keys(slots);
|
|
1469
|
-
for (let slotIndex = slotKeys.length - 1; slotIndex >= 0; slotIndex--) {
|
|
1470
|
-
const slotKey = slotKeys[slotIndex];
|
|
1471
|
-
const components = slots[slotKey];
|
|
1472
|
-
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
|
1473
|
-
const enqueueingComponent = components[componentIndex];
|
|
1474
|
-
const parentSlotIndexFn = () => {
|
|
1475
|
-
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1476
|
-
(x) => x === enqueueingComponent
|
|
1477
|
-
);
|
|
1478
|
-
return result;
|
|
1479
|
-
};
|
|
1480
|
-
componentQueue.push({
|
|
1481
|
-
ancestorsAndSelf: [
|
|
1482
|
-
{
|
|
1483
|
-
type: "slot",
|
|
1484
|
-
node: enqueueingComponent,
|
|
1485
|
-
parentSlot: slotKey,
|
|
1486
|
-
parentSlotIndexFn
|
|
1487
|
-
},
|
|
1488
|
-
...currentQueueEntry.ancestorsAndSelf
|
|
1489
|
-
],
|
|
1490
|
-
context: descendantContext
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1528
|
+
const childEntries = [];
|
|
1495
1529
|
const properties = getPropertiesValue(currentComponent.node);
|
|
1496
1530
|
if (properties) {
|
|
1497
1531
|
const propertyEntries = Object.entries(properties);
|
|
1498
|
-
for (
|
|
1499
|
-
const [propKey, propObject] = propertyEntries[propIndex];
|
|
1532
|
+
for (const [propKey, propObject] of propertyEntries) {
|
|
1500
1533
|
if (!isNestedNodeType(propObject.type)) {
|
|
1501
1534
|
continue;
|
|
1502
1535
|
}
|
|
@@ -1516,13 +1549,12 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1516
1549
|
continue;
|
|
1517
1550
|
}
|
|
1518
1551
|
}
|
|
1519
|
-
const blocks = (
|
|
1520
|
-
for (
|
|
1521
|
-
const enqueueingBlock = blocks[blockIndex];
|
|
1552
|
+
const blocks = (_c = propObject.value) != null ? _c : [];
|
|
1553
|
+
for (const enqueueingBlock of blocks) {
|
|
1522
1554
|
const blockIndexFn = () => {
|
|
1523
1555
|
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
|
1524
1556
|
};
|
|
1525
|
-
|
|
1557
|
+
childEntries.push({
|
|
1526
1558
|
ancestorsAndSelf: [
|
|
1527
1559
|
{
|
|
1528
1560
|
type: "block",
|
|
@@ -1537,6 +1569,36 @@ function walkNodeTree(node, visitor, options) {
|
|
|
1537
1569
|
}
|
|
1538
1570
|
}
|
|
1539
1571
|
}
|
|
1572
|
+
if (slots) {
|
|
1573
|
+
const slotKeys = Object.keys(slots);
|
|
1574
|
+
for (const slotKey of slotKeys) {
|
|
1575
|
+
const components = slots[slotKey];
|
|
1576
|
+
for (const enqueueingComponent of components) {
|
|
1577
|
+
const parentSlotIndexFn = () => {
|
|
1578
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
|
1579
|
+
(x) => x === enqueueingComponent
|
|
1580
|
+
);
|
|
1581
|
+
return result;
|
|
1582
|
+
};
|
|
1583
|
+
childEntries.push({
|
|
1584
|
+
ancestorsAndSelf: [
|
|
1585
|
+
{
|
|
1586
|
+
type: "slot",
|
|
1587
|
+
node: enqueueingComponent,
|
|
1588
|
+
parentSlot: slotKey,
|
|
1589
|
+
parentSlotIndexFn
|
|
1590
|
+
},
|
|
1591
|
+
...currentQueueEntry.ancestorsAndSelf
|
|
1592
|
+
],
|
|
1593
|
+
context: descendantContext
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
if (order === "dfs") {
|
|
1599
|
+
childEntries.reverse();
|
|
1600
|
+
}
|
|
1601
|
+
componentQueue.push(...childEntries);
|
|
1540
1602
|
} while (componentQueue.length > 0);
|
|
1541
1603
|
}
|
|
1542
1604
|
function isNestedNodeType(type) {
|
|
@@ -2402,8 +2464,7 @@ function extractLocales({ component }) {
|
|
|
2402
2464
|
return variations;
|
|
2403
2465
|
}
|
|
2404
2466
|
function localize(options) {
|
|
2405
|
-
const nodes = options
|
|
2406
|
-
const locale = options.locale;
|
|
2467
|
+
const { nodes, locale, keepLocalesFor } = options;
|
|
2407
2468
|
if (!locale) {
|
|
2408
2469
|
return;
|
|
2409
2470
|
}
|
|
@@ -2411,7 +2472,7 @@ function localize(options) {
|
|
|
2411
2472
|
walkNodeTree(nodes, (context) => {
|
|
2412
2473
|
const { type, node, actions } = context;
|
|
2413
2474
|
if (type !== "component") {
|
|
2414
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2475
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2415
2476
|
return;
|
|
2416
2477
|
}
|
|
2417
2478
|
const result = evaluateWalkTreeNodeVisibility({
|
|
@@ -2432,7 +2493,7 @@ function localize(options) {
|
|
|
2432
2493
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
|
2433
2494
|
replaceComponent.forEach((component) => {
|
|
2434
2495
|
removeLocaleProperty(component);
|
|
2435
|
-
localizeProperties(component, locale, vizControlLocaleRule);
|
|
2496
|
+
localizeProperties(component, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2436
2497
|
});
|
|
2437
2498
|
const [first, ...rest] = replaceComponent;
|
|
2438
2499
|
actions.replace(first);
|
|
@@ -2443,7 +2504,7 @@ function localize(options) {
|
|
|
2443
2504
|
actions.remove();
|
|
2444
2505
|
}
|
|
2445
2506
|
} else {
|
|
2446
|
-
localizeProperties(node, locale, vizControlLocaleRule);
|
|
2507
|
+
localizeProperties(node, locale, vizControlLocaleRule, keepLocalesFor);
|
|
2447
2508
|
}
|
|
2448
2509
|
});
|
|
2449
2510
|
}
|
|
@@ -2462,7 +2523,7 @@ function removeLocaleProperty(component) {
|
|
|
2462
2523
|
}
|
|
2463
2524
|
}
|
|
2464
2525
|
}
|
|
2465
|
-
function localizeProperties(node, locale, rules) {
|
|
2526
|
+
function localizeProperties(node, locale, rules, keepLocalesFor) {
|
|
2466
2527
|
const properties = getPropertiesValue(node);
|
|
2467
2528
|
if (!properties) {
|
|
2468
2529
|
return void 0;
|
|
@@ -2481,10 +2542,16 @@ function localizeProperties(node, locale, rules) {
|
|
|
2481
2542
|
if (currentLocaleConditionalValues !== void 0) {
|
|
2482
2543
|
propertyValue.conditions = currentLocaleConditionalValues;
|
|
2483
2544
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2545
|
+
const preserveLocales = (keepLocalesFor == null ? void 0 : keepLocalesFor(propertyId)) === true;
|
|
2546
|
+
if (!preserveLocales) {
|
|
2547
|
+
delete propertyValue.locales;
|
|
2548
|
+
delete propertyValue.localesConditions;
|
|
2549
|
+
}
|
|
2486
2550
|
if (propertyValue.value === void 0 && propertyValue.conditions === void 0) {
|
|
2487
|
-
|
|
2551
|
+
const hasLocales = preserveLocales && (propertyValue.locales || propertyValue.localesConditions);
|
|
2552
|
+
if (!hasLocales) {
|
|
2553
|
+
delete properties[propertyId];
|
|
2554
|
+
}
|
|
2488
2555
|
}
|
|
2489
2556
|
});
|
|
2490
2557
|
evaluateWalkTreePropertyCriteria({
|
|
@@ -3163,6 +3230,173 @@ __privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
|
3163
3230
|
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
3164
3231
|
var ProjectClient = _ProjectClient;
|
|
3165
3232
|
|
|
3233
|
+
// src/projection/matchesProjectionPattern.ts
|
|
3234
|
+
var DISALLOWED_PATTERN_CHARS = /[,&=?#[\]\s]/;
|
|
3235
|
+
var REGEX_METACHAR = /[\\^$.|?*+()[\]{}]/g;
|
|
3236
|
+
function isValidProjectionPattern(pattern) {
|
|
3237
|
+
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
3238
|
+
return false;
|
|
3239
|
+
}
|
|
3240
|
+
if (DISALLOWED_PATTERN_CHARS.test(pattern)) {
|
|
3241
|
+
return false;
|
|
3242
|
+
}
|
|
3243
|
+
return true;
|
|
3244
|
+
}
|
|
3245
|
+
function compilePattern(pattern) {
|
|
3246
|
+
let regexSource = "^";
|
|
3247
|
+
for (const ch of pattern) {
|
|
3248
|
+
if (ch === "*") {
|
|
3249
|
+
regexSource += ".*";
|
|
3250
|
+
} else {
|
|
3251
|
+
regexSource += ch.replace(REGEX_METACHAR, "\\$&");
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
regexSource += "$";
|
|
3255
|
+
return new RegExp(regexSource);
|
|
3256
|
+
}
|
|
3257
|
+
var PATTERN_CACHE_MAX = 1024;
|
|
3258
|
+
var patternRegexCache = /* @__PURE__ */ new Map();
|
|
3259
|
+
function matchesProjectionPattern(pattern, value) {
|
|
3260
|
+
let re = patternRegexCache.get(pattern);
|
|
3261
|
+
if (re === void 0) {
|
|
3262
|
+
if (!isValidProjectionPattern(pattern)) {
|
|
3263
|
+
throw new Error(`Invalid projection pattern: ${JSON.stringify(pattern)}`);
|
|
3264
|
+
}
|
|
3265
|
+
re = compilePattern(pattern);
|
|
3266
|
+
if (patternRegexCache.size >= PATTERN_CACHE_MAX) {
|
|
3267
|
+
const oldest = patternRegexCache.keys().next().value;
|
|
3268
|
+
if (oldest !== void 0) patternRegexCache.delete(oldest);
|
|
3269
|
+
}
|
|
3270
|
+
patternRegexCache.set(pattern, re);
|
|
3271
|
+
}
|
|
3272
|
+
return re.test(value);
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
// src/projection/queryToProjection.ts
|
|
3276
|
+
var TOP_LEVEL_OPERATOR_KEY = /^(fields|fieldTypes|slots)\[([A-Za-z]+)\]$/;
|
|
3277
|
+
var SLOTS_NAMED_KEY = /^slots\.([A-Za-z0-9_-]+)\[([A-Za-z]+)\]$/;
|
|
3278
|
+
function toStringValue2(value) {
|
|
3279
|
+
if (Array.isArray(value)) {
|
|
3280
|
+
return value.join(",");
|
|
3281
|
+
}
|
|
3282
|
+
return value;
|
|
3283
|
+
}
|
|
3284
|
+
function parseCsv(value) {
|
|
3285
|
+
const str = toStringValue2(value);
|
|
3286
|
+
if (!str) {
|
|
3287
|
+
return [];
|
|
3288
|
+
}
|
|
3289
|
+
return str.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
3290
|
+
}
|
|
3291
|
+
function parseDepth(value, key) {
|
|
3292
|
+
const str = toStringValue2(value);
|
|
3293
|
+
if (str === void 0 || str === "") {
|
|
3294
|
+
throw new Error(`Invalid select projection: '${key}' requires a non-negative integer value`);
|
|
3295
|
+
}
|
|
3296
|
+
if (!/^\d+$/.test(str)) {
|
|
3297
|
+
throw new Error(
|
|
3298
|
+
`Invalid select projection: '${key}' must be a non-negative integer (got ${JSON.stringify(str)})`
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
return Number(str);
|
|
3302
|
+
}
|
|
3303
|
+
function extractSelectKeys(source) {
|
|
3304
|
+
if (source instanceof URLSearchParams) {
|
|
3305
|
+
let out2;
|
|
3306
|
+
for (const [key, value] of source.entries()) {
|
|
3307
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3308
|
+
out2 != null ? out2 : out2 = {};
|
|
3309
|
+
out2[key] = out2[key] === void 0 ? value : `${out2[key]},${value}`;
|
|
3310
|
+
}
|
|
3311
|
+
return out2;
|
|
3312
|
+
}
|
|
3313
|
+
let out;
|
|
3314
|
+
for (const key in source) {
|
|
3315
|
+
if (!key.startsWith(SELECT_QUERY_PREFIX)) continue;
|
|
3316
|
+
out != null ? out : out = {};
|
|
3317
|
+
out[key] = source[key];
|
|
3318
|
+
}
|
|
3319
|
+
return out;
|
|
3320
|
+
}
|
|
3321
|
+
function queryToProjection(source) {
|
|
3322
|
+
var _a, _b, _c, _d, _e;
|
|
3323
|
+
if (!source) {
|
|
3324
|
+
return void 0;
|
|
3325
|
+
}
|
|
3326
|
+
const query = extractSelectKeys(source);
|
|
3327
|
+
if (!query) {
|
|
3328
|
+
return void 0;
|
|
3329
|
+
}
|
|
3330
|
+
const spec = {};
|
|
3331
|
+
for (const [rawKey, value] of Object.entries(query)) {
|
|
3332
|
+
const key = rawKey.slice(SELECT_QUERY_PREFIX.length);
|
|
3333
|
+
const namedMatch = SLOTS_NAMED_KEY.exec(key);
|
|
3334
|
+
if (namedMatch) {
|
|
3335
|
+
const [, slotName, operator2] = namedMatch;
|
|
3336
|
+
if (operator2 !== "depth") {
|
|
3337
|
+
throw new Error(
|
|
3338
|
+
`Invalid select projection: unsupported operator '${operator2}' for slots.${slotName}`
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
const slots = (_a = spec.slots) != null ? _a : spec.slots = {};
|
|
3342
|
+
const named = (_b = slots.named) != null ? _b : slots.named = {};
|
|
3343
|
+
named[slotName] = { ...named[slotName], depth: parseDepth(value, rawKey) };
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
const topMatch = TOP_LEVEL_OPERATOR_KEY.exec(key);
|
|
3347
|
+
if (!topMatch) {
|
|
3348
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3349
|
+
}
|
|
3350
|
+
const [, bucket, operator] = topMatch;
|
|
3351
|
+
if (bucket === "fields") {
|
|
3352
|
+
const fields = (_c = spec.fields) != null ? _c : spec.fields = {};
|
|
3353
|
+
switch (operator) {
|
|
3354
|
+
case "only":
|
|
3355
|
+
fields.only = parseCsv(value);
|
|
3356
|
+
break;
|
|
3357
|
+
case "except":
|
|
3358
|
+
fields.except = parseCsv(value);
|
|
3359
|
+
break;
|
|
3360
|
+
case "locales":
|
|
3361
|
+
fields.locales = parseCsv(value);
|
|
3362
|
+
break;
|
|
3363
|
+
default:
|
|
3364
|
+
throw new Error(`Invalid select projection: unsupported operator 'fields[${operator}]'`);
|
|
3365
|
+
}
|
|
3366
|
+
} else if (bucket === "fieldTypes") {
|
|
3367
|
+
const fieldTypes = (_d = spec.fieldTypes) != null ? _d : spec.fieldTypes = {};
|
|
3368
|
+
switch (operator) {
|
|
3369
|
+
case "only":
|
|
3370
|
+
fieldTypes.only = parseCsv(value);
|
|
3371
|
+
break;
|
|
3372
|
+
case "except":
|
|
3373
|
+
fieldTypes.except = parseCsv(value);
|
|
3374
|
+
break;
|
|
3375
|
+
default:
|
|
3376
|
+
throw new Error(`Invalid select projection: unsupported operator 'fieldTypes[${operator}]'`);
|
|
3377
|
+
}
|
|
3378
|
+
} else if (bucket === "slots") {
|
|
3379
|
+
const slots = (_e = spec.slots) != null ? _e : spec.slots = {};
|
|
3380
|
+
switch (operator) {
|
|
3381
|
+
case "only":
|
|
3382
|
+
slots.only = parseCsv(value);
|
|
3383
|
+
break;
|
|
3384
|
+
case "except":
|
|
3385
|
+
slots.except = parseCsv(value);
|
|
3386
|
+
break;
|
|
3387
|
+
case "depth":
|
|
3388
|
+
slots.depth = parseDepth(value, rawKey);
|
|
3389
|
+
break;
|
|
3390
|
+
default:
|
|
3391
|
+
throw new Error(`Invalid select projection: unsupported operator 'slots[${operator}]'`);
|
|
3392
|
+
}
|
|
3393
|
+
} else {
|
|
3394
|
+
throw new Error(`Invalid select projection key: ${JSON.stringify(rawKey)}`);
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
return spec;
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3166
3400
|
// src/PromptClient.ts
|
|
3167
3401
|
import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
|
|
3168
3402
|
var PromptsUrl = "/api/v1/prompts";
|
|
@@ -3291,7 +3525,9 @@ var RouteClient = class extends ApiClient16 {
|
|
|
3291
3525
|
/** Fetches lists of Canvas compositions, optionally by type */
|
|
3292
3526
|
async getRoute(options) {
|
|
3293
3527
|
const { projectId } = this.options;
|
|
3294
|
-
const
|
|
3528
|
+
const { select, ...rest } = options != null ? options : {};
|
|
3529
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
3530
|
+
const fetchUri = this.createUrl(ROUTE_URL, { ...rest, projectId, ...rewrittenSelect }, this.edgeApiHost);
|
|
3295
3531
|
return await this.apiClient(
|
|
3296
3532
|
fetchUri,
|
|
3297
3533
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
@@ -3654,7 +3890,7 @@ function handleRichTextNodeBinding(object, options) {
|
|
|
3654
3890
|
import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
|
|
3655
3891
|
|
|
3656
3892
|
// src/.version.ts
|
|
3657
|
-
var version = "20.
|
|
3893
|
+
var version = "20.66.0";
|
|
3658
3894
|
|
|
3659
3895
|
// src/WorkflowClient.ts
|
|
3660
3896
|
import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
|
|
@@ -3769,11 +4005,13 @@ export {
|
|
|
3769
4005
|
PreviewClient,
|
|
3770
4006
|
ProjectClient,
|
|
3771
4007
|
PromptClient,
|
|
4008
|
+
REFERENCE_DATA_TYPE_ID,
|
|
3772
4009
|
RelationshipClient,
|
|
3773
4010
|
ReleaseClient,
|
|
3774
4011
|
ReleaseContentsClient,
|
|
3775
4012
|
RouteClient,
|
|
3776
4013
|
SECRET_QUERY_STRING_PARAM,
|
|
4014
|
+
SELECT_QUERY_PREFIX,
|
|
3777
4015
|
UncachedCanvasClient,
|
|
3778
4016
|
UncachedCategoryClient,
|
|
3779
4017
|
UncachedContentClient,
|
|
@@ -3855,10 +4093,13 @@ export {
|
|
|
3855
4093
|
localize,
|
|
3856
4094
|
mapSlotToPersonalizedVariations,
|
|
3857
4095
|
mapSlotToTestVariations,
|
|
4096
|
+
matchesProjectionPattern,
|
|
3858
4097
|
mergeAssetConfigWithDefaults,
|
|
3859
4098
|
nullLimitPolicy,
|
|
3860
4099
|
parseComponentPlaceholderId,
|
|
3861
4100
|
parseVariableExpression,
|
|
4101
|
+
projectionToQuery,
|
|
4102
|
+
queryToProjection,
|
|
3862
4103
|
version,
|
|
3863
4104
|
walkNodeTree,
|
|
3864
4105
|
walkPropertyValues
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas",
|
|
3
|
-
"version": "20.63.
|
|
3
|
+
"version": "20.63.1-alpha.17+cd7eca3818",
|
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,16 +33,15 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/retry": "0.12.5",
|
|
36
|
-
"lexical": "0.39.0",
|
|
37
36
|
"p-limit": "3.1.0",
|
|
38
37
|
"p-retry": "5.1.2",
|
|
39
38
|
"p-throttle": "5.0.0",
|
|
40
39
|
"svix": "1.71.0"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@uniformdev/assets": "20.63.
|
|
44
|
-
"@uniformdev/context": "20.63.
|
|
45
|
-
"@uniformdev/richtext": "20.63.
|
|
42
|
+
"@uniformdev/assets": "20.63.1-alpha.17+cd7eca3818",
|
|
43
|
+
"@uniformdev/context": "20.63.1-alpha.17+cd7eca3818",
|
|
44
|
+
"@uniformdev/richtext": "20.63.1-alpha.17+cd7eca3818",
|
|
46
45
|
"immer": "10.1.3"
|
|
47
46
|
},
|
|
48
47
|
"files": [
|
|
@@ -51,5 +50,5 @@
|
|
|
51
50
|
"publishConfig": {
|
|
52
51
|
"access": "public"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "cd7eca38189533a6ba5899bf872b72e1331c4aa3"
|
|
55
54
|
}
|