@copado/agentia-cli 0.53.0-alpha.0 → 0.54.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.
@@ -0,0 +1,12 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type EnvironmentCredential } from '../../../lib/environment-types.js';
3
+ export default class CredentialCreate extends AgentiaCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ readonly default: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ readonly environmentid: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ readonly name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<EnvironmentCredential>;
12
+ }
@@ -0,0 +1,39 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { credentialCreateFlags, EnvironmentCredentialInputError, validateCredentialName, } from '../../../lib/environment-credential-flags.js';
3
+ import { createEnvironmentCredential, resolveEnvironmentOrgType, } from '../../../lib/environment-credential-operations.js';
4
+ export default class CredentialCreate extends AgentiaCommand {
5
+ static description = 'Create a Copado environment credential';
6
+ static examples = [
7
+ '<%= config.bin %> <%= command.id %> --environmentid <environment-id> --name "CI User"',
8
+ '<%= config.bin %> <%= command.id %> --environmentid <environment-id> --name "CI User" --default',
9
+ '<%= config.bin %> <%= command.id %> --environmentid <environment-id> --name "CI User" --json',
10
+ ];
11
+ static flags = credentialCreateFlags;
12
+ async run() {
13
+ const { flags } = await this.parse(CredentialCreate);
14
+ const nameError = validateCredentialName(flags.name);
15
+ if (nameError !== undefined) {
16
+ this.error(nameError, { exit: 2 });
17
+ }
18
+ try {
19
+ const orgType = await this.withSpinner('Fetching environment', () => resolveEnvironmentOrgType(flags.environmentid));
20
+ const credential = await this.withSpinner('Creating credential', () => createEnvironmentCredential({
21
+ defaultCredential: flags.default,
22
+ environmentId: flags.environmentid,
23
+ name: flags.name,
24
+ orgType,
25
+ }));
26
+ this.display(() => {
27
+ this.log(`Created credential ${credential.name ?? flags.name} (ID: ${credential.id ?? 'unknown id'}).`);
28
+ });
29
+ return credential;
30
+ }
31
+ catch (error) {
32
+ if (error instanceof EnvironmentCredentialInputError) {
33
+ this.error(error.message, { exit: error.exitCode });
34
+ }
35
+ throw error;
36
+ }
37
+ }
38
+ }
39
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/cicd/credential/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,8CAA8C,CAAA;AACrD,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,mDAAmD,CAAA;AAG1D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAU,WAAW,GAAG,wCAAwC,CAAA;IACtE,MAAM,CAAU,QAAQ,GAAG;QACzB,uFAAuF;QACvF,iGAAiG;QACjG,8FAA8F;KAC/F,CAAA;IACD,MAAM,CAAU,KAAK,GAAG,qBAAqB,CAAA;IAEtC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAClD,MAAM,SAAS,GAAG,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEpD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAA;QAClC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAClE,yBAAyB,CAAC,KAAK,CAAC,aAAa,CAAC,CAC/C,CAAA;YACD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,EAAE,GAAG,EAAE,CACpE,2BAA2B,CAAC;gBAC1B,iBAAiB,EAAE,KAAK,CAAC,OAAO;gBAChC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO;aACR,CAAC,CACH,CAAA;YAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,SAAS,UAAU,CAAC,EAAE,IAAI,YAAY,IAAI,CAAC,CAAA;YACzG,CAAC,CAAC,CAAA;YAEF,OAAO,UAAU,CAAA;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,+BAA+B,EAAE,CAAC;gBACrD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAC,CAAC,CAAA;YACnD,CAAC;YAED,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type EnvironmentCredential } from '../../../lib/environment-types.js';
3
+ export default class CredentialUpdate extends AgentiaCommand {
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ readonly default: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ readonly environmentid: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ readonly name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ run(): Promise<EnvironmentCredential>;
15
+ }
@@ -0,0 +1,57 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { collectCredentialUpdateFlagKeys, credentialUpdateFlags, EnvironmentCredentialInputError, validateCredentialName, } from '../../../lib/environment-credential-flags.js';
4
+ import { resolveEnvironmentOrgType, updateEnvironmentCredential, } from '../../../lib/environment-credential-operations.js';
5
+ export default class CredentialUpdate extends AgentiaCommand {
6
+ static args = {
7
+ id: Args.string({
8
+ description: 'Copado credential ID',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Update a Copado environment credential by ID';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> <credential-id> --environmentid <environment-id> --name "CI User"',
15
+ '<%= config.bin %> <%= command.id %> <credential-id> --environmentid <environment-id> --default',
16
+ '<%= config.bin %> <%= command.id %> <credential-id> --environmentid <environment-id> --no-default --json',
17
+ ];
18
+ static flags = credentialUpdateFlags;
19
+ async run() {
20
+ const { args, flags } = await this.parse(CredentialUpdate);
21
+ const selectedKeys = collectCredentialUpdateFlagKeys(flags);
22
+ if (selectedKeys.length === 0) {
23
+ this.error('Must provide at least one flag to update.', {
24
+ exit: 2,
25
+ suggestions: [
26
+ `${this.config.bin} cicd credential update ${args.id} --environmentid ${flags.environmentid} --name <name>`,
27
+ `${this.config.bin} cicd credential update ${args.id} --environmentid ${flags.environmentid} --default`,
28
+ ],
29
+ });
30
+ }
31
+ const nameError = validateCredentialName(flags.name);
32
+ if (nameError !== undefined) {
33
+ this.error(nameError, { exit: 2 });
34
+ }
35
+ try {
36
+ const orgType = await this.withSpinner('Fetching environment', () => resolveEnvironmentOrgType(flags.environmentid));
37
+ const credential = await this.withSpinner('Updating credential', () => updateEnvironmentCredential({
38
+ credentialId: args.id,
39
+ defaultCredential: flags.default,
40
+ environmentId: flags.environmentid,
41
+ name: flags.name,
42
+ orgType,
43
+ }));
44
+ this.display(() => {
45
+ this.log(`Updated credential ${credential.name ?? flags.name ?? args.id} (ID: ${credential.id ?? args.id}).`);
46
+ });
47
+ return credential;
48
+ }
49
+ catch (error) {
50
+ if (error instanceof EnvironmentCredentialInputError) {
51
+ this.error(error.message, { exit: error.exitCode });
52
+ }
53
+ throw error;
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/cicd/credential/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,8CAA8C,CAAA;AACrD,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,mDAAmD,CAAA;AAG1D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,8CAA8C,CAAA;IAC5E,MAAM,CAAU,QAAQ,GAAG;QACzB,uGAAuG;QACvG,gGAAgG;QAChG,0GAA0G;KAC3G,CAAA;IACD,MAAM,CAAU,KAAK,GAAG,qBAAqB,CAAA;IAEtC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QACxD,MAAM,YAAY,GAAG,+BAA+B,CAAC,KAAK,CAAC,CAAA;QAE3D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,CAAC,2CAA2C,EAAE;gBACtD,IAAI,EAAE,CAAC;gB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AY,+BAA+B,EAAE,CAAC;gBACrD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAC,CAAC,CAAA;YACnD,CAAC;YAED,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type EnvironmentCredentialMutationPayload } from './environment-types.js';
2
+ export declare const CUSTOM_DOMAIN_CREDENTIALS_UNSUPPORTED_MESSAGE = "Creating or updating credentials for Custom Domain environments is not supported.";
3
+ export declare const ENVIRONMENT_TYPE_REQUIRED_MESSAGE = "Environment type is required to create or update a credential.";
4
+ export declare class EnvironmentCredentialInputError extends Error {
5
+ readonly exitCode = 2;
6
+ constructor(message: string);
7
+ }
8
+ export declare const credentialEnvironmentIdFlag: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ export declare const credentialCreateFlags: {
10
+ readonly default: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ readonly environmentid: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ readonly name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ export declare const credentialUpdateFlags: {
15
+ readonly default: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ readonly environmentid: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ readonly name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ };
19
+ export type CredentialUpdateFlagValues = {
20
+ default?: boolean;
21
+ name?: string;
22
+ };
23
+ export declare function collectCredentialUpdateFlagKeys(flags: CredentialUpdateFlagValues): Array<'default' | 'name'>;
24
+ export declare function validateCredentialName(name: string | undefined): string | undefined;
25
+ export declare function buildCredentialCreatePayload(name: string, orgType: string, defaultCredential: boolean): EnvironmentCredentialMutationPayload;
26
+ export declare function buildCredentialUpdatePayload(orgType: string, flags: CredentialUpdateFlagValues): EnvironmentCredentialMutationPayload;
@@ -0,0 +1,70 @@
1
+ import { Flags } from '@oclif/core';
2
+ export const CUSTOM_DOMAIN_CREDENTIALS_UNSUPPORTED_MESSAGE = 'Creating or updating credentials for Custom Domain environments is not supported.';
3
+ export const ENVIRONMENT_TYPE_REQUIRED_MESSAGE = 'Environment type is required to create or update a credential.';
4
+ export class EnvironmentCredentialInputError extends Error {
5
+ exitCode = 2;
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = 'EnvironmentCredentialInputError';
9
+ }
10
+ }
11
+ export const credentialEnvironmentIdFlag = Flags.string({
12
+ description: 'Copado environment ID',
13
+ required: true,
14
+ });
15
+ export const credentialCreateFlags = {
16
+ default: Flags.boolean({
17
+ allowNo: true,
18
+ default: false,
19
+ description: 'Mark this credential as the environment default',
20
+ }),
21
+ environmentid: credentialEnvironmentIdFlag,
22
+ name: Flags.string({
23
+ description: 'Credential name',
24
+ required: true,
25
+ }),
26
+ };
27
+ export const credentialUpdateFlags = {
28
+ default: Flags.boolean({
29
+ allowNo: true,
30
+ description: 'Mark this credential as the environment default',
31
+ }),
32
+ environmentid: credentialEnvironmentIdFlag,
33
+ name: Flags.string({
34
+ description: 'Credential name',
35
+ }),
36
+ };
37
+ export function collectCredentialUpdateFlagKeys(flags) {
38
+ const selected = [];
39
+ if (flags.name !== undefined) {
40
+ selected.push('name');
41
+ }
42
+ if (flags.default !== undefined) {
43
+ selected.push('default');
44
+ }
45
+ return selected;
46
+ }
47
+ export function validateCredentialName(name) {
48
+ if (typeof name === 'string' && name.trim().length === 0) {
49
+ return 'name value cannot be empty';
50
+ }
51
+ return undefined;
52
+ }
53
+ export function buildCredentialCreatePayload(name, orgType, defaultCredential) {
54
+ return {
55
+ defaultCredential,
56
+ name,
57
+ orgType,
58
+ };
59
+ }
60
+ export function buildCredentialUpdatePayload(orgType, flags) {
61
+ const payload = { orgType };
62
+ if (flags.name !== undefined) {
63
+ payload.name = flags.name;
64
+ }
65
+ if (flags.default !== undefined) {
66
+ payload.defaultCredential = flags.default;
67
+ }
68
+ return payload;
69
+ }
70
+ //# sourceMappingURL=environment-credential-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-credential-flags.js","sourceRoot":"","sources":["../../src/lib/environment-credential-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAIjC,MAAM,CAAC,MAAM,6CAA6C,GACxD,mFAAmF,CAAA;AACrF,MAAM,CAAC,MAAM,iCAAiC,GAAG,gEAAgE,CAAA;AAEjH,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IAC/C,QAAQ,GAAG,CAAC,CAAA;IAErB,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAA;IAC/C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC,MAAM,CAAC;IACtD,WAAW,EAAE,uBAAuB;IACpC,QAAQ,EAAE,IAAI;CACf,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC;IACF,aAAa,EAAE,2BAA2B;IAC1C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,iBAAiB;QAC9B,QAAQ,EAAE,IAAI;KACf,CAAC;CACM,CAAA;AAEV,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,iDAAiD;KAC/D,CAAC;IACF,aAAa,EAAE,2BAA2B;IAC1C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,iBAAiB;KAC/B,CAAC;CACM,CAAA;AAOV,MAAM,UAAU,+BAA+B,CAAC,KAAiC;IAC/E,MAAM,QAAQ,GAA8B,EAAE,CAAA;IAE9C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACvB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC1B,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAwB;IAC7D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,4BAA4B,CAAA;IACrC,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,IAAY,EACZ,OAAe,EACf,iBAA0B;IAE1B,OAAO;QACL,iBAAiB;QACjB,IAAI;QACJ,OAAO;KACR,CAAA;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAe,EACf,KAAiC;IAEjC,MAAM,OAAO,GAAyC,EAAC,OAAO,EAAC,CAAA;IAE/D,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAA;IAC3C,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type EnvironmentCredential } from './environment-types.js';
2
+ export declare function resolveEnvironmentOrgType(environmentId: string): Promise<string>;
3
+ export declare function createEnvironmentCredential(input: {
4
+ defaultCredential: boolean;
5
+ environmentId: string;
6
+ name: string;
7
+ orgType: string;
8
+ }): Promise<EnvironmentCredential>;
9
+ export declare function updateEnvironmentCredential(input: {
10
+ credentialId: string;
11
+ defaultCredential?: boolean;
12
+ environmentId: string;
13
+ name?: string;
14
+ orgType: string;
15
+ }): Promise<EnvironmentCredential>;
@@ -0,0 +1,41 @@
1
+ import { CicdGateway } from './cicd-gateway.js';
2
+ import { buildCredentialCreatePayload, buildCredentialUpdatePayload, CUSTOM_DOMAIN_CREDENTIALS_UNSUPPORTED_MESSAGE, ENVIRONMENT_TYPE_REQUIRED_MESSAGE, EnvironmentCredentialInputError, } from './environment-credential-flags.js';
3
+ import { environmentCredentialEndpoint, environmentCredentialsEndpoint, environmentEndpoint, } from './environment-types.js';
4
+ export async function resolveEnvironmentOrgType(environmentId) {
5
+ const environment = await CicdGateway.call({
6
+ endpoint: environmentEndpoint(environmentId),
7
+ method: 'GET',
8
+ });
9
+ const orgType = typeof environment.type === 'string' ? environment.type.trim() : '';
10
+ if (orgType.length === 0) {
11
+ throw new EnvironmentCredentialInputError(ENVIRONMENT_TYPE_REQUIRED_MESSAGE);
12
+ }
13
+ if (orgType === 'Custom Domain') {
14
+ throw new EnvironmentCredentialInputError(CUSTOM_DOMAIN_CREDENTIALS_UNSUPPORTED_MESSAGE);
15
+ }
16
+ return orgType;
17
+ }
18
+ export async function createEnvironmentCredential(input) {
19
+ return CicdGateway.call({
20
+ body: buildCredentialCreatePayload(input.name, input.orgType, input.defaultCredential),
21
+ endpoint: environmentCredentialsEndpoint(input.environmentId),
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ },
25
+ method: 'POST',
26
+ });
27
+ }
28
+ export async function updateEnvironmentCredential(input) {
29
+ return CicdGateway.call({
30
+ body: buildCredentialUpdatePayload(input.orgType, {
31
+ default: input.defaultCredential,
32
+ name: input.name,
33
+ }),
34
+ endpoint: environmentCredentialEndpoint(input.environmentId, input.credentialId),
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ method: 'PATCH',
39
+ });
40
+ }
41
+ //# sourceMappingURL=environment-credential-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-credential-operations.js","sourceRoot":"","sources":["../../src/lib/environment-credential-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,6CAA6C,EAC7C,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAGL,6BAA6B,EAC7B,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,aAAqB;IACnE,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,CAAc;QACtD,QAAQ,EAAE,mBAAmB,CAAC,aAAa,CAAC;QAC5C,MAAM,EAAE,KAAK;KACd,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAEnF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,+BAA+B,CAAC,iCAAiC,CAAC,CAAA;IAC9E,CAAC;IAED,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;QAChC,MAAM,IAAI,+BAA+B,CAAC,6CAA6C,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAKjD;IACC,OAAO,WAAW,CAAC,IAAI,CAAwB;QAC7C,IAAI,EAAE,4BAA4B,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC;QACtF,QAAQ,EAAE,8BAA8B,CAAC,KAAK,CAAC,aAAa,CAAC;QAC7D,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAMjD;IACC,OAAO,WAAW,CAAC,IAAI,CAAwB;QAC7C,IAAI,EAAE,4BAA4B,CAAC,KAAK,CAAC,OAAO,EAAE;YAChD,OAAO,EAAE,KAAK,CAAC,iBAAiB;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,6BAA6B,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC;QAChF,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,MAAM,EAAE,OAAO;KAChB,CAAC,CAAA;AACJ,CAAC"}
@@ -21,6 +21,11 @@ export type EnvironmentCredential = {
21
21
  signature?: string;
22
22
  username?: string;
23
23
  };
24
+ export type EnvironmentCredentialMutationPayload = {
25
+ defaultCredential?: boolean;
26
+ name?: string;
27
+ orgType: string;
28
+ };
24
29
  export type Environment = {
25
30
  apexTestLevel?: string;
26
31
  createdBy?: string;
@@ -77,6 +82,8 @@ export type EnvironmentListFilters = ListPaginationQuery & {
77
82
  export declare const ENVIRONMENT_LIST_FILTER_KEYS: readonly ["name", "orgId", "platform", "type"];
78
83
  export declare function environmentsListEndpoint(filters?: EnvironmentListFilters): string;
79
84
  export declare function environmentEndpoint(id: string): string;
85
+ export declare function environmentCredentialsEndpoint(environmentId: string): string;
86
+ export declare function environmentCredentialEndpoint(environmentId: string, credentialId: string): string;
80
87
  export declare function environmentCredentialAuthUrlEndpoint(environmentId: string, credentialId: string, redirectUrl: string): string;
81
88
  export declare function environmentCredentialValidateEndpoint(environmentId: string, credentialId: string): string;
82
89
  export type EnvironmentCredentialValidation = {
@@ -26,6 +26,12 @@ export function environmentsListEndpoint(filters = {}) {
26
26
  export function environmentEndpoint(id) {
27
27
  return `/corpus/environments/${normalizeSalesforceId(id)}`;
28
28
  }
29
+ export function environmentCredentialsEndpoint(environmentId) {
30
+ return `/corpus/environments/${normalizeSalesforceId(environmentId)}/credentials/`;
31
+ }
32
+ export function environmentCredentialEndpoint(environmentId, credentialId) {
33
+ return `/corpus/environments/${normalizeSalesforceId(environmentId)}/credentials/${normalizeSalesforceId(credentialId)}`;
34
+ }
29
35
  export function environmentCredentialAuthUrlEndpoint(environmentId, credentialId, redirectUrl) {
30
36
  const endpoint = `/corpus/environments/${normalizeSalesforceId(environmentId)}/credentials/${normalizeSalesforceId(credentialId)}/auth-url`;
31
37
  return `${endpoint}?redirectUrl=${encodeURIComponent(redirectUrl)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"environment-types.js","sourceRoot":"","sources":["../../src/lib/environment-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,+BAA+B,EAA2B,MAAM,sBAAsB,CAAA;AAC9F,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,sBAAsB,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAU,CAAA;AAI7G,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAA;AAClD,MAAM,CAAC,MAAM,wBAAwB,GAAoB,sBAAsB,CAAA;AA8E/E,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAA8D,CAAA;AAE9I,MAAM,mCAAmC,GAAkE;IACzG,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;CACb,CAAA;AAED,MAAM,UAAU,wBAAwB,CAAC,UAAk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SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QAC9C,WAAW,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;QACzC,cAAc,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE;QAChD,oBAAoB,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE;QAC1D,oBAAoB,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE;QAC1D,wBAAwB,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE;QAClE,iCAAiC,SAAS,CAAC,WAAW,CAAC,0BAA0B,CAAC,EAAE;QACpF,4CAA4C,SAAS,CAAC,WAAW,CAAC,oCAAoC,CAAC,EAAE;QACzG,kCAAkC,SAAS,CAAC,WAAW,CAAC,0BAA0B,CAAC,EAAE;QACrF,oBAAoB,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;QAC3D,eAAe,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE;QACjD,iBAAiB,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE;QACrD,qBAAqB,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;QAC5D,uBAAuB,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE;QAChE,sBAAsB,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE;KAC/D,CAAA;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -41,6 +41,17 @@ type EnvironmentUpdateArgs = {
41
41
  type?: string;
42
42
  validationPromotionDefaultCredential?: string;
43
43
  };
44
+ type CredentialCreateArgs = {
45
+ default?: boolean;
46
+ environmentId: string;
47
+ name: string;
48
+ };
49
+ type CredentialUpdateArgs = {
50
+ default?: boolean;
51
+ environmentId: string;
52
+ id: string;
53
+ name?: string;
54
+ };
44
55
  type JobListArgs = JobListFilters & {
45
56
  mine?: boolean;
46
57
  };
@@ -179,6 +190,12 @@ declare function environmentCreate(args: EnvironmentCreateArgs): Promise<{
179
190
  declare function environmentUpdate(args: EnvironmentUpdateArgs): Promise<{
180
191
  environment: Environment;
181
192
  }>;
193
+ declare function credentialCreate(args: CredentialCreateArgs): Promise<{
194
+ credential: import("../environment-types.js").EnvironmentCredential;
195
+ }>;
196
+ declare function credentialUpdate(args: CredentialUpdateArgs): Promise<{
197
+ credential: import("../environment-types.js").EnvironmentCredential;
198
+ }>;
182
199
  declare function jobList(args: JobListArgs): Promise<Record<string, unknown>>;
183
200
  declare function jobGet(args: JobIdArgs): Promise<{
184
201
  job: import("../job-types.js").Job;
@@ -921,6 +938,8 @@ export declare const agentiaMcpToolHandlers: {
921
938
  }>;
922
939
  authGet: typeof authGet;
923
940
  authSet: typeof authSet;
941
+ credentialCreate: typeof credentialCreate;
942
+ credentialUpdate: typeof credentialUpdate;
924
943
  environmentAuthStatus: typeof environmentAuthStatus;
925
944
  environmentCreate: typeof environmentCreate;
926
945
  environmentGet: typeof environmentGet;
@@ -12,6 +12,8 @@ import { CICD_REGIONS } from '../cicd-region.js';
12
12
  import { ALL_CREDENTIAL_TYPES, credentialLabel, getCicdBaseUrl, getCredential, maskSecret, } from '../credential-store.js';
13
13
  import { readDefaults, readLastWorkItem, resolveDefaults, unsetDefaults, writeDefaults } from '../defaults-store.js';
14
14
  import { runEnvironmentAuthStatus } from '../environment-auth-status.js';
15
+ import { collectCredentialUpdateFlagKeys, validateCredentialName, } from '../environment-credential-flags.js';
16
+ import { createEnvironmentCredential, resolveEnvironmentOrgType, updateEnvironmentCredential, } from '../environment-credential-operations.js';
15
17
  import { buildCreatePayload, buildMutationPayload, ENVIRONMENT_STRING_VALIDATION_KEYS, validateNonEmptyStringFields, } from '../environment-flags.js';
16
18
  import { DEFAULT_ENVIRONMENT_PLATFORM, DEFAULT_ENVIRONMENT_TYPE, ENVIRONMENT_TYPES, environmentEndpoint, environmentsListEndpoint, } from '../environment-types.js';
17
19
  import { jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobsListPage, resolveJobStepForLog, } from '../job-types.js';
@@ -134,6 +136,43 @@ async function environmentUpdate(args) {
134
136
  });
135
137
  return { environment };
136
138
  }
139
+ async function credentialCreate(args) {
140
+ const name = assertRequired(args.name, 'name');
141
+ const nameError = validateCredentialName(name);
142
+ if (nameError !== undefined) {
143
+ throw new Error(nameError);
144
+ }
145
+ const orgType = await resolveEnvironmentOrgType(assertRequired(args.environmentId, 'environmentId'));
146
+ const credential = await createEnvironmentCredential({
147
+ defaultCredential: args.default ?? false,
148
+ environmentId: args.environmentId,
149
+ name,
150
+ orgType,
151
+ });
152
+ return { credential };
153
+ }
154
+ async function credentialUpdate(args) {
155
+ const selectedKeys = collectCredentialUpdateFlagKeys({
156
+ default: args.default,
157
+ name: args.name,
158
+ });
159
+ if (selectedKeys.length === 0) {
160
+ throw new Error('Must provide at least one field to update.');
161
+ }
162
+ const nameError = validateCredentialName(args.name);
163
+ if (nameError !== undefined) {
164
+ throw new Error(nameError);
165
+ }
166
+ const orgType = await resolveEnvironmentOrgType(assertRequired(args.environmentId, 'environmentId'));
167
+ const credential = await updateEnvironmentCredential({
168
+ credentialId: assertRequired(args.id, 'id'),
169
+ defaultCredential: args.default,
170
+ environmentId: args.environmentId,
171
+ name: args.name,
172
+ orgType,
173
+ });
174
+ return { credential };
175
+ }
137
176
  async function jobList(args) {
138
177
  const filters = {
139
178
  context: args.context,
@@ -700,6 +739,8 @@ export const agentiaMcpToolHandlers = {
700
739
  ...agentiaMcpAiToolHandlers,
701
740
  authGet,
702
741
  authSet,
742
+ credentialCreate,
743
+ credentialUpdate,
703
744
  environmentAuthStatus,
704
745
  environmentCreate,
705
746
  environmentGet,
@@ -840,6 +881,25 @@ export function registerAgentiaMcpTools(server) {
840
881
  },
841
882
  title: 'Agentia Environment Update',
842
883
  }, (args) => safelyHandleTool(() => environmentUpdate(args)));
884
+ server.registerTool('agentia_credential_create', {
885
+ description: 'Create a Copado environment credential via the CICD gateway.',
886
+ inputSchema: {
887
+ default: z.boolean().optional().describe('Mark this credential as the environment default.'),
888
+ environmentId: z.string().describe('Copado environment Id.'),
889
+ name: z.string().describe('Credential name.'),
890
+ },
891
+ title: 'Agentia Credential Create',
892
+ }, (args) => safelyHandleTool(() => credentialCreate(args)));
893
+ server.registerTool('agentia_credential_update', {
894
+ description: 'Update a Copado environment credential by Id via the CICD gateway.',
895
+ inputSchema: {
896
+ default: z.boolean().optional().describe('Mark this credential as the environment default.'),
897
+ environmentId: z.string().describe('Copado environment Id.'),
898
+ id: z.string().describe('Copado credential Id.'),
899
+ name: z.string().optional().describe('Credential name.'),
900
+ },
901
+ title: 'Agentia Credential Update',
902
+ }, (args) => safelyHandleTool(() => credentialUpdate(args)));
843
903
  server.registerTool('agentia_promotion_list', {
844
904
  description: 'List Copado promotions via the CICD gateway.',
845
905
  inputSchema: promotionListSchema,