@copado/agentia-cli 0.56.0-alpha.0 → 0.58.0-alpha.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/README.md +1180 -117
- package/dist/commands/cicd/data/commit/create.d.ts +11 -0
- package/dist/commands/cicd/data/commit/create.js +41 -0
- package/dist/commands/cicd/data/commit/create.js.map +1 -0
- package/dist/commands/cicd/data/commit/list.d.ts +10 -0
- package/dist/commands/cicd/data/commit/list.js +42 -0
- package/dist/commands/cicd/data/commit/list.js.map +1 -0
- package/dist/commands/cicd/data/dataset-file/content.d.ts +10 -0
- package/dist/commands/cicd/data/dataset-file/content.js +53 -0
- package/dist/commands/cicd/data/dataset-file/content.js.map +1 -0
- package/dist/commands/cicd/data/dataset-file/list.d.ts +10 -0
- package/dist/commands/cicd/data/dataset-file/list.js +42 -0
- package/dist/commands/cicd/data/dataset-file/list.js.map +1 -0
- package/dist/commands/cicd/data/filter/add.d.ts +13 -0
- package/dist/commands/cicd/data/filter/add.js +42 -0
- package/dist/commands/cicd/data/filter/add.js.map +1 -0
- package/dist/commands/cicd/data/filter/delete.d.ts +10 -0
- package/dist/commands/cicd/data/filter/delete.js +33 -0
- package/dist/commands/cicd/data/filter/delete.js.map +1 -0
- package/dist/commands/cicd/data/filter/list.d.ts +10 -0
- package/dist/commands/cicd/data/filter/list.js +42 -0
- package/dist/commands/cicd/data/filter/list.js.map +1 -0
- package/dist/commands/cicd/data/filter/update.d.ts +14 -0
- package/dist/commands/cicd/data/filter/update.js +46 -0
- package/dist/commands/cicd/data/filter/update.js.map +1 -0
- package/dist/commands/cicd/data/formula/create.d.ts +16 -0
- package/dist/commands/cicd/data/formula/create.js +62 -0
- package/dist/commands/cicd/data/formula/create.js.map +1 -0
- package/dist/commands/cicd/data/formula/list.d.ts +10 -0
- package/dist/commands/cicd/data/formula/list.js +42 -0
- package/dist/commands/cicd/data/formula/list.js.map +1 -0
- package/dist/commands/cicd/data/formula/update.d.ts +18 -0
- package/dist/commands/cicd/data/formula/update.js +78 -0
- package/dist/commands/cicd/data/formula/update.js.map +1 -0
- package/dist/commands/cicd/data/records/match.d.ts +11 -0
- package/dist/commands/cicd/data/records/match.js +39 -0
- package/dist/commands/cicd/data/records/match.js.map +1 -0
- package/dist/commands/cicd/data/records/search.d.ts +14 -0
- package/dist/commands/cicd/data/records/search.js +65 -0
- package/dist/commands/cicd/data/records/search.js.map +1 -0
- package/dist/commands/cicd/data/sobject/fields.d.ts +13 -0
- package/dist/commands/cicd/data/sobject/fields.js +56 -0
- package/dist/commands/cicd/data/sobject/fields.js.map +1 -0
- package/dist/commands/cicd/data/sobject/relationships.d.ts +13 -0
- package/dist/commands/cicd/data/sobject/relationships.js +66 -0
- package/dist/commands/cicd/data/sobject/relationships.js.map +1 -0
- package/dist/commands/cicd/data/sync/apply.d.ts +11 -0
- package/dist/commands/cicd/data/sync/apply.js +40 -0
- package/dist/commands/cicd/data/sync/apply.js.map +1 -0
- package/dist/commands/cicd/data/sync/preview-updates.d.ts +11 -0
- package/dist/commands/cicd/data/sync/preview-updates.js +58 -0
- package/dist/commands/cicd/data/sync/preview-updates.js.map +1 -0
- package/dist/commands/cicd/data/template/convert-old.d.ts +9 -0
- package/dist/commands/cicd/data/template/convert-old.js +29 -0
- package/dist/commands/cicd/data/template/convert-old.js.map +1 -0
- package/dist/commands/cicd/data/template/create.d.ts +13 -0
- package/dist/commands/cicd/data/template/create.js +56 -0
- package/dist/commands/cicd/data/template/create.js.map +1 -0
- package/dist/commands/cicd/data/template/delete.d.ts +9 -0
- package/dist/commands/cicd/data/template/delete.js +29 -0
- package/dist/commands/cicd/data/template/delete.js.map +1 -0
- package/dist/commands/cicd/data/template/get-detail.d.ts +10 -0
- package/dist/commands/cicd/data/template/get-detail.js +29 -0
- package/dist/commands/cicd/data/template/get-detail.js.map +1 -0
- package/dist/commands/cicd/data/template/get.d.ts +10 -0
- package/dist/commands/cicd/data/template/get.js +29 -0
- package/dist/commands/cicd/data/template/get.js.map +1 -0
- package/dist/commands/cicd/data/template/list.d.ts +11 -0
- package/dist/commands/cicd/data/template/list.js +44 -0
- package/dist/commands/cicd/data/template/list.js.map +1 -0
- package/dist/commands/cicd/data/template/save-detail.d.ts +13 -0
- package/dist/commands/cicd/data/template/save-detail.js +42 -0
- package/dist/commands/cicd/data/template/save-detail.js.map +1 -0
- package/dist/commands/cicd/function/defaults.d.ts +12 -0
- package/dist/commands/cicd/function/defaults.js +31 -0
- package/dist/commands/cicd/function/defaults.js.map +1 -0
- package/dist/commands/cicd/function/delete.d.ts +11 -0
- package/dist/commands/cicd/function/delete.js +29 -0
- package/dist/commands/cicd/function/delete.js.map +1 -0
- package/dist/commands/cicd/function/get.d.ts +10 -0
- package/dist/commands/cicd/function/get.js +30 -0
- package/dist/commands/cicd/function/get.js.map +1 -0
- package/dist/commands/cicd/function/list.d.ts +10 -0
- package/dist/commands/cicd/function/list.js +36 -0
- package/dist/commands/cicd/function/list.js.map +1 -0
- package/dist/commands/cicd/function/result/get.d.ts +10 -0
- package/dist/commands/cicd/function/result/get.js +30 -0
- package/dist/commands/cicd/function/result/get.js.map +1 -0
- package/dist/commands/cicd/function/result/log/get.d.ts +17 -0
- package/dist/commands/cicd/function/result/log/get.js +41 -0
- package/dist/commands/cicd/function/result/log/get.js.map +1 -0
- package/dist/commands/cicd/function/run-local.d.ts +17 -0
- package/dist/commands/cicd/function/run-local.js +64 -0
- package/dist/commands/cicd/function/run-local.js.map +1 -0
- package/dist/commands/cicd/function/run.d.ts +16 -0
- package/dist/commands/cicd/function/run.js +42 -0
- package/dist/commands/cicd/function/run.js.map +1 -0
- package/dist/commands/cicd/function/upsert.d.ts +27 -0
- package/dist/commands/cicd/function/upsert.js +45 -0
- package/dist/commands/cicd/function/upsert.js.map +1 -0
- package/dist/commands/cicd/promotion/run.d.ts +23 -0
- package/dist/commands/cicd/promotion/run.js +137 -0
- package/dist/commands/cicd/promotion/run.js.map +1 -0
- package/dist/commands/cicd/work/promote.d.ts +25 -0
- package/dist/commands/cicd/work/promote.js +141 -0
- package/dist/commands/cicd/work/promote.js.map +1 -0
- package/dist/lib/cicd-gateway.js +3 -2
- package/dist/lib/cicd-gateway.js.map +1 -1
- package/dist/lib/data-flags.d.ts +14 -0
- package/dist/lib/data-flags.js +61 -0
- package/dist/lib/data-flags.js.map +1 -0
- package/dist/lib/data-types.d.ts +322 -0
- package/dist/lib/data-types.js +176 -0
- package/dist/lib/data-types.js.map +1 -0
- package/dist/lib/function-flags.d.ts +69 -0
- package/dist/lib/function-flags.js +199 -0
- package/dist/lib/function-flags.js.map +1 -0
- package/dist/lib/function-local-run.d.ts +64 -0
- package/dist/lib/function-local-run.js +148 -0
- package/dist/lib/function-local-run.js.map +1 -0
- package/dist/lib/function-types.d.ts +106 -0
- package/dist/lib/function-types.js +171 -0
- package/dist/lib/function-types.js.map +1 -0
- package/dist/lib/mcp/data-tools.d.ts +159 -0
- package/dist/lib/mcp/data-tools.js +547 -0
- package/dist/lib/mcp/data-tools.js.map +1 -0
- package/dist/lib/mcp/tools.d.ts +231 -0
- package/dist/lib/mcp/tools.js +288 -0
- package/dist/lib/mcp/tools.js.map +1 -1
- package/dist/lib/mcp/work-tools.d.ts +29 -0
- package/dist/lib/mcp/work-tools.js +62 -0
- package/dist/lib/mcp/work-tools.js.map +1 -1
- package/dist/lib/promotion-run.d.ts +105 -0
- package/dist/lib/promotion-run.js +481 -0
- package/dist/lib/promotion-run.js.map +1 -0
- package/dist/lib/salesforce-id.d.ts +9 -0
- package/dist/lib/salesforce-id.js +30 -0
- package/dist/lib/salesforce-id.js.map +1 -1
- package/dist/lib/sf-org-context.js +5 -5
- package/dist/lib/sf-org-context.js.map +1 -1
- package/oclif.manifest.json +4818 -2752
- package/package.json +28 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { cellValue, table } from './format.js';
|
|
2
|
+
export const DATA_TEMPLATES_BASE = '/release/data-templates';
|
|
3
|
+
export function dataTemplatesListEndpoint(options) {
|
|
4
|
+
const params = new URLSearchParams();
|
|
5
|
+
if (options?.fetchRelated !== undefined) {
|
|
6
|
+
params.set('fetchRelated', String(options.fetchRelated));
|
|
7
|
+
}
|
|
8
|
+
if (options?.active !== undefined) {
|
|
9
|
+
params.set('active', String(options.active));
|
|
10
|
+
}
|
|
11
|
+
const query = params.toString();
|
|
12
|
+
return query.length > 0 ? `${DATA_TEMPLATES_BASE}?${query}` : DATA_TEMPLATES_BASE;
|
|
13
|
+
}
|
|
14
|
+
export function dataTemplateEndpoint(id) {
|
|
15
|
+
return `${DATA_TEMPLATES_BASE}/${encodeURIComponent(id)}`;
|
|
16
|
+
}
|
|
17
|
+
export function dataTemplateDetailEndpoint(id) {
|
|
18
|
+
return `${dataTemplateEndpoint(id)}/detail`;
|
|
19
|
+
}
|
|
20
|
+
export function dataTemplateConvertOldEndpoint(id) {
|
|
21
|
+
return `${DATA_TEMPLATES_BASE}/convert-old/${encodeURIComponent(id)}`;
|
|
22
|
+
}
|
|
23
|
+
export function dataTemplatesSyncEndpoint() {
|
|
24
|
+
return `${DATA_TEMPLATES_BASE}/sync`;
|
|
25
|
+
}
|
|
26
|
+
export function dataTemplatesRecordsEndpoint() {
|
|
27
|
+
return `${DATA_TEMPLATES_BASE}/records`;
|
|
28
|
+
}
|
|
29
|
+
export function dataTemplatesRecordsMatchEndpoint() {
|
|
30
|
+
return `${DATA_TEMPLATES_BASE}/records/match`;
|
|
31
|
+
}
|
|
32
|
+
export function dataTemplateRecordMatchingFormulasEndpoint(dataTemplateId) {
|
|
33
|
+
return `${dataTemplateEndpoint(dataTemplateId)}/record-matching-formulas`;
|
|
34
|
+
}
|
|
35
|
+
export function recordMatchingFormulasByObjectEndpoint(objectApiName) {
|
|
36
|
+
return `${DATA_TEMPLATES_BASE}/record-matching-formulas/${encodeURIComponent(objectApiName)}`;
|
|
37
|
+
}
|
|
38
|
+
export function recordMatchingFormulaEndpoint(formulaId) {
|
|
39
|
+
return `${DATA_TEMPLATES_BASE}/record-matching-formulas/${encodeURIComponent(formulaId)}`;
|
|
40
|
+
}
|
|
41
|
+
export function dataTemplatesCommitEndpoint() {
|
|
42
|
+
return `${DATA_TEMPLATES_BASE}/commit`;
|
|
43
|
+
}
|
|
44
|
+
export function dataTemplateUpdatesEndpoint() {
|
|
45
|
+
return `${DATA_TEMPLATES_BASE}/commit/data-template-updates`;
|
|
46
|
+
}
|
|
47
|
+
export function advancedFiltersEndpoint(dataTemplateId) {
|
|
48
|
+
return `${DATA_TEMPLATES_BASE}/advanced-filters/${encodeURIComponent(dataTemplateId)}`;
|
|
49
|
+
}
|
|
50
|
+
export function advancedFilterEndpoint(dataTemplateId, uuid) {
|
|
51
|
+
return `${advancedFiltersEndpoint(dataTemplateId)}/${encodeURIComponent(uuid)}`;
|
|
52
|
+
}
|
|
53
|
+
export function sobjectRelationshipsEndpoint(sobjectApiName, credentialId) {
|
|
54
|
+
const params = new URLSearchParams({ credentialId });
|
|
55
|
+
return `${DATA_TEMPLATES_BASE}/sobjects/${encodeURIComponent(sobjectApiName)}/relationships?${params}`;
|
|
56
|
+
}
|
|
57
|
+
export function sobjectFieldsEndpoint(sobjectApiName, credentialId) {
|
|
58
|
+
const params = new URLSearchParams({ credentialId });
|
|
59
|
+
return `${DATA_TEMPLATES_BASE}/sobjects/${encodeURIComponent(sobjectApiName)}/fields?${params}`;
|
|
60
|
+
}
|
|
61
|
+
export function userStoryDataCommitsEndpoint(userStoryId) {
|
|
62
|
+
return `/release/commit/user-story/${encodeURIComponent(userStoryId)}/data-commits`;
|
|
63
|
+
}
|
|
64
|
+
export function datasetFilesEndpoint(userStoryDataCommitId) {
|
|
65
|
+
return `/release/metadata/dataset-files/${encodeURIComponent(userStoryDataCommitId)}`;
|
|
66
|
+
}
|
|
67
|
+
export function datasetFileContentEndpoint(contentVersionId) {
|
|
68
|
+
return `/release/metadata/dataset-files/content/${encodeURIComponent(contentVersionId)}`;
|
|
69
|
+
}
|
|
70
|
+
export function normalizeDataTemplates(response) {
|
|
71
|
+
if (Array.isArray(response)) {
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
if (response && typeof response === 'object' && Array.isArray(response.data)) {
|
|
75
|
+
return response.data;
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
export function formatDataTemplateTable(templates) {
|
|
80
|
+
return table([
|
|
81
|
+
{ alias: 'ID', value: 'id' },
|
|
82
|
+
{ alias: 'NAME', value: 'name' },
|
|
83
|
+
{ alias: 'MAIN OBJECT', value: 'mainObject' },
|
|
84
|
+
{ alias: 'STATUS', value: 'status' },
|
|
85
|
+
{ alias: 'ACTIVE', value: 'active' },
|
|
86
|
+
{ alias: 'SOURCE ORG', value: 'sourceOrgName' },
|
|
87
|
+
], templates.map((template) => ({
|
|
88
|
+
active: cellValue(template.active),
|
|
89
|
+
id: cellValue(template.id),
|
|
90
|
+
mainObject: cellValue(template.mainObject),
|
|
91
|
+
name: cellValue(template.name),
|
|
92
|
+
sourceOrgName: cellValue(template.sourceOrgName),
|
|
93
|
+
status: cellValue(template.status),
|
|
94
|
+
})));
|
|
95
|
+
}
|
|
96
|
+
export function formatDataRecordTable(records) {
|
|
97
|
+
return table([
|
|
98
|
+
{ alias: 'ID', value: 'id' },
|
|
99
|
+
{ alias: 'NAME', value: 'name' },
|
|
100
|
+
{ alias: 'TYPE', value: 'type' },
|
|
101
|
+
{ alias: 'LAST MODIFIED', value: 'lastModifiedDate' },
|
|
102
|
+
], records.map((record) => ({
|
|
103
|
+
id: cellValue(record.id),
|
|
104
|
+
lastModifiedDate: cellValue(record.lastModifiedDate),
|
|
105
|
+
name: cellValue(record.name),
|
|
106
|
+
type: cellValue(record.type),
|
|
107
|
+
})));
|
|
108
|
+
}
|
|
109
|
+
export function formatUserStoryDataCommitTable(commits) {
|
|
110
|
+
return table([
|
|
111
|
+
{ alias: 'ID', value: 'id' },
|
|
112
|
+
{ alias: 'DATASET', value: 'datasetName' },
|
|
113
|
+
{ alias: 'MESSAGE', value: 'commitMessage', wrap: true },
|
|
114
|
+
{ alias: 'CREATED', value: 'createdDate' },
|
|
115
|
+
], commits.map((commit) => ({
|
|
116
|
+
commitMessage: cellValue(commit.commitMessage),
|
|
117
|
+
createdDate: cellValue(commit.createdDate),
|
|
118
|
+
datasetName: cellValue(commit.datasetName ?? commit.datasetId),
|
|
119
|
+
id: cellValue(commit.id),
|
|
120
|
+
})));
|
|
121
|
+
}
|
|
122
|
+
export function formatDatasetFileTable(files) {
|
|
123
|
+
return table([
|
|
124
|
+
{ alias: 'ID', value: 'id' },
|
|
125
|
+
{ alias: 'CONTENT VERSION', value: 'contentVersionId' },
|
|
126
|
+
{ alias: 'FILE', value: 'fileName' },
|
|
127
|
+
{ alias: 'MODIFIED', value: 'lastModifiedDate' },
|
|
128
|
+
], files.map((file) => ({
|
|
129
|
+
contentVersionId: cellValue(file.contentVersionId),
|
|
130
|
+
fileName: cellValue(file.fileName),
|
|
131
|
+
id: cellValue(file.id),
|
|
132
|
+
lastModifiedDate: cellValue(file.lastModifiedDate),
|
|
133
|
+
})));
|
|
134
|
+
}
|
|
135
|
+
export function formatAdvancedFilterTable(filters) {
|
|
136
|
+
return table([
|
|
137
|
+
{ alias: 'UUID', value: 'uuid' },
|
|
138
|
+
{ alias: 'NAME', value: 'filterName' },
|
|
139
|
+
{ alias: 'OBJECTS', value: 'objects' },
|
|
140
|
+
], filters.map((filter) => ({
|
|
141
|
+
filterName: cellValue(filter.filterName),
|
|
142
|
+
objects: cellValue(filter.objectFilters?.length ?? 0),
|
|
143
|
+
uuid: cellValue(filter.uuid),
|
|
144
|
+
})));
|
|
145
|
+
}
|
|
146
|
+
export function formatRecordMatchingFormulaTable(formulas) {
|
|
147
|
+
return table([
|
|
148
|
+
{ alias: 'ID', value: 'id' },
|
|
149
|
+
{ alias: 'NAME', value: 'name' },
|
|
150
|
+
{ alias: 'OBJECT', value: 'objectApiName' },
|
|
151
|
+
{ alias: 'HASH', value: 'hashFormula' },
|
|
152
|
+
], formulas.map((formula) => ({
|
|
153
|
+
hashFormula: cellValue(formula.hashFormula),
|
|
154
|
+
id: cellValue(formula.id),
|
|
155
|
+
name: cellValue(formula.name),
|
|
156
|
+
objectApiName: cellValue(formula.objectApiName),
|
|
157
|
+
})));
|
|
158
|
+
}
|
|
159
|
+
export function formatSyncResultTable(entries) {
|
|
160
|
+
return table([
|
|
161
|
+
{ alias: 'TEMPLATE', value: 'templateId' },
|
|
162
|
+
{ alias: 'OBJECT', value: 'objectApiName' },
|
|
163
|
+
{ alias: 'FIELD', value: 'fieldApiName' },
|
|
164
|
+
{ alias: 'OP', value: 'operation' },
|
|
165
|
+
{ alias: 'SYNCED', value: 'synced' },
|
|
166
|
+
{ alias: 'NEEDS ATTENTION', value: 'needsAttention' },
|
|
167
|
+
], entries.map((entry) => ({
|
|
168
|
+
fieldApiName: cellValue(entry.fieldApiName),
|
|
169
|
+
needsAttention: cellValue(entry.needsAttention),
|
|
170
|
+
objectApiName: cellValue(entry.objectApiName),
|
|
171
|
+
operation: cellValue(entry.operation),
|
|
172
|
+
synced: cellValue(entry.synced),
|
|
173
|
+
templateId: cellValue(entry.templateId),
|
|
174
|
+
})));
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=data-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-types.js","sourceRoot":"","sources":["../../src/lib/data-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,yBAAyB,CAAA;AA6S5D,MAAM,UAAU,yBAAyB,CAAC,OAAoD;IAC5F,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,IAAI,OAAO,EAAE,YAAY,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;IAC1D,CAAC;IA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YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC;QAC3C,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;QAC/C,aAAa,EAAE,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC;QAC7C,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC;QACrC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/B,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;KACxC,CAAC,CAAC,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type FunctionCreateDefaultsPayload, type FunctionUpsertPayload } from './function-types.js';
|
|
2
|
+
export declare const functionUpsertFlags: {
|
|
3
|
+
readonly 'apex-class': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
4
|
+
readonly callback: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
5
|
+
readonly description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
readonly file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
readonly 'flow-handler': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
readonly 'image-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
readonly name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
readonly 'parameters-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
readonly runtime: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
readonly script: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
readonly 'script-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
readonly size: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
readonly timeout: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
readonly type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
readonly version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
export declare const functionDefaultsFlags: {
|
|
20
|
+
readonly 'image-name': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
readonly name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
readonly runtime: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
};
|
|
24
|
+
export declare const functionRunFlags: {
|
|
25
|
+
readonly 'context-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
readonly 'deploy-first': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
27
|
+
readonly parameter: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
readonly 'show-validation-errors': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
|
+
};
|
|
30
|
+
type FunctionUpsertFlagValues = {
|
|
31
|
+
'apex-class'?: string;
|
|
32
|
+
callback?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
file?: string;
|
|
35
|
+
'flow-handler'?: string;
|
|
36
|
+
'image-name'?: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
'parameters-file'?: string;
|
|
39
|
+
runtime?: string;
|
|
40
|
+
script?: string;
|
|
41
|
+
'script-file'?: string;
|
|
42
|
+
size?: string;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
type?: string;
|
|
45
|
+
version?: string;
|
|
46
|
+
};
|
|
47
|
+
type FunctionDefaultsFlagValues = {
|
|
48
|
+
'image-name'?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
runtime?: string;
|
|
51
|
+
};
|
|
52
|
+
type FunctionRunFlagValues = {
|
|
53
|
+
'context-id'?: string;
|
|
54
|
+
'deploy-first'?: boolean;
|
|
55
|
+
parameter?: string[];
|
|
56
|
+
'show-validation-errors'?: boolean;
|
|
57
|
+
};
|
|
58
|
+
export declare function buildFunctionUpsertPayload(apiName: string, flags: FunctionUpsertFlagValues): Promise<FunctionUpsertPayload>;
|
|
59
|
+
export declare function buildFunctionDefaultsPayload(flags: FunctionDefaultsFlagValues): FunctionCreateDefaultsPayload;
|
|
60
|
+
export declare function buildFunctionRunPayload(flags: FunctionRunFlagValues): {
|
|
61
|
+
error?: string;
|
|
62
|
+
payload: {
|
|
63
|
+
contextId?: string;
|
|
64
|
+
deployFirst: boolean;
|
|
65
|
+
parameters?: Record<string, string>;
|
|
66
|
+
showValidationErrors: boolean;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { FUNCTION_RUNTIME_EXTENSION, FUNCTION_RUNTIMES, normalizeFunctionUpsertPayload, parseParameterAssignments, } from './function-types.js';
|
|
4
|
+
export const functionUpsertFlags = {
|
|
5
|
+
'apex-class': Flags.string({
|
|
6
|
+
description: 'Apex callback class',
|
|
7
|
+
}),
|
|
8
|
+
callback: Flags.string({
|
|
9
|
+
description: 'Function callback type',
|
|
10
|
+
}),
|
|
11
|
+
description: Flags.string({
|
|
12
|
+
description: 'Function description',
|
|
13
|
+
}),
|
|
14
|
+
file: Flags.string({
|
|
15
|
+
description: 'Path to a JSON file with the full upsert payload (overrides individual script flags)',
|
|
16
|
+
}),
|
|
17
|
+
'flow-handler': Flags.string({
|
|
18
|
+
description: 'Flow handler name',
|
|
19
|
+
}),
|
|
20
|
+
'image-name': Flags.string({
|
|
21
|
+
description: 'Function container image',
|
|
22
|
+
}),
|
|
23
|
+
name: Flags.string({
|
|
24
|
+
description: 'Function display name (defaults to the API name argument)',
|
|
25
|
+
}),
|
|
26
|
+
'parameters-file': Flags.string({
|
|
27
|
+
description: 'Path to a JSON file containing the parameters array',
|
|
28
|
+
}),
|
|
29
|
+
runtime: Flags.string({
|
|
30
|
+
description: 'Script runtime',
|
|
31
|
+
options: [...FUNCTION_RUNTIMES],
|
|
32
|
+
}),
|
|
33
|
+
script: Flags.string({
|
|
34
|
+
description: 'Inline script content',
|
|
35
|
+
}),
|
|
36
|
+
'script-file': Flags.string({
|
|
37
|
+
description: 'Path to a file whose contents become the script',
|
|
38
|
+
}),
|
|
39
|
+
size: Flags.string({
|
|
40
|
+
description: 'Function size',
|
|
41
|
+
}),
|
|
42
|
+
timeout: Flags.integer({
|
|
43
|
+
description: 'Function timeout in seconds',
|
|
44
|
+
}),
|
|
45
|
+
type: Flags.string({
|
|
46
|
+
description: 'Function type',
|
|
47
|
+
}),
|
|
48
|
+
version: Flags.string({
|
|
49
|
+
description: 'Function version',
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
export const functionDefaultsFlags = {
|
|
53
|
+
'image-name': Flags.string({
|
|
54
|
+
default: 'copado-function-core:v1',
|
|
55
|
+
description: 'Function container image',
|
|
56
|
+
}),
|
|
57
|
+
name: Flags.string({
|
|
58
|
+
description: 'Function display name used to scaffold defaults',
|
|
59
|
+
required: true,
|
|
60
|
+
}),
|
|
61
|
+
runtime: Flags.string({
|
|
62
|
+
default: 'bash',
|
|
63
|
+
description: 'Script runtime',
|
|
64
|
+
options: [...FUNCTION_RUNTIMES],
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
export const functionRunFlags = {
|
|
68
|
+
'context-id': Flags.string({
|
|
69
|
+
description: 'Execution context Id',
|
|
70
|
+
}),
|
|
71
|
+
'deploy-first': Flags.boolean({
|
|
72
|
+
default: false,
|
|
73
|
+
description: 'Deploy related metadata before running the function',
|
|
74
|
+
}),
|
|
75
|
+
parameter: Flags.string({
|
|
76
|
+
description: 'Run parameter as key=value (repeatable)',
|
|
77
|
+
multiple: true,
|
|
78
|
+
}),
|
|
79
|
+
'show-validation-errors': Flags.boolean({
|
|
80
|
+
allowNo: true,
|
|
81
|
+
default: true,
|
|
82
|
+
description: 'Surface validation errors from the gateway',
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
async function readJsonFile(path, label) {
|
|
86
|
+
let raw;
|
|
87
|
+
try {
|
|
88
|
+
raw = await readFile(path, 'utf8');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
throw new Error(`Unable to read ${label} file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
return JSON.parse(raw);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new Error(`${label} file ${path} is not valid JSON.`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function buildScript(flags, content) {
|
|
101
|
+
const runtime = (flags.runtime ?? 'bash');
|
|
102
|
+
return {
|
|
103
|
+
content,
|
|
104
|
+
extension: FUNCTION_RUNTIME_EXTENSION[runtime],
|
|
105
|
+
runtime,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function resolveScriptContent(flags) {
|
|
109
|
+
if (flags.script !== undefined && flags['script-file'] !== undefined) {
|
|
110
|
+
throw new Error('Cannot provide --script and --script-file together.');
|
|
111
|
+
}
|
|
112
|
+
if (flags.script !== undefined) {
|
|
113
|
+
return flags.script;
|
|
114
|
+
}
|
|
115
|
+
if (flags['script-file'] === undefined) {
|
|
116
|
+
throw new Error('Must provide --script, --script-file, or --file.');
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
return await readFile(flags['script-file'], 'utf8');
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
throw new Error(`Unable to read script file ${flags['script-file']}: ${error instanceof Error ? error.message : String(error)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function resolveParameters(flags) {
|
|
126
|
+
if (flags['parameters-file'] === undefined) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
const parameters = await readJsonFile(flags['parameters-file'], 'Parameters');
|
|
130
|
+
if (!Array.isArray(parameters)) {
|
|
131
|
+
throw new TypeError('Parameters file must contain a JSON array.');
|
|
132
|
+
}
|
|
133
|
+
return parameters;
|
|
134
|
+
}
|
|
135
|
+
function applyOptionalUpsertFields(payload, flags, parameters) {
|
|
136
|
+
return {
|
|
137
|
+
...payload,
|
|
138
|
+
...(flags.description === undefined ? {} : { description: flags.description }),
|
|
139
|
+
...(flags['apex-class'] === undefined ? {} : { apexClass: flags['apex-class'] }),
|
|
140
|
+
...(flags.callback === undefined ? {} : { callback: flags.callback }),
|
|
141
|
+
...(flags['flow-handler'] === undefined ? {} : { flowHandler: flags['flow-handler'] }),
|
|
142
|
+
...(flags.timeout === undefined ? {} : { timeout: flags.timeout }),
|
|
143
|
+
...(parameters === undefined ? {} : { parameters }),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export async function buildFunctionUpsertPayload(apiName, flags) {
|
|
147
|
+
if (flags.file !== undefined) {
|
|
148
|
+
const conflictingFlags = Object.entries(flags)
|
|
149
|
+
.filter(([key, value]) => key !== 'file' && value !== undefined)
|
|
150
|
+
.map(([key]) => `--${key}`);
|
|
151
|
+
if (conflictingFlags.length > 0) {
|
|
152
|
+
throw new Error(`Cannot combine --file with payload flags: ${conflictingFlags.join(', ')}.`);
|
|
153
|
+
}
|
|
154
|
+
const fromFile = await readJsonFile(flags.file, 'Upsert');
|
|
155
|
+
return normalizeFunctionUpsertPayload(apiName, fromFile);
|
|
156
|
+
}
|
|
157
|
+
const scriptContent = await resolveScriptContent(flags);
|
|
158
|
+
const parameters = await resolveParameters(flags);
|
|
159
|
+
const payload = {
|
|
160
|
+
apiName,
|
|
161
|
+
imageName: flags['image-name'] ?? 'copado-function-core:v1',
|
|
162
|
+
name: flags.name?.trim() || apiName,
|
|
163
|
+
script: buildScript(flags, scriptContent),
|
|
164
|
+
size: flags.size ?? 'S',
|
|
165
|
+
type: flags.type ?? 'Custom',
|
|
166
|
+
version: flags.version ?? '1',
|
|
167
|
+
};
|
|
168
|
+
return normalizeFunctionUpsertPayload(apiName, applyOptionalUpsertFields(payload, flags, parameters));
|
|
169
|
+
}
|
|
170
|
+
export function buildFunctionDefaultsPayload(flags) {
|
|
171
|
+
return {
|
|
172
|
+
imageName: flags['image-name'] ?? 'copado-function-core:v1',
|
|
173
|
+
name: flags.name,
|
|
174
|
+
runtime: (flags.runtime ?? 'bash'),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export function buildFunctionRunPayload(flags) {
|
|
178
|
+
try {
|
|
179
|
+
const parameters = parseParameterAssignments(flags.parameter);
|
|
180
|
+
return {
|
|
181
|
+
payload: {
|
|
182
|
+
deployFirst: flags['deploy-first'] ?? false,
|
|
183
|
+
showValidationErrors: flags['show-validation-errors'] ?? true,
|
|
184
|
+
...(flags['context-id'] === undefined ? {} : { contextId: flags['context-id'] }),
|
|
185
|
+
...(parameters === undefined ? {} : { parameters }),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
return {
|
|
191
|
+
error: error instanceof Error ? error.message : String(error),
|
|
192
|
+
payload: {
|
|
193
|
+
deployFirst: false,
|
|
194
|
+
showValidationErrors: true,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=function-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-flags.js","sourceRoot":"","sources":["../../src/lib/function-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EAOjB,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,qBAAqB;KACnC,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,wBAAwB;KACtC,CAAC;IACF,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;QACxB,WAAW,EAAE,sBAAsB;KACpC,CAAC;IACF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,sFAAsF;KACpG,CAAC;IACF,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC;QAC3B,WAAW,EAAE,mBAAmB;KACjC,CAAC;IACF,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,0BAA0B;KACxC,CAAC;IACF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,2DAA2D;KACzE,CAAC;IACF,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,qDAAqD;KACnE,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC;KAChC,CAAC;IACF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EAA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,YAAY,CAAC,EAAC,CAAC;gBAC9E,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,UAAU,EAAC,CAAC;aAClD;SACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,OAAO,EAAE;gBACP,WAAW,EAAE,KAAK;gBAClB,oBAAoB,EAAE,IAAI;aAC3B;SACF,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type FunctionRuntime } from './function-types.js';
|
|
2
|
+
/** Default Copado Function image; partners can override when the Copado registry is unavailable. */
|
|
3
|
+
export declare const DEFAULT_FUNCTION_LOCAL_IMAGE = "copado-function-core:v1";
|
|
4
|
+
/** Container working directory (matches Copado Function runtime). */
|
|
5
|
+
export declare const FUNCTION_LOCAL_CONTAINER_APP_DIR = "/app";
|
|
6
|
+
/** Fixed container path for the function script (matches Copado Function runtime). */
|
|
7
|
+
export declare const FUNCTION_LOCAL_CONTAINER_SCRIPT_PATH = "/tmp/cf_function.sh";
|
|
8
|
+
export type LocalFunctionRunInvocation = {
|
|
9
|
+
args: string[];
|
|
10
|
+
command: string;
|
|
11
|
+
display: string;
|
|
12
|
+
};
|
|
13
|
+
export type LocalFunctionRunResult = {
|
|
14
|
+
args: string[];
|
|
15
|
+
command: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
exitCode: null | number;
|
|
18
|
+
image: string;
|
|
19
|
+
runtime: FunctionRuntime;
|
|
20
|
+
script: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
stdout: string;
|
|
23
|
+
};
|
|
24
|
+
export type LocalFunctionProcessRunner = (invocation: LocalFunctionRunInvocation, options: {
|
|
25
|
+
cwd: string;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
exitCode: null | number;
|
|
28
|
+
stderr: string;
|
|
29
|
+
stdout: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function runtimeFromFunctionScriptPath(scriptPath: string): FunctionRuntime;
|
|
32
|
+
export declare function runtimeInterpreter(runtime: FunctionRuntime): string;
|
|
33
|
+
export declare function resolveLocalFunctionRuntime(scriptPath: string, runtimeFlag: string | undefined): FunctionRuntime;
|
|
34
|
+
export declare function assertLocalFunctionScriptReadable(scriptPath: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Host directory bind-mounted at `/app`.
|
|
37
|
+
* Defaults to the current process working directory (workspace root when invoked from a project).
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveLocalFunctionHostAppDir(cwdFlag: string | undefined): string;
|
|
40
|
+
export declare function buildDockerLocalFunctionRunInvocation(options: {
|
|
41
|
+
env?: Record<string, string>;
|
|
42
|
+
hostAppDir: string;
|
|
43
|
+
image: string;
|
|
44
|
+
platform?: string;
|
|
45
|
+
runtime: FunctionRuntime;
|
|
46
|
+
scriptPath: string;
|
|
47
|
+
}): LocalFunctionRunInvocation;
|
|
48
|
+
export declare function runLocalFunctionProcess(invocation: LocalFunctionRunInvocation, options: {
|
|
49
|
+
cwd: string;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
exitCode: null | number;
|
|
52
|
+
stderr: string;
|
|
53
|
+
stdout: string;
|
|
54
|
+
}>;
|
|
55
|
+
export declare function executeLocalFunctionRun(options: {
|
|
56
|
+
cwd?: string;
|
|
57
|
+
image?: string;
|
|
58
|
+
parameter?: string[];
|
|
59
|
+
platform?: string;
|
|
60
|
+
runProcess?: LocalFunctionProcessRunner;
|
|
61
|
+
runtime?: string;
|
|
62
|
+
script: string;
|
|
63
|
+
}): Promise<LocalFunctionRunResult>;
|
|
64
|
+
export declare function formatLocalFunctionRunResult(result: LocalFunctionRunResult): string;
|