@uniformdev/canvas 19.62.0 → 19.62.1-alpha.127
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/LICENSE.txt +1 -1
- package/dist/index.d.mts +18684 -6955
- package/dist/index.d.ts +18684 -6955
- package/dist/index.esm.js +611 -202
- package/dist/index.js +649 -218
- package/dist/index.mjs +611 -202
- package/package.json +6 -5
package/dist/index.esm.js
CHANGED
@@ -476,12 +476,30 @@ 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
|
-
async getCompositionList(
|
482
|
+
async getCompositionList(params = {}) {
|
482
483
|
const { projectId } = this.options;
|
483
|
-
const
|
484
|
-
|
484
|
+
const { resolveData, filters, ...originParams } = params;
|
485
|
+
const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
|
486
|
+
const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
|
487
|
+
let rhs = typeof value === "object" ? Object.values(value)[0] : value;
|
488
|
+
rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
|
489
|
+
return { ...acc, [lhs]: rhs };
|
490
|
+
}, {});
|
491
|
+
if (!resolveData) {
|
492
|
+
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
493
|
+
return this.apiClient(fetchUri);
|
494
|
+
}
|
495
|
+
const edgeParams = {
|
496
|
+
...originParams,
|
497
|
+
projectId,
|
498
|
+
...params.diagnostics ? { diagnostics: "true" } : {},
|
499
|
+
...rewrittenFilters
|
500
|
+
};
|
501
|
+
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
502
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
485
503
|
}
|
486
504
|
getCompositionByNodePath(options) {
|
487
505
|
return this.getOneComposition(options);
|
@@ -499,12 +517,12 @@ var CanvasClient = class extends ApiClient {
|
|
499
517
|
return this.getOneComposition(options);
|
500
518
|
}
|
501
519
|
/** Fetches historical versions of a composition or pattern */
|
502
|
-
async
|
503
|
-
const
|
520
|
+
async getCompositionHistory(options) {
|
521
|
+
const historyUrl = this.createUrl("/api/v1/canvas-history", {
|
504
522
|
...options,
|
505
523
|
projectId: this.options.projectId
|
506
524
|
});
|
507
|
-
return this.apiClient(
|
525
|
+
return this.apiClient(historyUrl);
|
508
526
|
}
|
509
527
|
getOneComposition({
|
510
528
|
skipDataResolution,
|
@@ -521,7 +539,7 @@ var CanvasClient = class extends ApiClient {
|
|
521
539
|
...diagnostics ? { diagnostics: "true" } : {}
|
522
540
|
};
|
523
541
|
const edgeUrl = this.createUrl("/api/v1/composition", edgeParams, this.edgeApiHost);
|
524
|
-
return this.apiClient(edgeUrl);
|
542
|
+
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
525
543
|
}
|
526
544
|
/** Updates or creates a Canvas component definition */
|
527
545
|
async updateComposition(body) {
|
@@ -546,7 +564,7 @@ var CanvasClient = class extends ApiClient {
|
|
546
564
|
async getComponentDefinitions(options) {
|
547
565
|
const { projectId } = this.options;
|
548
566
|
const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
|
549
|
-
return
|
567
|
+
return this.apiClient(fetchUri);
|
550
568
|
}
|
551
569
|
/** Updates or creates a Canvas component definition */
|
552
570
|
async updateComponentDefinition(body) {
|
@@ -616,73 +634,10 @@ var UncachedCategoryClient = class extends CategoryClient {
|
|
616
634
|
}
|
617
635
|
};
|
618
636
|
|
619
|
-
// src/CompositionRelationshipClient.ts
|
620
|
-
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
621
|
-
var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
|
622
|
-
var unstable_CompositionRelationshipClient = class extends ApiClient3 {
|
623
|
-
constructor(options) {
|
624
|
-
super(options);
|
625
|
-
this.getDefinitionsRelationships = async ({
|
626
|
-
definitionIds,
|
627
|
-
withCompositions
|
628
|
-
}) => {
|
629
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
630
|
-
type: "definition",
|
631
|
-
projectId: this._options.projectId,
|
632
|
-
definitionIds: definitionIds.join(","),
|
633
|
-
withCompositions
|
634
|
-
});
|
635
|
-
return this.apiClient(url);
|
636
|
-
};
|
637
|
-
this.clearAllRelationships = async () => {
|
638
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
639
|
-
return this.apiClient(url, {
|
640
|
-
method: "POST",
|
641
|
-
body: JSON.stringify({
|
642
|
-
type: "clear",
|
643
|
-
projectId: this._options.projectId
|
644
|
-
})
|
645
|
-
});
|
646
|
-
};
|
647
|
-
this.indexCompositionRelationships = async ({
|
648
|
-
state,
|
649
|
-
compositionId
|
650
|
-
}) => {
|
651
|
-
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
652
|
-
return this.apiClient(url, {
|
653
|
-
method: "POST",
|
654
|
-
body: JSON.stringify({
|
655
|
-
type: "index",
|
656
|
-
projectId: this._options.projectId,
|
657
|
-
state,
|
658
|
-
compositionId
|
659
|
-
})
|
660
|
-
});
|
661
|
-
};
|
662
|
-
this.getVersion = async () => {
|
663
|
-
const url = this.createUrl("/api/v1/usage-tracking", {
|
664
|
-
projectId: this._options.projectId
|
665
|
-
});
|
666
|
-
return this.apiClient(url).then((response) => response.version);
|
667
|
-
};
|
668
|
-
this.setVersion = async (version) => {
|
669
|
-
const url = this.createUrl("/api/v1/usage-tracking");
|
670
|
-
return this.apiClient(url, {
|
671
|
-
method: "POST",
|
672
|
-
body: JSON.stringify({
|
673
|
-
projectId: this._options.projectId,
|
674
|
-
version
|
675
|
-
})
|
676
|
-
});
|
677
|
-
};
|
678
|
-
this._options = options;
|
679
|
-
}
|
680
|
-
};
|
681
|
-
|
682
637
|
// src/ContentClient.ts
|
683
|
-
import { ApiClient as
|
638
|
+
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
684
639
|
var _contentTypesUrl, _entriesUrl;
|
685
|
-
var _ContentClient = class _ContentClient extends
|
640
|
+
var _ContentClient = class _ContentClient extends ApiClient3 {
|
686
641
|
constructor(options) {
|
687
642
|
var _a;
|
688
643
|
super(options);
|
@@ -695,16 +650,42 @@ var _ContentClient = class _ContentClient extends ApiClient4 {
|
|
695
650
|
}
|
696
651
|
getEntries(options) {
|
697
652
|
const { projectId } = this.options;
|
698
|
-
const { skipDataResolution, ...params } = options;
|
699
|
-
const
|
700
|
-
|
653
|
+
const { skipDataResolution, filters, ...params } = options;
|
654
|
+
const rewrittenFilters = Object.entries(filters != null ? filters : {}).reduce((acc, [key, value]) => {
|
655
|
+
const lhs = `filters.${key}` + (typeof value === "object" ? `[${Object.keys(value)[0]}]` : "");
|
656
|
+
let rhs = typeof value === "object" ? Object.values(value)[0] : value;
|
657
|
+
rhs = Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim();
|
658
|
+
return { ...acc, [lhs]: rhs };
|
659
|
+
}, {});
|
660
|
+
if (skipDataResolution) {
|
661
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
662
|
+
return this.apiClient(url);
|
663
|
+
}
|
664
|
+
const edgeUrl = this.createUrl(
|
665
|
+
__privateGet(_ContentClient, _entriesUrl),
|
666
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
667
|
+
this.edgeApiHost
|
668
|
+
);
|
669
|
+
return this.apiClient(
|
670
|
+
edgeUrl,
|
671
|
+
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
672
|
+
);
|
673
|
+
}
|
674
|
+
/** Fetches historical versions of an entry */
|
675
|
+
async getEntryHistory(options) {
|
676
|
+
const historyUrl = this.createUrl("/api/v1/entries-history", {
|
677
|
+
...options,
|
678
|
+
projectId: this.options.projectId
|
679
|
+
});
|
680
|
+
return this.apiClient(historyUrl);
|
701
681
|
}
|
702
|
-
async upsertContentType(body) {
|
682
|
+
async upsertContentType(body, opts = {}) {
|
703
683
|
const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
|
704
684
|
await this.apiClient(fetchUri, {
|
705
685
|
method: "PUT",
|
706
686
|
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
707
|
-
expectNoContent: true
|
687
|
+
expectNoContent: true,
|
688
|
+
headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
|
708
689
|
});
|
709
690
|
}
|
710
691
|
async upsertEntry(body) {
|
@@ -753,10 +734,10 @@ var UncachedContentClient = class extends ContentClient {
|
|
753
734
|
};
|
754
735
|
|
755
736
|
// src/DataSourceClient.ts
|
756
|
-
import { ApiClient as
|
737
|
+
import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
|
757
738
|
var dataSourceUrl = "/api/v1/data-source";
|
758
739
|
var dataSourcesUrl = "/api/v1/data-sources";
|
759
|
-
var DataSourceClient = class extends
|
740
|
+
var DataSourceClient = class extends ApiClient4 {
|
760
741
|
constructor(options) {
|
761
742
|
super(options);
|
762
743
|
}
|
@@ -793,9 +774,9 @@ var DataSourceClient = class extends ApiClient5 {
|
|
793
774
|
};
|
794
775
|
|
795
776
|
// src/DataTypeClient.ts
|
796
|
-
import { ApiClient as
|
777
|
+
import { ApiClient as ApiClient5 } from "@uniformdev/context/api";
|
797
778
|
var _url;
|
798
|
-
var _DataTypeClient = class _DataTypeClient extends
|
779
|
+
var _DataTypeClient = class _DataTypeClient extends ApiClient5 {
|
799
780
|
constructor(options) {
|
800
781
|
super(options);
|
801
782
|
}
|
@@ -951,12 +932,14 @@ function getComponentPath(ancestorsAndSelf) {
|
|
951
932
|
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
952
933
|
var CANVAS_TEST_TYPE = "$test";
|
953
934
|
var CANVAS_LOCALIZATION_TYPE = "$localization";
|
935
|
+
var CANVAS_SLOT_SECTION_TYPE = "$slotSection";
|
954
936
|
var CANVAS_INTENT_TAG_PARAM = "intentTag";
|
955
937
|
var CANVAS_LOCALE_TAG_PARAM = "locale";
|
956
938
|
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
957
939
|
var CANVAS_PERSONALIZE_SLOT = "pz";
|
958
940
|
var CANVAS_TEST_SLOT = "test";
|
959
941
|
var CANVAS_LOCALIZATION_SLOT = "localized";
|
942
|
+
var CANVAS_SLOT_SECTION_SLOT = "$slotSectionItems";
|
960
943
|
var CANVAS_DRAFT_STATE = 0;
|
961
944
|
var CANVAS_PUBLISHED_STATE = 64;
|
962
945
|
var CANVAS_EDITOR_STATE = 63;
|
@@ -966,6 +949,7 @@ var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
|
|
966
949
|
var SECRET_QUERY_STRING_PARAM = "secret";
|
967
950
|
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
968
951
|
var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
|
952
|
+
var IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM = "is_incontext_editing_forced_settings";
|
969
953
|
var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
|
970
954
|
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
971
955
|
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
@@ -977,32 +961,79 @@ var EMPTY_COMPOSITION = {
|
|
977
961
|
_name: "An empty composition used for contextual editing",
|
978
962
|
type: "_empty_composition_type"
|
979
963
|
};
|
980
|
-
var EDGE_MIN_CACHE_TTL =
|
981
|
-
var EDGE_MAX_CACHE_TTL =
|
964
|
+
var EDGE_MIN_CACHE_TTL = 10;
|
965
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
982
966
|
var EDGE_DEFAULT_CACHE_TTL = 30;
|
983
967
|
var EDGE_CACHE_DISABLED = -1;
|
984
|
-
var
|
985
|
-
var
|
986
|
-
var
|
968
|
+
var ASSET_PARAMETER_TYPE = "asset";
|
969
|
+
var ASSETS_SOURCE_UNIFORM = "uniform-assets";
|
970
|
+
var ASSETS_SOURCE_CUSTOM_URL = "custom-url";
|
987
971
|
|
988
|
-
// src/utils/
|
989
|
-
function
|
990
|
-
return
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
fields: entry.entry.fields
|
998
|
-
},
|
999
|
-
state: entry.state,
|
1000
|
-
projectId: entry.projectId
|
1001
|
-
};
|
972
|
+
// src/utils/guards.ts
|
973
|
+
function isRootEntryReference(root) {
|
974
|
+
return root.type === "root" && isEntryData(root.node);
|
975
|
+
}
|
976
|
+
function isEntryData(entryData) {
|
977
|
+
return Boolean(entryData && typeof entryData === "object" && "fields" in entryData);
|
978
|
+
}
|
979
|
+
function isAssetParamValue(value) {
|
980
|
+
return Array.isArray(value) && (value.length > 0 ? isAssetParamValueItem(value[0]) : true);
|
1002
981
|
}
|
982
|
+
function isAssetParamValueItem(item) {
|
983
|
+
return Boolean(
|
984
|
+
item instanceof Object && "_source" in item && "fields" in item && item.fields instanceof Object && "url" in item.fields && item.fields.url instanceof Object
|
985
|
+
);
|
986
|
+
}
|
987
|
+
|
988
|
+
// src/utils/properties.ts
|
1003
989
|
function getPropertiesValue(entity) {
|
1004
990
|
return "parameters" in entity && entity.parameters ? entity.parameters : "fields" in entity && entity.fields ? entity.fields : void 0;
|
1005
991
|
}
|
992
|
+
function getPropertyValue(parameter) {
|
993
|
+
return parameter ? parameter.value : parameter;
|
994
|
+
}
|
995
|
+
function getLocalizedPropertyValues(parameter) {
|
996
|
+
if (!parameter) {
|
997
|
+
return parameter;
|
998
|
+
}
|
999
|
+
const localizedValues = /* @__PURE__ */ new Map();
|
1000
|
+
if (typeof parameter.value !== "undefined") {
|
1001
|
+
localizedValues.set(void 0, parameter.value);
|
1002
|
+
}
|
1003
|
+
if (parameter.locales !== void 0) {
|
1004
|
+
for (const [locale, localeValue] of Object.entries(parameter.locales)) {
|
1005
|
+
localizedValues.set(locale, localeValue);
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
return localizedValues;
|
1009
|
+
}
|
1010
|
+
function flattenValues(data, options = {}) {
|
1011
|
+
if (!data) {
|
1012
|
+
return data;
|
1013
|
+
} else if (Array.isArray(data) && options.toSingle) {
|
1014
|
+
return data.length > 0 ? flattenSingleNodeValues(data[0]) : void 0;
|
1015
|
+
} else if (Array.isArray(data)) {
|
1016
|
+
return data.map((node) => flattenSingleNodeValues(node, options));
|
1017
|
+
} else {
|
1018
|
+
return flattenSingleNodeValues(data, options);
|
1019
|
+
}
|
1020
|
+
}
|
1021
|
+
function flattenSingleNodeValues(data, options = {}) {
|
1022
|
+
const { levels = 1 } = options;
|
1023
|
+
const properties = getPropertiesValue(data);
|
1024
|
+
return properties ? Object.fromEntries(
|
1025
|
+
Object.entries(properties).map(([id, parameter]) => {
|
1026
|
+
const value = getPropertyValue(parameter);
|
1027
|
+
if (levels > 0 && Array.isArray(value) && // In the future ASSET_PARAMETER_TYPE will be a nested data type
|
1028
|
+
(isNestedNodeType(parameter.type) || parameter.type === ASSET_PARAMETER_TYPE)) {
|
1029
|
+
const nestedOptions = { ...options, levels: levels - 1 };
|
1030
|
+
return [id, value.map((item) => flattenValues(item, nestedOptions))];
|
1031
|
+
} else {
|
1032
|
+
return [id, value];
|
1033
|
+
}
|
1034
|
+
})
|
1035
|
+
) : properties;
|
1036
|
+
}
|
1006
1037
|
|
1007
1038
|
// src/enhancement/walkNodeTree.ts
|
1008
1039
|
function walkNodeTree(node, visitor, options) {
|
@@ -1022,7 +1053,83 @@ function walkNodeTree(node, visitor, options) {
|
|
1022
1053
|
let visitDescendants = true;
|
1023
1054
|
let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
|
1024
1055
|
let visitorInfo;
|
1025
|
-
if (currentComponent.type === "root" || currentComponent.type === "
|
1056
|
+
if (currentComponent.type === "root" && isRootEntryReference(currentComponent) || currentComponent.type === "block") {
|
1057
|
+
visitorInfo = {
|
1058
|
+
type: "entry",
|
1059
|
+
node: currentComponent.node,
|
1060
|
+
ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
|
1061
|
+
actions: {
|
1062
|
+
replace: (replacementNode) => {
|
1063
|
+
Object.assign(currentComponent.node, replacementNode);
|
1064
|
+
const propertiesToCheck = ["fields", "_dataResources", "_author"];
|
1065
|
+
propertiesToCheck.forEach((property) => {
|
1066
|
+
if (!replacementNode[property]) {
|
1067
|
+
delete currentComponent.node[property];
|
1068
|
+
}
|
1069
|
+
});
|
1070
|
+
},
|
1071
|
+
remove: () => {
|
1072
|
+
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1073
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1074
|
+
if (currentComponentLocation.type === "block") {
|
1075
|
+
const { fieldName, blockIndex } = currentComponentLocation;
|
1076
|
+
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1077
|
+
blockValue.splice(blockIndex, 1);
|
1078
|
+
if (blockValue.length === 0) {
|
1079
|
+
const properties2 = getPropertiesValue(parentComponent.node);
|
1080
|
+
delete properties2[fieldName];
|
1081
|
+
}
|
1082
|
+
} else {
|
1083
|
+
throw new Error("Unknown node type");
|
1084
|
+
}
|
1085
|
+
},
|
1086
|
+
insertAfter: (nodes) => {
|
1087
|
+
const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
|
1088
|
+
if (currentNodeInfo.type !== "block") {
|
1089
|
+
throw new Error("Unknown type");
|
1090
|
+
}
|
1091
|
+
const { fieldName, blockIndex } = currentNodeInfo;
|
1092
|
+
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1093
|
+
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1094
|
+
if (fieldName && typeof blockIndex !== "undefined") {
|
1095
|
+
getPropertiesValue(parentComponent.node)[fieldName].value.splice(
|
1096
|
+
blockIndex + 1,
|
1097
|
+
0,
|
1098
|
+
...nodesToInsert
|
1099
|
+
);
|
1100
|
+
componentQueue.unshift(
|
1101
|
+
...nodesToInsert.map((enqueueingComponent) => ({
|
1102
|
+
ancestorsAndSelf: [
|
1103
|
+
{
|
1104
|
+
type: "block",
|
1105
|
+
node: enqueueingComponent,
|
1106
|
+
fieldName,
|
1107
|
+
get blockIndex() {
|
1108
|
+
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1109
|
+
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1110
|
+
}
|
1111
|
+
},
|
1112
|
+
// slice removes 'self' since we are inserting a peer of self
|
1113
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1114
|
+
],
|
1115
|
+
context: descendantContext
|
1116
|
+
}))
|
1117
|
+
);
|
1118
|
+
}
|
1119
|
+
},
|
1120
|
+
stopProcessingDescendants() {
|
1121
|
+
visitDescendants = false;
|
1122
|
+
},
|
1123
|
+
setDescendantsContext(context) {
|
1124
|
+
descendantContext = context;
|
1125
|
+
},
|
1126
|
+
setChildContext(child, context) {
|
1127
|
+
childContexts.set(child, context);
|
1128
|
+
}
|
1129
|
+
},
|
1130
|
+
context: descendantContext
|
1131
|
+
};
|
1132
|
+
} else {
|
1026
1133
|
visitorInfo = {
|
1027
1134
|
type: "component",
|
1028
1135
|
node: currentComponent.node,
|
@@ -1113,82 +1220,6 @@ function walkNodeTree(node, visitor, options) {
|
|
1113
1220
|
},
|
1114
1221
|
context: descendantContext
|
1115
1222
|
};
|
1116
|
-
} else {
|
1117
|
-
visitorInfo = {
|
1118
|
-
type: "entry",
|
1119
|
-
node: currentComponent.node,
|
1120
|
-
ancestorsAndSelf: currentQueueEntry.ancestorsAndSelf,
|
1121
|
-
actions: {
|
1122
|
-
replace: (replacementNode) => {
|
1123
|
-
Object.assign(currentComponent.node, replacementNode);
|
1124
|
-
const propertiesToCheck = ["fields", "_dataResources", "_author"];
|
1125
|
-
propertiesToCheck.forEach((property) => {
|
1126
|
-
if (!replacementNode[property]) {
|
1127
|
-
delete currentComponent.node[property];
|
1128
|
-
}
|
1129
|
-
});
|
1130
|
-
},
|
1131
|
-
remove: () => {
|
1132
|
-
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1133
|
-
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1134
|
-
if (currentComponentLocation.type === "block") {
|
1135
|
-
const { fieldName, blockIndex } = currentComponentLocation;
|
1136
|
-
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1137
|
-
blockValue.splice(blockIndex, 1);
|
1138
|
-
if (blockValue.length === 0) {
|
1139
|
-
const properties2 = getPropertiesValue(parentComponent.node);
|
1140
|
-
delete properties2[fieldName];
|
1141
|
-
}
|
1142
|
-
} else {
|
1143
|
-
throw new Error("Unknown node type");
|
1144
|
-
}
|
1145
|
-
},
|
1146
|
-
insertAfter: (nodes) => {
|
1147
|
-
const currentNodeInfo = currentQueueEntry.ancestorsAndSelf[0];
|
1148
|
-
if (currentNodeInfo.type !== "block") {
|
1149
|
-
throw new Error("Unknown type");
|
1150
|
-
}
|
1151
|
-
const { fieldName, blockIndex } = currentNodeInfo;
|
1152
|
-
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1153
|
-
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1154
|
-
if (fieldName && typeof blockIndex !== "undefined") {
|
1155
|
-
getPropertiesValue(parentComponent.node)[fieldName].value.splice(
|
1156
|
-
blockIndex + 1,
|
1157
|
-
0,
|
1158
|
-
...nodesToInsert
|
1159
|
-
);
|
1160
|
-
componentQueue.unshift(
|
1161
|
-
...nodesToInsert.map((enqueueingComponent) => ({
|
1162
|
-
ancestorsAndSelf: [
|
1163
|
-
{
|
1164
|
-
type: "block",
|
1165
|
-
node: enqueueingComponent,
|
1166
|
-
fieldName,
|
1167
|
-
get blockIndex() {
|
1168
|
-
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1169
|
-
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1170
|
-
}
|
1171
|
-
},
|
1172
|
-
// slice removes 'self' since we are inserting a peer of self
|
1173
|
-
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1174
|
-
],
|
1175
|
-
context: descendantContext
|
1176
|
-
}))
|
1177
|
-
);
|
1178
|
-
}
|
1179
|
-
},
|
1180
|
-
stopProcessingDescendants() {
|
1181
|
-
visitDescendants = false;
|
1182
|
-
},
|
1183
|
-
setDescendantsContext(context) {
|
1184
|
-
descendantContext = context;
|
1185
|
-
},
|
1186
|
-
setChildContext(child, context) {
|
1187
|
-
childContexts.set(child, context);
|
1188
|
-
}
|
1189
|
-
},
|
1190
|
-
context: descendantContext
|
1191
|
-
};
|
1192
1223
|
}
|
1193
1224
|
visitor(visitorInfo);
|
1194
1225
|
if (!visitDescendants) {
|
@@ -1226,7 +1257,7 @@ function walkNodeTree(node, visitor, options) {
|
|
1226
1257
|
const propertyEntries = Object.entries(properties);
|
1227
1258
|
for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
|
1228
1259
|
const [propKey, propObject] = propertyEntries[propIndex];
|
1229
|
-
if (propObject.type
|
1260
|
+
if (!isNestedNodeType(propObject.type))
|
1230
1261
|
continue;
|
1231
1262
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1232
1263
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
@@ -1252,6 +1283,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1252
1283
|
}
|
1253
1284
|
} while (componentQueue.length > 0);
|
1254
1285
|
}
|
1286
|
+
function isNestedNodeType(type) {
|
1287
|
+
return type === CANVAS_BLOCK_PARAM_TYPE;
|
1288
|
+
}
|
1255
1289
|
function getBlockValue(component, parameterName) {
|
1256
1290
|
var _a;
|
1257
1291
|
const parameter = (_a = getPropertiesValue(component)) == null ? void 0 : _a[parameterName];
|
@@ -1520,7 +1554,7 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1520
1554
|
if (currentLocation.type === "block") {
|
1521
1555
|
const { fieldName: parameterName, blockIndex } = currentLocation;
|
1522
1556
|
if (parameterName && blockIndex !== void 0) {
|
1523
|
-
const noun = parentLocation
|
1557
|
+
const noun = getNounForLocation(parentLocation);
|
1524
1558
|
path.push(`${noun}/${parameterName}/value/${blockIndex}`);
|
1525
1559
|
}
|
1526
1560
|
} else {
|
@@ -1534,6 +1568,40 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1534
1568
|
}
|
1535
1569
|
return `/${path.join("/")}`;
|
1536
1570
|
}
|
1571
|
+
function getNounForLocation(parentLocation) {
|
1572
|
+
let noun = "parameters";
|
1573
|
+
if (parentLocation && "type" in parentLocation) {
|
1574
|
+
if (parentLocation.type === "block" || isRootEntryReference(parentLocation)) {
|
1575
|
+
noun = "fields";
|
1576
|
+
}
|
1577
|
+
}
|
1578
|
+
return noun;
|
1579
|
+
}
|
1580
|
+
function getNounForNode(node) {
|
1581
|
+
let noun = "parameters";
|
1582
|
+
if (isEntryData(node)) {
|
1583
|
+
noun = "fields";
|
1584
|
+
}
|
1585
|
+
return noun;
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
// src/enhancement/findInNodeTree.ts
|
1589
|
+
function findParameterInNodeTree(data, predicate) {
|
1590
|
+
const results = [];
|
1591
|
+
walkNodeTree(data, ({ node, ancestorsAndSelf }) => {
|
1592
|
+
const parameters = getPropertiesValue(node);
|
1593
|
+
if (parameters) {
|
1594
|
+
Object.entries(parameters).filter(([key, field]) => predicate(field, key, node)).forEach(([key, field]) => {
|
1595
|
+
results.push({
|
1596
|
+
key,
|
1597
|
+
pointer: (ancestorsAndSelf.length === 1 ? "" : getComponentJsonPointer(ancestorsAndSelf)) + `/${getNounForNode(node)}/${key}`,
|
1598
|
+
parameter: field
|
1599
|
+
});
|
1600
|
+
});
|
1601
|
+
}
|
1602
|
+
});
|
1603
|
+
return results;
|
1604
|
+
}
|
1537
1605
|
|
1538
1606
|
// src/enhancement/localize.ts
|
1539
1607
|
function extractLocales({ component }) {
|
@@ -1550,23 +1618,31 @@ function extractLocales({ component }) {
|
|
1550
1618
|
});
|
1551
1619
|
return variations;
|
1552
1620
|
}
|
1553
|
-
function localize({
|
1554
|
-
composition
|
1555
|
-
locale
|
1556
|
-
}) {
|
1557
|
-
walkNodeTree(composition, ({ type, node, actions }) => {
|
1621
|
+
function localize(options) {
|
1622
|
+
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1623
|
+
const locale = options.locale;
|
1624
|
+
walkNodeTree(nodes, ({ type, node, actions }) => {
|
1558
1625
|
if (type !== "component") {
|
1559
|
-
|
1626
|
+
if (typeof locale === "string") {
|
1627
|
+
localizeProperties(node.fields, locale);
|
1628
|
+
}
|
1560
1629
|
return;
|
1561
1630
|
}
|
1631
|
+
const shouldRunPropertyLocalization = typeof locale === "string";
|
1562
1632
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1563
1633
|
const locales = extractLocales({ component: node });
|
1564
|
-
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1634
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1565
1635
|
let replaceComponent;
|
1566
1636
|
if (resolvedLocale) {
|
1567
1637
|
replaceComponent = locales[resolvedLocale];
|
1568
1638
|
}
|
1569
1639
|
if (replaceComponent == null ? void 0 : replaceComponent.length) {
|
1640
|
+
replaceComponent.forEach((component) => {
|
1641
|
+
removeLocaleProperty(component);
|
1642
|
+
if (shouldRunPropertyLocalization) {
|
1643
|
+
localizeProperties(getPropertiesValue(component), locale);
|
1644
|
+
}
|
1645
|
+
});
|
1570
1646
|
const [first, ...rest] = replaceComponent;
|
1571
1647
|
actions.replace(first);
|
1572
1648
|
if (rest.length) {
|
@@ -1575,6 +1651,42 @@ function localize({
|
|
1575
1651
|
} else {
|
1576
1652
|
actions.remove();
|
1577
1653
|
}
|
1654
|
+
} else if (shouldRunPropertyLocalization) {
|
1655
|
+
localizeProperties(getPropertiesValue(node), locale);
|
1656
|
+
}
|
1657
|
+
});
|
1658
|
+
}
|
1659
|
+
function removeLocaleProperty(component) {
|
1660
|
+
const properties = getPropertiesValue(component);
|
1661
|
+
const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
|
1662
|
+
if (localeTagProperty) {
|
1663
|
+
delete properties[CANVAS_LOCALE_TAG_PARAM];
|
1664
|
+
}
|
1665
|
+
if (properties && Object.keys(properties).length === 0) {
|
1666
|
+
if ("fields" in component) {
|
1667
|
+
delete component.fields;
|
1668
|
+
}
|
1669
|
+
if ("parameters" in component) {
|
1670
|
+
delete component.parameters;
|
1671
|
+
}
|
1672
|
+
}
|
1673
|
+
}
|
1674
|
+
function localizeProperties(properties, locale) {
|
1675
|
+
if (!properties) {
|
1676
|
+
return void 0;
|
1677
|
+
}
|
1678
|
+
Object.entries(properties).forEach(([key, property]) => {
|
1679
|
+
var _a;
|
1680
|
+
if (!locale) {
|
1681
|
+
delete property.locales;
|
1682
|
+
}
|
1683
|
+
const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
|
1684
|
+
if (currentLocaleValue !== void 0) {
|
1685
|
+
property.value = currentLocaleValue;
|
1686
|
+
}
|
1687
|
+
delete property.locales;
|
1688
|
+
if (property.value === void 0) {
|
1689
|
+
delete properties[key];
|
1578
1690
|
}
|
1579
1691
|
});
|
1580
1692
|
}
|
@@ -1724,6 +1836,39 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1724
1836
|
} while (componentQueue.length > 0);
|
1725
1837
|
}
|
1726
1838
|
|
1839
|
+
// src/LocaleClient.ts
|
1840
|
+
import { ApiClient as ApiClient6 } from "@uniformdev/context/api";
|
1841
|
+
var localesUrl = "/api/v1/locales";
|
1842
|
+
var LocaleClient = class extends ApiClient6 {
|
1843
|
+
constructor(options) {
|
1844
|
+
super(options);
|
1845
|
+
}
|
1846
|
+
/** Fetches all locales for a project */
|
1847
|
+
async get(options) {
|
1848
|
+
const { projectId } = this.options;
|
1849
|
+
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
1850
|
+
return await this.apiClient(fetchUri);
|
1851
|
+
}
|
1852
|
+
/** Updates or creates (based on id) a locale */
|
1853
|
+
async upsert(body) {
|
1854
|
+
const fetchUri = this.createUrl(localesUrl);
|
1855
|
+
await this.apiClient(fetchUri, {
|
1856
|
+
method: "PUT",
|
1857
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1858
|
+
expectNoContent: true
|
1859
|
+
});
|
1860
|
+
}
|
1861
|
+
/** Deletes a locale */
|
1862
|
+
async remove(body) {
|
1863
|
+
const fetchUri = this.createUrl(localesUrl);
|
1864
|
+
await this.apiClient(fetchUri, {
|
1865
|
+
method: "DELETE",
|
1866
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1867
|
+
expectNoContent: true
|
1868
|
+
});
|
1869
|
+
}
|
1870
|
+
};
|
1871
|
+
|
1727
1872
|
// src/utils/hash.ts
|
1728
1873
|
var generateHash = ({
|
1729
1874
|
composition,
|
@@ -1794,6 +1939,12 @@ var isOpenParameterEditorMessage = (message) => {
|
|
1794
1939
|
var isUpdateComponentReferencesMessage = (message) => {
|
1795
1940
|
return message.type === "update-component-references";
|
1796
1941
|
};
|
1942
|
+
var isRequestComponentSuggestionMessage = (message) => {
|
1943
|
+
return message.type === "request-component-suggestion";
|
1944
|
+
};
|
1945
|
+
var isSuggestComponentMessage = (message) => {
|
1946
|
+
return message.type === "suggest-component";
|
1947
|
+
};
|
1797
1948
|
var createCanvasChannel = ({
|
1798
1949
|
listenTo,
|
1799
1950
|
broadcastTo
|
@@ -1802,7 +1953,13 @@ var createCanvasChannel = ({
|
|
1802
1953
|
const handlers = {};
|
1803
1954
|
const broadcastToItems = [...broadcastTo];
|
1804
1955
|
const postMessage = (message) => {
|
1805
|
-
broadcastToItems.forEach((item) => item.postMessage(JSON.stringify(message), "*"));
|
1956
|
+
broadcastToItems.forEach((item) => item == null ? void 0 : item.postMessage(JSON.stringify(message), "*"));
|
1957
|
+
for (const handlerId in handlers) {
|
1958
|
+
const handler = handlers[handlerId];
|
1959
|
+
if (handler.types.includes(message.type)) {
|
1960
|
+
handler.handler(message, new MessageEvent(message.type));
|
1961
|
+
}
|
1962
|
+
}
|
1806
1963
|
};
|
1807
1964
|
const selectComponent = (id) => {
|
1808
1965
|
const message = {
|
@@ -1811,7 +1968,7 @@ var createCanvasChannel = ({
|
|
1811
1968
|
};
|
1812
1969
|
postMessage(message);
|
1813
1970
|
};
|
1814
|
-
const ready = () => {
|
1971
|
+
const ready = (options) => {
|
1815
1972
|
var _a, _b;
|
1816
1973
|
if (typeof window === "undefined") {
|
1817
1974
|
return;
|
@@ -1821,7 +1978,8 @@ var createCanvasChannel = ({
|
|
1821
1978
|
const message = {
|
1822
1979
|
type: "ready",
|
1823
1980
|
framework,
|
1824
|
-
version
|
1981
|
+
version,
|
1982
|
+
rsc: options == null ? void 0 : options.rsc
|
1825
1983
|
};
|
1826
1984
|
postMessage(message);
|
1827
1985
|
};
|
@@ -1944,6 +2102,20 @@ var createCanvasChannel = ({
|
|
1944
2102
|
};
|
1945
2103
|
postMessage(message);
|
1946
2104
|
};
|
2105
|
+
const requestComponentSuggestion = (options) => {
|
2106
|
+
const message = {
|
2107
|
+
...options,
|
2108
|
+
type: "request-component-suggestion"
|
2109
|
+
};
|
2110
|
+
postMessage(message);
|
2111
|
+
};
|
2112
|
+
const suggestComponent = (options) => {
|
2113
|
+
const message = {
|
2114
|
+
...options,
|
2115
|
+
type: "suggest-component"
|
2116
|
+
};
|
2117
|
+
postMessage(message);
|
2118
|
+
};
|
1947
2119
|
const updateFeatureFlags = (options) => {
|
1948
2120
|
const message = {
|
1949
2121
|
...options,
|
@@ -1997,7 +2169,9 @@ var createCanvasChannel = ({
|
|
1997
2169
|
openParameterEditor,
|
1998
2170
|
reportRenderedCompositions,
|
1999
2171
|
editorStateUpdated,
|
2000
|
-
updateComponentReferences
|
2172
|
+
updateComponentReferences,
|
2173
|
+
requestComponentSuggestion,
|
2174
|
+
suggestComponent
|
2001
2175
|
};
|
2002
2176
|
};
|
2003
2177
|
|
@@ -2079,10 +2253,166 @@ function subscribeToComposition({
|
|
2079
2253
|
};
|
2080
2254
|
}
|
2081
2255
|
|
2082
|
-
// src/
|
2256
|
+
// src/PromptClient.ts
|
2083
2257
|
import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
|
2258
|
+
var PromptsUrl = "/api/v1/prompts";
|
2259
|
+
var PromptClient = class extends ApiClient7 {
|
2260
|
+
constructor(options) {
|
2261
|
+
super(options);
|
2262
|
+
}
|
2263
|
+
/** Fetches Prompts for a project */
|
2264
|
+
async get(options) {
|
2265
|
+
const { projectId } = this.options;
|
2266
|
+
const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
|
2267
|
+
return await this.apiClient(fetchUri);
|
2268
|
+
}
|
2269
|
+
/** Updates or creates (based on id) a Prompt */
|
2270
|
+
async upsert(body) {
|
2271
|
+
const fetchUri = this.createUrl(PromptsUrl);
|
2272
|
+
await this.apiClient(fetchUri, {
|
2273
|
+
method: "PUT",
|
2274
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2275
|
+
expectNoContent: true
|
2276
|
+
});
|
2277
|
+
}
|
2278
|
+
/** Deletes a Prompt */
|
2279
|
+
async remove(body) {
|
2280
|
+
const fetchUri = this.createUrl(PromptsUrl);
|
2281
|
+
await this.apiClient(fetchUri, {
|
2282
|
+
method: "DELETE",
|
2283
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2284
|
+
expectNoContent: true
|
2285
|
+
});
|
2286
|
+
}
|
2287
|
+
};
|
2288
|
+
|
2289
|
+
// src/RelationshipClient.ts
|
2290
|
+
import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
|
2291
|
+
var RELATIONSHIPS_URL = "/api/v1/relationships";
|
2292
|
+
var RelationshipClient = class extends ApiClient8 {
|
2293
|
+
constructor(options) {
|
2294
|
+
super(options);
|
2295
|
+
this.get = async (options) => {
|
2296
|
+
const { projectId } = this.options;
|
2297
|
+
const url = this.createUrl(RELATIONSHIPS_URL, { ...options, projectId });
|
2298
|
+
return this.apiClient(url);
|
2299
|
+
};
|
2300
|
+
this.clearProjectRelationships = async () => {
|
2301
|
+
const { projectId } = this.options;
|
2302
|
+
const url = this.createUrl(RELATIONSHIPS_URL);
|
2303
|
+
return this.apiClient(url, {
|
2304
|
+
method: "POST",
|
2305
|
+
body: JSON.stringify({
|
2306
|
+
action: "clear",
|
2307
|
+
projectId
|
2308
|
+
})
|
2309
|
+
});
|
2310
|
+
};
|
2311
|
+
this.indexRelationships = async ({ state, id, type }) => {
|
2312
|
+
const { projectId } = this.options;
|
2313
|
+
const url = this.createUrl(RELATIONSHIPS_URL);
|
2314
|
+
return this.apiClient(url, {
|
2315
|
+
method: "POST",
|
2316
|
+
body: JSON.stringify({
|
2317
|
+
action: "index",
|
2318
|
+
type,
|
2319
|
+
projectId,
|
2320
|
+
state,
|
2321
|
+
id
|
2322
|
+
})
|
2323
|
+
});
|
2324
|
+
};
|
2325
|
+
this.getVersion = async () => {
|
2326
|
+
const { projectId } = this.options;
|
2327
|
+
const url = this.createUrl("/api/v1/usage-tracking", {
|
2328
|
+
projectId
|
2329
|
+
});
|
2330
|
+
return this.apiClient(url).then((response) => response.version);
|
2331
|
+
};
|
2332
|
+
this.setVersion = async (version) => {
|
2333
|
+
const { projectId } = this.options;
|
2334
|
+
const url = this.createUrl("/api/v1/usage-tracking");
|
2335
|
+
return this.apiClient(url, {
|
2336
|
+
method: "POST",
|
2337
|
+
body: JSON.stringify({
|
2338
|
+
projectId,
|
2339
|
+
version
|
2340
|
+
})
|
2341
|
+
});
|
2342
|
+
};
|
2343
|
+
}
|
2344
|
+
};
|
2345
|
+
|
2346
|
+
// src/ReleaseClient.ts
|
2347
|
+
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2348
|
+
var releasesUrl = "/api/v1/releases";
|
2349
|
+
var ReleaseClient = class extends ApiClient9 {
|
2350
|
+
constructor(options) {
|
2351
|
+
super(options);
|
2352
|
+
}
|
2353
|
+
/** Fetches all releases for a project */
|
2354
|
+
async get(options) {
|
2355
|
+
const { projectId } = this.options;
|
2356
|
+
const fetchUri = this.createUrl(releasesUrl, { ...options, projectId });
|
2357
|
+
return await this.apiClient(fetchUri);
|
2358
|
+
}
|
2359
|
+
/** Updates or creates (based on id) a release */
|
2360
|
+
async upsert(body) {
|
2361
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2362
|
+
await this.apiClient(fetchUri, {
|
2363
|
+
method: "PUT",
|
2364
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2365
|
+
expectNoContent: true
|
2366
|
+
});
|
2367
|
+
}
|
2368
|
+
/** Deletes a release */
|
2369
|
+
async remove(body) {
|
2370
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2371
|
+
await this.apiClient(fetchUri, {
|
2372
|
+
method: "DELETE",
|
2373
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2374
|
+
expectNoContent: true
|
2375
|
+
});
|
2376
|
+
}
|
2377
|
+
/** Readies or unreadies a release for merging */
|
2378
|
+
async ready(body) {
|
2379
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2380
|
+
await this.apiClient(fetchUri, {
|
2381
|
+
method: "PATCH",
|
2382
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2383
|
+
expectNoContent: true
|
2384
|
+
});
|
2385
|
+
}
|
2386
|
+
};
|
2387
|
+
|
2388
|
+
// src/ReleaseContentsClient.ts
|
2389
|
+
import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
|
2390
|
+
var releaseContentsUrl = "/api/v1/release-contents";
|
2391
|
+
var ReleaseContentsClient = class extends ApiClient10 {
|
2392
|
+
constructor(options) {
|
2393
|
+
super(options);
|
2394
|
+
}
|
2395
|
+
/** Fetches all entities added to a release */
|
2396
|
+
async get(options) {
|
2397
|
+
const { projectId } = this.options;
|
2398
|
+
const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
|
2399
|
+
return await this.apiClient(fetchUri);
|
2400
|
+
}
|
2401
|
+
/** Removes a release content from a release */
|
2402
|
+
async remove(body) {
|
2403
|
+
const fetchUri = this.createUrl(releaseContentsUrl);
|
2404
|
+
await this.apiClient(fetchUri, {
|
2405
|
+
method: "DELETE",
|
2406
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2407
|
+
expectNoContent: true
|
2408
|
+
});
|
2409
|
+
}
|
2410
|
+
};
|
2411
|
+
|
2412
|
+
// src/RouteClient.ts
|
2413
|
+
import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
|
2084
2414
|
var ROUTE_URL = "/api/v1/route";
|
2085
|
-
var RouteClient = class extends
|
2415
|
+
var RouteClient = class extends ApiClient11 {
|
2086
2416
|
constructor(options) {
|
2087
2417
|
var _a;
|
2088
2418
|
if (!options.limitPolicy) {
|
@@ -2095,10 +2425,16 @@ var RouteClient = class extends ApiClient7 {
|
|
2095
2425
|
async getRoute(options) {
|
2096
2426
|
const { projectId } = this.options;
|
2097
2427
|
const fetchUri = this.createUrl(ROUTE_URL, { ...options, projectId }, this.edgeApiHost);
|
2098
|
-
return await this.apiClient(
|
2428
|
+
return await this.apiClient(
|
2429
|
+
fetchUri,
|
2430
|
+
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
2431
|
+
);
|
2099
2432
|
}
|
2100
2433
|
};
|
2101
2434
|
|
2435
|
+
// src/types/locales.ts
|
2436
|
+
var LOCALE_DYNAMIC_INPUT_NAME = "locale";
|
2437
|
+
|
2102
2438
|
// src/utils/createApiEnhancer.ts
|
2103
2439
|
var createUniformApiEnhancer = ({ apiUrl }) => {
|
2104
2440
|
return async (message) => {
|
@@ -2121,6 +2457,28 @@ var createUniformApiEnhancer = ({ apiUrl }) => {
|
|
2121
2457
|
};
|
2122
2458
|
};
|
2123
2459
|
|
2460
|
+
// src/utils/entryConverter.ts
|
2461
|
+
function convertEntryToPutEntry(entry) {
|
2462
|
+
return {
|
2463
|
+
entry: {
|
2464
|
+
type: entry.entry.type,
|
2465
|
+
_dataResources: entry.entry._dataResources,
|
2466
|
+
_id: entry.entry._id,
|
2467
|
+
_name: entry.entry._name,
|
2468
|
+
_slug: entry.entry._slug,
|
2469
|
+
_pattern: entry.entry._pattern,
|
2470
|
+
_overridability: entry.entry._overridability,
|
2471
|
+
_overrides: entry.entry._overrides,
|
2472
|
+
fields: entry.entry.fields,
|
2473
|
+
_locales: entry.entry._locales
|
2474
|
+
},
|
2475
|
+
pattern: entry.pattern,
|
2476
|
+
state: entry.state,
|
2477
|
+
projectId: entry.projectId,
|
2478
|
+
releaseId: entry.releaseId
|
2479
|
+
};
|
2480
|
+
}
|
2481
|
+
|
2124
2482
|
// src/utils/getParameterAttributes.ts
|
2125
2483
|
var ATTRIBUTE_COMPONENT_ID = "data-uniform-component-id";
|
2126
2484
|
var ATTRIBUTE_PARAMETER_ID = "data-uniform-parameter-id";
|
@@ -2194,17 +2552,41 @@ function mapSlotToTestVariations(slot) {
|
|
2194
2552
|
}
|
2195
2553
|
|
2196
2554
|
// src/utils/placeholder.ts
|
2555
|
+
var SEPARATOR = "_";
|
2197
2556
|
var isComponentPlaceholderId = (id) => {
|
2198
2557
|
if (id === PLACEHOLDER_ID) {
|
2199
2558
|
return true;
|
2200
2559
|
}
|
2560
|
+
if (typeof id !== "string") {
|
2561
|
+
return false;
|
2562
|
+
}
|
2201
2563
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2202
2564
|
};
|
2203
|
-
var generateComponentPlaceholderId = (randomId, sdkVersion) => {
|
2565
|
+
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
2204
2566
|
if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
|
2205
2567
|
return PLACEHOLDER_ID;
|
2206
2568
|
}
|
2207
|
-
|
2569
|
+
let idParts = [PLACEHOLDER_ID, randomId];
|
2570
|
+
if (parent) {
|
2571
|
+
idParts = [...idParts, parent.nodeId, parent.slotId];
|
2572
|
+
}
|
2573
|
+
return idParts.join(SEPARATOR);
|
2574
|
+
};
|
2575
|
+
var parseComponentPlaceholderId = (id) => {
|
2576
|
+
if (!isComponentPlaceholderId(id)) {
|
2577
|
+
return;
|
2578
|
+
}
|
2579
|
+
const idParts = id.split(SEPARATOR);
|
2580
|
+
const result = {
|
2581
|
+
id: idParts[1]
|
2582
|
+
};
|
2583
|
+
if (idParts[2]) {
|
2584
|
+
result.parent = {
|
2585
|
+
nodeId: idParts[2],
|
2586
|
+
slotId: idParts[3]
|
2587
|
+
};
|
2588
|
+
}
|
2589
|
+
return result;
|
2208
2590
|
};
|
2209
2591
|
|
2210
2592
|
// src/utils/variables/parseVariableExpression.ts
|
@@ -2247,9 +2629,14 @@ function parseVariableExpression(serialized, onToken) {
|
|
2247
2629
|
continue;
|
2248
2630
|
}
|
2249
2631
|
if (char === variableSuffix && state === "variable") {
|
2632
|
+
if (serialized[index - 1] === escapeCharacter) {
|
2633
|
+
bufferEndIndex++;
|
2634
|
+
continue;
|
2635
|
+
}
|
2250
2636
|
state = "text";
|
2251
2637
|
if (bufferEndIndex > bufferStartIndex) {
|
2252
|
-
|
2638
|
+
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
2639
|
+
if (handleToken(unescapedVariableName, "variable") === false) {
|
2253
2640
|
return tokenCount;
|
2254
2641
|
}
|
2255
2642
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
@@ -2309,7 +2696,7 @@ import { produce } from "immer";
|
|
2309
2696
|
|
2310
2697
|
// src/utils/variables/createVariableReference.ts
|
2311
2698
|
function createVariableReference(variableName) {
|
2312
|
-
return `\${${variableName}}`;
|
2699
|
+
return `\${${variableName.replace(/([${}])/g, "\\$1")}}`;
|
2313
2700
|
}
|
2314
2701
|
|
2315
2702
|
// src/utils/variables/bindVariablesToObject.ts
|
@@ -2393,6 +2780,9 @@ function handleRichTextNodeBinding(object, options) {
|
|
2393
2780
|
import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
|
2394
2781
|
var CanvasClientError = ApiClientError2;
|
2395
2782
|
export {
|
2783
|
+
ASSETS_SOURCE_CUSTOM_URL,
|
2784
|
+
ASSETS_SOURCE_UNIFORM,
|
2785
|
+
ASSET_PARAMETER_TYPE,
|
2396
2786
|
ATTRIBUTE_COMPONENT_ID,
|
2397
2787
|
ATTRIBUTE_MULTILINE,
|
2398
2788
|
ATTRIBUTE_PARAMETER_ID,
|
@@ -2413,6 +2803,8 @@ export {
|
|
2413
2803
|
CANVAS_PERSONALIZE_SLOT,
|
2414
2804
|
CANVAS_PERSONALIZE_TYPE,
|
2415
2805
|
CANVAS_PUBLISHED_STATE,
|
2806
|
+
CANVAS_SLOT_SECTION_SLOT,
|
2807
|
+
CANVAS_SLOT_SECTION_TYPE,
|
2416
2808
|
CANVAS_TEST_SLOT,
|
2417
2809
|
CANVAS_TEST_TYPE,
|
2418
2810
|
CANVAS_TEST_VARIANT_PARAM,
|
@@ -2425,21 +2817,25 @@ export {
|
|
2425
2817
|
DataTypeClient,
|
2426
2818
|
EDGE_CACHE_DISABLED,
|
2427
2819
|
EDGE_DEFAULT_CACHE_TTL,
|
2428
|
-
EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
|
2429
2820
|
EDGE_MAX_CACHE_TTL,
|
2430
|
-
EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
|
2431
2821
|
EDGE_MIN_CACHE_TTL,
|
2432
|
-
EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
|
2433
2822
|
EMPTY_COMPOSITION,
|
2434
2823
|
EnhancerBuilder,
|
2435
2824
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
2436
2825
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
2437
2826
|
IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM,
|
2438
2827
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
2828
|
+
IN_CONTEXT_EDITOR_FORCED_SETTINGS_QUERY_STRING_PARAM,
|
2439
2829
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
2440
2830
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2441
2831
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2832
|
+
LOCALE_DYNAMIC_INPUT_NAME,
|
2833
|
+
LocaleClient,
|
2442
2834
|
PLACEHOLDER_ID,
|
2835
|
+
PromptClient,
|
2836
|
+
RelationshipClient,
|
2837
|
+
ReleaseClient,
|
2838
|
+
ReleaseContentsClient,
|
2443
2839
|
RouteClient,
|
2444
2840
|
SECRET_QUERY_STRING_PARAM,
|
2445
2841
|
UncachedCanvasClient,
|
@@ -2458,25 +2854,38 @@ export {
|
|
2458
2854
|
createVariableReference,
|
2459
2855
|
enhance,
|
2460
2856
|
extractLocales,
|
2857
|
+
findParameterInNodeTree,
|
2858
|
+
flattenValues,
|
2461
2859
|
generateComponentPlaceholderId,
|
2462
2860
|
generateHash,
|
2463
2861
|
getBlockValue,
|
2464
2862
|
getChannelName,
|
2465
2863
|
getComponentJsonPointer,
|
2466
2864
|
getComponentPath,
|
2865
|
+
getLocalizedPropertyValues,
|
2866
|
+
getNounForLocation,
|
2867
|
+
getNounForNode,
|
2467
2868
|
getParameterAttributes,
|
2468
2869
|
getPropertiesValue,
|
2870
|
+
getPropertyValue,
|
2469
2871
|
isAddComponentMessage,
|
2470
2872
|
isAllowedReferrer,
|
2873
|
+
isAssetParamValue,
|
2874
|
+
isAssetParamValueItem,
|
2471
2875
|
isComponentActionMessage,
|
2472
2876
|
isComponentPlaceholderId,
|
2473
2877
|
isDismissPlaceholderMessage,
|
2878
|
+
isEntryData,
|
2474
2879
|
isMovingComponentMessage,
|
2880
|
+
isNestedNodeType,
|
2475
2881
|
isOpenParameterEditorMessage,
|
2476
2882
|
isReadyMessage,
|
2477
2883
|
isReportRenderedCompositionsMessage,
|
2884
|
+
isRequestComponentSuggestionMessage,
|
2885
|
+
isRootEntryReference,
|
2478
2886
|
isSelectComponentMessage,
|
2479
2887
|
isSelectParameterMessage,
|
2888
|
+
isSuggestComponentMessage,
|
2480
2889
|
isSystemComponentDefinition,
|
2481
2890
|
isTriggerCompositionActionMessage,
|
2482
2891
|
isUpdateComponentParameterMessage,
|
@@ -2490,9 +2899,9 @@ export {
|
|
2490
2899
|
mapSlotToPersonalizedVariations,
|
2491
2900
|
mapSlotToTestVariations,
|
2492
2901
|
nullLimitPolicy,
|
2902
|
+
parseComponentPlaceholderId,
|
2493
2903
|
parseVariableExpression,
|
2494
2904
|
subscribeToComposition,
|
2495
|
-
unstable_CompositionRelationshipClient,
|
2496
2905
|
walkComponentTree,
|
2497
2906
|
walkNodeTree
|
2498
2907
|
};
|