@uniformdev/canvas 19.79.1-alpha.13 → 19.79.1-alpha.25
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 +8742 -1930
- package/dist/index.d.ts +8742 -1930
- package/dist/index.esm.js +149 -12
- package/dist/index.js +159 -15
- package/dist/index.mjs +149 -12
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
@@ -481,15 +481,22 @@ var CanvasClient = class extends ApiClient {
|
|
481
481
|
/** Fetches lists of Canvas compositions, optionally by type */
|
482
482
|
async getCompositionList(params = {}) {
|
483
483
|
const { projectId } = this.options;
|
484
|
-
const { resolveData, ...originParams } = params;
|
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
|
+
}, {});
|
485
491
|
if (!resolveData) {
|
486
|
-
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId });
|
492
|
+
const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
|
487
493
|
return this.apiClient(fetchUri);
|
488
494
|
}
|
489
495
|
const edgeParams = {
|
490
496
|
...originParams,
|
491
497
|
projectId,
|
492
|
-
...params.diagnostics ? { diagnostics: "true" } : {}
|
498
|
+
...params.diagnostics ? { diagnostics: "true" } : {},
|
499
|
+
...rewrittenFilters
|
493
500
|
};
|
494
501
|
const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
|
495
502
|
return this.apiClient(edgeUrl, this.edgeApiRequestInit);
|
@@ -643,12 +650,22 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
|
|
643
650
|
}
|
644
651
|
getEntries(options) {
|
645
652
|
const { projectId } = this.options;
|
646
|
-
const { skipDataResolution, ...params } = options;
|
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
|
+
}, {});
|
647
660
|
if (skipDataResolution) {
|
648
|
-
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId });
|
661
|
+
const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
|
649
662
|
return this.apiClient(url);
|
650
663
|
}
|
651
|
-
const edgeUrl = this.createUrl(
|
664
|
+
const edgeUrl = this.createUrl(
|
665
|
+
__privateGet(_ContentClient, _entriesUrl),
|
666
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters },
|
667
|
+
this.edgeApiHost
|
668
|
+
);
|
652
669
|
return this.apiClient(
|
653
670
|
edgeUrl,
|
654
671
|
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
@@ -915,12 +932,14 @@ function getComponentPath(ancestorsAndSelf) {
|
|
915
932
|
var CANVAS_PERSONALIZE_TYPE = "$personalization";
|
916
933
|
var CANVAS_TEST_TYPE = "$test";
|
917
934
|
var CANVAS_LOCALIZATION_TYPE = "$localization";
|
935
|
+
var CANVAS_SLOT_SECTION_TYPE = "$slotSection";
|
918
936
|
var CANVAS_INTENT_TAG_PARAM = "intentTag";
|
919
937
|
var CANVAS_LOCALE_TAG_PARAM = "locale";
|
920
938
|
var CANVAS_BLOCK_PARAM_TYPE = "$block";
|
921
939
|
var CANVAS_PERSONALIZE_SLOT = "pz";
|
922
940
|
var CANVAS_TEST_SLOT = "test";
|
923
941
|
var CANVAS_LOCALIZATION_SLOT = "localized";
|
942
|
+
var CANVAS_SLOT_SECTION_SLOT = "$slotSectionItems";
|
924
943
|
var CANVAS_DRAFT_STATE = 0;
|
925
944
|
var CANVAS_PUBLISHED_STATE = 64;
|
926
945
|
var CANVAS_EDITOR_STATE = 63;
|
@@ -1905,6 +1924,12 @@ var isOpenParameterEditorMessage = (message) => {
|
|
1905
1924
|
var isUpdateComponentReferencesMessage = (message) => {
|
1906
1925
|
return message.type === "update-component-references";
|
1907
1926
|
};
|
1927
|
+
var isRequestComponentSuggestionMessage = (message) => {
|
1928
|
+
return message.type === "request-component-suggestion";
|
1929
|
+
};
|
1930
|
+
var isSuggestComponentMessage = (message) => {
|
1931
|
+
return message.type === "suggest-component";
|
1932
|
+
};
|
1908
1933
|
var createCanvasChannel = ({
|
1909
1934
|
listenTo,
|
1910
1935
|
broadcastTo
|
@@ -2056,6 +2081,20 @@ var createCanvasChannel = ({
|
|
2056
2081
|
};
|
2057
2082
|
postMessage(message);
|
2058
2083
|
};
|
2084
|
+
const requestComponentSuggestion = (options) => {
|
2085
|
+
const message = {
|
2086
|
+
...options,
|
2087
|
+
type: "request-component-suggestion"
|
2088
|
+
};
|
2089
|
+
postMessage(message);
|
2090
|
+
};
|
2091
|
+
const suggestComponent = (options) => {
|
2092
|
+
const message = {
|
2093
|
+
...options,
|
2094
|
+
type: "suggest-component"
|
2095
|
+
};
|
2096
|
+
postMessage(message);
|
2097
|
+
};
|
2059
2098
|
const updateFeatureFlags = (options) => {
|
2060
2099
|
const message = {
|
2061
2100
|
...options,
|
@@ -2109,7 +2148,9 @@ var createCanvasChannel = ({
|
|
2109
2148
|
openParameterEditor,
|
2110
2149
|
reportRenderedCompositions,
|
2111
2150
|
editorStateUpdated,
|
2112
|
-
updateComponentReferences
|
2151
|
+
updateComponentReferences,
|
2152
|
+
requestComponentSuggestion,
|
2153
|
+
suggestComponent
|
2113
2154
|
};
|
2114
2155
|
};
|
2115
2156
|
|
@@ -2281,10 +2322,76 @@ var RelationshipClient = class extends ApiClient8 {
|
|
2281
2322
|
}
|
2282
2323
|
};
|
2283
2324
|
|
2284
|
-
// src/
|
2325
|
+
// src/ReleaseClient.ts
|
2285
2326
|
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2327
|
+
var releasesUrl = "/api/v1/releases";
|
2328
|
+
var ReleaseClient = class extends ApiClient9 {
|
2329
|
+
constructor(options) {
|
2330
|
+
super(options);
|
2331
|
+
}
|
2332
|
+
/** Fetches all releases for a project */
|
2333
|
+
async get(options) {
|
2334
|
+
const { projectId } = this.options;
|
2335
|
+
const fetchUri = this.createUrl(releasesUrl, { ...options, projectId });
|
2336
|
+
return await this.apiClient(fetchUri);
|
2337
|
+
}
|
2338
|
+
/** Updates or creates (based on id) a release */
|
2339
|
+
async upsert(body) {
|
2340
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2341
|
+
await this.apiClient(fetchUri, {
|
2342
|
+
method: "PUT",
|
2343
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2344
|
+
expectNoContent: true
|
2345
|
+
});
|
2346
|
+
}
|
2347
|
+
/** Deletes a release */
|
2348
|
+
async remove(body) {
|
2349
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2350
|
+
await this.apiClient(fetchUri, {
|
2351
|
+
method: "DELETE",
|
2352
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2353
|
+
expectNoContent: true
|
2354
|
+
});
|
2355
|
+
}
|
2356
|
+
/** Readies or unreadies a release for merging */
|
2357
|
+
async ready(body) {
|
2358
|
+
const fetchUri = this.createUrl(releasesUrl);
|
2359
|
+
await this.apiClient(fetchUri, {
|
2360
|
+
method: "PATCH",
|
2361
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2362
|
+
expectNoContent: true
|
2363
|
+
});
|
2364
|
+
}
|
2365
|
+
};
|
2366
|
+
|
2367
|
+
// src/ReleaseContentsClient.ts
|
2368
|
+
import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
|
2369
|
+
var releaseContentsUrl = "/api/v1/release-contents";
|
2370
|
+
var ReleaseContentsClient = class extends ApiClient10 {
|
2371
|
+
constructor(options) {
|
2372
|
+
super(options);
|
2373
|
+
}
|
2374
|
+
/** Fetches all entities added to a release */
|
2375
|
+
async get(options) {
|
2376
|
+
const { projectId } = this.options;
|
2377
|
+
const fetchUri = this.createUrl(releaseContentsUrl, { ...options, projectId });
|
2378
|
+
return await this.apiClient(fetchUri);
|
2379
|
+
}
|
2380
|
+
/** Removes a release content from a release */
|
2381
|
+
async remove(body) {
|
2382
|
+
const fetchUri = this.createUrl(releaseContentsUrl);
|
2383
|
+
await this.apiClient(fetchUri, {
|
2384
|
+
method: "DELETE",
|
2385
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
2386
|
+
expectNoContent: true
|
2387
|
+
});
|
2388
|
+
}
|
2389
|
+
};
|
2390
|
+
|
2391
|
+
// src/RouteClient.ts
|
2392
|
+
import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
|
2286
2393
|
var ROUTE_URL = "/api/v1/route";
|
2287
|
-
var RouteClient = class extends
|
2394
|
+
var RouteClient = class extends ApiClient11 {
|
2288
2395
|
constructor(options) {
|
2289
2396
|
var _a;
|
2290
2397
|
if (!options.limitPolicy) {
|
@@ -2344,8 +2451,10 @@ function convertEntryToPutEntry(entry) {
|
|
2344
2451
|
fields: entry.entry.fields,
|
2345
2452
|
_locales: entry.entry._locales
|
2346
2453
|
},
|
2454
|
+
pattern: entry.pattern,
|
2347
2455
|
state: entry.state,
|
2348
|
-
projectId: entry.projectId
|
2456
|
+
projectId: entry.projectId,
|
2457
|
+
releaseId: entry.releaseId
|
2349
2458
|
};
|
2350
2459
|
}
|
2351
2460
|
|
@@ -2422,6 +2531,7 @@ function mapSlotToTestVariations(slot) {
|
|
2422
2531
|
}
|
2423
2532
|
|
2424
2533
|
// src/utils/placeholder.ts
|
2534
|
+
var SEPARATOR = "_";
|
2425
2535
|
var isComponentPlaceholderId = (id) => {
|
2426
2536
|
if (id === PLACEHOLDER_ID) {
|
2427
2537
|
return true;
|
@@ -2431,11 +2541,31 @@ var isComponentPlaceholderId = (id) => {
|
|
2431
2541
|
}
|
2432
2542
|
return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
|
2433
2543
|
};
|
2434
|
-
var generateComponentPlaceholderId = (randomId, sdkVersion) => {
|
2544
|
+
var generateComponentPlaceholderId = (randomId, sdkVersion, parent) => {
|
2435
2545
|
if (typeof sdkVersion === "undefined" || sdkVersion === 1) {
|
2436
2546
|
return PLACEHOLDER_ID;
|
2437
2547
|
}
|
2438
|
-
|
2548
|
+
let idParts = [PLACEHOLDER_ID, randomId];
|
2549
|
+
if (parent) {
|
2550
|
+
idParts = [...idParts, parent.nodeId, parent.slotId];
|
2551
|
+
}
|
2552
|
+
return idParts.join(SEPARATOR);
|
2553
|
+
};
|
2554
|
+
var parseComponentPlaceholderId = (id) => {
|
2555
|
+
if (!isComponentPlaceholderId(id)) {
|
2556
|
+
return;
|
2557
|
+
}
|
2558
|
+
const idParts = id.split(SEPARATOR);
|
2559
|
+
const result = {
|
2560
|
+
id: idParts[1]
|
2561
|
+
};
|
2562
|
+
if (idParts[2]) {
|
2563
|
+
result.parent = {
|
2564
|
+
nodeId: idParts[2],
|
2565
|
+
slotId: idParts[3]
|
2566
|
+
};
|
2567
|
+
}
|
2568
|
+
return result;
|
2439
2569
|
};
|
2440
2570
|
|
2441
2571
|
// src/utils/variables/parseVariableExpression.ts
|
@@ -2652,6 +2782,8 @@ export {
|
|
2652
2782
|
CANVAS_PERSONALIZE_SLOT,
|
2653
2783
|
CANVAS_PERSONALIZE_TYPE,
|
2654
2784
|
CANVAS_PUBLISHED_STATE,
|
2785
|
+
CANVAS_SLOT_SECTION_SLOT,
|
2786
|
+
CANVAS_SLOT_SECTION_TYPE,
|
2655
2787
|
CANVAS_TEST_SLOT,
|
2656
2788
|
CANVAS_TEST_TYPE,
|
2657
2789
|
CANVAS_TEST_VARIANT_PARAM,
|
@@ -2681,6 +2813,8 @@ export {
|
|
2681
2813
|
PLACEHOLDER_ID,
|
2682
2814
|
PromptClient,
|
2683
2815
|
RelationshipClient,
|
2816
|
+
ReleaseClient,
|
2817
|
+
ReleaseContentsClient,
|
2684
2818
|
RouteClient,
|
2685
2819
|
SECRET_QUERY_STRING_PARAM,
|
2686
2820
|
UncachedCanvasClient,
|
@@ -2725,9 +2859,11 @@ export {
|
|
2725
2859
|
isOpenParameterEditorMessage,
|
2726
2860
|
isReadyMessage,
|
2727
2861
|
isReportRenderedCompositionsMessage,
|
2862
|
+
isRequestComponentSuggestionMessage,
|
2728
2863
|
isRootEntryReference,
|
2729
2864
|
isSelectComponentMessage,
|
2730
2865
|
isSelectParameterMessage,
|
2866
|
+
isSuggestComponentMessage,
|
2731
2867
|
isSystemComponentDefinition,
|
2732
2868
|
isTriggerCompositionActionMessage,
|
2733
2869
|
isUpdateComponentParameterMessage,
|
@@ -2741,6 +2877,7 @@ export {
|
|
2741
2877
|
mapSlotToPersonalizedVariations,
|
2742
2878
|
mapSlotToTestVariations,
|
2743
2879
|
nullLimitPolicy,
|
2880
|
+
parseComponentPlaceholderId,
|
2744
2881
|
parseVariableExpression,
|
2745
2882
|
subscribeToComposition,
|
2746
2883
|
walkComponentTree,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.79.1-alpha.
|
3
|
+
"version": "19.79.1-alpha.25+87cea1cd47",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -38,9 +38,9 @@
|
|
38
38
|
"pusher-js": "8.2.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "19.79.1-alpha.
|
42
|
-
"@uniformdev/context": "19.79.1-alpha.
|
43
|
-
"immer": "10.0.
|
41
|
+
"@uniformdev/assets": "19.79.1-alpha.25+87cea1cd47",
|
42
|
+
"@uniformdev/context": "19.79.1-alpha.25+87cea1cd47",
|
43
|
+
"immer": "10.0.4"
|
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": "87cea1cd47c691f7d32b876660d5f7c984bb1d87"
|
52
52
|
}
|