@salesforce/ui-theme-manager 11.46.0
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 +82 -0
- package/README.md +29 -0
- package/dist/authoring/core/ThemeManagerPanelRoot.d.cts +43 -0
- package/dist/authoring/core/ThemeManagerPanelRoot.d.ts +43 -0
- package/dist/authoring/core/ThemeManagerPanelRoot.d.ts.map +1 -0
- package/dist/authoring/core/components/AssetsSection.d.cts +12 -0
- package/dist/authoring/core/components/AssetsSection.d.ts +12 -0
- package/dist/authoring/core/components/AssetsSection.d.ts.map +1 -0
- package/dist/authoring/core/components/BordersSection.d.cts +9 -0
- package/dist/authoring/core/components/BordersSection.d.ts +9 -0
- package/dist/authoring/core/components/BordersSection.d.ts.map +1 -0
- package/dist/authoring/core/components/ButtonSection.d.cts +9 -0
- package/dist/authoring/core/components/ButtonSection.d.ts +9 -0
- package/dist/authoring/core/components/ButtonSection.d.ts.map +1 -0
- package/dist/authoring/core/components/ColorEditors.d.cts +8 -0
- package/dist/authoring/core/components/ColorEditors.d.ts +8 -0
- package/dist/authoring/core/components/ColorEditors.d.ts.map +1 -0
- package/dist/authoring/core/components/ColorField.d.cts +45 -0
- package/dist/authoring/core/components/ColorField.d.ts +45 -0
- package/dist/authoring/core/components/ColorField.d.ts.map +1 -0
- package/dist/authoring/core/components/SaveBar.d.cts +8 -0
- package/dist/authoring/core/components/SaveBar.d.ts +8 -0
- package/dist/authoring/core/components/SaveBar.d.ts.map +1 -0
- package/dist/authoring/core/components/SearchBox.d.cts +16 -0
- package/dist/authoring/core/components/SearchBox.d.ts +16 -0
- package/dist/authoring/core/components/SearchBox.d.ts.map +1 -0
- package/dist/authoring/core/components/TabSwitcher.d.cts +13 -0
- package/dist/authoring/core/components/TabSwitcher.d.ts +13 -0
- package/dist/authoring/core/components/TabSwitcher.d.ts.map +1 -0
- package/dist/authoring/core/components/ThemeGallery.d.cts +9 -0
- package/dist/authoring/core/components/ThemeGallery.d.ts +9 -0
- package/dist/authoring/core/components/ThemeGallery.d.ts.map +1 -0
- package/dist/authoring/core/components/TypographySection.d.cts +9 -0
- package/dist/authoring/core/components/TypographySection.d.ts +9 -0
- package/dist/authoring/core/components/TypographySection.d.ts.map +1 -0
- package/dist/authoring/core/index.d.cts +8 -0
- package/dist/authoring/core/index.d.ts +8 -0
- package/dist/authoring/core/index.d.ts.map +1 -0
- package/dist/authoring/core/labels.d.cts +89 -0
- package/dist/authoring/core/labels.d.ts +89 -0
- package/dist/authoring/core/labels.d.ts.map +1 -0
- package/dist/authoring/react/index.d.cts +16 -0
- package/dist/authoring/react/index.d.ts +16 -0
- package/dist/authoring/react/index.d.ts.map +1 -0
- package/dist/authoring/react/index.js +1 -0
- package/dist/authoring/react/styles.css +1 -0
- package/dist/authoring/web-component/index.d.cts +34 -0
- package/dist/authoring/web-component/index.d.ts +34 -0
- package/dist/authoring/web-component/index.d.ts.map +1 -0
- package/dist/authoring/web-component/index.js +729 -0
- package/dist/protocol/brandCss.cjs +255 -0
- package/dist/protocol/brandCss.d.cts +42 -0
- package/dist/protocol/brandCss.d.ts +42 -0
- package/dist/protocol/brandCss.d.ts.map +1 -0
- package/dist/protocol/brandCss.js +255 -0
- package/dist/protocol/brandResolver.cjs +61 -0
- package/dist/protocol/brandResolver.d.cts +28 -0
- package/dist/protocol/brandResolver.d.ts +28 -0
- package/dist/protocol/brandResolver.d.ts.map +1 -0
- package/dist/protocol/brandResolver.js +61 -0
- package/dist/protocol/brandSearch.cjs +64 -0
- package/dist/protocol/brandSearch.d.cts +133 -0
- package/dist/protocol/brandSearch.d.ts +133 -0
- package/dist/protocol/brandSearch.d.ts.map +1 -0
- package/dist/protocol/brandSearch.js +64 -0
- package/dist/protocol/brandTypes.cjs +30 -0
- package/dist/protocol/brandTypes.d.cts +198 -0
- package/dist/protocol/brandTypes.d.ts +198 -0
- package/dist/protocol/brandTypes.d.ts.map +1 -0
- package/dist/protocol/brandTypes.js +30 -0
- package/dist/protocol/deriveColors.cjs +67 -0
- package/dist/protocol/deriveColors.d.cts +39 -0
- package/dist/protocol/deriveColors.d.ts +39 -0
- package/dist/protocol/deriveColors.d.ts.map +1 -0
- package/dist/protocol/deriveColors.js +67 -0
- package/dist/protocol/index.cjs +55 -0
- package/dist/protocol/index.d.cts +20 -0
- package/dist/protocol/index.d.ts +20 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +55 -0
- package/dist/protocol/messageTypes.cjs +32 -0
- package/dist/protocol/messageTypes.d.cts +86 -0
- package/dist/protocol/messageTypes.d.ts +86 -0
- package/dist/protocol/messageTypes.d.ts.map +1 -0
- package/dist/protocol/messageTypes.js +32 -0
- package/dist/protocol/ootbThemes.cjs +229 -0
- package/dist/protocol/ootbThemes.d.cts +6 -0
- package/dist/protocol/ootbThemes.d.ts +6 -0
- package/dist/protocol/ootbThemes.d.ts.map +1 -0
- package/dist/protocol/ootbThemes.js +229 -0
- package/dist/protocol/themeCss.cjs +47 -0
- package/dist/protocol/themeCss.d.cts +18 -0
- package/dist/protocol/themeCss.d.ts +18 -0
- package/dist/protocol/themeCss.d.ts.map +1 -0
- package/dist/protocol/themeCss.js +47 -0
- package/dist/protocol/types.d.cts +74 -0
- package/dist/protocol/types.d.ts +74 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/utils.cjs +10 -0
- package/dist/protocol/utils.d.cts +20 -0
- package/dist/protocol/utils.d.ts +20 -0
- package/dist/protocol/utils.d.ts.map +1 -0
- package/dist/protocol/utils.js +10 -0
- package/dist/runtime/fontFace.cjs +43 -0
- package/dist/runtime/fontFace.d.cts +15 -0
- package/dist/runtime/fontFace.d.ts +15 -0
- package/dist/runtime/fontFace.d.ts.map +1 -0
- package/dist/runtime/fontFace.js +43 -0
- package/dist/runtime/previewContent.cjs +344 -0
- package/dist/runtime/previewContent.d.cts +43 -0
- package/dist/runtime/previewContent.d.ts +43 -0
- package/dist/runtime/previewContent.d.ts.map +1 -0
- package/dist/runtime/previewContent.js +344 -0
- package/dist/runtime/previewRuntime.d.cts +10 -0
- package/dist/runtime/previewRuntime.d.ts +10 -0
- package/dist/runtime/previewRuntime.d.ts.map +1 -0
- package/dist/runtime/theme-preview-runtime.js +466 -0
- package/package.json +74 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Brand } from './brandTypes.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a brand reference string.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isBrandRef(value: unknown): value is string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a single brand reference to its literal value.
|
|
8
|
+
* Returns the original value if it's not a reference.
|
|
9
|
+
* Handles chained references up to MAX_RESOLVE_DEPTH.
|
|
10
|
+
*
|
|
11
|
+
* @param brand - The brand object containing all tokens
|
|
12
|
+
* @param ref - The reference string or literal value
|
|
13
|
+
* @param depth - Current recursion depth (internal use)
|
|
14
|
+
* @returns The resolved literal value
|
|
15
|
+
* @throws Error if reference is invalid or max depth exceeded
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveRef(brand: Brand, ref: unknown, depth?: number): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves all brand token references in a brand object, returning a deep-resolved copy.
|
|
20
|
+
* Every {!$brand.path.to.token} reference is replaced by its literal value.
|
|
21
|
+
* Handles chained references (references that point to other references).
|
|
22
|
+
* Leaves literal "normal" (in letterSpacing) untouched.
|
|
23
|
+
*
|
|
24
|
+
* @param brand - The brand object to resolve
|
|
25
|
+
* @returns A new brand object with all references resolved to literals
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveBrandTokens(brand: Brand): Brand;
|
|
28
|
+
//# sourceMappingURL=brandResolver.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Brand } from './brandTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a brand reference string.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isBrandRef(value: unknown): value is string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a single brand reference to its literal value.
|
|
8
|
+
* Returns the original value if it's not a reference.
|
|
9
|
+
* Handles chained references up to MAX_RESOLVE_DEPTH.
|
|
10
|
+
*
|
|
11
|
+
* @param brand - The brand object containing all tokens
|
|
12
|
+
* @param ref - The reference string or literal value
|
|
13
|
+
* @param depth - Current recursion depth (internal use)
|
|
14
|
+
* @returns The resolved literal value
|
|
15
|
+
* @throws Error if reference is invalid or max depth exceeded
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveRef(brand: Brand, ref: unknown, depth?: number): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves all brand token references in a brand object, returning a deep-resolved copy.
|
|
20
|
+
* Every {!$brand.path.to.token} reference is replaced by its literal value.
|
|
21
|
+
* Handles chained references (references that point to other references).
|
|
22
|
+
* Leaves literal "normal" (in letterSpacing) untouched.
|
|
23
|
+
*
|
|
24
|
+
* @param brand - The brand object to resolve
|
|
25
|
+
* @returns A new brand object with all references resolved to literals
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveBrandTokens(brand: Brand): Brand;
|
|
28
|
+
//# sourceMappingURL=brandResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brandResolver.d.ts","sourceRoot":"","sources":["../../src/protocol/brandResolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAY1C;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAyCzE;AAgCD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAEtD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const BRAND_REF_PATTERN = /^\{!\$brand\.([^}]+)\}$/;
|
|
2
|
+
const MAX_RESOLVE_DEPTH = 10;
|
|
3
|
+
function isBrandRef(value) {
|
|
4
|
+
return typeof value === "string" && BRAND_REF_PATTERN.test(value);
|
|
5
|
+
}
|
|
6
|
+
function resolveRef(brand, ref, depth = 0) {
|
|
7
|
+
if (depth > MAX_RESOLVE_DEPTH) {
|
|
8
|
+
throw new Error(`Max resolution depth exceeded resolving: ${ref}`);
|
|
9
|
+
}
|
|
10
|
+
if (!isBrandRef(ref)) {
|
|
11
|
+
return ref;
|
|
12
|
+
}
|
|
13
|
+
const match = ref.match(BRAND_REF_PATTERN);
|
|
14
|
+
if (!match || !match[1]) {
|
|
15
|
+
return ref;
|
|
16
|
+
}
|
|
17
|
+
const path = match[1];
|
|
18
|
+
const parts = path.split(".");
|
|
19
|
+
let current = brand;
|
|
20
|
+
for (const part of parts) {
|
|
21
|
+
if (current == null || typeof current !== "object") {
|
|
22
|
+
throw new Error(`Invalid reference path: ${ref} (failed at ${part})`);
|
|
23
|
+
}
|
|
24
|
+
current = current[part];
|
|
25
|
+
if (current === void 0) {
|
|
26
|
+
throw new Error(`Reference not found: ${ref} (${part} is undefined)`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (isBrandRef(current)) {
|
|
30
|
+
return resolveRef(brand, current, depth + 1);
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
}
|
|
34
|
+
function resolveValue(brand, value) {
|
|
35
|
+
if (value == null) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (isBrandRef(value)) {
|
|
39
|
+
const resolved = resolveRef(brand, value);
|
|
40
|
+
return resolveValue(brand, resolved);
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return value.map((item) => resolveValue(brand, item));
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "object") {
|
|
46
|
+
const result = {};
|
|
47
|
+
for (const [key, val] of Object.entries(value)) {
|
|
48
|
+
result[key] = resolveValue(brand, val);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function resolveBrandTokens(brand) {
|
|
55
|
+
return resolveValue(brand, brand);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
isBrandRef,
|
|
59
|
+
resolveBrandTokens,
|
|
60
|
+
resolveRef
|
|
61
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const MIN_SEARCH_QUERY_LENGTH = 3;
|
|
4
|
+
const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
|
|
5
|
+
const DEFAULT_BRAND_SEARCH_OPTIONS = {
|
|
6
|
+
searchLanguage: "en_US",
|
|
7
|
+
channelType: "PublicUnauthenticated",
|
|
8
|
+
contentTypeFqn: "sfdc_cms__brand"
|
|
9
|
+
};
|
|
10
|
+
function isValidSearchQuery(query) {
|
|
11
|
+
return query.trim().length >= MIN_SEARCH_QUERY_LENGTH;
|
|
12
|
+
}
|
|
13
|
+
function resolveSearchApiVersion(apiVersion) {
|
|
14
|
+
const parsed = parseFloat(apiVersion);
|
|
15
|
+
const version = Number.isFinite(parsed) ? Math.max(parsed, SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION) : SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION;
|
|
16
|
+
return version.toFixed(1);
|
|
17
|
+
}
|
|
18
|
+
function buildBrandSearchRequest(query, apiVersion, options = {}) {
|
|
19
|
+
const version = resolveSearchApiVersion(apiVersion);
|
|
20
|
+
return {
|
|
21
|
+
path: `/services/data/v${version}/actions/standard/searchCmsChannelContent`,
|
|
22
|
+
body: {
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
searchKeyword: query,
|
|
26
|
+
searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
|
|
27
|
+
channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
|
|
28
|
+
contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function parseBrandSearchResponse(response) {
|
|
35
|
+
const results = Array.isArray(response) ? response : [response];
|
|
36
|
+
const result = results[0];
|
|
37
|
+
if (!result) {
|
|
38
|
+
return { success: false, items: [], totalResults: 0, error: "No response from server" };
|
|
39
|
+
}
|
|
40
|
+
if (!result.isSuccess) {
|
|
41
|
+
const error = result.errors?.length ? result.errors.map((e) => e.message).join("; ") : "Unknown error";
|
|
42
|
+
return { success: false, items: [], totalResults: 0, error };
|
|
43
|
+
}
|
|
44
|
+
let items = [];
|
|
45
|
+
const rawSearchResults = result.outputValues?.searchResults;
|
|
46
|
+
if (Array.isArray(rawSearchResults)) {
|
|
47
|
+
items = rawSearchResults;
|
|
48
|
+
} else if (rawSearchResults && typeof rawSearchResults === "object") {
|
|
49
|
+
items = [rawSearchResults];
|
|
50
|
+
}
|
|
51
|
+
const totalResults = result.outputValues?.totalResults ?? items.length;
|
|
52
|
+
return { success: true, items, totalResults };
|
|
53
|
+
}
|
|
54
|
+
function getContentUrl(item) {
|
|
55
|
+
return item.managedContentChannelDeliveryDetails?.find((detail) => detail?.contentUrl)?.contentUrl;
|
|
56
|
+
}
|
|
57
|
+
exports.DEFAULT_BRAND_SEARCH_OPTIONS = DEFAULT_BRAND_SEARCH_OPTIONS;
|
|
58
|
+
exports.MIN_SEARCH_QUERY_LENGTH = MIN_SEARCH_QUERY_LENGTH;
|
|
59
|
+
exports.SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION;
|
|
60
|
+
exports.buildBrandSearchRequest = buildBrandSearchRequest;
|
|
61
|
+
exports.getContentUrl = getContentUrl;
|
|
62
|
+
exports.isValidSearchQuery = isValidSearchQuery;
|
|
63
|
+
exports.parseBrandSearchResponse = parseBrandSearchResponse;
|
|
64
|
+
exports.resolveSearchApiVersion = resolveSearchApiVersion;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Brand search protocol for the `searchCmsChannelContent` standard invocable
|
|
8
|
+
* action, which supersedes the deprecated `searchBrands` action.
|
|
9
|
+
*
|
|
10
|
+
* This module is host-neutral: it builds the request payload and parses the
|
|
11
|
+
* response, but performs no I/O. The host (e.g. the VS Code extension) is
|
|
12
|
+
* responsible for the authenticated transport — issuing the POST with its own
|
|
13
|
+
* connection and feeding the raw response back to `parseBrandSearchResponse`.
|
|
14
|
+
*
|
|
15
|
+
* Response differences from the deprecated `searchBrands` action:
|
|
16
|
+
* - `searchResults` is a structured JSON array (not a JSON-encoded string).
|
|
17
|
+
* - `contentUrl` is no longer a top-level item field — it is nested under
|
|
18
|
+
* `managedContentChannelDeliveryDetails[].contentUrl`.
|
|
19
|
+
*/
|
|
20
|
+
/** Minimum search query length accepted by the action. */
|
|
21
|
+
export declare const MIN_SEARCH_QUERY_LENGTH = 3;
|
|
22
|
+
/** Minimum API version that exposes the `searchCmsChannelContent` action. */
|
|
23
|
+
export declare const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
|
|
24
|
+
/** Default input parameters for a brand search on an unauthenticated channel. */
|
|
25
|
+
export declare const DEFAULT_BRAND_SEARCH_OPTIONS: {
|
|
26
|
+
readonly searchLanguage: "en_US";
|
|
27
|
+
readonly channelType: "PublicUnauthenticated";
|
|
28
|
+
readonly contentTypeFqn: "sfdc_cms__brand";
|
|
29
|
+
};
|
|
30
|
+
/** Channel delivery details for a search item; carries the deliverable content URL. */
|
|
31
|
+
export interface ChannelDeliveryDetails {
|
|
32
|
+
contentUrl?: string;
|
|
33
|
+
publishedDate?: string;
|
|
34
|
+
managedContentChannelDetails?: {
|
|
35
|
+
id?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A single item in the `searchCmsChannelContent` results array.
|
|
42
|
+
*
|
|
43
|
+
* Distinct from the display-oriented `BrandSummary` in brandTypes: this mirrors
|
|
44
|
+
* the raw action output, where `contentUrl` is nested under
|
|
45
|
+
* `managedContentChannelDeliveryDetails[]` rather than at the top level.
|
|
46
|
+
*/
|
|
47
|
+
export interface BrandSearchItem {
|
|
48
|
+
managedContentId: string;
|
|
49
|
+
managedContentKey: string;
|
|
50
|
+
title: string;
|
|
51
|
+
contentType?: string;
|
|
52
|
+
language?: string;
|
|
53
|
+
managedContentChannelDeliveryDetails?: ChannelDeliveryDetails[];
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
/** Input parameters for the search action (one entry of the `inputs` array). */
|
|
57
|
+
export interface BrandSearchRequestInput {
|
|
58
|
+
searchKeyword: string;
|
|
59
|
+
searchLanguage: string;
|
|
60
|
+
channelType: string;
|
|
61
|
+
contentTypeFqn: string;
|
|
62
|
+
}
|
|
63
|
+
/** Overridable subset of the search inputs; keyword is supplied separately. */
|
|
64
|
+
export type BrandSearchOptions = Partial<Omit<BrandSearchRequestInput, "searchKeyword">>;
|
|
65
|
+
/** A ready-to-send request: the action path and the POST body. */
|
|
66
|
+
export interface BrandSearchRequest {
|
|
67
|
+
path: string;
|
|
68
|
+
body: {
|
|
69
|
+
inputs: BrandSearchRequestInput[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** A single invocable-action response entry. */
|
|
73
|
+
export interface BrandSearchInvocationResponse {
|
|
74
|
+
actionName?: string;
|
|
75
|
+
errors?: {
|
|
76
|
+
statusCode?: string;
|
|
77
|
+
message?: string;
|
|
78
|
+
fields?: string[];
|
|
79
|
+
}[] | null;
|
|
80
|
+
isSuccess?: boolean;
|
|
81
|
+
outputValues?: {
|
|
82
|
+
searchResults?: unknown;
|
|
83
|
+
totalResults?: number;
|
|
84
|
+
pageNumber?: number;
|
|
85
|
+
pageSize?: number;
|
|
86
|
+
} | null;
|
|
87
|
+
}
|
|
88
|
+
/** Parsed outcome of a brand search: the items, total, and success/error state. */
|
|
89
|
+
export interface ParsedBrandSearch {
|
|
90
|
+
success: boolean;
|
|
91
|
+
items: BrandSearchItem[];
|
|
92
|
+
totalResults: number;
|
|
93
|
+
error?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Whether a query meets the minimum length (after trimming) to be searchable. */
|
|
96
|
+
export declare function isValidSearchQuery(query: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve the API version to call the search action with: the given version
|
|
99
|
+
* floored at the minimum that exposes `searchCmsChannelContent`. Falls back to
|
|
100
|
+
* the minimum when the input is not a parseable version.
|
|
101
|
+
*
|
|
102
|
+
* @param apiVersion - The host connection's API version (e.g. "60.0", "68.0")
|
|
103
|
+
* @returns A version string with one decimal place (e.g. "62.0", "68.0")
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveSearchApiVersion(apiVersion: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Build the request path and body for a brand search. The API version is
|
|
108
|
+
* floored to the action's minimum; input parameters default to an
|
|
109
|
+
* unauthenticated brand-content search and may be overridden.
|
|
110
|
+
*
|
|
111
|
+
* @param query - The search keyword
|
|
112
|
+
* @param apiVersion - The host connection's API version
|
|
113
|
+
* @param options - Optional overrides for language, channel type, content type
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildBrandSearchRequest(query: string, apiVersion: string, options?: BrandSearchOptions): BrandSearchRequest;
|
|
116
|
+
/**
|
|
117
|
+
* Parse the raw `searchCmsChannelContent` response into items and a total.
|
|
118
|
+
*
|
|
119
|
+
* The response is an array of invocation entries (a single object is tolerated
|
|
120
|
+
* and wrapped). On a non-success entry, returns the joined error messages.
|
|
121
|
+
* `searchResults` is expected to be a structured array; a single object is
|
|
122
|
+
* wrapped into a one-item array.
|
|
123
|
+
*
|
|
124
|
+
* @param response - The raw response body from the invocable-action call
|
|
125
|
+
*/
|
|
126
|
+
export declare function parseBrandSearchResponse(response: unknown): ParsedBrandSearch;
|
|
127
|
+
/**
|
|
128
|
+
* Extract the deliverable content URL from a search item. `searchCmsChannelContent`
|
|
129
|
+
* nests it under `managedContentChannelDeliveryDetails[].contentUrl`; returns the
|
|
130
|
+
* first entry that has one, or undefined when none is present.
|
|
131
|
+
*/
|
|
132
|
+
export declare function getContentUrl(item: BrandSearchItem): string | undefined;
|
|
133
|
+
//# sourceMappingURL=brandSearch.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Brand search protocol for the `searchCmsChannelContent` standard invocable
|
|
8
|
+
* action, which supersedes the deprecated `searchBrands` action.
|
|
9
|
+
*
|
|
10
|
+
* This module is host-neutral: it builds the request payload and parses the
|
|
11
|
+
* response, but performs no I/O. The host (e.g. the VS Code extension) is
|
|
12
|
+
* responsible for the authenticated transport — issuing the POST with its own
|
|
13
|
+
* connection and feeding the raw response back to `parseBrandSearchResponse`.
|
|
14
|
+
*
|
|
15
|
+
* Response differences from the deprecated `searchBrands` action:
|
|
16
|
+
* - `searchResults` is a structured JSON array (not a JSON-encoded string).
|
|
17
|
+
* - `contentUrl` is no longer a top-level item field — it is nested under
|
|
18
|
+
* `managedContentChannelDeliveryDetails[].contentUrl`.
|
|
19
|
+
*/
|
|
20
|
+
/** Minimum search query length accepted by the action. */
|
|
21
|
+
export declare const MIN_SEARCH_QUERY_LENGTH = 3;
|
|
22
|
+
/** Minimum API version that exposes the `searchCmsChannelContent` action. */
|
|
23
|
+
export declare const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
|
|
24
|
+
/** Default input parameters for a brand search on an unauthenticated channel. */
|
|
25
|
+
export declare const DEFAULT_BRAND_SEARCH_OPTIONS: {
|
|
26
|
+
readonly searchLanguage: "en_US";
|
|
27
|
+
readonly channelType: "PublicUnauthenticated";
|
|
28
|
+
readonly contentTypeFqn: "sfdc_cms__brand";
|
|
29
|
+
};
|
|
30
|
+
/** Channel delivery details for a search item; carries the deliverable content URL. */
|
|
31
|
+
export interface ChannelDeliveryDetails {
|
|
32
|
+
contentUrl?: string;
|
|
33
|
+
publishedDate?: string;
|
|
34
|
+
managedContentChannelDetails?: {
|
|
35
|
+
id?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
type?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A single item in the `searchCmsChannelContent` results array.
|
|
42
|
+
*
|
|
43
|
+
* Distinct from the display-oriented `BrandSummary` in brandTypes: this mirrors
|
|
44
|
+
* the raw action output, where `contentUrl` is nested under
|
|
45
|
+
* `managedContentChannelDeliveryDetails[]` rather than at the top level.
|
|
46
|
+
*/
|
|
47
|
+
export interface BrandSearchItem {
|
|
48
|
+
managedContentId: string;
|
|
49
|
+
managedContentKey: string;
|
|
50
|
+
title: string;
|
|
51
|
+
contentType?: string;
|
|
52
|
+
language?: string;
|
|
53
|
+
managedContentChannelDeliveryDetails?: ChannelDeliveryDetails[];
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
/** Input parameters for the search action (one entry of the `inputs` array). */
|
|
57
|
+
export interface BrandSearchRequestInput {
|
|
58
|
+
searchKeyword: string;
|
|
59
|
+
searchLanguage: string;
|
|
60
|
+
channelType: string;
|
|
61
|
+
contentTypeFqn: string;
|
|
62
|
+
}
|
|
63
|
+
/** Overridable subset of the search inputs; keyword is supplied separately. */
|
|
64
|
+
export type BrandSearchOptions = Partial<Omit<BrandSearchRequestInput, "searchKeyword">>;
|
|
65
|
+
/** A ready-to-send request: the action path and the POST body. */
|
|
66
|
+
export interface BrandSearchRequest {
|
|
67
|
+
path: string;
|
|
68
|
+
body: {
|
|
69
|
+
inputs: BrandSearchRequestInput[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** A single invocable-action response entry. */
|
|
73
|
+
export interface BrandSearchInvocationResponse {
|
|
74
|
+
actionName?: string;
|
|
75
|
+
errors?: {
|
|
76
|
+
statusCode?: string;
|
|
77
|
+
message?: string;
|
|
78
|
+
fields?: string[];
|
|
79
|
+
}[] | null;
|
|
80
|
+
isSuccess?: boolean;
|
|
81
|
+
outputValues?: {
|
|
82
|
+
searchResults?: unknown;
|
|
83
|
+
totalResults?: number;
|
|
84
|
+
pageNumber?: number;
|
|
85
|
+
pageSize?: number;
|
|
86
|
+
} | null;
|
|
87
|
+
}
|
|
88
|
+
/** Parsed outcome of a brand search: the items, total, and success/error state. */
|
|
89
|
+
export interface ParsedBrandSearch {
|
|
90
|
+
success: boolean;
|
|
91
|
+
items: BrandSearchItem[];
|
|
92
|
+
totalResults: number;
|
|
93
|
+
error?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Whether a query meets the minimum length (after trimming) to be searchable. */
|
|
96
|
+
export declare function isValidSearchQuery(query: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve the API version to call the search action with: the given version
|
|
99
|
+
* floored at the minimum that exposes `searchCmsChannelContent`. Falls back to
|
|
100
|
+
* the minimum when the input is not a parseable version.
|
|
101
|
+
*
|
|
102
|
+
* @param apiVersion - The host connection's API version (e.g. "60.0", "68.0")
|
|
103
|
+
* @returns A version string with one decimal place (e.g. "62.0", "68.0")
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveSearchApiVersion(apiVersion: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Build the request path and body for a brand search. The API version is
|
|
108
|
+
* floored to the action's minimum; input parameters default to an
|
|
109
|
+
* unauthenticated brand-content search and may be overridden.
|
|
110
|
+
*
|
|
111
|
+
* @param query - The search keyword
|
|
112
|
+
* @param apiVersion - The host connection's API version
|
|
113
|
+
* @param options - Optional overrides for language, channel type, content type
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildBrandSearchRequest(query: string, apiVersion: string, options?: BrandSearchOptions): BrandSearchRequest;
|
|
116
|
+
/**
|
|
117
|
+
* Parse the raw `searchCmsChannelContent` response into items and a total.
|
|
118
|
+
*
|
|
119
|
+
* The response is an array of invocation entries (a single object is tolerated
|
|
120
|
+
* and wrapped). On a non-success entry, returns the joined error messages.
|
|
121
|
+
* `searchResults` is expected to be a structured array; a single object is
|
|
122
|
+
* wrapped into a one-item array.
|
|
123
|
+
*
|
|
124
|
+
* @param response - The raw response body from the invocable-action call
|
|
125
|
+
*/
|
|
126
|
+
export declare function parseBrandSearchResponse(response: unknown): ParsedBrandSearch;
|
|
127
|
+
/**
|
|
128
|
+
* Extract the deliverable content URL from a search item. `searchCmsChannelContent`
|
|
129
|
+
* nests it under `managedContentChannelDeliveryDetails[].contentUrl`; returns the
|
|
130
|
+
* first entry that has one, or undefined when none is present.
|
|
131
|
+
*/
|
|
132
|
+
export declare function getContentUrl(item: BrandSearchItem): string | undefined;
|
|
133
|
+
//# sourceMappingURL=brandSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brandSearch.d.ts","sourceRoot":"","sources":["../../src/protocol/brandSearch.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const MIN_SEARCH_QUERY_LENGTH = 3;
|
|
2
|
+
const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
|
|
3
|
+
const DEFAULT_BRAND_SEARCH_OPTIONS = {
|
|
4
|
+
searchLanguage: "en_US",
|
|
5
|
+
channelType: "PublicUnauthenticated",
|
|
6
|
+
contentTypeFqn: "sfdc_cms__brand"
|
|
7
|
+
};
|
|
8
|
+
function isValidSearchQuery(query) {
|
|
9
|
+
return query.trim().length >= MIN_SEARCH_QUERY_LENGTH;
|
|
10
|
+
}
|
|
11
|
+
function resolveSearchApiVersion(apiVersion) {
|
|
12
|
+
const parsed = parseFloat(apiVersion);
|
|
13
|
+
const version = Number.isFinite(parsed) ? Math.max(parsed, SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION) : SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION;
|
|
14
|
+
return version.toFixed(1);
|
|
15
|
+
}
|
|
16
|
+
function buildBrandSearchRequest(query, apiVersion, options = {}) {
|
|
17
|
+
const version = resolveSearchApiVersion(apiVersion);
|
|
18
|
+
return {
|
|
19
|
+
path: `/services/data/v${version}/actions/standard/searchCmsChannelContent`,
|
|
20
|
+
body: {
|
|
21
|
+
inputs: [
|
|
22
|
+
{
|
|
23
|
+
searchKeyword: query,
|
|
24
|
+
searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
|
|
25
|
+
channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
|
|
26
|
+
contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function parseBrandSearchResponse(response) {
|
|
33
|
+
const results = Array.isArray(response) ? response : [response];
|
|
34
|
+
const result = results[0];
|
|
35
|
+
if (!result) {
|
|
36
|
+
return { success: false, items: [], totalResults: 0, error: "No response from server" };
|
|
37
|
+
}
|
|
38
|
+
if (!result.isSuccess) {
|
|
39
|
+
const error = result.errors?.length ? result.errors.map((e) => e.message).join("; ") : "Unknown error";
|
|
40
|
+
return { success: false, items: [], totalResults: 0, error };
|
|
41
|
+
}
|
|
42
|
+
let items = [];
|
|
43
|
+
const rawSearchResults = result.outputValues?.searchResults;
|
|
44
|
+
if (Array.isArray(rawSearchResults)) {
|
|
45
|
+
items = rawSearchResults;
|
|
46
|
+
} else if (rawSearchResults && typeof rawSearchResults === "object") {
|
|
47
|
+
items = [rawSearchResults];
|
|
48
|
+
}
|
|
49
|
+
const totalResults = result.outputValues?.totalResults ?? items.length;
|
|
50
|
+
return { success: true, items, totalResults };
|
|
51
|
+
}
|
|
52
|
+
function getContentUrl(item) {
|
|
53
|
+
return item.managedContentChannelDeliveryDetails?.find((detail) => detail?.contentUrl)?.contentUrl;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
DEFAULT_BRAND_SEARCH_OPTIONS,
|
|
57
|
+
MIN_SEARCH_QUERY_LENGTH,
|
|
58
|
+
SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION,
|
|
59
|
+
buildBrandSearchRequest,
|
|
60
|
+
getContentUrl,
|
|
61
|
+
isValidSearchQuery,
|
|
62
|
+
parseBrandSearchResponse,
|
|
63
|
+
resolveSearchApiVersion
|
|
64
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function getBrandTitle(brand) {
|
|
4
|
+
return brand["sfdc_cms:title"] ?? "Untitled Brand";
|
|
5
|
+
}
|
|
6
|
+
function getBrandLogoUrl(brand) {
|
|
7
|
+
const url = brand.logo?.url;
|
|
8
|
+
return typeof url === "string" && url.length > 0 ? url : void 0;
|
|
9
|
+
}
|
|
10
|
+
function getBrandLogoAltText(brand) {
|
|
11
|
+
const alt = brand.logo?.altText;
|
|
12
|
+
return typeof alt === "string" && alt.length > 0 ? alt : getBrandTitle(brand);
|
|
13
|
+
}
|
|
14
|
+
function unwrapBrandEnvelope(raw) {
|
|
15
|
+
if (raw === null || raw === void 0) {
|
|
16
|
+
throw new Error("unwrapBrandEnvelope: input is null or undefined");
|
|
17
|
+
}
|
|
18
|
+
if (typeof raw !== "object") {
|
|
19
|
+
throw new Error(`unwrapBrandEnvelope: input is not an object (got ${typeof raw})`);
|
|
20
|
+
}
|
|
21
|
+
const obj = raw;
|
|
22
|
+
if ("contentBody" in obj && obj.contentBody !== null && typeof obj.contentBody === "object") {
|
|
23
|
+
return obj.contentBody;
|
|
24
|
+
}
|
|
25
|
+
return raw;
|
|
26
|
+
}
|
|
27
|
+
exports.getBrandLogoAltText = getBrandLogoAltText;
|
|
28
|
+
exports.getBrandLogoUrl = getBrandLogoUrl;
|
|
29
|
+
exports.getBrandTitle = getBrandTitle;
|
|
30
|
+
exports.unwrapBrandEnvelope = unwrapBrandEnvelope;
|