@copado/agentia-cli 0.57.0-alpha.0 → 0.59.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 +1090 -116
- 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/lib/cicd-gateway.js +3 -2
- package/dist/lib/cicd-gateway.js.map +1 -1
- package/dist/lib/cli-update.d.ts +2 -0
- package/dist/lib/cli-update.js +20 -1
- package/dist/lib/cli-update.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 +188 -0
- package/dist/lib/mcp/tools.js +215 -0
- package/dist/lib/mcp/tools.js.map +1 -1
- 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 +4876 -3011
- package/package.json +28 -1
|
@@ -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 @@
|
|
|
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C,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;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { FUNCTION_RUNTIMES, parseParameterAssignments } from './function-types.js';
|
|
5
|
+
/** Default Copado Function image; partners can override when the Copado registry is unavailable. */
|
|
6
|
+
export const DEFAULT_FUNCTION_LOCAL_IMAGE = 'copado-function-core:v1';
|
|
7
|
+
/** Container working directory (matches Copado Function runtime). */
|
|
8
|
+
export const FUNCTION_LOCAL_CONTAINER_APP_DIR = '/app';
|
|
9
|
+
/** Fixed container path for the function script (matches Copado Function runtime). */
|
|
10
|
+
export const FUNCTION_LOCAL_CONTAINER_SCRIPT_PATH = '/tmp/cf_function.sh';
|
|
11
|
+
export function runtimeFromFunctionScriptPath(scriptPath) {
|
|
12
|
+
const normalized = scriptPath.replaceAll('\\', '/').toLowerCase();
|
|
13
|
+
if (normalized.endsWith('.js')) {
|
|
14
|
+
return 'node';
|
|
15
|
+
}
|
|
16
|
+
if (normalized.endsWith('.py')) {
|
|
17
|
+
return 'python';
|
|
18
|
+
}
|
|
19
|
+
return 'bash';
|
|
20
|
+
}
|
|
21
|
+
export function runtimeInterpreter(runtime) {
|
|
22
|
+
if (runtime === 'node') {
|
|
23
|
+
return 'node';
|
|
24
|
+
}
|
|
25
|
+
if (runtime === 'python') {
|
|
26
|
+
return 'python3';
|
|
27
|
+
}
|
|
28
|
+
return 'bash';
|
|
29
|
+
}
|
|
30
|
+
export function resolveLocalFunctionRuntime(scriptPath, runtimeFlag) {
|
|
31
|
+
if (runtimeFlag === undefined) {
|
|
32
|
+
return runtimeFromFunctionScriptPath(scriptPath);
|
|
33
|
+
}
|
|
34
|
+
if (!FUNCTION_RUNTIMES.includes(runtimeFlag)) {
|
|
35
|
+
throw new Error(`Unsupported runtime "${runtimeFlag}". Expected one of: ${FUNCTION_RUNTIMES.join(', ')}.`);
|
|
36
|
+
}
|
|
37
|
+
return runtimeFlag;
|
|
38
|
+
}
|
|
39
|
+
export async function assertLocalFunctionScriptReadable(scriptPath) {
|
|
40
|
+
const resolved = path.resolve(scriptPath);
|
|
41
|
+
try {
|
|
42
|
+
await access(resolved);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new Error(`Function script not found or unreadable: ${resolved}`);
|
|
46
|
+
}
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Host directory bind-mounted at `/app`.
|
|
51
|
+
* Defaults to the current process working directory (workspace root when invoked from a project).
|
|
52
|
+
*/
|
|
53
|
+
export function resolveLocalFunctionHostAppDir(cwdFlag) {
|
|
54
|
+
if (cwdFlag === undefined || cwdFlag.trim().length === 0) {
|
|
55
|
+
return process.cwd();
|
|
56
|
+
}
|
|
57
|
+
return path.resolve(cwdFlag);
|
|
58
|
+
}
|
|
59
|
+
export function buildDockerLocalFunctionRunInvocation(options) {
|
|
60
|
+
const image = options.image.trim();
|
|
61
|
+
if (image.length === 0) {
|
|
62
|
+
throw new Error('Docker image must not be empty. Pass --image to override the default Copado Function image.');
|
|
63
|
+
}
|
|
64
|
+
const args = ['run', '--rm'];
|
|
65
|
+
if (options.platform !== undefined && options.platform.trim().length > 0) {
|
|
66
|
+
args.push('--platform', options.platform.trim());
|
|
67
|
+
}
|
|
68
|
+
for (const [key, value] of Object.entries(options.env ?? {})) {
|
|
69
|
+
args.push('-e', `${key}=${value}`);
|
|
70
|
+
}
|
|
71
|
+
args.push('-v', `${options.hostAppDir}:${FUNCTION_LOCAL_CONTAINER_APP_DIR}`, '-v', `${options.scriptPath}:${FUNCTION_LOCAL_CONTAINER_SCRIPT_PATH}`, '-w', FUNCTION_LOCAL_CONTAINER_APP_DIR, image, runtimeInterpreter(options.runtime), FUNCTION_LOCAL_CONTAINER_SCRIPT_PATH);
|
|
72
|
+
return {
|
|
73
|
+
args,
|
|
74
|
+
command: 'docker',
|
|
75
|
+
display: `docker ${args.join(' ')}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function runLocalFunctionProcess(invocation, options) {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const child = spawn(invocation.command, invocation.args, {
|
|
81
|
+
cwd: options.cwd,
|
|
82
|
+
env: process.env,
|
|
83
|
+
});
|
|
84
|
+
let stdout = '';
|
|
85
|
+
let stderr = '';
|
|
86
|
+
child.stdout.on('data', (chunk) => {
|
|
87
|
+
stdout += String(chunk);
|
|
88
|
+
});
|
|
89
|
+
child.stderr.on('data', (chunk) => {
|
|
90
|
+
stderr += String(chunk);
|
|
91
|
+
});
|
|
92
|
+
child.on('error', (error) => {
|
|
93
|
+
reject(error);
|
|
94
|
+
});
|
|
95
|
+
child.on('close', (code) => {
|
|
96
|
+
resolve({ exitCode: code, stderr, stdout });
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export async function executeLocalFunctionRun(options) {
|
|
101
|
+
const script = await assertLocalFunctionScriptReadable(options.script);
|
|
102
|
+
const runtime = resolveLocalFunctionRuntime(script, options.runtime);
|
|
103
|
+
const hostAppDir = resolveLocalFunctionHostAppDir(options.cwd);
|
|
104
|
+
const image = options.image === undefined || options.image.trim().length === 0
|
|
105
|
+
? DEFAULT_FUNCTION_LOCAL_IMAGE
|
|
106
|
+
: options.image.trim();
|
|
107
|
+
const env = parseParameterAssignments(options.parameter);
|
|
108
|
+
const invocation = buildDockerLocalFunctionRunInvocation({
|
|
109
|
+
hostAppDir,
|
|
110
|
+
image,
|
|
111
|
+
runtime,
|
|
112
|
+
scriptPath: script,
|
|
113
|
+
...(env === undefined ? {} : { env }),
|
|
114
|
+
...(options.platform === undefined ? {} : { platform: options.platform }),
|
|
115
|
+
});
|
|
116
|
+
const runProcess = options.runProcess ?? runLocalFunctionProcess;
|
|
117
|
+
const processResult = await runProcess(invocation, { cwd: hostAppDir });
|
|
118
|
+
return {
|
|
119
|
+
args: invocation.args,
|
|
120
|
+
command: invocation.command,
|
|
121
|
+
cwd: hostAppDir,
|
|
122
|
+
exitCode: processResult.exitCode,
|
|
123
|
+
image,
|
|
124
|
+
runtime,
|
|
125
|
+
script,
|
|
126
|
+
stderr: processResult.stderr,
|
|
127
|
+
stdout: processResult.stdout,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function formatLocalFunctionRunResult(result) {
|
|
131
|
+
const lines = [
|
|
132
|
+
`Script: ${result.script}`,
|
|
133
|
+
`Runtime: ${result.runtime}`,
|
|
134
|
+
`Image: ${result.image}`,
|
|
135
|
+
`Command: ${result.command} ${result.args.join(' ')}`,
|
|
136
|
+
`App mount (/app): ${result.cwd}`,
|
|
137
|
+
`Container script: ${FUNCTION_LOCAL_CONTAINER_SCRIPT_PATH}`,
|
|
138
|
+
`Exit code: ${result.exitCode ?? 'null'}`,
|
|
139
|
+
];
|
|
140
|
+
if (result.stdout.trim().length > 0) {
|
|
141
|
+
lines.push('', 'stdout:', result.stdout.endsWith('\n') ? result.stdout.slice(0, -1) : result.stdout);
|
|
142
|
+
}
|
|
143
|
+
if (result.stderr.trim().length > 0) {
|
|
144
|
+
lines.push('', 'stderr:', result.stderr.endsWith('\n') ? result.stderr.slice(0, -1) : result.stderr);
|
|
145
|
+
}
|
|
146
|
+
return lines.join('\n');
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=function-local-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-local-run.js","sourceRoot":"","sources":["../../src/lib/function-local-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,iBAAiB,EAAwB,yBAAyB,EAAC,MAAM,qBAAqB,CAAA;AAEtG,oGAAoG;AACpG,MAAM,CAAC,MAAM,4BAA4B,GAAG,yBAAyB,CAAA;AAErE,qEAAqE;AACrE,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAA;AAEtD,sFAAsF;AACtF,MAAM,CAAC,MAAM,oCAAoC,GAAG,qBAAqB,CAAA;AA2BzE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+1,106 @@
|
|
|
1
|
+
export declare const FUNCTION_LIST_TYPES: readonly ["custom", "all"];
|
|
2
|
+
export type FunctionListType = (typeof FUNCTION_LIST_TYPES)[number];
|
|
3
|
+
export declare const FUNCTION_RUNTIMES: readonly ["bash", "node", "python"];
|
|
4
|
+
export type FunctionRuntime = (typeof FUNCTION_RUNTIMES)[number];
|
|
5
|
+
export declare const FUNCTION_EXTENSIONS: readonly ["sh", "js", "py"];
|
|
6
|
+
export type FunctionExtension = (typeof FUNCTION_EXTENSIONS)[number];
|
|
7
|
+
export declare const FUNCTION_RUNTIME_EXTENSION: Record<FunctionRuntime, FunctionExtension>;
|
|
8
|
+
export type FunctionParameter = {
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type FunctionScript = {
|
|
14
|
+
content?: string;
|
|
15
|
+
extension?: FunctionExtension;
|
|
16
|
+
runtime?: FunctionRuntime;
|
|
17
|
+
};
|
|
18
|
+
export type CopadoFunction = {
|
|
19
|
+
apexClass?: null | string;
|
|
20
|
+
apiName: string;
|
|
21
|
+
callback?: null | string;
|
|
22
|
+
description?: null | string;
|
|
23
|
+
flowHandler?: null | string;
|
|
24
|
+
id?: null | string;
|
|
25
|
+
imageName?: null | string;
|
|
26
|
+
name: string;
|
|
27
|
+
options?: null | Record<string, unknown>[];
|
|
28
|
+
ownerName?: null | string;
|
|
29
|
+
parameters?: FunctionParameter[];
|
|
30
|
+
script?: FunctionScript | null;
|
|
31
|
+
size?: null | string;
|
|
32
|
+
timeout?: null | number;
|
|
33
|
+
type?: null | string;
|
|
34
|
+
version?: null | string;
|
|
35
|
+
};
|
|
36
|
+
export type FunctionUpsertPayload = {
|
|
37
|
+
apexClass?: null | string;
|
|
38
|
+
apiName: string;
|
|
39
|
+
callback?: null | string;
|
|
40
|
+
description?: null | string;
|
|
41
|
+
flowHandler?: null | string;
|
|
42
|
+
imageName?: string;
|
|
43
|
+
name: string;
|
|
44
|
+
parameters?: FunctionParameter[];
|
|
45
|
+
script: FunctionScript;
|
|
46
|
+
size?: string;
|
|
47
|
+
timeout?: null | number;
|
|
48
|
+
type?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
};
|
|
51
|
+
export type FunctionUpsertInput = Omit<Partial<FunctionUpsertPayload>, 'script'> & {
|
|
52
|
+
script?: Partial<FunctionScript>;
|
|
53
|
+
};
|
|
54
|
+
export type FunctionCreateDefaultsPayload = {
|
|
55
|
+
imageName?: string;
|
|
56
|
+
name: string;
|
|
57
|
+
runtime?: FunctionRuntime;
|
|
58
|
+
};
|
|
59
|
+
export type FunctionRunPayload = {
|
|
60
|
+
contextId?: null | string;
|
|
61
|
+
deployFirst?: boolean;
|
|
62
|
+
function?: FunctionUpsertPayload | null;
|
|
63
|
+
parameters?: null | Record<string, string>;
|
|
64
|
+
showValidationErrors?: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type FunctionRunResult = {
|
|
67
|
+
apiName: string;
|
|
68
|
+
resultId: string;
|
|
69
|
+
status: string;
|
|
70
|
+
};
|
|
71
|
+
export type FunctionResultStatus = {
|
|
72
|
+
messages?: null | string[];
|
|
73
|
+
resultData?: unknown;
|
|
74
|
+
resultId: string;
|
|
75
|
+
status: string;
|
|
76
|
+
};
|
|
77
|
+
export type FunctionsListResponse = CopadoFunction[] | {
|
|
78
|
+
data?: CopadoFunction[];
|
|
79
|
+
};
|
|
80
|
+
export type FunctionResponse = CopadoFunction | {
|
|
81
|
+
data?: CopadoFunction;
|
|
82
|
+
};
|
|
83
|
+
export type FunctionRunResponse = FunctionRunResult | {
|
|
84
|
+
data?: FunctionRunResult;
|
|
85
|
+
};
|
|
86
|
+
export type FunctionResultStatusResponse = FunctionResultStatus | {
|
|
87
|
+
data?: FunctionResultStatus;
|
|
88
|
+
};
|
|
89
|
+
export type FunctionListFilters = {
|
|
90
|
+
type?: FunctionListType;
|
|
91
|
+
};
|
|
92
|
+
export declare function functionsEndpoint(filters?: FunctionListFilters): string;
|
|
93
|
+
export declare function functionEndpoint(apiName: string): string;
|
|
94
|
+
export declare function functionRunEndpoint(apiName: string): string;
|
|
95
|
+
export declare function functionResultEndpoint(resultId: string): string;
|
|
96
|
+
export declare function functionResultLogEndpoint(resultId: string, fileType?: string): string;
|
|
97
|
+
export declare function normalizeFunctionUpsertPayload(apiNameValue: string, input: FunctionUpsertInput): FunctionUpsertPayload;
|
|
98
|
+
export declare function normalizeFunctionsList(response: FunctionsListResponse): CopadoFunction[];
|
|
99
|
+
export declare function normalizeFunction(response: FunctionResponse): CopadoFunction;
|
|
100
|
+
export declare function normalizeFunctionRunResult(response: FunctionRunResponse): FunctionRunResult;
|
|
101
|
+
export declare function normalizeFunctionResultStatus(response: FunctionResultStatusResponse): FunctionResultStatus;
|
|
102
|
+
export declare function formatFunctionTable(functions: CopadoFunction[]): string;
|
|
103
|
+
export declare function formatFunctionDetail(fn: CopadoFunction): string;
|
|
104
|
+
export declare function formatFunctionRunResult(result: FunctionRunResult): string;
|
|
105
|
+
export declare function formatFunctionResultStatus(result: FunctionResultStatus): string;
|
|
106
|
+
export declare function parseParameterAssignments(values: string[] | undefined): Record<string, string> | undefined;
|