@forge/cli-shared 5.1.0-next.1 → 5.1.0-next.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @forge/cli-shared
2
2
 
3
+ ## 5.1.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bf2dda: Get AAID from AGG when credentials are supplied via environment
8
+
3
9
  ## 5.1.0-next.1
4
10
 
5
11
  ### Minor Changes
@@ -1,7 +1,8 @@
1
1
  import * as t from 'io-ts';
2
- import { Logger } from '../../ui';
3
2
  import { CachedConf } from '../../cache';
4
3
  import { UserError } from '../../shared';
4
+ import { Logger } from '../../ui';
5
+ import { UserRepository } from './user-repository';
5
6
  export declare const EMAIL_KEY = "FORGE_EMAIL";
6
7
  export declare const API_TOKEN_KEY = "FORGE_API_TOKEN";
7
8
  export interface Keytar {
@@ -30,7 +31,6 @@ export declare class KeytarAccessError extends UserError {
30
31
  }
31
32
  export interface CredentialGetter {
32
33
  getCredentials(): Promise<PersonalApiCredentialsValidated>;
33
- getInstructionsWhenInvalid(): string;
34
34
  }
35
35
  export interface CredentialStore extends CredentialGetter {
36
36
  setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
@@ -41,8 +41,9 @@ export declare class CredentialStoreImpl implements CredentialStore {
41
41
  private readonly instructionsURL;
42
42
  private readonly keytar;
43
43
  private readonly cachedConfig;
44
+ private readonly userRepository;
44
45
  private keytarAccount;
45
- constructor(logger: Logger, instructionsURL: string, keytar: Keytar | null, cachedConfig: CachedConf);
46
+ constructor(logger: Logger, instructionsURL: string, keytar: Keytar | null, cachedConfig: CachedConf, userRepository: UserRepository);
46
47
  private wrapKeytarError;
47
48
  decodeCredentials(credentialsString: string | null): PersonalApiCredentialsValidated;
48
49
  getCredentialsKeytar(keytar: Keytar): Promise<PersonalApiCredentialsValidated | undefined>;
@@ -51,7 +52,6 @@ export declare class CredentialStoreImpl implements CredentialStore {
51
52
  getCredentials(): Promise<PersonalApiCredentialsValidated>;
52
53
  setCredentials(credentials: PersonalApiCredentialsValidated): Promise<void>;
53
54
  deleteCredentials(): Promise<void>;
54
- getInstructionsWhenInvalid(): string;
55
55
  }
56
- export declare function getCredentialStore(logger: Logger): CredentialStore;
56
+ export declare function getCredentialStore(logger: Logger, userRepository: UserRepository): CredentialStore;
57
57
  //# sourceMappingURL=credential-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/credential-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAQ,MAAM,UAAU,CAAC;AACxC,OAAO,EAAuB,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,SAAS,EAAa,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,SAAS,gBAAgB,CAAC;AACvC,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAc/C,MAAM,WAAW,MAAM;IACrB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEtE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAUD,eAAO,MAAM,2BAA2B;;;EAGtC,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;EAI/C,CAAC;AAEH,oBAAY,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAClF,oBAAY,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oCAAoC,C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AAC;CAC5D;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,cAAc,CAAC,WAAW,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,qBAAa,mBAAoB,YAAW,eAAe;IAIvD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAPjC,OAAO,CAAC,aAAa,CAAS;gBAGX,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,YAAY,EAAE,UAAU,EACxB,cAAc,EAAE,cAAc;IAKjD,OAAO,CAAC,eAAe;IAoBvB,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,+BAA+B;IAoB9E,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,+BAA+B,GAAG,SAAS,CAAC;IAehG,+BAA+B,IAAI,+BAA+B,GAAG,SAAS;IAS9E,kCAAkC,IAAI,IAAI;IAIpC,cAAc,IAAI,OAAO,CAAC,+BAA+B,CAAC;IA8B1D,cAAc,CAAC,WAAW,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3E,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;CAWzC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,eAAe,CAKlG"}
@@ -5,14 +5,13 @@ const tslib_1 = require("tslib");
5
5
  const os_1 = require("os");
6
6
  const Either_1 = require("fp-ts/lib/Either");
7
7
  const t = tslib_1.__importStar(require("io-ts"));
8
- const ui_1 = require("../../ui");
9
8
  const cache_1 = require("../../cache");
10
9
  const instruction_1 = require("../instruction");
11
10
  const graphql_1 = require("../../graphql");
12
11
  const shared_1 = require("../../shared");
12
+ const ui_1 = require("../../ui");
13
13
  exports.EMAIL_KEY = 'FORGE_EMAIL';
14
14
  exports.API_TOKEN_KEY = 'FORGE_API_TOKEN';
15
- const AAID_KEY = 'FORGE_AAID';
16
15
  const KEYTAR_SERVICE = 'Atlassian';
17
16
  const CACHE_CREDENTIALS_KEY = 'forge-credentials';
18
17
  var KeytarAccount;
@@ -60,12 +59,14 @@ class CredentialStoreImpl {
60
59
  instructionsURL;
61
60
  keytar;
62
61
  cachedConfig;
62
+ userRepository;
63
63
  keytarAccount;
64
- constructor(logger, instructionsURL, keytar, cachedConfig) {
64
+ constructor(logger, instructionsURL, keytar, cachedConfig, userRepository) {
65
65
  this.logger = logger;
66
66
  this.instructionsURL = instructionsURL;
67
67
  this.keytar = keytar;
68
68
  this.cachedConfig = cachedConfig;
69
+ this.userRepository = userRepository;
69
70
  this.keytarAccount = (0, graphql_1.getEnvironment)(KeytarAccount);
70
71
  }
71
72
  wrapKeytarError(e) {
@@ -140,11 +141,12 @@ class CredentialStoreImpl {
140
141
  }
141
142
  }
142
143
  if (process.env[exports.API_TOKEN_KEY] && process.env[exports.EMAIL_KEY]) {
143
- return {
144
+ const credentials = {
144
145
  email: process.env[exports.EMAIL_KEY],
145
- token: process.env[exports.API_TOKEN_KEY],
146
- accountId: process.env[AAID_KEY] || ''
146
+ token: process.env[exports.API_TOKEN_KEY]
147
147
  };
148
+ const { accountId } = await this.userRepository.getUser(credentials);
149
+ return { ...credentials, accountId };
148
150
  }
149
151
  if (this.keytar) {
150
152
  const result = await this.getCredentialsKeytar(this.keytar);
@@ -177,18 +179,12 @@ class CredentialStoreImpl {
177
179
  }
178
180
  this.deleteInsecurePlaintextCredentials();
179
181
  }
180
- getInstructionsWhenInvalid() {
181
- if (process.env[exports.API_TOKEN_KEY] && process.env[exports.EMAIL_KEY]) {
182
- return ui_1.Text.error.invalidTokenInEnv(this.instructionsURL, exports.EMAIL_KEY, exports.API_TOKEN_KEY);
183
- }
184
- return ui_1.Text.error.invalidTokenInKeytar;
185
- }
186
182
  }
187
183
  exports.CredentialStoreImpl = CredentialStoreImpl;
188
- function getCredentialStore(logger) {
184
+ function getCredentialStore(logger, userRepository) {
189
185
  const keytar = getKeytar();
190
186
  const cachedConfig = cache_1.CachedConf.getCache(cache_1.CONFIG_PROJECT_NAME);
191
187
  const instructionsUrl = (0, instruction_1.getInstructionsUrl)();
192
- return new CredentialStoreImpl(logger, instructionsUrl, keytar, cachedConfig);
188
+ return new CredentialStoreImpl(logger, instructionsUrl, keytar, cachedConfig, userRepository);
193
189
  }
194
190
  exports.getCredentialStore = getCredentialStore;
@@ -3,4 +3,5 @@ export * from './login';
3
3
  export * from './logout';
4
4
  export * from './me-graphql-client';
5
5
  export * from './token-authenticator';
6
+ export * from './user-repository';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
@@ -6,3 +6,4 @@ tslib_1.__exportStar(require("./login"), exports);
6
6
  tslib_1.__exportStar(require("./logout"), exports);
7
7
  tslib_1.__exportStar(require("./me-graphql-client"), exports);
8
8
  tslib_1.__exportStar(require("./token-authenticator"), exports);
9
+ tslib_1.__exportStar(require("./user-repository"), exports);
@@ -1,19 +1,10 @@
1
- import { GraphQLClient, User } from '../../graphql';
2
- import { Logger } from '../../ui';
3
- import { Authenticator } from '../../auth';
4
- import { CredentialStore, PersonalApiCredentials, PersonalApiCredentialsValidated } from './credential-store';
1
+ import { User } from '../../graphql';
2
+ import { UserRepository } from '../../auth';
3
+ import { CredentialStore, PersonalApiCredentials } from './credential-store';
5
4
  export declare class LoginCommand {
6
- private readonly createGraphQLClient;
5
+ private readonly userRepository;
7
6
  private readonly store;
8
- private readonly logger;
9
- constructor(createGraphQLClient: (authenticator: Authenticator) => GraphQLClient, store: CredentialStore, logger: Logger);
10
- execute(credentials: PersonalApiCredentials): Promise<{
11
- user: User;
12
- creds: PersonalApiCredentialsValidated;
13
- analytics: {
14
- userId: string;
15
- };
16
- }>;
17
- getUser(credentials: PersonalApiCredentials): Promise<User>;
7
+ constructor(userRepository: UserRepository, store: CredentialStore);
8
+ execute(credentials: PersonalApiCredentials): Promise<User>;
18
9
  }
19
10
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAE9G,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,mBAAmB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,aAAa,EACpE,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM;IAGpB,OAAO,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAAC;QACjE,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,EAAE,+BAA+B,CAAC;QACvC,SAAS,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/B,CAAC;IAmBW,OAAO,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAUzE"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,eAAe;IAG5B,OAAO,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAOzE"}
@@ -1,40 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoginCommand = void 0;
4
- const me_graphql_client_1 = require("./me-graphql-client");
5
- const token_authenticator_1 = require("./token-authenticator");
6
4
  class LoginCommand {
7
- createGraphQLClient;
5
+ userRepository;
8
6
  store;
9
- logger;
10
- constructor(createGraphQLClient, store, logger) {
11
- this.createGraphQLClient = createGraphQLClient;
7
+ constructor(userRepository, store) {
8
+ this.userRepository = userRepository;
12
9
  this.store = store;
13
- this.logger = logger;
14
10
  }
15
11
  async execute(credentials) {
16
- const user = await this.getUser(credentials);
17
- const creds = {
18
- ...credentials,
19
- accountId: user.accountId
20
- };
21
- await this.store.setCredentials(creds);
22
- return {
23
- user,
24
- creds,
25
- analytics: {
26
- userId: creds.accountId
27
- }
28
- };
29
- }
30
- async getUser(credentials) {
31
- const authenticator = new token_authenticator_1.PersonalTokenAuthenticator({
32
- getCredentials: async () => ({ ...credentials, accountId: '' }),
33
- getInstructionsWhenInvalid: this.store.getInstructionsWhenInvalid
34
- });
35
- const graphqlClient = this.createGraphQLClient(authenticator);
36
- const meClient = new me_graphql_client_1.MeGraphqlClient(graphqlClient, this.logger);
37
- return await meClient.getUser();
12
+ const user = await this.userRepository.getUser(credentials);
13
+ await this.store.setCredentials({ ...credentials, accountId: user.accountId });
14
+ return user;
38
15
  }
39
16
  }
40
17
  exports.LoginCommand = LoginCommand;
@@ -1 +1 @@
1
- {"version":3,"file":"token-authenticator.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/token-authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,0BAA2B,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,gBAAgB;IAEjD,sBAAsB;IAO5B,0BAA0B,IAAI,MAAM;CAG5C"}
1
+ {"version":3,"file":"token-authenticator.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/token-authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAiB,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAEhF,qBAAa,0BAA2B,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,gBAAgB;IAEjD,sBAAsB;IAO5B,0BAA0B,IAAI,MAAM;CAO5C"}
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PersonalTokenAuthenticator = void 0;
4
+ const ui_1 = require("../../ui");
4
5
  const authenticator_1 = require("../authenticator");
6
+ const instruction_1 = require("../instruction");
7
+ const credential_store_1 = require("./credential-store");
5
8
  class PersonalTokenAuthenticator {
6
9
  credentialStore;
7
10
  constructor(credentialStore) {
@@ -12,7 +15,11 @@ class PersonalTokenAuthenticator {
12
15
  return (0, authenticator_1.getBasicAuthorizationHeader)(email, token);
13
16
  }
14
17
  getInstructionsWhenInvalid() {
15
- return this.credentialStore.getInstructionsWhenInvalid();
18
+ const instructionsUrl = (0, instruction_1.getInstructionsUrl)();
19
+ if (process.env[credential_store_1.API_TOKEN_KEY] && process.env[credential_store_1.EMAIL_KEY]) {
20
+ return ui_1.Text.error.invalidTokenInEnv(instructionsUrl, credential_store_1.EMAIL_KEY, credential_store_1.API_TOKEN_KEY);
21
+ }
22
+ return ui_1.Text.error.invalidTokenInKeytar;
16
23
  }
17
24
  }
18
25
  exports.PersonalTokenAuthenticator = PersonalTokenAuthenticator;
@@ -0,0 +1,14 @@
1
+ import { GraphQLClient, User } from '../../graphql';
2
+ import { Logger } from '../../ui';
3
+ import { Authenticator } from '..';
4
+ import { PersonalApiCredentials } from './credential-store';
5
+ export interface UserRepository {
6
+ getUser(credentials: PersonalApiCredentials): Promise<User>;
7
+ }
8
+ export declare class UserRepositoryImpl {
9
+ private readonly createGraphQLClient;
10
+ private readonly logger;
11
+ constructor(createGraphQLClient: (authenticator: Authenticator) => GraphQLClient, logger: Logger);
12
+ getUser(credentials: PersonalApiCredentials): Promise<User>;
13
+ }
14
+ //# sourceMappingURL=user-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-repository.d.ts","sourceRoot":"","sources":["../../../src/auth/personal/user-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAInC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,mBAAmB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,aAAa,EACpE,MAAM,EAAE,MAAM;IAGpB,OAAO,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CASzE"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserRepositoryImpl = void 0;
4
+ const me_graphql_client_1 = require("./me-graphql-client");
5
+ const token_authenticator_1 = require("./token-authenticator");
6
+ class UserRepositoryImpl {
7
+ createGraphQLClient;
8
+ logger;
9
+ constructor(createGraphQLClient, logger) {
10
+ this.createGraphQLClient = createGraphQLClient;
11
+ this.logger = logger;
12
+ }
13
+ async getUser(credentials) {
14
+ const authenticator = new token_authenticator_1.PersonalTokenAuthenticator({
15
+ getCredentials: async () => ({ ...credentials, accountId: '' })
16
+ });
17
+ const graphqlClient = this.createGraphQLClient(authenticator);
18
+ const meClient = new me_graphql_client_1.MeGraphqlClient(graphqlClient, this.logger);
19
+ return await meClient.getUser();
20
+ }
21
+ }
22
+ exports.UserRepositoryImpl = UserRepositoryImpl;
@@ -53619,6 +53619,16 @@ export declare type ToolchainDisassociateContainersPayload = Payload & {
53619
53619
  errors?: Maybe<Array<MutationError>>;
53620
53620
  success: Scalars['Boolean']['output'];
53621
53621
  };
53622
+ export declare enum ToolchainDisassociateEntitiesErrorCode {
53623
+ UnknownAssociation = "UNKNOWN_ASSOCIATION"
53624
+ }
53625
+ export declare type ToolchainDisassociateEntitiesErrorExtension = MutationErrorExtension & {
53626
+ __typename?: 'ToolchainDisassociateEntitiesErrorExtension';
53627
+ entityId?: Maybe<Scalars['ID']['output']>;
53628
+ errorCode?: Maybe<ToolchainDisassociateEntitiesErrorCode>;
53629
+ errorType?: Maybe<Scalars['String']['output']>;
53630
+ statusCode?: Maybe<Scalars['Int']['output']>;
53631
+ };
53622
53632
  export declare type ToolchainDisassociateEntitiesInput = {
53623
53633
  cloudId: Scalars['ID']['input'];
53624
53634
  disassociations: Array<ToolchainDisassociateEntityInput>;