sf-plugin-cms 0.1.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +277 -0
  3. package/lib/commands/cms/command-base.d.ts +16 -0
  4. package/lib/commands/cms/command-base.js +42 -0
  5. package/lib/commands/cms/command-base.js.map +1 -0
  6. package/lib/commands/cms/export/workspace.d.ts +14 -0
  7. package/lib/commands/cms/export/workspace.js +42 -0
  8. package/lib/commands/cms/export/workspace.js.map +1 -0
  9. package/lib/commands/cms/get/channel.d.ts +13 -0
  10. package/lib/commands/cms/get/channel.js +23 -0
  11. package/lib/commands/cms/get/channel.js.map +1 -0
  12. package/lib/commands/cms/get/content.d.ts +17 -0
  13. package/lib/commands/cms/get/content.js +35 -0
  14. package/lib/commands/cms/get/content.js.map +1 -0
  15. package/lib/commands/cms/get/variant.d.ts +13 -0
  16. package/lib/commands/cms/get/variant.js +23 -0
  17. package/lib/commands/cms/get/variant.js.map +1 -0
  18. package/lib/commands/cms/get/workspace.d.ts +13 -0
  19. package/lib/commands/cms/get/workspace.js +23 -0
  20. package/lib/commands/cms/get/workspace.js.map +1 -0
  21. package/lib/commands/cms/import/workspace.d.ts +18 -0
  22. package/lib/commands/cms/import/workspace.js +77 -0
  23. package/lib/commands/cms/import/workspace.js.map +1 -0
  24. package/lib/commands/cms/info.d.ts +12 -0
  25. package/lib/commands/cms/info.js +13 -0
  26. package/lib/commands/cms/info.js.map +1 -0
  27. package/lib/commands/cms/list/channel.d.ts +15 -0
  28. package/lib/commands/cms/list/channel.js +28 -0
  29. package/lib/commands/cms/list/channel.js.map +1 -0
  30. package/lib/commands/cms/list/workspace.d.ts +15 -0
  31. package/lib/commands/cms/list/workspace.js +27 -0
  32. package/lib/commands/cms/list/workspace.js.map +1 -0
  33. package/lib/generated/operations.d.ts +233 -0
  34. package/lib/generated/operations.js +317 -0
  35. package/lib/generated/operations.js.map +1 -0
  36. package/lib/index.d.ts +8 -0
  37. package/lib/index.js +9 -0
  38. package/lib/index.js.map +1 -0
  39. package/lib/openapi/generate.d.ts +30 -0
  40. package/lib/openapi/generate.js +150 -0
  41. package/lib/openapi/generate.js.map +1 -0
  42. package/lib/openapi/intake.d.ts +26 -0
  43. package/lib/openapi/intake.js +176 -0
  44. package/lib/openapi/intake.js.map +1 -0
  45. package/lib/openapi/selected.d.ts +11 -0
  46. package/lib/openapi/selected.js +49 -0
  47. package/lib/openapi/selected.js.map +1 -0
  48. package/lib/services/export-workspace.d.ts +37 -0
  49. package/lib/services/export-workspace.js +214 -0
  50. package/lib/services/export-workspace.js.map +1 -0
  51. package/lib/services/import-workspace.d.ts +112 -0
  52. package/lib/services/import-workspace.js +570 -0
  53. package/lib/services/import-workspace.js.map +1 -0
  54. package/lib/services/read.d.ts +20 -0
  55. package/lib/services/read.js +73 -0
  56. package/lib/services/read.js.map +1 -0
  57. package/lib/services/write.d.ts +27 -0
  58. package/lib/services/write.js +21 -0
  59. package/lib/services/write.js.map +1 -0
  60. package/lib/transport/json-mutation.d.ts +15 -0
  61. package/lib/transport/json-mutation.js +81 -0
  62. package/lib/transport/json-mutation.js.map +1 -0
  63. package/lib/transport/json-request.d.ts +26 -0
  64. package/lib/transport/json-request.js +135 -0
  65. package/lib/transport/json-request.js.map +1 -0
  66. package/lib/transport/redact-secrets.d.ts +6 -0
  67. package/lib/transport/redact-secrets.js +31 -0
  68. package/lib/transport/redact-secrets.js.map +1 -0
  69. package/messages/cms.export.workspace.md +29 -0
  70. package/messages/cms.get.channel.md +25 -0
  71. package/messages/cms.get.content.md +41 -0
  72. package/messages/cms.get.variant.md +25 -0
  73. package/messages/cms.get.workspace.md +25 -0
  74. package/messages/cms.import.workspace.md +45 -0
  75. package/messages/cms.list.channel.md +33 -0
  76. package/messages/cms.list.workspace.md +32 -0
  77. package/package.json +98 -0
