@salesforce/plugin-orchestrator 1.0.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 +28 -0
- package/LICENSE.txt +12 -0
- package/README.md +145 -0
- package/lib/commands/orchestrator/create/app.d.ts +19 -0
- package/lib/commands/orchestrator/create/app.js +144 -0
- package/lib/commands/orchestrator/create/app.js.map +1 -0
- package/lib/commands/orchestrator/create/template.d.ts +17 -0
- package/lib/commands/orchestrator/create/template.js +96 -0
- package/lib/commands/orchestrator/create/template.js.map +1 -0
- package/lib/commands/orchestrator/decouple/app.d.ts +14 -0
- package/lib/commands/orchestrator/decouple/app.js +106 -0
- package/lib/commands/orchestrator/decouple/app.js.map +1 -0
- package/lib/commands/orchestrator/delete/app.d.ts +15 -0
- package/lib/commands/orchestrator/delete/app.js +102 -0
- package/lib/commands/orchestrator/delete/app.js.map +1 -0
- package/lib/commands/orchestrator/delete/template.d.ts +15 -0
- package/lib/commands/orchestrator/delete/template.js +108 -0
- package/lib/commands/orchestrator/delete/template.js.map +1 -0
- package/lib/commands/orchestrator/display/app.d.ts +15 -0
- package/lib/commands/orchestrator/display/app.js +85 -0
- package/lib/commands/orchestrator/display/app.js.map +1 -0
- package/lib/commands/orchestrator/display/template.d.ts +15 -0
- package/lib/commands/orchestrator/display/template.js +105 -0
- package/lib/commands/orchestrator/display/template.js.map +1 -0
- package/lib/commands/orchestrator/list/app.d.ts +13 -0
- package/lib/commands/orchestrator/list/app.js +62 -0
- package/lib/commands/orchestrator/list/app.js.map +1 -0
- package/lib/commands/orchestrator/list/template.d.ts +14 -0
- package/lib/commands/orchestrator/list/template.js +64 -0
- package/lib/commands/orchestrator/list/template.js.map +1 -0
- package/lib/commands/orchestrator/template/create.d.ts +17 -0
- package/lib/commands/orchestrator/template/create.js +96 -0
- package/lib/commands/orchestrator/template/create.js.map +1 -0
- package/lib/commands/orchestrator/template/delete.d.ts +15 -0
- package/lib/commands/orchestrator/template/delete.js +108 -0
- package/lib/commands/orchestrator/template/delete.js.map +1 -0
- package/lib/commands/orchestrator/template/display.d.ts +15 -0
- package/lib/commands/orchestrator/template/display.js +105 -0
- package/lib/commands/orchestrator/template/display.js.map +1 -0
- package/lib/commands/orchestrator/template/list.d.ts +13 -0
- package/lib/commands/orchestrator/template/list.js +62 -0
- package/lib/commands/orchestrator/template/list.js.map +1 -0
- package/lib/commands/orchestrator/template/update.d.ts +17 -0
- package/lib/commands/orchestrator/template/update.js +107 -0
- package/lib/commands/orchestrator/template/update.js.map +1 -0
- package/lib/commands/orchestrator/update/app.d.ts +20 -0
- package/lib/commands/orchestrator/update/app.js +145 -0
- package/lib/commands/orchestrator/update/app.js.map +1 -0
- package/lib/commands/orchestrator/update/template.d.ts +17 -0
- package/lib/commands/orchestrator/update/template.js +107 -0
- package/lib/commands/orchestrator/update/template.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/app/appDisplayUtil.d.ts +26 -0
- package/lib/utils/app/appDisplayUtil.js +153 -0
- package/lib/utils/app/appDisplayUtil.js.map +1 -0
- package/lib/utils/app/appListUtils.d.ts +34 -0
- package/lib/utils/app/appListUtils.js +81 -0
- package/lib/utils/app/appListUtils.js.map +1 -0
- package/lib/utils/app/appTypes.d.ts +44 -0
- package/lib/utils/app/appTypes.js +8 -0
- package/lib/utils/app/appTypes.js.map +1 -0
- package/lib/utils/app/appframeworkapp.d.ts +64 -0
- package/lib/utils/app/appframeworkapp.js +175 -0
- package/lib/utils/app/appframeworkapp.js.map +1 -0
- package/lib/utils/display/displayUtil.d.ts +27 -0
- package/lib/utils/display/displayUtil.js +80 -0
- package/lib/utils/display/displayUtil.js.map +1 -0
- package/lib/utils/request.d.ts +15 -0
- package/lib/utils/request.js +18 -0
- package/lib/utils/request.js.map +1 -0
- package/lib/utils/template/appframeworktemplate.d.ts +67 -0
- package/lib/utils/template/appframeworktemplate.js +114 -0
- package/lib/utils/template/appframeworktemplate.js.map +1 -0
- package/lib/utils/template/templateDisplayUtil.d.ts +42 -0
- package/lib/utils/template/templateDisplayUtil.js +142 -0
- package/lib/utils/template/templateDisplayUtil.js.map +1 -0
- package/lib/utils/template/templateHighlighter.d.ts +23 -0
- package/lib/utils/template/templateHighlighter.js +68 -0
- package/lib/utils/template/templateHighlighter.js.map +1 -0
- package/lib/utils/template/templateListUtils.d.ts +40 -0
- package/lib/utils/template/templateListUtils.js +126 -0
- package/lib/utils/template/templateListUtils.js.map +1 -0
- package/lib/utils/template/templateTypes.d.ts +114 -0
- package/lib/utils/template/templateTypes.js +15 -0
- package/lib/utils/template/templateTypes.js.map +1 -0
- package/lib/utils/utils.d.ts +21 -0
- package/lib/utils/utils.js +49 -0
- package/lib/utils/utils.js.map +1 -0
- package/messages/appframework.create.app.md +124 -0
- package/messages/appframework.create.template.md +82 -0
- package/messages/appframework.decouple.app.md +82 -0
- package/messages/appframework.delete.app.md +94 -0
- package/messages/appframework.delete.template.md +162 -0
- package/messages/appframework.display.app.md +70 -0
- package/messages/appframework.display.template.md +101 -0
- package/messages/appframework.list.app.md +126 -0
- package/messages/appframework.list.template.md +78 -0
- package/messages/appframework.template.create.md +82 -0
- package/messages/appframework.template.delete.md +162 -0
- package/messages/appframework.template.display.md +101 -0
- package/messages/appframework.template.list.md +78 -0
- package/messages/appframework.template.update.md +78 -0
- package/messages/appframework.update.app.md +142 -0
- package/messages/appframework.update.template.md +78 -0
- package/npm-shrinkwrap.json +14309 -0
- package/oclif.lock +7751 -0
- package/oclif.manifest.json +1731 -0
- package/package.json +226 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { request } from '../request.js';
|
|
2
|
+
export default class AppFrameworkTemplate {
|
|
3
|
+
connection;
|
|
4
|
+
constructor(connection) {
|
|
5
|
+
this.connection = connection;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* List templates in the org
|
|
9
|
+
*
|
|
10
|
+
* @returns Array of template objects
|
|
11
|
+
*/
|
|
12
|
+
async list() {
|
|
13
|
+
const url = '/templates';
|
|
14
|
+
const response = await request(this.connection, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
url,
|
|
17
|
+
});
|
|
18
|
+
return response?.templates ?? [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get a specific template by ID or name
|
|
22
|
+
*
|
|
23
|
+
* @param idOrName - ID or name of the template to retrieve
|
|
24
|
+
* @returns Template object or null if not found
|
|
25
|
+
*/
|
|
26
|
+
async getTemplate(idOrName) {
|
|
27
|
+
if (!idOrName) {
|
|
28
|
+
throw new Error('Template ID or name must be provided');
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const url = `/templates/${idOrName}`;
|
|
32
|
+
const template = await request(this.connection, {
|
|
33
|
+
method: 'GET',
|
|
34
|
+
url,
|
|
35
|
+
});
|
|
36
|
+
return template;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.statusCode !== 404) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const templates = await this.list();
|
|
44
|
+
const template = templates.find((t) => t.name === idOrName);
|
|
45
|
+
return template ?? null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a new template
|
|
49
|
+
*
|
|
50
|
+
* @param options - Template creation options
|
|
51
|
+
* @returns The ID of the newly created template
|
|
52
|
+
*/
|
|
53
|
+
async create(options) {
|
|
54
|
+
const url = '/templates';
|
|
55
|
+
const body = Object.fromEntries(Object.entries({
|
|
56
|
+
name: options.name,
|
|
57
|
+
templateType: options.templateType ?? 'app',
|
|
58
|
+
templateSubtype: options.templateSubtype,
|
|
59
|
+
label: options.label,
|
|
60
|
+
description: options.description,
|
|
61
|
+
maxAppCount: options.maxAppCount,
|
|
62
|
+
tags: options.tags,
|
|
63
|
+
releaseInfo: options.releaseInfo,
|
|
64
|
+
}).filter((entries) => entries[1] !== undefined));
|
|
65
|
+
const response = await request(this.connection, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
url,
|
|
68
|
+
body,
|
|
69
|
+
});
|
|
70
|
+
return response.id;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Update an existing template
|
|
74
|
+
*
|
|
75
|
+
* Note: Only label and description fields can be updated directly.
|
|
76
|
+
* The template's name cannot be updated as it's a unique identifier.
|
|
77
|
+
*
|
|
78
|
+
* @param templateIdOrName - ID or name of the template to update
|
|
79
|
+
* @param options - Optional update options
|
|
80
|
+
* @param options.label - Optional new label for the template
|
|
81
|
+
* @param options.description - Optional new description for the template
|
|
82
|
+
* @returns The updated template data
|
|
83
|
+
*/
|
|
84
|
+
async update(templateIdOrName, options) {
|
|
85
|
+
const template = await this.getTemplate(templateIdOrName);
|
|
86
|
+
if (!template) {
|
|
87
|
+
throw new Error(`Template "${templateIdOrName}" not found`);
|
|
88
|
+
}
|
|
89
|
+
const url = `/templates/${template.id}`;
|
|
90
|
+
const body = Object.fromEntries(Object.entries({
|
|
91
|
+
label: options?.label,
|
|
92
|
+
description: options?.description,
|
|
93
|
+
}).filter((entries) => entries[1] !== undefined));
|
|
94
|
+
const response = await request(this.connection, {
|
|
95
|
+
method: 'PATCH',
|
|
96
|
+
url,
|
|
97
|
+
body,
|
|
98
|
+
});
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Delete a template
|
|
103
|
+
*
|
|
104
|
+
* @param templateId - ID of the template to delete
|
|
105
|
+
*/
|
|
106
|
+
async deleteTemplate(templateId) {
|
|
107
|
+
const url = `/templates/${templateId}`;
|
|
108
|
+
await request(this.connection, {
|
|
109
|
+
method: 'DELETE',
|
|
110
|
+
url,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=appframeworktemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appframeworktemplate.js","sourceRoot":"","sources":["../../../src/utils/template/appfram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,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CACjD,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAc,IAAI,CAAC,UAAU,EAAE;YAC3D,MAAM,EAAE,OAAO;YACf,GAAG;YACH,IAAI;SACL,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,UAAkB;QAC5C,MAAM,GAAG,GAAG,cAAc,UAAU,EAAE,CAAC;QACvC,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YAC7B,MAAM,EAAE,QAAQ;YAChB,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { TemplateData } from './templateTypes.js';
|
|
3
|
+
export declare class TemplateDisplayUtil {
|
|
4
|
+
/**
|
|
5
|
+
* Process templates data for table display
|
|
6
|
+
* This can be expanded with any additional processing needs
|
|
7
|
+
*
|
|
8
|
+
* @param templates - Raw template data
|
|
9
|
+
* @returns Processed template data ready for display
|
|
10
|
+
*/
|
|
11
|
+
static processTemplatesForDisplay(templates: TemplateData[]): TemplateData[];
|
|
12
|
+
/**
|
|
13
|
+
* Display detailed information about a single template
|
|
14
|
+
*
|
|
15
|
+
* @param command - The SfCommand instance
|
|
16
|
+
* @param template - The template data to display
|
|
17
|
+
*/
|
|
18
|
+
static displayTemplateDetail(command: SfCommand<unknown>, template: TemplateData): void;
|
|
19
|
+
/**
|
|
20
|
+
* Display a list of templates in a table format
|
|
21
|
+
*
|
|
22
|
+
* @param command - The SfCommand instance
|
|
23
|
+
* @param templates - The template data to display
|
|
24
|
+
* @param title - Optional title for the table
|
|
25
|
+
*/
|
|
26
|
+
static displayTemplateList(command: SfCommand<unknown>, templates: TemplateData[], title?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get color function based on template type
|
|
29
|
+
*
|
|
30
|
+
* @param templateType - The template type string
|
|
31
|
+
* @returns A color function to apply to text
|
|
32
|
+
*/
|
|
33
|
+
private static getTemplateTypeColor;
|
|
34
|
+
/**
|
|
35
|
+
* Display a section of template details
|
|
36
|
+
*
|
|
37
|
+
* @param command - The command instance
|
|
38
|
+
* @param title - Section title
|
|
39
|
+
* @param details - Key-value pairs to display
|
|
40
|
+
*/
|
|
41
|
+
private static displaySection;
|
|
42
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import ansis from 'ansis';
|
|
8
|
+
export class TemplateDisplayUtil {
|
|
9
|
+
/**
|
|
10
|
+
* Process templates data for table display
|
|
11
|
+
* This can be expanded with any additional processing needs
|
|
12
|
+
*
|
|
13
|
+
* @param templates - Raw template data
|
|
14
|
+
* @returns Processed template data ready for display
|
|
15
|
+
*/
|
|
16
|
+
static processTemplatesForDisplay(templates) {
|
|
17
|
+
return templates;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Display detailed information about a single template
|
|
21
|
+
*
|
|
22
|
+
* @param command - The SfCommand instance
|
|
23
|
+
* @param template - The template data to display
|
|
24
|
+
*/
|
|
25
|
+
static displayTemplateDetail(command, template) {
|
|
26
|
+
const templateTypeString = String(template.templateType ?? 'unknown');
|
|
27
|
+
const typeColor = this.getTemplateTypeColor(templateTypeString);
|
|
28
|
+
const templateLabel = String(template.label ?? template.name ?? template.id);
|
|
29
|
+
command.log('');
|
|
30
|
+
command.styledHeader(`Template Details: ${typeColor(templateLabel)}`);
|
|
31
|
+
this.displaySection(command, 'Basic Information', {
|
|
32
|
+
ID: template.id,
|
|
33
|
+
Name: template.name,
|
|
34
|
+
Label: template.label,
|
|
35
|
+
Description: template.description,
|
|
36
|
+
Type: typeColor(templateTypeString),
|
|
37
|
+
Subtype: template.templateSubtype,
|
|
38
|
+
Namespace: template.namespace,
|
|
39
|
+
'Origin App ID': template.applicationSourceId,
|
|
40
|
+
'Max App Count': template.maxAppCount,
|
|
41
|
+
});
|
|
42
|
+
this.displaySection(command, 'Version Information', {
|
|
43
|
+
'Template Version': template.templateVersion,
|
|
44
|
+
'Asset Version': template.assetVersion,
|
|
45
|
+
Created: ansis.dim(template.created ?? 'n/a'),
|
|
46
|
+
'Last Modified': ansis.dim(template.modified ?? 'n/a'),
|
|
47
|
+
});
|
|
48
|
+
this.displaySection(command, 'References', {
|
|
49
|
+
'Template ID': template.templateId,
|
|
50
|
+
'Folder ID': template.folderId,
|
|
51
|
+
'API URL': template.url,
|
|
52
|
+
'Configuration URL': template.configurationUrl,
|
|
53
|
+
'Readiness URL': template.readinessUrl,
|
|
54
|
+
});
|
|
55
|
+
this.displaySection(command, 'Content Details', {
|
|
56
|
+
Industries: template.industries,
|
|
57
|
+
'Target Audience': template.audience,
|
|
58
|
+
'Rules Count': template.rules?.length ?? 0,
|
|
59
|
+
'Chain Definitions Count': template.chainDefinitions?.length ?? 0,
|
|
60
|
+
'Has Icons': template.icons ? 'Yes' : 'No',
|
|
61
|
+
'Has Variable Definition': template.variableDefinition ? 'Yes' : 'No',
|
|
62
|
+
'Has Layout Definition': template.layoutDefinition ? 'Yes' : 'No',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Display a list of templates in a table format
|
|
67
|
+
*
|
|
68
|
+
* @param command - The SfCommand instance
|
|
69
|
+
* @param templates - The template data to display
|
|
70
|
+
* @param title - Optional title for the table
|
|
71
|
+
*/
|
|
72
|
+
static displayTemplateList(command, templates, title = 'AppFramework Templates') {
|
|
73
|
+
if (templates.length === 0) {
|
|
74
|
+
command.log('No templates found.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
command.styledHeader(`Found ${templates.length} template(s)`);
|
|
78
|
+
const tableData = templates.map((template) => {
|
|
79
|
+
const typeString = String(template.templateType ?? 'n/a');
|
|
80
|
+
const typeWithColor = this.getTemplateTypeColor(typeString)(typeString);
|
|
81
|
+
return {
|
|
82
|
+
Id: template.id ?? 'n/a',
|
|
83
|
+
Type: typeWithColor,
|
|
84
|
+
Version: template.templateVersion ?? 'n/a',
|
|
85
|
+
Subtype: template.templateSubtype ?? 'n/a',
|
|
86
|
+
Name: template.name ?? 'n/a',
|
|
87
|
+
Label: template.label ?? 'n/a',
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
command.table({
|
|
91
|
+
data: tableData,
|
|
92
|
+
title,
|
|
93
|
+
columns: [
|
|
94
|
+
{ key: 'Id', width: '30%' },
|
|
95
|
+
{ key: 'Name', width: '25%' },
|
|
96
|
+
{ key: 'Label', width: '25%' },
|
|
97
|
+
{ key: 'Type', width: '10%' },
|
|
98
|
+
{ key: 'Subtype', width: '5%' },
|
|
99
|
+
{ key: 'Version', width: '5%' },
|
|
100
|
+
],
|
|
101
|
+
overflow: 'truncate-end',
|
|
102
|
+
sort: {
|
|
103
|
+
Label: 'asc',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
command.log('');
|
|
107
|
+
command.log(`Legend: ${ansis.green('app')} - Application templates, ${ansis.blue('component')} - Component templates, ${ansis.yellow('other')} - Other template types`);
|
|
108
|
+
command.log('');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get color function based on template type
|
|
112
|
+
*
|
|
113
|
+
* @param templateType - The template type string
|
|
114
|
+
* @returns A color function to apply to text
|
|
115
|
+
*/
|
|
116
|
+
static getTemplateTypeColor(templateType) {
|
|
117
|
+
const typeString = templateType.toLowerCase();
|
|
118
|
+
if (typeString === 'app') {
|
|
119
|
+
return ansis.green;
|
|
120
|
+
}
|
|
121
|
+
else if (typeString === 'component') {
|
|
122
|
+
return ansis.blue;
|
|
123
|
+
}
|
|
124
|
+
return ansis.yellow;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Display a section of template details
|
|
128
|
+
*
|
|
129
|
+
* @param command - The command instance
|
|
130
|
+
* @param title - Section title
|
|
131
|
+
* @param details - Key-value pairs to display
|
|
132
|
+
*/
|
|
133
|
+
static displaySection(command, title, details) {
|
|
134
|
+
command.log(ansis.bold(`=== ${title}`));
|
|
135
|
+
for (const [key, value] of Object.entries(details)) {
|
|
136
|
+
const formattedValue = value === null || value === undefined ? 'n/a' : String(value);
|
|
137
|
+
command.log(`${ansis.bold(`${key}:`)} ${formattedValue}`);
|
|
138
|
+
}
|
|
139
|
+
command.log('');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=templateDisplayUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateDisplayUtil.js","sourceRoot":"","sources":["../../../src/utils/template/templateDisplayUtil.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,OAAO,mBAAmB;IAC9B;;;;;;OAMG;IACI,MAAM,CAAC,0BAA0B,CAAC,SAAyB;QAChE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,qBAAqB,CAAC,OAA2B,EAAE,QAAsB;QACrF,MAAM,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC;QACtE,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;QAChE,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE7E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,YAAY,CAAC,qBA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c,CAAC,OAA2B,EAAE,KAAa,EAAE,OAAgC;QACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;QAExC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,MAAM,cAAc,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrF,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TemplateData } from './templateTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Style a value based on predefined styling rules
|
|
4
|
+
*
|
|
5
|
+
* @param key - The field name to style
|
|
6
|
+
* @param value - The value to style
|
|
7
|
+
* @returns The styled value
|
|
8
|
+
*/
|
|
9
|
+
export declare const getStyledValue: (key: string, value: string | null | undefined) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Apply styling to all fields in a template object based on predefined rules
|
|
12
|
+
*
|
|
13
|
+
* @param objectToStyle - The template object to style
|
|
14
|
+
* @returns A new object with styled field values
|
|
15
|
+
*/
|
|
16
|
+
export declare const getStyledObject: (objectToStyle: TemplateData) => TemplateData;
|
|
17
|
+
/**
|
|
18
|
+
* Group templates by type for better organization
|
|
19
|
+
*
|
|
20
|
+
* @param templates - Array of template data
|
|
21
|
+
* @returns Object with templates grouped by type
|
|
22
|
+
*/
|
|
23
|
+
export declare const groupTemplatesByType: (templates: TemplateData[]) => Record<string, TemplateData[]>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import ansis from 'ansis';
|
|
8
|
+
const styledProperties = new Map([
|
|
9
|
+
[
|
|
10
|
+
'templateType',
|
|
11
|
+
new Map([
|
|
12
|
+
['app', ansis.greenBright],
|
|
13
|
+
['component', ansis.cyanBright],
|
|
14
|
+
['else', ansis.yellowBright],
|
|
15
|
+
]),
|
|
16
|
+
],
|
|
17
|
+
['templateVersion', new Map([['else', ansis.blue]])],
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Style a value based on predefined styling rules
|
|
21
|
+
*
|
|
22
|
+
* @param key - The field name to style
|
|
23
|
+
* @param value - The value to style
|
|
24
|
+
* @returns The styled value
|
|
25
|
+
*/
|
|
26
|
+
export const getStyledValue = (key, value) => {
|
|
27
|
+
if (value === null || value === undefined)
|
|
28
|
+
return '';
|
|
29
|
+
const prop = styledProperties.get(key);
|
|
30
|
+
if (!prop)
|
|
31
|
+
return value;
|
|
32
|
+
const colorMethod = prop.get(value) ?? prop.get('else');
|
|
33
|
+
return colorMethod(value);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Apply styling to all fields in a template object based on predefined rules
|
|
37
|
+
*
|
|
38
|
+
* @param objectToStyle - The template object to style
|
|
39
|
+
* @returns A new object with styled field values
|
|
40
|
+
*/
|
|
41
|
+
export const getStyledObject = (objectToStyle) => Object.fromEntries(Object.entries(objectToStyle).map(([key, value]) => [
|
|
42
|
+
key,
|
|
43
|
+
typeof value === 'string' ? getStyledValue(key, value) : value,
|
|
44
|
+
]));
|
|
45
|
+
/**
|
|
46
|
+
* Group templates by type for better organization
|
|
47
|
+
*
|
|
48
|
+
* @param templates - Array of template data
|
|
49
|
+
* @returns Object with templates grouped by type
|
|
50
|
+
*/
|
|
51
|
+
export const groupTemplatesByType = (templates) => {
|
|
52
|
+
const groups = {
|
|
53
|
+
app: [],
|
|
54
|
+
component: [],
|
|
55
|
+
other: [],
|
|
56
|
+
};
|
|
57
|
+
templates.forEach((template) => {
|
|
58
|
+
const type = template.templateType?.toLowerCase() ?? 'other';
|
|
59
|
+
if (type === 'app' || type === 'component') {
|
|
60
|
+
groups[type].push(template);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
groups.other.push(template);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return groups;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=templateHighlighter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateHighlighter.js","sourceRoot":"","sources":["../../../src/utils/template/templateHighlighter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAA6B;IAC3D;QACE,cAAc;QACd,IAAI,GAAG,CAAC;YACN,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC;YAC1B,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC;YAC/B,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC;SAC7B,CAAC;KACH;IACD,CAAC,iBAAiB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,KAAgC,EAAU,EAAE;IACtF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAErD,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvC,IAA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
+
import { TemplateData, RawTemplate, Icon, Rule } from './templateTypes.js';
|
|
2
|
+
export type TemplateOutputField = keyof TemplateData;
|
|
3
|
+
export type TemplateOutput = Record<string, string | number | Icon | Rule[] | undefined>;
|
|
4
|
+
export declare const DETAILED_FIELDS: TemplateOutputField[];
|
|
5
|
+
export declare const SIMPLE_FIELDS: TemplateOutputField[];
|
|
6
|
+
/**
|
|
7
|
+
* Process raw templates from the API into a structured format
|
|
8
|
+
*
|
|
9
|
+
* @param rawTemplates - Raw template data from the API
|
|
10
|
+
* @returns Processed template data
|
|
11
|
+
*/
|
|
12
|
+
export declare const processTemplates: (rawTemplates: RawTemplate[]) => TemplateData[];
|
|
13
|
+
/**
|
|
14
|
+
* Process templates for display with customizable field selection
|
|
15
|
+
*
|
|
16
|
+
* @param templates - Template data array
|
|
17
|
+
* @param fields - Fields to include in the output
|
|
18
|
+
* @returns Processed template data for display
|
|
19
|
+
*/
|
|
20
|
+
export declare const processTemplateOutput: (templates: TemplateData[], fields?: TemplateOutputField[]) => TemplateOutput[];
|
|
21
|
+
/**
|
|
22
|
+
* Process templates for detailed display
|
|
23
|
+
*
|
|
24
|
+
* @param templates - Template data array
|
|
25
|
+
* @returns Processed template data for detailed display
|
|
26
|
+
*/
|
|
27
|
+
export declare const processOutput: (templates: TemplateData[]) => TemplateOutput[];
|
|
28
|
+
/**
|
|
29
|
+
* Process templates for simple display
|
|
30
|
+
*
|
|
31
|
+
* @param templates - Template data array
|
|
32
|
+
* @returns Processed template data for simple display
|
|
33
|
+
*/
|
|
34
|
+
export declare const processSimpleOutput: (templates: TemplateData[]) => TemplateOutput[];
|
|
35
|
+
export declare class TemplateListUtil {
|
|
36
|
+
static processTemplates: (rawTemplates: RawTemplate[]) => TemplateData[];
|
|
37
|
+
static processOutput: (templates: TemplateData[]) => TemplateOutput[];
|
|
38
|
+
static processSimpleOutput: (templates: TemplateData[]) => TemplateOutput[];
|
|
39
|
+
static processTemplate: (rawTemplate: RawTemplate) => TemplateData;
|
|
40
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Define standard field sets
|
|
2
|
+
export const DETAILED_FIELDS = [
|
|
3
|
+
'name',
|
|
4
|
+
'label',
|
|
5
|
+
'templateId',
|
|
6
|
+
'templateType',
|
|
7
|
+
'namespace',
|
|
8
|
+
'templateVersion',
|
|
9
|
+
'created',
|
|
10
|
+
'modified',
|
|
11
|
+
'description',
|
|
12
|
+
'industries',
|
|
13
|
+
'audience',
|
|
14
|
+
];
|
|
15
|
+
export const SIMPLE_FIELDS = [
|
|
16
|
+
'label',
|
|
17
|
+
'templateId',
|
|
18
|
+
'name',
|
|
19
|
+
'templateType',
|
|
20
|
+
'templateSubtype',
|
|
21
|
+
'templateVersion',
|
|
22
|
+
'applicationSourceId',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Helper for date formatting
|
|
26
|
+
*/
|
|
27
|
+
const formatDate = (dateString) => (dateString ? new Date(dateString).toLocaleDateString() : 'n/a');
|
|
28
|
+
/**
|
|
29
|
+
* Helper for default values
|
|
30
|
+
*/
|
|
31
|
+
const defaultIfEmpty = (value, defaultValue = 'n/a') => value ? (Array.isArray(value) ? value.join(', ') : value) : defaultValue;
|
|
32
|
+
/**
|
|
33
|
+
* Capitalize the first letter of a string
|
|
34
|
+
*/
|
|
35
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
36
|
+
/**
|
|
37
|
+
* Process a single raw template into a structured format
|
|
38
|
+
*
|
|
39
|
+
* @param rawTemplate - Raw template data from the API
|
|
40
|
+
* @returns Processed template data
|
|
41
|
+
*/
|
|
42
|
+
const processTemplate = (rawTemplate) => ({
|
|
43
|
+
id: rawTemplate.id,
|
|
44
|
+
name: rawTemplate.name,
|
|
45
|
+
label: rawTemplate.label,
|
|
46
|
+
description: rawTemplate.description,
|
|
47
|
+
templateType: rawTemplate.templateType,
|
|
48
|
+
templateId: rawTemplate.templateId,
|
|
49
|
+
folderId: rawTemplate.folderId,
|
|
50
|
+
namespace: rawTemplate.namespace,
|
|
51
|
+
templateVersion: rawTemplate.releaseInfo?.templateVersion,
|
|
52
|
+
assetVersion: rawTemplate.assetVersion,
|
|
53
|
+
created: formatDate(rawTemplate.createdDate),
|
|
54
|
+
modified: formatDate(rawTemplate.lastModifiedDate),
|
|
55
|
+
industries: defaultIfEmpty(rawTemplate.tags?.industries),
|
|
56
|
+
audience: defaultIfEmpty(rawTemplate.tags?.targetAudience),
|
|
57
|
+
templateSubtype: rawTemplate.templateSubtype,
|
|
58
|
+
applicationSourceId: rawTemplate.applicationSourceId,
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Process raw templates from the API into a structured format
|
|
62
|
+
*
|
|
63
|
+
* @param rawTemplates - Raw template data from the API
|
|
64
|
+
* @returns Processed template data
|
|
65
|
+
*/
|
|
66
|
+
export const processTemplates = (rawTemplates) => {
|
|
67
|
+
if (!rawTemplates?.length) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return rawTemplates.map(processTemplate);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Process templates for display with customizable field selection
|
|
74
|
+
*
|
|
75
|
+
* @param templates - Template data array
|
|
76
|
+
* @param fields - Fields to include in the output
|
|
77
|
+
* @returns Processed template data for display
|
|
78
|
+
*/
|
|
79
|
+
export const processTemplateOutput = (templates, fields = DETAILED_FIELDS) => templates.map((template) => {
|
|
80
|
+
const output = {};
|
|
81
|
+
fields.forEach((field) => {
|
|
82
|
+
const value = template[field];
|
|
83
|
+
// Special case for applicationSourceId to match the expected "SourceID" in tests
|
|
84
|
+
if (field === 'applicationSourceId') {
|
|
85
|
+
output['SourceID'] = value ?? 'n/a';
|
|
86
|
+
}
|
|
87
|
+
// Special case for templateType to match the expected "Type" in tests
|
|
88
|
+
else if (field === 'templateType') {
|
|
89
|
+
output['Type'] = value ?? 'n/a';
|
|
90
|
+
}
|
|
91
|
+
// Special case for templateSubtype to match the expected "SubType" in tests
|
|
92
|
+
else if (field === 'templateSubtype') {
|
|
93
|
+
output['SubType'] = value ?? 'n/a';
|
|
94
|
+
}
|
|
95
|
+
// Special case for templateVersion to match the expected "Version" in tests
|
|
96
|
+
else if (field === 'templateVersion') {
|
|
97
|
+
output['Version'] = value ?? 'n/a';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
output[capitalizeFirstLetter(field.toString())] = value ?? 'n/a';
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return output;
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Process templates for detailed display
|
|
107
|
+
*
|
|
108
|
+
* @param templates - Template data array
|
|
109
|
+
* @returns Processed template data for detailed display
|
|
110
|
+
*/
|
|
111
|
+
export const processOutput = (templates) => processTemplateOutput(templates, DETAILED_FIELDS);
|
|
112
|
+
/**
|
|
113
|
+
* Process templates for simple display
|
|
114
|
+
*
|
|
115
|
+
* @param templates - Template data array
|
|
116
|
+
* @returns Processed template data for simple display
|
|
117
|
+
*/
|
|
118
|
+
export const processSimpleOutput = (templates) => processTemplateOutput(templates, SIMPLE_FIELDS);
|
|
119
|
+
// For backward compatibility with code that uses the class-based approach
|
|
120
|
+
export class TemplateListUtil {
|
|
121
|
+
static processTemplates = processTemplates;
|
|
122
|
+
static processOutput = processOutput;
|
|
123
|
+
static processSimpleOutput = processSimpleOutput;
|
|
124
|
+
static processTemplate = processTemplate;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=templateListUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateListUtils.js","sourceRoot":"","sources":["../../../src/utils/template/templateListUtils.ts"],"names":[],"mappings":"AAcA,6BAA6B;AAC7B,MAAM,CAAC,MAAM,eAAe,GAA0B;IACpD,MAAM;IACN,OAAO;IACP,YAAY;IACZ,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,SAAS;IACT,UAAU;IACV,aAAa;IACb,YAAY;IACZ,UAAU;CACX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