sf-plugin-cms 0.4.0 → 0.5.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.
Files changed (56) hide show
  1. package/README.md +241 -20
  2. package/lib/commands/cms/export/workspace.d.ts +5 -1
  3. package/lib/commands/cms/export/workspace.js +60 -2
  4. package/lib/commands/cms/export/workspace.js.map +1 -1
  5. package/lib/commands/cms/import/workspace.d.ts +12 -4
  6. package/lib/commands/cms/import/workspace.js +167 -20
  7. package/lib/commands/cms/import/workspace.js.map +1 -1
  8. package/lib/commands/cms/info.js +21 -2
  9. package/lib/commands/cms/info.js.map +1 -1
  10. package/lib/contracts/info.d.ts +7 -4
  11. package/lib/contracts/info.js +17 -8
  12. package/lib/contracts/info.js.map +1 -1
  13. package/lib/contracts/shared.d.ts +2 -1
  14. package/lib/contracts/shared.js +11 -3
  15. package/lib/contracts/shared.js.map +1 -1
  16. package/lib/contracts/workspace-export.d.ts +23 -3
  17. package/lib/contracts/workspace-export.js +118 -5
  18. package/lib/contracts/workspace-export.js.map +1 -1
  19. package/lib/contracts/workspace-import.d.ts +64 -0
  20. package/lib/contracts/workspace-import.js +119 -0
  21. package/lib/contracts/workspace-import.js.map +1 -1
  22. package/lib/index.d.ts +3 -1
  23. package/lib/index.js +2 -0
  24. package/lib/index.js.map +1 -1
  25. package/lib/services/email-fragment.d.ts +15 -0
  26. package/lib/services/email-fragment.js +199 -0
  27. package/lib/services/email-fragment.js.map +1 -0
  28. package/lib/services/export-workspace.d.ts +13 -1
  29. package/lib/services/export-workspace.js +183 -7
  30. package/lib/services/export-workspace.js.map +1 -1
  31. package/lib/services/image-import.d.ts +91 -0
  32. package/lib/services/image-import.js +579 -0
  33. package/lib/services/image-import.js.map +1 -0
  34. package/lib/services/import-workspace.d.ts +16 -3
  35. package/lib/services/import-workspace.js +142 -14
  36. package/lib/services/import-workspace.js.map +1 -1
  37. package/lib/services/landing-page-template.d.ts +52 -0
  38. package/lib/services/landing-page-template.js +421 -0
  39. package/lib/services/landing-page-template.js.map +1 -0
  40. package/lib/services/landing-page.d.ts +43 -0
  41. package/lib/services/landing-page.js +117 -0
  42. package/lib/services/landing-page.js.map +1 -0
  43. package/lib/services/web-fragment.d.ts +41 -0
  44. package/lib/services/web-fragment.js +245 -0
  45. package/lib/services/web-fragment.js.map +1 -0
  46. package/lib/transport/experimental-media.d.ts +30 -0
  47. package/lib/transport/experimental-media.js +224 -0
  48. package/lib/transport/experimental-media.js.map +1 -0
  49. package/lib/transport/json-request.d.ts +9 -1
  50. package/lib/transport/json-request.js +30 -3
  51. package/lib/transport/json-request.js.map +1 -1
  52. package/lib/transport/multipart-image-create.d.ts +28 -0
  53. package/lib/transport/multipart-image-create.js +189 -0
  54. package/lib/transport/multipart-image-create.js.map +1 -0
  55. package/messages/cms.import.workspace.md +6 -0
  56. package/package.json +1 -1
