@uniformdev/canvas 19.79.0 → 19.79.1-alpha.13
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 +3277 -1187
- package/dist/index.d.ts +3277 -1187
- package/dist/index.esm.js +287 -107
- package/dist/index.js +314 -120
- package/dist/index.mjs +287 -107
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
@@ -476,6 +476,7 @@ var CanvasClient = class extends ApiClient {
|
|
476
476
|
}
|
477
477
|
super(options);
|
478
478
|
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
479
|
+
this.edgeApiRequestInit = options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0;
|
479
480
|
}
|
480
481
|
/** Fetches lists of Canvas compositions, optionally by type */
|
481
482
|
async getCompositionList(params = {}) {
|
@@ -491,7 +492,7 @@ var CanvasClient = class extends ApiClient {
|
|
491
492
|
...params.diagnostics ? { diagnostics: "true" } : {}
|
492
493
|
};
|
493
494
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
494
|
-
return this.apiClient(edgeUrl);
|
495
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
495
496
|
}
|
496
497
|
getCompositionByNodePath(options) {
|
497
498
|
return this.getOneComposition(options);
|
@@ -531,7 +532,7 @@ var CanvasClient = class extends ApiClient {
|
|
531
532
|
...diagnostics ? { diagnostics: "true" } : {}
|
532
533
|
};
|
533
534
|
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
534
|
-
return this.apiClient(edgeUrl);
|
535
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
535
536
|
}
|
536
537
|
/** Updates or creates a Canvas component definition */
|
537
538
|
async updateComposition(body) {
|
@@ -626,73 +627,10 @@ var UncachedCategoryClient = class extends CategoryClient {
|
|
626
627
|
}
|
627
628
|
};
|
628
629
|
|
629
|
-
// src/CompositionRelationshipClient.ts
|
630
|
-
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
631
|
-
var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
|
632
|
-
var unstable_CompositionRelationshipClient = class extends ApiClient3 {
|
633
|
-
constructor(options) {
|
634
|
-
super(options);
|
635
|
-
this.getDefinitionsRelationships = async ({
|
636
|
-
definitionIds,
|
637
|
-
withCompositions
|
638
|
-
}) => {
|
639
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
640
|
-
type: "definition",
|
641
|
-
projectId: this._options.projectId,
|
642
|
-
definitionIds: definitionIds.join(","),
|
643
|
-
withCompositions
|
644
|
-
});
|
645
|
-
return this.apiClient(url);
|
646
|
-
};
|
647
|
-
this.clearAllRelationships = async () => {
|
648
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
649
|
-
return this.apiClient(url, {
|
650
|
-
method: "POST",
|
651
|
-
body: JSON.stringify({
|
652
|
-
type: "clear",
|
653
|
-
projectId: this._options.projectId
|
654
|
-
})
|
655
|
-
});
|
656
|
-
};
|
657
|
-
this.indexCompositionRelationships = async ({
|
658
|
-
state,
|
659
|
-
compositionId
|
660
|
-
}) => {
|
661
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
662
|
-
return this.apiClient(url, {
|
663
|
-
method: "POST",
|
664
|
-
body: JSON.stringify({
|
665
|
-
type: "index",
|
666
|
-
projectId: this._options.projectId,
|
667
|
-
state,
|
668
|
-
compositionId
|
669
|
-
})
|
670
|
-
});
|
671
|
-
};
|
672
|
-
this.getVersion = async () => {
|
673
|
-
const url = this.createUrl("/api/v1/usage-tracking", {
|
674
|
-
projectId: this._options.projectId
|
675
|
-
});
|
676
|
-
return this.apiClient(url).then((response) => response.version);
|
677
|
-
};
|
678
|
-
this.setVersion = async (version) => {
|
679
|
-
const url = this.createUrl("/api/v1/usage-tracking");
|
680
|
-
return this.apiClient(url, {
|
681
|
-
method: "POST",
|
682
|
-
body: JSON.stringify({
|
683
|
-
projectId: this._options.projectId,
|
684
|
-
version
|
685
|
-
})
|
686
|
-
});
|
687
|
-
};
|
688
|
-
this._options = options;
|
689
|
-
}
|
690
|
-
};
|
691
|
-
|
692
630
|
// src/ContentClient.ts
|
693
|
-
import { ApiClient as
|
631
|
+
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
694
632
|
var _contentTypesUrl, _entriesUrl;
|
695
|
-
var _ContentClient = class _ContentClient extends
|
633
|
+
var _ContentClient = class _ContentClient extends ApiClient3 {
|
696
634
|
constructor(options) {
|
697
635
|
var _a;
|
698
636
|
super(options);
|
@@ -706,8 +644,15 @@ var _ContentClient = class _ContentClient extends ApiClient4 {
|
|
706
644
|
getEntries(options) {
|
707
645
|
const { projectId } = this.options;
|
708
646
|
const { skipDataResolution, ...params } = options;
|
709
|
-
|
710
|
-
|
647
|
+
if (skipDataResolution) {
|
648
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId });
|
649
|
+
return this.apiClient(url);
|
650
|
+
}
|
651
|
+
const edgeUrl = this.createUrl(__privateGet(_ContentClient, _entriesUrl), this.getEdgeOptions(params), this.edgeApiHost);
|
652
|
+
return this.apiClient(
|
653
|
+
edgeUrl,
|
654
|
+
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
655
|
+
);
|
711
656
|
}
|
712
657
|
/** Fetches historical versions of an entry */
|
713
658
|
async getEntryHistory(options) {
|
@@ -772,10 +717,10 @@ var UncachedContentClient = class extends ContentClient {
|
|
772
717
|
};
|
773
718
|
|
774
719
|
// src/DataSourceClient.ts
|
775
|
-
import { ApiClient as
|
720
|
+
import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
|
776
721
|
var dataSourceUrl = "/api/v1/data-source";
|
777
722
|
var dataSourcesUrl = "/api/v1/data-sources";
|
778
|
-
var DataSourceClient = class extends
|
723
|
+
var DataSourceClient = class extends ApiClient4 {
|
779
724
|
constructor(options) {
|
780
725
|
super(options);
|
781
726
|
}
|
@@ -812,9 +757,9 @@ var DataSourceClient = class extends ApiClient5 {
|
|
812
757
|
};
|
813
758
|
|
814
759
|
// src/DataTypeClient.ts
|
815
|
-
import { ApiClient as
|
760
|
+
import { ApiClient as ApiClient5 } from "@uniformdev/context/api";
|
816
761
|
var _url;
|
817
|
-
var _DataTypeClient = class _DataTypeClient extends
|
762
|
+
var _DataTypeClient = class _DataTypeClient extends ApiClient5 {
|
818
763
|
constructor(options) {
|
819
764
|
super(options);
|
820
765
|
}
|
@@ -985,6 +930,7 @@ var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
985
930
|
var SECRET_QUERY_STRING_PARAM = "secret";
|
986
931
|
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
987
932
|
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
933
|
+
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
988
934
|
var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
|
989
935
|
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
990
936
|
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
@@ -1000,25 +946,9 @@ var EDGE_MIN_CACHE_TTL = 10;
|
|
1000
946
|
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
1001
947
|
var EDGE_DEFAULT_CACHE_TTL = 30;
|
1002
948
|
var EDGE_CACHE_DISABLED = -1;
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
return {
|
1007
|
-
entry: {
|
1008
|
-
type: entry.entry.type,
|
1009
|
-
_dataResources: entry.entry._dataResources,
|
1010
|
-
_id: entry.entry._id,
|
1011
|
-
_name: entry.entry._name,
|
1012
|
-
_slug: entry.entry._slug,
|
1013
|
-
fields: entry.entry.fields
|
1014
|
-
},
|
1015
|
-
state: entry.state,
|
1016
|
-
projectId: entry.projectId
|
1017
|
-
};
|
1018
|
-
}
|
1019
|
-
function getPropertiesValue(entity) {
|
1020
|
-
return "parameters" in entity && entity.parameters ? entity.parameters : "fields" in entity && entity.fields ? entity.fields : void 0;
|
1021
|
-
}
|
949
|
+
var ASSET_PARAMETER_TYPE = "asset";
|
950
|
+
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
951
|
+
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
1022
952
|
|
1023
953
|
// src/utils/guards.ts
|
1024
954
|
function isRootEntryReference(root) {
|
@@ -1027,6 +957,49 @@ function isRootEntryReference(root) {
|
|
1027
957
|
function isEntryData(entryData) {
|
1028
958
|
return Boolean(entryData && typeof entryData === "object" && "fields" in entryData);
|
1029
959
|
}
|
960
|
+
function isAssetParamValue(value) {
|
961
|
+
return Array.isArray(value) && (value.length > 0 ? isAssetParamValueItem(value[0]) : true);
|
962
|
+
}
|
963
|
+
function isAssetParamValueItem(item) {
|
964
|
+
return Boolean(
|
965
|
+
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
966
|
+
);
|
967
|
+
}
|
968
|
+
|
969
|
+
// src/utils/properties.ts
|
970
|
+
function getPropertiesValue(entity) {
|
971
|
+
return "parameters" in entity && entity.parameters ? entity.parameters : "fields" in entity && entity.fields ? entity.fields : void 0;
|
972
|
+
}
|
973
|
+
function getPropertyValue(parameter) {
|
974
|
+
return parameter ? parameter.value : parameter;
|
975
|
+
}
|
976
|
+
function flattenValues(data, options = {}) {
|
977
|
+
if (!data) {
|
978
|
+
return data;
|
979
|
+
} else if (Array.isArray(data) && options.toSingle) {
|
980
|
+
return data.length > 0 ? flattenSingleNodeValues(data[0]) : void 0;
|
981
|
+
} else if (Array.isArray(data)) {
|
982
|
+
return data.map((node) => flattenSingleNodeValues(node, options));
|
983
|
+
} else {
|
984
|
+
return flattenSingleNodeValues(data, options);
|
985
|
+
}
|
986
|
+
}
|
987
|
+
function flattenSingleNodeValues(data, options = {}) {
|
988
|
+
const { levels = 1 } = options;
|
989
|
+
const properties = getPropertiesValue(data);
|
990
|
+
return properties ? Object.fromEntries(
|
991
|
+
Object.entries(properties).map(([id, parameter]) => {
|
992
|
+
const value = getPropertyValue(parameter);
|
993
|
+
if (levels > 0 && Array.isArray(value) && // In the future ASSET_PARAMETER_TYPE will be a nested data type
|
994
|
+
(isNestedNodeType(parameter.type) || parameter.type === ASSET_PARAMETER_TYPE)) {
|
995
|
+
const nestedOptions = { ...options, levels: levels - 1 };
|
996
|
+
return [id, value.map((item) => flattenValues(item, nestedOptions))];
|
997
|
+
} else {
|
998
|
+
return [id, value];
|
999
|
+
}
|
1000
|
+
})
|
1001
|
+
) : properties;
|
1002
|
+
}
|
1030
1003
|
|
1031
1004
|
// src/enhancement/walkNodeTree.ts
|
1032
1005
|
function walkNodeTree(node, visitor, options) {
|
@@ -1250,7 +1223,7 @@ function walkNodeTree(node, visitor, options) {
|
|
1250
1223
|
const propertyEntries = Object.entries(properties);
|
1251
1224
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1252
1225
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1253
|
-
if (propObject.type
|
1226
|
+
if (!isNestedNodeType(propObject.type))
|
1254
1227
|
continue;
|
1255
1228
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1256
1229
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
@@ -1276,6 +1249,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1276
1249
|
}
|
1277
1250
|
} while (componentQueue.length > 0);
|
1278
1251
|
}
|
1252
|
+
function isNestedNodeType(type) {
|
1253
|
+
return type === CANVAS_BLOCK_PARAM_TYPE;
|
1254
|
+
}
|
1279
1255
|
function getBlockValue(component, parameterName) {
|
1280
1256
|
var _a;
|
1281
1257
|
const parameter = (_a = getPropertiesValue(component)) == null ? void 0 : _a[parameterName];
|
@@ -1567,6 +1543,31 @@ function getNounForLocation(parentLocation) {
|
|
1567
1543
|
}
|
1568
1544
|
return noun;
|
1569
1545
|
}
|
1546
|
+
function getNounForNode(node) {
|
1547
|
+
let noun = "parameters";
|
1548
|
+
if (isEntryData(node)) {
|
1549
|
+
noun = "fields";
|
1550
|
+
}
|
1551
|
+
return noun;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
// src/enhancement/findInNodeTree.ts
|
1555
|
+
function findParameterInNodeTree(data, predicate) {
|
1556
|
+
const results = [];
|
1557
|
+
walkNodeTree(data, ({ node, ancestorsAndSelf }) => {
|
1558
|
+
const parameters = getPropertiesValue(node);
|
1559
|
+
if (parameters) {
|
1560
|
+
Object.entries(parameters).filter(([key, field]) => predicate(field, key, node)).forEach(([key, field]) => {
|
1561
|
+
results.push({
|
1562
|
+
key,
|
1563
|
+
pointer: (ancestorsAndSelf.length === 1 ? "" : getComponentJsonPointer(ancestorsAndSelf)) + `/${getNounForNode(node)}/${key}`,
|
1564
|
+
parameter: field
|
1565
|
+
});
|
1566
|
+
});
|
1567
|
+
}
|
1568
|
+
});
|
1569
|
+
return results;
|
1570
|
+
}
|
1570
1571
|
|
1571
1572
|
// src/enhancement/localize.ts
|
1572
1573
|
function extractLocales({ component }) {
|
@@ -1583,23 +1584,31 @@ function extractLocales({ component }) {
|
|
1583
1584
|
});
|
1584
1585
|
return variations;
|
1585
1586
|
}
|
1586
|
-
function localize({
|
1587
|
-
composition
|
1588
|
-
locale
|
1589
|
-
}) {
|
1590
|
-
walkNodeTree(composition, ({ type, node, actions }) => {
|
1587
|
+
function localize(options) {
|
1588
|
+
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1589
|
+
const locale = options.locale;
|
1590
|
+
walkNodeTree(nodes, ({ type, node, actions }) => {
|
1591
1591
|
if (type !== "component") {
|
1592
|
-
|
1592
|
+
if (typeof locale === "string") {
|
1593
|
+
localizeProperties(node.fields, locale);
|
1594
|
+
}
|
1593
1595
|
return;
|
1594
1596
|
}
|
1597
|
+
const shouldRunPropertyLocalization = typeof locale === "string";
|
1595
1598
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1596
1599
|
const locales = extractLocales({ component: node });
|
1597
|
-
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1600
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1598
1601
|
let replaceComponent;
|
1599
1602
|
if (resolvedLocale) {
|
1600
1603
|
replaceComponent = locales[resolvedLocale];
|
1601
1604
|
}
|
1602
1605
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1606
|
+
replaceComponent.forEach((component) => {
|
1607
|
+
removeLocaleProperty(component);
|
1608
|
+
if (shouldRunPropertyLocalization) {
|
1609
|
+
localizeProperties(getPropertiesValue(component), locale);
|
1610
|
+
}
|
1611
|
+
});
|
1603
1612
|
const [first, ...rest] = replaceComponent;
|
1604
1613
|
actions.replace(first);
|
1605
1614
|
if (rest.length) {
|
@@ -1608,6 +1617,42 @@ function localize({
|
|
1608
1617
|
} else {
|
1609
1618
|
actions.remove();
|
1610
1619
|
}
|
1620
|
+
} else if (shouldRunPropertyLocalization) {
|
1621
|
+
localizeProperties(getPropertiesValue(node), locale);
|
1622
|
+
}
|
1623
|
+
});
|
1624
|
+
}
|
1625
|
+
function removeLocaleProperty(component) {
|
1626
|
+
const properties = getPropertiesValue(component);
|
1627
|
+
const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
|
1628
|
+
if (localeTagProperty) {
|
1629
|
+
delete properties[CANVAS_LOCALE_TAG_PARAM];
|
1630
|
+
}
|
1631
|
+
if (properties && Object.keys(properties).length === 0) {
|
1632
|
+
if ("fields" in component) {
|
1633
|
+
delete component.fields;
|
1634
|
+
}
|
1635
|
+
if ("parameters" in component) {
|
1636
|
+
delete component.parameters;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
}
|
1640
|
+
function localizeProperties(properties, locale) {
|
1641
|
+
if (!properties) {
|
1642
|
+
return void 0;
|
1643
|
+
}
|
1644
|
+
Object.entries(properties).forEach(([key, property]) => {
|
1645
|
+
var _a;
|
1646
|
+
if (!locale) {
|
1647
|
+
delete property.locales;
|
1648
|
+
}
|
1649
|
+
const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
|
1650
|
+
if (currentLocaleValue !== void 0) {
|
1651
|
+
property.value = currentLocaleValue;
|
1652
|
+
}
|
1653
|
+
delete property.locales;
|
1654
|
+
if (property.value === void 0) {
|
1655
|
+
delete properties[key];
|
1611
1656
|
}
|
1612
1657
|
});
|
1613
1658
|
}
|
@@ -1757,6 +1802,39 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1757
1802
|
} while (componentQueue.length > 0);
|
1758
1803
|
}
|
1759
1804
|
|
1805
|
+
// src/LocaleClient.ts
|
1806
|
+
import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
|
1807
|
+
var localesUrl = "/api/v1/locales";
|
1808
|
+
var LocaleClient = class extends ApiClient6 {
|
1809
|
+
constructor(options) {
|
1810
|
+
super(options);
|
1811
|
+
}
|
1812
|
+
/** Fetches all locales for a project */
|
1813
|
+
async get(options) {
|
1814
|
+
const { projectId } = this.options;
|
1815
|
+
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
1816
|
+
return await this.apiClient(fetchUri);
|
1817
|
+
}
|
1818
|
+
/** Updates or creates (based on id) a locale */
|
1819
|
+
async upsert(body) {
|
1820
|
+
const fetchUri = this.createUrl(localesUrl);
|
1821
|
+
await this.apiClient(fetchUri, {
|
1822
|
+
method: "PUT",
|
1823
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1824
|
+
expectNoContent: true
|
1825
|
+
});
|
1826
|
+
}
|
1827
|
+
/** Deletes a locale */
|
1828
|
+
async remove(body) {
|
1829
|
+
const fetchUri = this.createUrl(localesUrl);
|
1830
|
+
await this.apiClient(fetchUri, {
|
1831
|
+
method: "DELETE",
|
1832
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1833
|
+
expectNoContent: true
|
1834
|
+
});
|
1835
|
+
}
|
1836
|
+
};
|
1837
|
+
|
1760
1838
|
// src/utils/hash.ts
|
1761
1839
|
var generateHash = ({
|
1762
1840
|
composition,
|
@@ -1835,7 +1913,7 @@ var createCanvasChannel = ({
|
|
1835
1913
|
const handlers = {};
|
1836
1914
|
const broadcastToItems = [...broadcastTo];
|
1837
1915
|
const postMessage = (message) => {
|
1838
|
-
broadcastToItems.forEach((item) => item.postMessage(JSON.stringify(message), "*"));
|
1916
|
+
broadcastToItems.forEach((item) => item == null ? void 0 : item.postMessage(JSON.stringify(message), "*"));
|
1839
1917
|
};
|
1840
1918
|
const selectComponent = (id) => {
|
1841
1919
|
const message = {
|
@@ -2146,10 +2224,67 @@ var PromptClient = class extends ApiClient7 {
|
|
2146
2224
|
}
|
2147
2225
|
};
|
2148
2226
|
|
2149
|
-
// src/
|
2227
|
+
// src/RelationshipClient.ts
|
2150
2228
|
import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
|
2229
|
+
var RELATIONSHIPS_URL = "/api/v1/relationships";
|
2230
|
+
var RelationshipClient = class extends ApiClient8 {
|
2231
|
+
constructor(options) {
|
2232
|
+
super(options);
|
2233
|
+
this.get = async (options) => {
|
2234
|
+
const { projectId } = this.options;
|
2235
|
+
const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
|
2236
|
+
return this.apiClient(url);
|
2237
|
+
};
|
2238
|
+
this.clearProjectRelationships = async () => {
|
2239
|
+
const { projectId } = this.options;
|
2240
|
+
const url = this.createUrl(RELATIONSHIPS_URL);
|
2241
|
+
return this.apiClient(url, {
|
2242
|
+
method: "POST",
|
2243
|
+
body: JSON.stringify({
|
2244
|
+
action: "clear",
|
2245
|
+
projectId
|
2246
|
+
})
|
2247
|
+
});
|
2248
|
+
};
|
2249
|
+
this.indexRelationships = async ({ state, id, type }) => {
|
2250
|
+
const { projectId } = this.options;
|
2251
|
+
const url = this.createUrl(RELATIONSHIPS_URL);
|
2252
|
+
return this.apiClient(url, {
|
2253
|
+
method: "POST",
|
2254
|
+
body: JSON.stringify({
|
2255
|
+
action: "index",
|
2256
|
+
type,
|
2257
|
+
projectId,
|
2258
|
+
state,
|
2259
|
+
id
|
2260
|
+
})
|
2261
|
+
});
|
2262
|
+
};
|
2263
|
+
this.getVersion = async () => {
|
2264
|
+
const { projectId } = this.options;
|
2265
|
+
const url = this.createUrl("/api/v1/usage-tracking", {
|
2266
|
+
projectId
|
2267
|
+
});
|
2268
|
+
return this.apiClient(url).then((response) => response.version);
|
2269
|
+
};
|
2270
|
+
this.setVersion = async (version) => {
|
2271
|
+
const { projectId } = this.options;
|
2272
|
+
const url = this.createUrl("/api/v1/usage-tracking");
|
2273
|
+
return this.apiClient(url, {
|
2274
|
+
method: "POST",
|
2275
|
+
body: JSON.stringify({
|
2276
|
+
projectId,
|
2277
|
+
version
|
2278
|
+
})
|
2279
|
+
});
|
2280
|
+
};
|
2281
|
+
}
|
2282
|
+
};
|
2283
|
+
|
2284
|
+
// src/RouteClient.ts
|
2285
|
+
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2151
2286
|
var ROUTE_URL = "/api/v1/route";
|
2152
|
-
var RouteClient = class extends
|
2287
|
+
var RouteClient = class extends ApiClient9 {
|
2153
2288
|
constructor(options) {
|
2154
2289
|
var _a;
|
2155
2290
|
if (!options.limitPolicy) {
|
@@ -2162,10 +2297,16 @@ var RouteClient = class extends ApiClient8 {
|
|
2162
2297
|
async getRoute(options) {
|
2163
2298
|
const { projectId } = this.options;
|
2164
2299
|
const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
|
2165
|
-
return await this.apiClient(
|
2300
|
+
return await this.apiClient(
|
2301
|
+
fetchUri,
|
2302
|
+
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
2303
|
+
);
|
2166
2304
|
}
|
2167
2305
|
};
|
2168
2306
|
|
2307
|
+
// src/types/locales.ts
|
2308
|
+
var LOCALE_DYNAMIC_INPUT_NAME = "locale";
|
2309
|
+
|
2169
2310
|
// src/utils/createApiEnhancer.ts
|
2170
2311
|
var createUniformApiEnhancer = ({ apiUrl }) => {
|
2171
2312
|
return async (message) => {
|
@@ -2188,6 +2329,26 @@ var createUniformApiEnhancer = ({ apiUrl }) => {
|
|
2188
2329
|
};
|
2189
2330
|
};
|
2190
2331
|
|
2332
|
+
// src/utils/entryConverter.ts
|
2333
|
+
function convertEntryToPutEntry(entry) {
|
2334
|
+
return {
|
2335
|
+
entry: {
|
2336
|
+
type: entry.entry.type,
|
2337
|
+
_dataResources: entry.entry._dataResources,
|
2338
|
+
_id: entry.entry._id,
|
2339
|
+
_name: entry.entry._name,
|
2340
|
+
_slug: entry.entry._slug,
|
2341
|
+
_pattern: entry.entry._pattern,
|
2342
|
+
_overridability: entry.entry._overridability,
|
2343
|
+
_overrides: entry.entry._overrides,
|
2344
|
+
fields: entry.entry.fields,
|
2345
|
+
_locales: entry.entry._locales
|
2346
|
+
},
|
2347
|
+
state: entry.state,
|
2348
|
+
projectId: entry.projectId
|
2349
|
+
};
|
2350
|
+
}
|
2351
|
+
|
2191
2352
|
// src/utils/getParameterAttributes.ts
|
2192
2353
|
var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
|
2193
2354
|
var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
|
@@ -2317,9 +2478,14 @@ function parseVariableExpression(serialized, onToken) {
|
|
2317
2478
|
continue;
|
2318
2479
|
}
|
2319
2480
|
if (char === variableSuffix && state === "variable") {
|
2481
|
+
if (serialized[index - 1] === escapeCharacter) {
|
2482
|
+
bufferEndIndex++;
|
2483
|
+
continue;
|
2484
|
+
}
|
2320
2485
|
state = "text";
|
2321
2486
|
if (bufferEndIndex > bufferStartIndex) {
|
2322
|
-
|
2487
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
2488
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
2323
2489
|
return tokenCount;
|
2324
2490
|
}
|
2325
2491
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
@@ -2379,7 +2545,7 @@ import { produce } from "immer";
|
|
2379
2545
|
|
2380
2546
|
// src/utils/variables/createVariableReference.ts
|
2381
2547
|
function createVariableReference(variableName) {
|
2382
|
-
return `\${${variableName}}`;
|
2548
|
+
return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
|
2383
2549
|
}
|
2384
2550
|
|
2385
2551
|
// src/utils/variables/bindVariablesToObject.ts
|
@@ -2463,6 +2629,9 @@ function handleRichTextNodeBinding(object, options) {
|
|
2463
2629
|
import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
|
2464
2630
|
var CanvasClientError = ApiClientError2;
|
2465
2631
|
export {
|
2632
|
+
ASSETS_SOURCE_CUSTOM_URL,
|
2633
|
+
ASSETS_SOURCE_UNIFORM,
|
2634
|
+
ASSET_PARAMETER_TYPE,
|
2466
2635
|
ATTRIBUTE_COMPONENT_ID,
|
2467
2636
|
ATTRIBUTE_MULTILINE,
|
2468
2637
|
ATTRIBUTE_PARAMETER_ID,
|
@@ -2503,11 +2672,15 @@ export {
|
|
2503
2672
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
2504
2673
|
IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
|
2505
2674
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
2675
|
+
IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM,
|
2506
2676
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
2507
2677
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2508
2678
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2679
|
+
LOCALE_DYNAMIC_INPUT_NAME,
|
2680
|
+
LocaleClient,
|
2509
2681
|
PLACEHOLDER_ID,
|
2510
2682
|
PromptClient,
|
2683
|
+
RelationshipClient,
|
2511
2684
|
RouteClient,
|
2512
2685
|
SECRET_QUERY_STRING_PARAM,
|
2513
2686
|
UncachedCanvasClient,
|
@@ -2526,21 +2699,29 @@ export {
|
|
2526
2699
|
createVariableReference,
|
2527
2700
|
enhance,
|
2528
2701
|
extractLocales,
|
2702
|
+
findParameterInNodeTree,
|
2703
|
+
flattenValues,
|
2529
2704
|
generateComponentPlaceholderId,
|
2530
2705
|
generateHash,
|
2531
2706
|
getBlockValue,
|
2532
2707
|
getChannelName,
|
2533
2708
|
getComponentJsonPointer,
|
2534
2709
|
getComponentPath,
|
2710
|
+
getNounForLocation,
|
2711
|
+
getNounForNode,
|
2535
2712
|
getParameterAttributes,
|
2536
2713
|
getPropertiesValue,
|
2714
|
+
getPropertyValue,
|
2537
2715
|
isAddComponentMessage,
|
2538
2716
|
isAllowedReferrer,
|
2717
|
+
isAssetParamValue,
|
2718
|
+
isAssetParamValueItem,
|
2539
2719
|
isComponentActionMessage,
|
2540
2720
|
isComponentPlaceholderId,
|
2541
2721
|
isDismissPlaceholderMessage,
|
2542
2722
|
isEntryData,
|
2543
2723
|
isMovingComponentMessage,
|
2724
|
+
isNestedNodeType,
|
2544
2725
|
isOpenParameterEditorMessage,
|
2545
2726
|
isReadyMessage,
|
2546
2727
|
isReportRenderedCompositionsMessage,
|
@@ -2562,7 +2743,6 @@ export {
|
|
2562
2743
|
nullLimitPolicy,
|
2563
2744
|
parseVariableExpression,
|
2564
2745
|
subscribeToComposition,
|
2565
|
-
unstable_CompositionRelationshipClient,
|
2566
2746
|
walkComponentTree,
|
2567
2747
|
walkNodeTree
|
2568
2748
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.79.
|
3
|
+
"version": "19.79.1-alpha.13+608a273da",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -31,16 +31,16 @@
|
|
31
31
|
"document": "api-extractor run --local"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
|
-
"@types/retry": "0.12.
|
34
|
+
"@types/retry": "0.12.5",
|
35
35
|
"lexical": "^0.12.0",
|
36
36
|
"p-retry": "5.1.2",
|
37
37
|
"p-throttle": "5.0.0",
|
38
38
|
"pusher-js": "8.2.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "19.79.
|
42
|
-
"@uniformdev/context": "19.79.
|
43
|
-
"immer": "
|
41
|
+
"@uniformdev/assets": "19.79.1-alpha.13+608a273da",
|
42
|
+
"@uniformdev/context": "19.79.1-alpha.13+608a273da",
|
43
|
+
"immer": "10.0.3"
|
44
44
|
},
|
45
45
|
"files": [
|
46
46
|
"/dist"
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"publishConfig": {
|
49
49
|
"access": "public"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "608a273da87aa432f17b2c8ce15d747dadab0cd1"
|
52
52
|
}
|