@@ -0,0 +1,73 @@
1
+ import { getSelectedOperation, requestJson, } from '../transport/json-request.js';
2
+ function isRecord(value) {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
5
+ function optionalInteger(record, key) {
6
+ const value = record[key];
7
+ return typeof value === 'number' && Number.isInteger(value) ? value : undefined;
8
+ }
9
+ function readItems(data) {
10
+ if (Array.isArray(data))
11
+ return data.filter(isRecord);
12
+ if (!isRecord(data))
13
+ return [];
14
+ for (const key of ['items', 'spaces', 'contentSpaces', 'channels']) {
15
+ const value = data[key];
16
+ if (Array.isArray(value))
17
+ return value.filter(isRecord);
18
+ }
19
+ const spaceChannels = data.spaceChannels;
20
+ if (Array.isArray(spaceChannels)) {
21
+ return spaceChannels
22
+ .filter(isRecord)
23
+ .map((item) => item.channelSummary)
24
+ .filter(isRecord);
25
+ }
26
+ return [];
27
+ }
28
+ function toPage(data) {
29
+ const record = isRecord(data) ? data : {};
30
+ const result = { items: readItems(data) };
31
+ const page = optionalInteger(record, 'currentPage') ?? optionalInteger(record, 'page');
32
+ const pageSize = optionalInteger(record, 'pageSize');
33
+ const total = optionalInteger(record, 'total') ??
34
+ optionalInteger(record, 'totalCount') ??
35
+ optionalInteger(record, 'totalItems') ??
36
+ optionalInteger(record, 'totalSpaceChannels');
37
+ if (page !== undefined)
38
+ result.page = page;
39
+ if (pageSize !== undefined)
40
+ result.pageSize = pageSize;
41
+ if (total !== undefined)
42
+ result.total = total;
43
+ return result;
44
+ }
45
+ async function list(connection, operationKey, path, query, options) {
46
+ const response = await requestJson(connection, getSelectedOperation(operationKey), { path, query }, options);
47
+ return toPage(response.data);
48
+ }
49
+ async function get(connection, operationKey, path, query = {}, options = {}) {
50
+ const response = await requestJson(connection, getSelectedOperation(operationKey), { path, query }, options);
51
+ if (!isRecord(response.data))
52
+ throw new TypeError(`Unexpected ${operationKey} response shape`);
53
+ return response.data;
54
+ }
55
+ export function listWorkspaces(connection, query = {}, options = {}) {
56
+ return list(connection, 'workspace.list', {}, query, options);
57
+ }
58
+ export function getWorkspace(connection, contentSpaceId, options = {}) {
59
+ return get(connection, 'workspace.get', { contentSpaceId }, {}, options);
60
+ }
61
+ export function listWorkspaceChannels(connection, contentSpaceId, query = {}, options = {}) {
62
+ return list(connection, 'workspace.channel.list', { contentSpaceId }, query, options);
63
+ }
64
+ export function getChannel(connection, channelId, options = {}) {
65
+ return get(connection, 'channel.get', { channelId }, {}, options);
66
+ }
67
+ export function getContent(connection, contentKeyOrId, query = {}, options = {}) {
68
+ return get(connection, 'content.get', { contentKeyOrId }, query, options);
69
+ }
70
+ export function getVariant(connection, variantId, options = {}) {
71
+ return get(connection, 'variant.get', { variantId }, {}, options);
72
+ }
73
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/services/read.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,WAAW,GAGZ,MAAM,8BAA8B,CAAC;AAetC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,eAAe,CAAC,MAAiB,EAAE,GAAW;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,SAAS,SAAS,CAAC,IAAa;IAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,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B,EACtB,QAAkC,EAAE,EACpC,UAA8B,EAAE;IAEhC,OAAO,IAAI,CAAC,UAAU,EAAE,wBAAwB,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,UAA6B,EAC7B,SAAiB,EACjB,UAA8B,EAAE;IAEhC,OAAO,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,UAA6B,EAC7B,cAAsB,EACtB,QAAkC,EAAE,EACpC,UAA8B,EAAE;IAEhC,OAAO,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,UAA6B,EAC7B,SAAiB,EACjB,UAA8B,EAAE;IAEhC,OAAO,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import { type EmptyMutationSuccess, type JsonMutationBody } from '../transport/json-mutation.js';
3
+ import { type JsonRequestOptions } from '../transport/json-request.js';
4
+ import type { CmsRecord } from './read.js';
5
+ type RequestConnection = Pick<Connection, 'request'>;
6
+ export type CreateContentInput = JsonMutationBody & {
7
+ apiName?: string;
8
+ contentBody: Readonly<Record<string, unknown>>;
9
+ contentKey?: string;
10
+ contentSpaceOrFolderId: string;
11
+ contentType: string;
12
+ externalId?: string;
13
+ externalSource?: Readonly<Record<string, unknown>>;
14
+ title: string;
15
+ urlName?: string;
16
+ };
17
+ export type CreateVariantInput = JsonMutationBody & {
18
+ contentBody: Readonly<Record<string, unknown>>;
19
+ language: string;
20
+ managedContentKeyOrId: string;
21
+ title?: string;
22
+ urlName?: string;
23
+ };
24
+ export declare function createContent(connection: RequestConnection, body: CreateContentInput, options?: JsonRequestOptions): Promise<CmsRecord>;
25
+ export declare function createVariant(connection: RequestConnection, body: CreateVariantInput, options?: JsonRequestOptions): Promise<CmsRecord>;
26
+ export declare function deleteVariant(connection: RequestConnection, variantId: string, options?: JsonRequestOptions): Promise<EmptyMutationSuccess>;
27
+ export {};
@@ -0,0 +1,21 @@
1
+ import { requestEmptyMutation, requestJsonMutation, } from '../transport/json-mutation.js';
2
+ import { getSelectedOperation } from '../transport/json-request.js';
3
+ function isRecord(value) {
4
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
5
+ }
6
+ async function create(connection, operationKey, body, options) {
7
+ const response = await requestJsonMutation(connection, getSelectedOperation(operationKey), body, {}, options);
8
+ if (!isRecord(response.data))
9
+ throw new TypeError(`Unexpected ${operationKey} response shape`);
10
+ return response.data;
11
+ }
12
+ export function createContent(connection, body, options = {}) {
13
+ return create(connection, 'content.create', body, options);
14
+ }
15
+ export function createVariant(connection, body, options = {}) {
16
+ return create(connection, 'variant.create', body, options);
17
+ }
18
+ export function deleteVariant(connection, variantId, options = {}) {
19
+ return requestEmptyMutation(connection, getSelectedOperation('variant.delete'), { path: { variantId } }, options);
20
+ }
21
+ //# sourceMappingURL=write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/services/write.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAA2B,MAAM,8BAA8B,CAAC;AAyB7F,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,KAAK,UAAU,MAAM,CACnB,UAA6B,EAC7B,YAAiD,EACjD,IAA6C,EAC7C,OAA2B;IAE3B,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CACxC,UAAU,EACV,oBAAoB,CAAC,YAAY,CAAC,EAClC,IAAI,EACJ,EAAE,EACF,OAAO,CACR,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,cAAc,YAAY,iBAAiB,CAAC,CAAC;IAC/F,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAA6B,EAC7B,IAAwB,EACxB,UAA8B,EAAE;IAEhC,OAAO,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAA6B,EAC7B,IAAwB,EACxB,UAA8B,EAAE;IAEhC,OAAO,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAA6B,EAC7B,SAAiB,EACjB,UAA8B,EAAE;IAEhC,OAAO,oBAAoB,CACzB,UAAU,EACV,oBAAoB,CAAC,gBAAgB,CAAC,EACtC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,EACvB,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import type { SelectedOperation } from '../generated/operations.js';
3
+ import { type JsonRequestOptions, type JsonRequestValues } from './json-request.js';
4
+ export type JsonMutationBody = Readonly<Record<string, unknown>>;
5
+ export type JsonMutationSuccess<T> = {
6
+ data: T;
7
+ operationKey: SelectedOperation['localKey'];
8
+ };
9
+ export type EmptyMutationSuccess = {
10
+ operationKey: SelectedOperation['localKey'];
11
+ };
12
+ type RequestConnection = Pick<Connection, 'request'> & Partial<Pick<Connection, 'accessToken' | 'instanceUrl' | 'version'>>;
13
+ export declare function requestJsonMutation<T>(connection: RequestConnection, operation: SelectedOperation, body: JsonMutationBody, values?: JsonRequestValues, options?: JsonRequestOptions): Promise<JsonMutationSuccess<T>>;
14
+ export declare function requestEmptyMutation(connection: RequestConnection, operation: SelectedOperation, values?: JsonRequestValues, options?: JsonRequestOptions): Promise<EmptyMutationSuccess>;
15
+ export {};
@@ -0,0 +1,81 @@
1
+ import { Connection as JsforceConnection } from '@jsforce/jsforce-node';
2
+ import { buildOperationUrl, CmsRequestError, } from './json-request.js';
3
+ import { redactSecrets } from './redact-secrets.js';
4
+ const DEFAULT_TIMEOUT_MS = 30_000;
5
+ function isRecord(value) {
6
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
7
+ }
8
+ function errorStatus(error) {
9
+ if (!isRecord(error))
10
+ return undefined;
11
+ for (const key of ['statusCode', 'status']) {
12
+ const value = error[key];
13
+ if (typeof value === 'number' && Number.isInteger(value))
14
+ return value;
15
+ }
16
+ return undefined;
17
+ }
18
+ function safeErrorMessage(error) {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ return redactSecrets(message || 'CMS request failed');
21
+ }
22
+ function withoutRefreshReplay(connection) {
23
+ return connection.accessToken && connection.instanceUrl
24
+ ? new JsforceConnection({
25
+ accessToken: connection.accessToken,
26
+ instanceUrl: connection.instanceUrl,
27
+ version: connection.version,
28
+ })
29
+ : connection;
30
+ }
31
+ function validateMutationOperation(operation, hasBody) {
32
+ if (operation.method !== 'POST' && operation.method !== 'DELETE') {
33
+ throw new CmsRequestError(operation.localKey, `Unsupported mutation method: ${operation.method}`);
34
+ }
35
+ const requestBodyMediaTypes = operation.requestBodyMediaTypes;
36
+ if (hasBody && !requestBodyMediaTypes.includes('application/json')) {
37
+ throw new CmsRequestError(operation.localKey, 'Mutation operation does not accept application/json');
38
+ }
39
+ if (!hasBody && operation.requestBodyPresent) {
40
+ throw new CmsRequestError(operation.localKey, 'Mutation operation requires a request body');
41
+ }
42
+ }
43
+ async function sendMutation(connection, operation, values, body, options) {
44
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
45
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
46
+ throw new CmsRequestError(operation.localKey, 'Request timeout must be a positive number');
47
+ }
48
+ if (options.signal?.aborted) {
49
+ throw new CmsRequestError(operation.localKey, 'CMS request cancelled');
50
+ }
51
+ validateMutationOperation(operation, body !== undefined);
52
+ const request = withoutRefreshReplay(connection).request({
53
+ method: operation.method,
54
+ url: buildOperationUrl(operation, values),
55
+ headers: { 'content-type': 'application/json' },
56
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
57
+ }, { retry: { maxRetries: 0 }, timeout: timeoutMs });
58
+ const cancel = () => {
59
+ request.stream().destroy(new Error('CMS request cancelled'));
60
+ };
61
+ options.signal?.addEventListener('abort', cancel, { once: true });
62
+ try {
63
+ return await request;
64
+ }
65
+ catch (error) {
66
+ const message = options.signal?.aborted ? 'CMS request cancelled' : safeErrorMessage(error);
67
+ throw new CmsRequestError(operation.localKey, message, errorStatus(error));
68
+ }
69
+ finally {
70
+ options.signal?.removeEventListener('abort', cancel);
71
+ }
72
+ }
73
+ export async function requestJsonMutation(connection, operation, body, values = {}, options = {}) {
74
+ const data = await sendMutation(connection, operation, values, body, options);
75
+ return { data, operationKey: operation.localKey };
76
+ }
77
+ export async function requestEmptyMutation(connection, operation, values = {}, options = {}) {
78
+ await sendMutation(connection, operation, values, undefined, options);
79
+ return { operationKey: operation.localKey };
80
+ }
81
+ //# sourceMappingURL=json-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-mutation.js","sourceRoot":"","sources":["../../src/transport/json-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAIxE,OAAO,EACL,iBAAiB,EACjB,eAAe,GAGhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,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E,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAA6B,EAC7B,SAA4B,EAC5B,SAA4B,EAAE,EAC9B,UAA8B,EAAE;IAEhC,MAAM,YAAY,CAAU,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/E,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import { type SelectedOperation } from '../generated/operations.js';
3
+ export type OperationParameterValues = Readonly<Record<string, boolean | number | readonly string[] | string | undefined>>;
4
+ export type JsonRequestValues = {
5
+ path?: OperationParameterValues;
6
+ query?: OperationParameterValues;
7
+ };
8
+ export type JsonRequestOptions = {
9
+ signal?: AbortSignal;
10
+ timeoutMs?: number;
11
+ };
12
+ export type JsonSuccess<T> = {
13
+ data: T;
14
+ operationKey: SelectedOperation['localKey'];
15
+ status: number;
16
+ };
17
+ type RequestConnection = Pick<Connection, 'request'>;
18
+ export declare class CmsRequestError extends Error {
19
+ readonly operationKey: SelectedOperation['localKey'];
20
+ readonly status?: number;
21
+ constructor(operationKey: SelectedOperation['localKey'], message: string, status?: number);
22
+ }
23
+ export declare function buildOperationUrl(operation: SelectedOperation, values?: JsonRequestValues): string;
24
+ export declare function requestJson<T>(connection: RequestConnection, operation: SelectedOperation, values?: JsonRequestValues, options?: JsonRequestOptions): Promise<JsonSuccess<T>>;
25
+ export declare function getSelectedOperation(operationKey: SelectedOperation['localKey']): SelectedOperation;
26
+ export {};
@@ -0,0 +1,135 @@
1
+ import { SELECTED_OPERATIONS } from '../generated/operations.js';
2
+ import { redactSecrets } from './redact-secrets.js';
3
+ const DEFAULT_TIMEOUT_MS = 30_000;
4
+ export class CmsRequestError extends Error {
5
+ operationKey;
6
+ status;
7
+ constructor(operationKey, message, status) {
8
+ super(message);
9
+ this.name = 'CmsRequestError';
10
+ this.operationKey = operationKey;
11
+ this.status = status;
12
+ }
13
+ }
14
+ function isRecord(value) {
15
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
16
+ }
17
+ function errorStatus(error) {
18
+ if (!isRecord(error))
19
+ return undefined;
20
+ for (const key of ['statusCode', 'status']) {
21
+ const value = error[key];
22
+ if (typeof value === 'number' && Number.isInteger(value))
23
+ return value;
24
+ }
25
+ if (error.errorCode === 'NOT_FOUND' || error.name === 'NOT_FOUND')
26
+ return 404;
27
+ if (isRecord(error.data) && error.data.errorCode === 'NOT_FOUND')
28
+ return 404;
29
+ return undefined;
30
+ }
31
+ function safeErrorMessage(error) {
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ return redactSecrets(message || 'CMS request failed');
34
+ }
35
+ function assertValueType(operation, name, type, value) {
36
+ const valid = (type === 'string' && typeof value === 'string') ||
37
+ (type === 'boolean' && typeof value === 'boolean') ||
38
+ (type === 'integer' && typeof value === 'number' && Number.isInteger(value)) ||
39
+ (type === 'string-array' &&
40
+ Array.isArray(value) &&
41
+ value.length > 0 &&
42
+ value.every((item) => typeof item === 'string'));
43
+ if (!valid) {
44
+ throw new CmsRequestError(operation.localKey, `Invalid ${type} parameter: ${name}`);
45
+ }
46
+ }
47
+ function validateKnownParameters(operation, location, values) {
48
+ const known = new Set(operation.parameters
49
+ .filter((parameter) => parameter.location === location)
50
+ .map((parameter) => parameter.name));
51
+ for (const name of Object.keys(values)) {
52
+ if (!known.has(name)) {
53
+ throw new CmsRequestError(operation.localKey, `Unknown ${location} parameter: ${name}`);
54
+ }
55
+ }
56
+ }
57
+ export function buildOperationUrl(operation, values = {}) {
58
+ const pathValues = values.path ?? {};
59
+ const queryValues = values.query ?? {};
60
+ validateKnownParameters(operation, 'path', pathValues);
61
+ validateKnownParameters(operation, 'query', queryValues);
62
+ const parameters = operation.parameters;
63
+ let requestPath = operation.path;
64
+ for (const parameter of parameters.filter(({ location }) => location === 'path')) {
65
+ const value = pathValues[parameter.name];
66
+ if (value === undefined) {
67
+ throw new CmsRequestError(operation.localKey, `Missing required path parameter: ${parameter.name}`);
68
+ }
69
+ assertValueType(operation, parameter.name, parameter.type, value);
70
+ if (typeof value === 'string' && value.length === 0) {
71
+ throw new CmsRequestError(operation.localKey, `Empty path parameter: ${parameter.name}`);
72
+ }
73
+ requestPath = requestPath.replace(`{${parameter.name}}`, encodeURIComponent(String(value)));
74
+ }
75
+ const search = new URLSearchParams();
76
+ const queryParameters = parameters
77
+ .filter(({ location }) => location === 'query')
78
+ .toSorted((left, right) => left.name.localeCompare(right.name));
79
+ for (const parameter of queryParameters) {
80
+ const value = queryValues[parameter.name];
81
+ if (value === undefined) {
82
+ if (parameter.required) {
83
+ throw new CmsRequestError(operation.localKey, `Missing required query parameter: ${parameter.name}`);
84
+ }
85
+ continue;
86
+ }
87
+ assertValueType(operation, parameter.name, parameter.type, value);
88
+ if (parameter.type === 'string-array') {
89
+ for (const item of value)
90
+ search.append(parameter.name, item);
91
+ }
92
+ else {
93
+ search.set(parameter.name, String(value));
94
+ }
95
+ }
96
+ const query = search.toString();
97
+ return query.length > 0 ? `${requestPath}?${query}` : requestPath;
98
+ }
99
+ function successStatus(operation) {
100
+ const status = operation.responses.find(({ status: value }) => /^2\d\d$/u.test(value))?.status;
101
+ return status === undefined ? 200 : Number(status);
102
+ }
103
+ export async function requestJson(connection, operation, values = {}, options = {}) {
104
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
105
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
106
+ throw new CmsRequestError(operation.localKey, 'Request timeout must be a positive number');
107
+ }
108
+ if (options.signal?.aborted) {
109
+ throw new CmsRequestError(operation.localKey, 'CMS request cancelled');
110
+ }
111
+ const url = buildOperationUrl(operation, values);
112
+ const request = connection.request({ method: operation.method, url }, { timeout: timeoutMs });
113
+ const cancel = () => {
114
+ request.stream().destroy(new Error('CMS request cancelled'));
115
+ };
116
+ options.signal?.addEventListener('abort', cancel, { once: true });
117
+ try {
118
+ const data = await request;
119
+ return { data, operationKey: operation.localKey, status: successStatus(operation) };
120
+ }
121
+ catch (error) {
122
+ const message = options.signal?.aborted ? 'CMS request cancelled' : safeErrorMessage(error);
123
+ throw new CmsRequestError(operation.localKey, message, errorStatus(error));
124
+ }
125
+ finally {
126
+ options.signal?.removeEventListener('abort', cancel);
127
+ }
128
+ }
129
+ export function getSelectedOperation(operationKey) {
130
+ const operation = SELECTED_OPERATIONS.find(({ localKey }) => localKey === operationKey);
131
+ if (!operation)
132
+ throw new CmsRequestError(operationKey, `Unknown operation: ${operationKey}`);
133
+ return operation;
134
+ }
135
+ //# sourceMappingURL=json-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-request.js","sourceRoot":"","sources":["../../src/transport/json-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAkCpD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,YAAY,CAAgC;IAC5C,MAAM,CAAU;IAEhC,YACE,YAA2C,EAC3C,OAAe,EACf,MAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QA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K,CAAC,CAAC,CAAC;IAC7E,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,YAA2C;IAE3C,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC;IACxF,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,eAAe,CAAC,YAAY,EAAE,sBAAsB,YAAY,EAAE,CAAC,CAAC;IAC9F,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Redacts credential-shaped values from transport diagnostics without replacing ordinary prose.
3
+ * @param {string} message - Diagnostic text that may contain request credentials.
4
+ * @returns {string} The diagnostic text with recognized secret values replaced.
5
+ */
6
+ export declare function redactSecrets(message: string): string;
@@ -0,0 +1,31 @@
1
+ const REDACTED = '[REDACTED]';
2
+ const AUTHORIZATION_HEADERS = '(?:authorization|proxy-authorization)';
3
+ const COOKIE_HEADERS = '(?:cookie|set-cookie)';
4
+ const QUERY_KEYS = [
5
+ 'access_token',
6
+ 'id_token',
7
+ 'refresh_token',
8
+ 'signature',
9
+ 'sig',
10
+ 'token',
11
+ 'x-amz-credential',
12
+ 'x-amz-security-token',
13
+ 'x-amz-signature',
14
+ 'se',
15
+ 'sp',
16
+ 'sr',
17
+ 'sv',
18
+ ].join('|');
19
+ /**
20
+ * Redacts credential-shaped values from transport diagnostics without replacing ordinary prose.
21
+ * @param {string} message - Diagnostic text that may contain request credentials.
22
+ * @returns {string} The diagnostic text with recognized secret values replaced.
23
+ */
24
+ export function redactSecrets(message) {
25
+ return message
26
+ .replaceAll(new RegExp(String.raw `(${AUTHORIZATION_HEADERS}\s*[:=]\s*)(?:(?:bearer|basic)\s+)?[^\s,;]+`, 'giu'), `$1${REDACTED}`)
27
+ .replaceAll(new RegExp(String.raw `(${COOKIE_HEADERS}\s*[:=]\s*)[^\r\n]+`, 'giu'), `$1${REDACTED}`)
28
+ .replaceAll(/(bearer\s+)[a-z\d._~+/=-]+/giu, `$1${REDACTED}`)
29
+ .replaceAll(new RegExp(String.raw `([?&](?:${QUERY_KEYS})=)[^&#\s]+`, 'giu'), `$1${REDACTED}`);
30
+ }
31
+ //# sourceMappingURL=redact-secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact-secrets.js","sourceRoot":"","sources":["../../src/transport/redact-secrets.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AACtE,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,UAAU,GAAG;IACjB,cAAc;IACd,UAAU;IACV,eAAe;IACf,WAAW;IACX,KAAK;IACL,OAAO;IACP,kBAAkB;IAClB,sBAAsB;IACtB,iBAAiB;IACjB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,OAAO;SACX,UAAU,CACT,IAAI,MAAM,CACR,MAAM,CAAC,GAAG,CAAA,IAAI,qBAAqB,6CAA6C,EAChF,KAAK,CACN,EACD,KAAK,QAAQ,EAAE,CAChB;SACA,UAAU,CACT,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,IAAI,cAAc,qBAAqB,EAAE,KAAK,CAAC,EACpE,KAAK,QAAQ,EAAE,CAChB;SACA,UAAU,CAAC,+BAA+B,EAAE,KAAK,QAAQ,EAAE,CAAC;SAC5D,UAAU,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,WAAW,UAAU,aAAa,EAAE,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC,CAAC;AAClG,CAAC"}
@@ -0,0 +1,29 @@
1
+ # summary
2
+
3
+ Experimentally export a CMS workspace using a read-only, best-effort process.
4
+
5
+ # description
6
+
7
+ Reads a Marketing Cloud CMS workspace and writes the variants observed by an experimental, best-effort search. This is not a complete or guaranteed backup and does not mutate org data.
8
+
9
+ # examples
10
+
11
+ - Export the variants observed for one workspace into a new directory:
12
+
13
+ <%= config.bin %> <%= command.id %> --target-org my-org --workspace-id 0Zu... --output-dir ./cms-export
14
+
15
+ # flags.target-org.summary
16
+
17
+ Username or alias of the target Salesforce org.
18
+
19
+ # flags.api-version.summary
20
+
21
+ Salesforce API version used for CMS requests.
22
+
23
+ # flags.workspace-id.summary
24
+
25
+ CMS workspace content-space ID.
26
+
27
+ # flags.output-dir.summary
28
+
29
+ New directory to receive the experimental best-effort export.
@@ -0,0 +1,25 @@
1
+ # summary
2
+
3
+ Get a CMS channel.
4
+
5
+ # description
6
+
7
+ Retrieves a channel by its identifier.
8
+
9
+ # examples
10
+
11
+ - Get a channel:
12
+
13
+ <%= config.bin %> <%= command.id %> --target-org my-org --channel-id 0ap...
14
+
15
+ # flags.target-org.summary
16
+
17
+ Username or alias of the target Salesforce org.
18
+
19
+ # flags.api-version.summary
20
+
21
+ Salesforce API version used for CMS requests.
22
+
23
+ # flags.channel-id.summary
24
+
25
+ CMS channel identifier.
@@ -0,0 +1,41 @@
1
+ # summary
2
+
3
+ Get CMS content.
4
+
5
+ # description
6
+
7
+ Retrieves content by its key or identifier.
8
+
9
+ # examples
10
+
11
+ - Get content:
12
+
13
+ <%= config.bin %> <%= command.id %> --target-org my-org --content-key-or-id news-banner
14
+
15
+ # flags.target-org.summary
16
+
17
+ Username or alias of the target Salesforce org.
18
+
19
+ # flags.api-version.summary
20
+
21
+ Salesforce API version used for CMS requests.
22
+
23
+ # flags.content-key-or-id.summary
24
+
25
+ CMS content key or identifier.
26
+
27
+ # flags.content-version.summary
28
+
29
+ Content version selector.
30
+
31
+ # flags.language.summary
32
+
33
+ Content language selector.
34
+
35
+ # flags.variant-version.summary
36
+
37
+ Variant version selector.
38
+
39
+ # flags.version.summary
40
+
41
+ Document version selector.
@@ -0,0 +1,25 @@
1
+ # summary
2
+
3
+ Get a CMS content variant.
4
+
5
+ # description
6
+
7
+ Retrieves a content variant by its identifier.
8
+
9
+ # examples
10
+
11
+ - Get a variant:
12
+
13
+ <%= config.bin %> <%= command.id %> --target-org my-org --variant-id 0aV...
14
+
15
+ # flags.target-org.summary
16
+
17
+ Username or alias of the target Salesforce org.
18
+
19
+ # flags.api-version.summary
20
+
21
+ Salesforce API version used for CMS requests.
22
+
23
+ # flags.variant-id.summary
24
+
25
+ CMS content variant identifier.
@@ -0,0 +1,25 @@
1
+ # summary
2
+
3
+ Get a Marketing Cloud CMS workspace.
4
+
5
+ # description
6
+
7
+ Retrieves one CMS workspace by its content-space ID.
8
+
9
+ # examples
10
+
11
+ - Get a workspace:
12
+
13
+ <%= config.bin %> <%= command.id %> --target-org my-org --workspace-id 0Zu...
14
+
15
+ # flags.target-org.summary
16
+
17
+ Username or alias of the target Salesforce org.
18
+
19
+ # flags.api-version.summary
20
+
21
+ Salesforce API version used for CMS requests.
22
+
23
+ # flags.workspace-id.summary
24
+
25
+ CMS workspace content-space ID.