@@ -0,0 +1,117 @@
1
+ import { assertLandingPageTemplateItem, planLandingPageTemplateCopies, validateLandingPageTemplatePrerequisites, } from './landing-page-template.js';
2
+ const LANDING_PAGE_TYPE = 'sfdc_cms__landingPage';
3
+ const TEMPLATE_TYPE = 'sfdc_cms__landingPageTemplate';
4
+ function record(value) {
5
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
6
+ }
7
+ function exactKeys(value, required, optional, label) {
8
+ const keys = Object.keys(value);
9
+ if (required.some((key) => !keys.includes(key)) ||
10
+ keys.some((key) => !required.includes(key) && !optional.includes(key))) {
11
+ throw new TypeError(`${label} contains unsupported or missing fields`);
12
+ }
13
+ }
14
+ /**
15
+ * Validate the exact captured landing-page authoring shape.
16
+ * @param {WorkspaceImportItem} item - Captured workspace item to validate.
17
+ * @returns {object} Extracted image and Data Graph prerequisites.
18
+ */
19
+ export function assertLandingPageItem(item) {
20
+ if (item.contentType !== LANDING_PAGE_TYPE) {
21
+ throw new TypeError(`Landing-page profile requires exact content type ${LANDING_PAGE_TYPE}`);
22
+ }
23
+ const inspect = (value) => {
24
+ if (Array.isArray(value)) {
25
+ for (const child of value)
26
+ inspect(child);
27
+ return;
28
+ }
29
+ if (!record(value))
30
+ return;
31
+ if (record(value.source) &&
32
+ value.source.type === 'imageReference' &&
33
+ (!record(value.source.ref) ||
34
+ Object.keys(value.source.ref).length !== 1 ||
35
+ typeof value.source.ref.contentKey !== 'string' ||
36
+ typeof value.url !== 'string' ||
37
+ !value.url.startsWith(`/cms/media/${value.source.ref.contentKey}`))) {
38
+ throw new TypeError('Landing-page image URL must match its exact image content key');
39
+ }
40
+ for (const child of Object.values(value))
41
+ inspect(child);
42
+ };
43
+ inspect(item.contentBody);
44
+ return assertLandingPageTemplateItem({ ...item, contentType: TEMPLATE_TYPE });
45
+ }
46
+ function rows(value) {
47
+ if (!Array.isArray(value) || value.length === 0 || value.some((row) => !record(row))) {
48
+ throw new TypeError('Landing-page mappings must be a nonempty array of objects');
49
+ }
50
+ return value;
51
+ }
52
+ /**
53
+ * Plan exact type-qualified landing-page creates using only evidenced image references.
54
+ * @param {LoadedWorkspaceExport} source - Verified source workspace package.
55
+ * @param {unknown} input - User-supplied landing-page mapping JSON.
56
+ * @returns {PlannedLandingPageCopies} Validated create proposal.
57
+ */
58
+ export function planLandingPageCopies(source, input) {
59
+ const transformedRows = rows(input).map((row, index) => {
60
+ exactKeys(row, ['source', 'target', 'imageDependencies', 'dataGraphs'], [], `Landing-page mapping ${index}`);
61
+ if (!record(row.source)) {
62
+ throw new TypeError(`Landing-page mapping ${index}.source must be an object`);
63
+ }
64
+ exactKeys(row.source, ['family', 'type', 'apiName'], [], `Landing-page mapping ${index}.source`);
65
+ if (row.source.family !== 'cms' || row.source.type !== 'landingPage') {
66
+ throw new TypeError(`Landing-page mapping ${index}.source must select cms/landingPage`);
67
+ }
68
+ if (!Array.isArray(row.imageDependencies)) {
69
+ throw new TypeError(`Landing-page mapping ${index}.imageDependencies must be an array`);
70
+ }
71
+ const cmsDependencies = row.imageDependencies.map((dependency, dependencyIndex) => {
72
+ if (!record(dependency)) {
73
+ throw new TypeError(`Landing-page image dependency ${dependencyIndex} must be an object`);
74
+ }
75
+ exactKeys(dependency, ['sourceContentKey', 'targetApiName'], ['targetTitle'], `Landing-page image dependency ${dependencyIndex}`);
76
+ return { ...dependency, sourceType: 'image' };
77
+ });
78
+ return {
79
+ source: { ...row.source, type: 'landingPageTemplate' },
80
+ target: row.target,
81
+ cmsDependencies,
82
+ dataGraphs: row.dataGraphs,
83
+ };
84
+ });
85
+ const transformedSource = {
86
+ ...source,
87
+ items: source.items.map((item) => item.contentType === LANDING_PAGE_TYPE ? { ...item, contentType: TEMPLATE_TYPE } : item),
88
+ };
89
+ const planned = planLandingPageTemplateCopies(transformedSource, transformedRows);
90
+ const items = planned.items.map((item) => ({ ...item, contentType: LANDING_PAGE_TYPE }));
91
+ for (const item of items)
92
+ assertLandingPageItem(item);
93
+ return {
94
+ ...planned,
95
+ items,
96
+ cmsPrerequisites: planned.cmsPrerequisites,
97
+ };
98
+ }
99
+ /**
100
+ * Resolve exact typed images, validate Data Graph identities, and rewrite evidenced references.
101
+ * @param {RequestConnection} connection - Destination org connection.
102
+ * @param {string} workspaceId - Exact destination workspace ID.
103
+ * @param {PlannedLandingPageCopies} proposal - Landing-page proposal to validate.
104
+ * @param {JsonRequestOptions} options - Optional request metadata and signal.
105
+ * @returns {Promise<void>} Resolves after every prerequisite is validated and rewritten.
106
+ */
107
+ export async function validateLandingPagePrerequisites(connection, workspaceId, proposal, options = {}) {
108
+ const templateProposal = {
109
+ ...proposal,
110
+ items: proposal.items.map((item) => ({ ...item, contentType: TEMPLATE_TYPE })),
111
+ };
112
+ await validateLandingPageTemplatePrerequisites(connection, workspaceId, templateProposal, options);
113
+ for (const [index, item] of templateProposal.items.entries()) {
114
+ proposal.items[index] = { ...item, contentType: LANDING_PAGE_TYPE };
115
+ }
116
+ }
117
+ //# sourceMappingURL=landing-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"landing-page.js","sourceRoot":"","sources":["../../src/services/landing-page.ts"],"names":[],"mapp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AC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;KAC/E,CAAC;IACF,MAAM,wCAAwC,CAC5C,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,OAAO,CACR,CAAC;IACF,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5D,QAAQ,CAAC,KAA+B,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjG,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import type { LoadedWorkspaceExport, WorkspaceImportItem } from './import-workspace.js';
3
+ import type { PlannedImportIdentities } from './import-identities.js';
4
+ type QueryConnection = {
5
+ readonly query?: Connection['query'];
6
+ };
7
+ export type WebFragmentDataGraphPrerequisite = {
8
+ readonly sourceDeveloperName: string;
9
+ readonly sourceDataSpace: string;
10
+ readonly targetDeveloperName: string;
11
+ readonly targetDataSpace: string;
12
+ readonly resolution: 'preserved' | 'explicit-map';
13
+ validationStatus?: 'pending' | 'passed' | 'failed';
14
+ };
15
+ export type PlannedWebFragmentCopies = PlannedImportIdentities & {
16
+ readonly dataGraphs: readonly WebFragmentDataGraphPrerequisite[];
17
+ };
18
+ /**
19
+ * Validate the evidenced landing-page content-block shape.
20
+ * @param {WorkspaceImportItem} item - Integrity-verified web-fragment item.
21
+ * @returns {{developerName: string, dataSpace: string}[]} Exact named Data Graph prerequisites.
22
+ */
23
+ export declare function assertWebFragmentItem(item: WorkspaceImportItem): readonly {
24
+ developerName: string;
25
+ dataSpace: string;
26
+ }[];
27
+ /**
28
+ * Plan one or many exact type-qualified web-fragment creates.
29
+ * @param {LoadedWorkspaceExport} source - Integrity-verified workspace package.
30
+ * @param {unknown} input - Explicit source, target, and Data Graph map rows.
31
+ * @returns {PlannedWebFragmentCopies} Selected creates and exact prerequisite evidence.
32
+ */
33
+ export declare function planWebFragmentCopies(source: LoadedWorkspaceExport, input: unknown): PlannedWebFragmentCopies;
34
+ /**
35
+ * Prove each exact target Data Graph developer-name/data-space pair exists uniquely.
36
+ * @param {QueryConnection} connection - Destination org query transport.
37
+ * @param {readonly WebFragmentDataGraphPrerequisite[]} prerequisites - Exact target prerequisites.
38
+ * @returns {Promise<void>} Fulfilled only when every prerequisite resolves exactly once.
39
+ */
40
+ export declare function validateDataGraphPrerequisites(connection: QueryConnection, prerequisites: readonly WebFragmentDataGraphPrerequisite[]): Promise<void>;
41
+ export {};
@@ -0,0 +1,245 @@
1
+ import { isDeepStrictEqual } from 'node:util';
2
+ const WEB_FRAGMENT_TYPE = 'sfdc_cms__webFragment';
3
+ const DATA_GRAPH_PROVIDER = 'sfdc_cms__dataGraphDataProvider';
4
+ const BODY_KEYS = [
5
+ 'lightning:backgroundImage',
6
+ 'lightning:brandSource',
7
+ 'lightning:dataProviders',
8
+ 'lightning:expressions',
9
+ 'sfdc_cms:block',
10
+ 'sfdc_cms:title',
11
+ 'sfdc_cms:variants',
12
+ ];
13
+ const BACKGROUND_IMAGE = { position: 'center center', repeat: 'no-repeat', size: 'cover' };
14
+ function record(value) {
15
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
16
+ }
17
+ function exactKeys(value, expected, label) {
18
+ if (Object.keys(value).toSorted().join('\0') !== [...expected].toSorted().join('\0')) {
19
+ throw new TypeError(`${label} must contain exactly ${expected.join(', ')}`);
20
+ }
21
+ }
22
+ function nonempty(value, label) {
23
+ if (typeof value !== 'string' || value.trim().length === 0) {
24
+ throw new TypeError(`${label} must be a nonempty string`);
25
+ }
26
+ }
27
+ function identifier(value, label) {
28
+ nonempty(value, label);
29
+ if (!/^[A-Za-z][A-Za-z\d_]*$/u.test(value)) {
30
+ throw new TypeError(`${label} must be an exact developer/API name`);
31
+ }
32
+ }
33
+ function dataSpace(value, label) {
34
+ nonempty(value, label);
35
+ if (!/^[A-Za-z][A-Za-z\d_]*$/u.test(value)) {
36
+ throw new TypeError(`${label} must be an exact data-space developer name`);
37
+ }
38
+ }
39
+ function assertBlock(value) {
40
+ if (!record(value))
41
+ throw new TypeError('Web fragment sfdc_cms:block must be an object');
42
+ if (value.definition !== 'sfdc_cms/rootContentBlock' || value.type !== 'block') {
43
+ throw new TypeError('Web fragment root block definition/type is unsupported');
44
+ }
45
+ nonempty(value.id, 'Web fragment root block id');
46
+ if (!Array.isArray(value.children))
47
+ throw new TypeError('Web fragment root children must be an array');
48
+ }
49
+ function provider(value, label) {
50
+ if (!record(value))
51
+ throw new TypeError(`${label} must be an object`);
52
+ exactKeys(value, ['attributes', 'definition', 'sfdcExpressionKey'], label);
53
+ if (value.definition !== DATA_GRAPH_PROVIDER || value.sfdcExpressionKey !== '$dataGraph') {
54
+ throw new TypeError(`${label} must use the exact Data Graph provider definition`);
55
+ }
56
+ if (!record(value.attributes))
57
+ throw new TypeError(`${label}.attributes must be an object`);
58
+ exactKeys(value.attributes, ['dataGraphApiName', 'dataspace'], `${label}.attributes`);
59
+ identifier(value.attributes.dataGraphApiName, `${label}.attributes.dataGraphApiName`);
60
+ dataSpace(value.attributes.dataspace, `${label}.attributes.dataspace`);
61
+ return {
62
+ developerName: value.attributes.dataGraphApiName,
63
+ dataSpace: value.attributes.dataspace,
64
+ };
65
+ }
66
+ /**
67
+ * Validate the evidenced landing-page content-block shape.
68
+ * @param {WorkspaceImportItem} item - Integrity-verified web-fragment item.
69
+ * @returns {{developerName: string, dataSpace: string}[]} Exact named Data Graph prerequisites.
70
+ */
71
+ export function assertWebFragmentItem(item) {
72
+ if (item.contentType !== WEB_FRAGMENT_TYPE) {
73
+ throw new TypeError(`Web fragment profile requires exact content type ${WEB_FRAGMENT_TYPE}`);
74
+ }
75
+ identifier(item.apiName, 'Web fragment apiName');
76
+ nonempty(item.title, 'Web fragment title');
77
+ exactKeys(item.contentBody, BODY_KEYS, 'Web fragment contentBody');
78
+ if (item.contentBody['sfdc_cms:title'] !== item.title) {
79
+ throw new TypeError('Web fragment body title must match the top-level title');
80
+ }
81
+ if (!isDeepStrictEqual(item.contentBody['lightning:brandSource'], {
82
+ defaultBrandOption: 'sfdcBrand',
83
+ })) {
84
+ throw new TypeError('Web fragment brand source must match the evidenced Salesforce-brand profile');
85
+ }
86
+ if (!isDeepStrictEqual(item.contentBody['lightning:backgroundImage'], BACKGROUND_IMAGE)) {
87
+ throw new TypeError('Web fragment background image must match the evidenced profile');
88
+ }
89
+ if (!Array.isArray(item.contentBody['lightning:expressions'])) {
90
+ throw new TypeError('Web fragment lightning:expressions must be an array');
91
+ }
92
+ if (!Array.isArray(item.contentBody['sfdc_cms:variants'])) {
93
+ throw new TypeError('Web fragment sfdc_cms:variants must be an array');
94
+ }
95
+ assertBlock(item.contentBody['sfdc_cms:block']);
96
+ const providers = item.contentBody['lightning:dataProviders'];
97
+ if (!Array.isArray(providers) || providers.length === 0) {
98
+ throw new TypeError('Web fragment requires at least one exact named Data Graph provider');
99
+ }
100
+ const prerequisites = providers.map((value, index) => provider(value, `Data Graph provider ${index}`));
101
+ const identities = new Set(prerequisites.map(({ developerName, dataSpace: space }) => `${developerName}\0${space}`));
102
+ if (identities.size !== prerequisites.length) {
103
+ throw new TypeError('Web fragment Data Graph providers must be unique');
104
+ }
105
+ return prerequisites;
106
+ }
107
+ function mappingRows(value) {
108
+ if (!Array.isArray(value) || value.length === 0 || value.some((row) => !record(row))) {
109
+ throw new TypeError('Web fragment mappings must be a nonempty array of objects');
110
+ }
111
+ return value;
112
+ }
113
+ /**
114
+ * Plan one or many exact type-qualified web-fragment creates.
115
+ * @param {LoadedWorkspaceExport} source - Integrity-verified workspace package.
116
+ * @param {unknown} input - Explicit source, target, and Data Graph map rows.
117
+ * @returns {PlannedWebFragmentCopies} Selected creates and exact prerequisite evidence.
118
+ */
119
+ export function planWebFragmentCopies(source, input) {
120
+ if (!source.integrity.verified)
121
+ throw new TypeError('Source integrity must be verified first');
122
+ const sourceKeys = new Set(source.items.map((item) => item.contentKey));
123
+ const sourceNames = new Set(source.items.flatMap((item) => (item.apiName === undefined ? [] : [item.apiName])));
124
+ const targetKeys = new Set();
125
+ const targetNames = new Set();
126
+ const selected = new Set();
127
+ const items = [];
128
+ const dataGraphs = [];
129
+ for (const [index, row] of mappingRows(input).entries()) {
130
+ exactKeys(row, ['source', 'target', 'dataGraphs'], `Web fragment mapping ${index}`);
131
+ if (!record(row.source))
132
+ throw new TypeError(`Web fragment mapping ${index}.source must be an object`);
133
+ exactKeys(row.source, ['family', 'type', 'apiName'], `Web fragment mapping ${index}.source`);
134
+ if (row.source.family !== 'cms' || row.source.type !== 'webFragment') {
135
+ throw new TypeError(`Web fragment mapping ${index}.source must select cms/webFragment`);
136
+ }
137
+ identifier(row.source.apiName, `Web fragment mapping ${index}.source.apiName`);
138
+ const sourceApiName = row.source.apiName;
139
+ if (selected.has(sourceApiName))
140
+ throw new TypeError(`Duplicate web fragment selection: ${sourceApiName}`);
141
+ const matches = source.items.filter((item) => item.contentType === WEB_FRAGMENT_TYPE && item.apiName === sourceApiName);
142
+ if (matches.length !== 1) {
143
+ throw new TypeError(`Typed source API name must match exactly one web fragment: ${sourceApiName}`);
144
+ }
145
+ const item = matches[0];
146
+ const sourcePrerequisites = assertWebFragmentItem(item);
147
+ if (!record(row.target))
148
+ throw new TypeError(`Web fragment mapping ${index}.target must be an object`);
149
+ exactKeys(row.target, ['contentKey', 'apiName'], `Web fragment mapping ${index}.target`);
150
+ identifier(row.target.contentKey, `Web fragment mapping ${index}.target.contentKey`);
151
+ identifier(row.target.apiName, `Web fragment mapping ${index}.target.apiName`);
152
+ const contentKey = row.target.contentKey;
153
+ const apiName = row.target.apiName;
154
+ if (sourceKeys.has(contentKey) || targetKeys.has(contentKey)) {
155
+ throw new TypeError('Target web fragment content keys must be fresh and unique');
156
+ }
157
+ if (sourceNames.has(apiName) || targetNames.has(apiName)) {
158
+ throw new TypeError('Target web fragment API names must be fresh and unique');
159
+ }
160
+ if (!Array.isArray(row.dataGraphs) || row.dataGraphs.length !== sourcePrerequisites.length) {
161
+ throw new TypeError('Each source Data Graph prerequisite requires exactly one mapping row');
162
+ }
163
+ const mapped = new Map();
164
+ for (const [graphIndex, raw] of row.dataGraphs.entries()) {
165
+ if (!record(raw))
166
+ throw new TypeError(`Web fragment mapping ${index}.dataGraphs[${graphIndex}] must be an object`);
167
+ exactKeys(raw, ['sourceDeveloperName', 'sourceDataSpace', 'targetDeveloperName', 'targetDataSpace'], `Web fragment mapping ${index}.dataGraphs[${graphIndex}]`);
168
+ identifier(raw.sourceDeveloperName, 'sourceDeveloperName');
169
+ dataSpace(raw.sourceDataSpace, 'sourceDataSpace');
170
+ identifier(raw.targetDeveloperName, 'targetDeveloperName');
171
+ dataSpace(raw.targetDataSpace, 'targetDataSpace');
172
+ const key = `${raw.sourceDeveloperName}\0${raw.sourceDataSpace}`;
173
+ if (mapped.has(key))
174
+ throw new TypeError('Duplicate Data Graph source mapping');
175
+ mapped.set(key, {
176
+ sourceDeveloperName: raw.sourceDeveloperName,
177
+ sourceDataSpace: raw.sourceDataSpace,
178
+ targetDeveloperName: raw.targetDeveloperName,
179
+ targetDataSpace: raw.targetDataSpace,
180
+ resolution: raw.sourceDeveloperName === raw.targetDeveloperName &&
181
+ raw.sourceDataSpace === raw.targetDataSpace
182
+ ? 'preserved'
183
+ : 'explicit-map',
184
+ validationStatus: 'pending',
185
+ });
186
+ }
187
+ for (const prerequisite of sourcePrerequisites) {
188
+ if (!mapped.has(`${prerequisite.developerName}\0${prerequisite.dataSpace}`)) {
189
+ throw new TypeError(`Missing exact Data Graph mapping for ${prerequisite.developerName}/${prerequisite.dataSpace}`);
190
+ }
191
+ }
192
+ const providers = item.contentBody['lightning:dataProviders'].map((value) => {
193
+ const identity = provider(value, 'Data Graph provider');
194
+ const target = mapped.get(`${identity.developerName}\0${identity.dataSpace}`);
195
+ return {
196
+ ...value,
197
+ attributes: {
198
+ dataGraphApiName: target.targetDeveloperName,
199
+ dataspace: target.targetDataSpace,
200
+ },
201
+ };
202
+ });
203
+ selected.add(sourceApiName);
204
+ targetKeys.add(contentKey);
205
+ targetNames.add(apiName);
206
+ dataGraphs.push(...mapped.values());
207
+ items.push({
208
+ ...item,
209
+ apiName,
210
+ contentKey,
211
+ contentBody: { ...item.contentBody, 'lightning:dataProviders': providers },
212
+ });
213
+ }
214
+ return {
215
+ items: items.toSorted((left, right) => left.apiName.localeCompare(right.apiName)),
216
+ targetContentKeys: [...targetKeys].toSorted(),
217
+ dataGraphs: dataGraphs.toSorted((left, right) => `${left.targetDeveloperName}\0${left.targetDataSpace}`.localeCompare(`${right.targetDeveloperName}\0${right.targetDataSpace}`)),
218
+ };
219
+ }
220
+ function soqlString(value) {
221
+ return `'${value.replaceAll('\\', '\\\\').replaceAll("'", String.raw `\'`)}'`;
222
+ }
223
+ /**
224
+ * Prove each exact target Data Graph developer-name/data-space pair exists uniquely.
225
+ * @param {QueryConnection} connection - Destination org query transport.
226
+ * @param {readonly WebFragmentDataGraphPrerequisite[]} prerequisites - Exact target prerequisites.
227
+ * @returns {Promise<void>} Fulfilled only when every prerequisite resolves exactly once.
228
+ */
229
+ export async function validateDataGraphPrerequisites(connection, prerequisites) {
230
+ if (connection.query === undefined) {
231
+ throw new TypeError('Destination Data Graph prerequisites cannot be queried');
232
+ }
233
+ const unique = new Map(prerequisites.map((value) => [`${value.targetDeveloperName}\0${value.targetDataSpace}`, value]));
234
+ for (const prerequisite of unique.values()) {
235
+ const result = await connection.query(`SELECT DeveloperName, DataSpaceDevName FROM DataGraph WHERE DeveloperName = ${soqlString(prerequisite.targetDeveloperName)} AND DataSpaceDevName = ${soqlString(prerequisite.targetDataSpace)}`);
236
+ const matches = result.records.filter((record) => record.DeveloperName === prerequisite.targetDeveloperName &&
237
+ record.DataSpaceDevName === prerequisite.targetDataSpace);
238
+ if (result.totalSize !== 1 || result.records.length !== 1 || matches.length !== 1) {
239
+ prerequisite.validationStatus = 'failed';
240
+ throw new TypeError(`Data Graph prerequisite must resolve exactly once: ${prerequisite.targetDeveloperName}/${prerequisite.targetDataSpace}`);
241
+ }
242
+ prerequisite.validationStatus = 'passed';
243
+ }
244
+ }
245
+ //# sourceMappingURL=web-fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-fragment.js","sourceRoot":"","sources":["../../src/services/web-fragment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAClD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;AAC9D,MAAM,SAAS,GAAG;IAChB,2BAA2B;IAC3B,uBAAuB;IACvB,yBAAyB;IACzB,uBAAuB;IACvB,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;CACX,CAAC;AACX,MAAM,gBAAgB,GAAG,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAkB3F,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,SAAS,CAAC,KAAiB,EAAE,QAA2B,EAAE,KAAa;IAC9E,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,yBAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc,EAAE,KAAa;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KAAK,CAAC,CAAC,CAChG,CAAC;IACF,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CACnC,+EAA+E,UAAU,CAAC,YAAY,CAAC,mBAAmB,CAAC,2BAA2B,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,CACjM,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CACnC,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,aAAa,KAAK,YAAY,CAAC,mBAAmB;YACzD,MAAM,CAAC,gBAAgB,KAAK,YAAY,CAAC,eAAe,CAC3D,CAAC;QACF,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,YAAY,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YACzC,MAAM,IAAI,SAAS,CACjB,sDAAsD,YAAY,CAAC,mBAAmB,IAAI,YAAY,CAAC,eAAe,EAAE,CACzH,CAAC;QACJ,CAAC;QACD,YAAY,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IAC3C,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { FileHandle } from 'node:fs/promises';
2
+ export declare const EXPERIMENTAL_MEDIA_POLICY: {
3
+ readonly approvedRedirectSuffix: "file.force.com";
4
+ readonly maxRedirects: 3;
5
+ readonly perImageBytes: number;
6
+ readonly totalBytes: number;
7
+ };
8
+ export type ExperimentalMediaDownload = {
9
+ readonly bytes: number;
10
+ readonly contentLength?: number;
11
+ readonly md5: string;
12
+ readonly mimeType: string;
13
+ readonly sha256: string;
14
+ };
15
+ type ExperimentalMediaFileHandle = Pick<FileHandle, 'close' | 'write'>;
16
+ export type ExperimentalMediaDownloadOptions = {
17
+ readonly accessToken: string;
18
+ readonly expectedMd5: string;
19
+ readonly expectedMimeType: string;
20
+ readonly expectedSize: number;
21
+ readonly fetch?: typeof fetch;
22
+ readonly instanceUrl: string;
23
+ readonly maxBytes?: number;
24
+ readonly openFile?: (file: string) => Promise<ExperimentalMediaFileHandle>;
25
+ readonly outputFile: string;
26
+ readonly unlinkFile?: (file: string) => Promise<void>;
27
+ };
28
+ export declare function isApprovedSalesforceMediaUrl(value: string | URL): boolean;
29
+ export declare function downloadExperimentalCmsMedia(source: URL, options: ExperimentalMediaDownloadOptions): Promise<ExperimentalMediaDownload>;
30
+ export {};