@forge/cli 0.0.0-experimental-819498d → 0.0.0-experimental-a9f00a0

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.
Files changed (135) hide show
  1. package/CHANGELOG.md +2901 -7
  2. package/README.md +18 -19
  3. package/npm-shrinkwrap.json +1957 -4159
  4. package/out/analytics-client/analytics-client.d.ts +0 -24
  5. package/out/analytics-client/analytics-client.d.ts.map +1 -1
  6. package/out/analytics-client/analytics-client.js +0 -115
  7. package/out/analytics-client/analytics-message-handler.d.ts +1 -5
  8. package/out/analytics-client/analytics-message-handler.d.ts.map +1 -1
  9. package/out/analytics-client/analytics-message-handler.js +2 -30
  10. package/out/autocomplete/autocomplete-config.json +16 -26
  11. package/out/bin/cli.js +0 -2
  12. package/out/bin/postinstall.js +0 -13
  13. package/out/command-line/anon-user-id.js +6 -10
  14. package/out/command-line/command.d.ts +7 -3
  15. package/out/command-line/command.d.ts.map +1 -1
  16. package/out/command-line/command.js +56 -60
  17. package/out/command-line/controller/deploy-controller.d.ts +13 -2
  18. package/out/command-line/controller/deploy-controller.d.ts.map +1 -1
  19. package/out/command-line/controller/deploy-controller.js +67 -5
  20. package/out/command-line/controller/install-controller.d.ts +2 -1
  21. package/out/command-line/controller/install-controller.d.ts.map +1 -1
  22. package/out/command-line/controller/install-controller.js +28 -32
  23. package/out/command-line/controller/lint-controller.js +1 -1
  24. package/out/command-line/controller/pre-command-controller.js +1 -1
  25. package/out/command-line/controller/prerequisites-controller.d.ts +11 -0
  26. package/out/command-line/controller/prerequisites-controller.d.ts.map +1 -0
  27. package/out/command-line/controller/prerequisites-controller.js +34 -0
  28. package/out/command-line/controller/stubController.d.ts +9 -0
  29. package/out/command-line/controller/stubController.d.ts.map +1 -0
  30. package/out/command-line/controller/stubController.js +15 -0
  31. package/out/command-line/controller/tunnel-controller.d.ts.map +1 -1
  32. package/out/command-line/controller/tunnel-controller.js +0 -1
  33. package/out/command-line/dependency-injection.d.ts +11 -3
  34. package/out/command-line/dependency-injection.d.ts.map +1 -1
  35. package/out/command-line/dependency-injection.js +38 -23
  36. package/out/command-line/index.d.ts.map +1 -1
  37. package/out/command-line/index.js +4 -0
  38. package/out/command-line/register-app-commands.d.ts.map +1 -1
  39. package/out/command-line/register-app-commands.js +1 -9
  40. package/out/command-line/register-authentication-command.d.ts.map +1 -1
  41. package/out/command-line/register-authentication-command.js +0 -16
  42. package/out/command-line/register-deployment-commands.d.ts +8 -0
  43. package/out/command-line/register-deployment-commands.d.ts.map +1 -1
  44. package/out/command-line/register-environment-variables-commands.d.ts +1 -1
  45. package/out/command-line/register-environment-variables-commands.d.ts.map +1 -1
  46. package/out/command-line/register-environment-variables-commands.js +22 -7
  47. package/out/command-line/register-installation-commands.d.ts +1 -1
  48. package/out/command-line/register-installation-commands.d.ts.map +1 -1
  49. package/out/command-line/register-installation-commands.js +19 -13
  50. package/out/command-line/register-providers-commands.d.ts +3 -0
  51. package/out/command-line/register-providers-commands.d.ts.map +1 -0
  52. package/out/command-line/register-providers-commands.js +43 -0
  53. package/out/command-line/register-webtrigger-commands.d.ts.map +1 -1
  54. package/out/command-line/register-webtrigger-commands.js +9 -11
  55. package/out/command-line/unique-machine-id.d.ts.map +1 -1
  56. package/out/command-line/unique-machine-id.js +1 -10
  57. package/out/command-line/version-info.d.ts +1 -0
  58. package/out/command-line/version-info.d.ts.map +1 -1
  59. package/out/command-line/version-info.js +3 -2
  60. package/out/command-line/view/deploy-view.d.ts +7 -1
  61. package/out/command-line/view/deploy-view.d.ts.map +1 -1
  62. package/out/command-line/view/deploy-view.js +22 -5
  63. package/out/command-line/view/install-view.d.ts +5 -5
  64. package/out/command-line/view/install-view.d.ts.map +1 -1
  65. package/out/command-line/view/install-view.js +20 -15
  66. package/out/command-line/view/lint-view.d.ts +3 -2
  67. package/out/command-line/view/lint-view.d.ts.map +1 -1
  68. package/out/command-line/view/lint-view.js +3 -0
  69. package/out/command-line/view/lite-lint-view.d.ts +3 -2
  70. package/out/command-line/view/lite-lint-view.d.ts.map +1 -1
  71. package/out/command-line/view/lite-lint-view.js +3 -0
  72. package/out/deploy/deployer/deploy-monitor-graphql-client.js +1 -1
  73. package/out/deploy/deployer/trigger-deploy-graphql-client.js +1 -1
  74. package/out/deploy/packager/archiver.d.ts +3 -2
  75. package/out/deploy/packager/archiver.d.ts.map +1 -1
  76. package/out/deploy/packager/archiver.js +10 -2
  77. package/out/deploy/packager/packager.d.ts +1 -3
  78. package/out/deploy/packager/packager.d.ts.map +1 -1
  79. package/out/deploy/packager/packager.js +2 -25
  80. package/out/deploy/uploader/artifact-graphql-client.js +2 -2
  81. package/out/environment-variables/graphql-client.d.ts +1 -1
  82. package/out/environment-variables/graphql-client.js +3 -3
  83. package/out/installations/graphql-client.d.ts +7 -9
  84. package/out/installations/graphql-client.d.ts.map +1 -1
  85. package/out/installations/graphql-client.js +61 -85
  86. package/out/installations/install-app-site.d.ts +2 -8
  87. package/out/installations/install-app-site.d.ts.map +1 -1
  88. package/out/installations/install-app-site.js +2 -3
  89. package/out/installations/uninstall-app.d.ts +0 -1
  90. package/out/installations/uninstall-app.d.ts.map +1 -1
  91. package/out/installations/uninstall-app.js +2 -4
  92. package/out/migration-keys/graphql-client.d.ts +8 -0
  93. package/out/migration-keys/graphql-client.d.ts.map +1 -0
  94. package/out/migration-keys/graphql-client.js +55 -0
  95. package/out/providers/configure-provider.d.ts +19 -0
  96. package/out/providers/configure-provider.d.ts.map +1 -0
  97. package/out/providers/configure-provider.js +14 -0
  98. package/out/providers/graphql-client.d.ts +12 -0
  99. package/out/providers/graphql-client.d.ts.map +1 -0
  100. package/out/providers/graphql-client.js +47 -0
  101. package/out/service/installation-service.d.ts +13 -11
  102. package/out/service/installation-service.d.ts.map +1 -1
  103. package/out/service/installation-service.js +38 -13
  104. package/out/service/lint-service.d.ts +2 -2
  105. package/out/service/lint-service.d.ts.map +1 -1
  106. package/out/service/lint-service.js +2 -2
  107. package/out/service/lite-lint-service.d.ts +3 -3
  108. package/out/service/lite-lint-service.d.ts.map +1 -1
  109. package/out/service/lite-lint-service.js +2 -2
  110. package/out/service/migration-keys-service.d.ts +19 -0
  111. package/out/service/migration-keys-service.d.ts.map +1 -0
  112. package/out/service/migration-keys-service.js +14 -0
  113. package/out/service/resource-packaging-service.d.ts +3 -2
  114. package/out/service/resource-packaging-service.d.ts.map +1 -1
  115. package/out/service/resource-packaging-service.js +6 -2
  116. package/out/service/tunnel-analytics-service.d.ts +0 -5
  117. package/out/service/tunnel-analytics-service.d.ts.map +1 -1
  118. package/out/service/tunnel-analytics-service.js +3 -14
  119. package/out/service/tunnel-service.d.ts +1 -3
  120. package/out/service/tunnel-service.d.ts.map +1 -1
  121. package/out/service/tunnel-service.js +8 -9
  122. package/out/webtrigger/get-webtrigger-url.d.ts +10 -4
  123. package/out/webtrigger/get-webtrigger-url.d.ts.map +1 -1
  124. package/out/webtrigger/get-webtrigger-url.js +11 -21
  125. package/out/webtrigger/graphql-client.d.ts +14 -0
  126. package/out/webtrigger/graphql-client.d.ts.map +1 -0
  127. package/out/webtrigger/graphql-client.js +52 -0
  128. package/out/workers/forge-cli-workers.js +2 -2
  129. package/package.json +12 -13
  130. package/out/bin/preinstall.d.ts +0 -3
  131. package/out/bin/preinstall.d.ts.map +0 -1
  132. package/out/bin/preinstall.js +0 -9
  133. package/out/command-line/cli-prerequisites.d.ts +0 -3
  134. package/out/command-line/cli-prerequisites.d.ts.map +0 -1
  135. package/out/command-line/cli-prerequisites.js +0 -37
@@ -21,7 +21,9 @@ export declare class UpgradeError extends GraphQlMutationError {
21
21
  }
22
22
  export declare class EnvironmentNotFoundError extends Error {
23
23
  }
24
- export declare class MissingInstallationDetailsError extends Error {
24
+ export declare class MissingTaskIdError extends Error {
25
+ }
26
+ export declare class InstallationRequestFailedError extends Error {
25
27
  }
26
28
  export declare class MissingAppError extends Error {
27
29
  }
@@ -40,22 +42,18 @@ export declare class InstallationsGraphqlClient implements InstallAppClient, Lis
40
42
  private readonly pause;
41
43
  static buildInstallationContext(product: string, cloudId: string): string;
42
44
  constructor(graphqlClient: GraphQLClient, pause: Pause);
43
- installAppIntoSite({ environmentKey, site, product, appId }: AppInstallSiteDetails): Promise<{
44
- installationId: string;
45
- }>;
46
- upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<{
47
- installationId: string;
48
- }>;
45
+ installAppIntoSite({ environmentKey, site, product, appId }: AppInstallSiteDetails): Promise<void>;
46
+ upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<void>;
47
+ private monitorAppInstallOrUpgrade;
49
48
  uninstallApp(input: AppUninstallationInput): Promise<boolean>;
50
49
  uninstallMultipleApps(apps: AppUninstallationInput[]): Promise<Partial<UninstallAppOutput>[]>;
51
50
  listInstallations(appId: string): Promise<Installation[]>;
52
51
  getInstallation(appId: string, installationId: string): Promise<Installation>;
53
52
  private getAppInstallationTask;
54
53
  private monitorUninstallApp;
55
- private createCloudIdToHostnameMap;
56
54
  private resolveInstallationsHostnames;
57
55
  private getAllInstallations;
58
56
  private getCloudId;
59
- getScopes(appId: string, environmentKey: string): Promise<AppEnvironment['scopes']>;
57
+ getVersions(appId: string, environmentKey: string, firstN?: number): Promise<AppEnvironment['versions']>;
60
58
  }
61
59
  //# sourceMappingURL=graphql-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/installations/graphql-client.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EACL,cAAc,EAGd,aAAa,EACb,oBAAoB,EAEpB,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,sBAAsB,EAQvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,iCAAi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AAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;IAmB7F,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAKzD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;YAS5E,sBAAsB;YA8BtB,mBAAmB;YAiBnB,6BAA6B;YAI7B,mBAAmB;YAsCnB,UAAU;IAgBX,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;CAqCjH"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InstallationsGraphqlClient = exports.InvalidAtlassianSiteError = exports.UnknownSiteWithoutCloudIdError = exports.InstallationNotFoundError = exports.MissingAppUninstallTask = exports.MissingAppError = exports.MissingInstallationDetailsError = exports.EnvironmentNotFoundError = exports.UpgradeError = exports.InstallationError = exports.AlreadyInstalledError = exports.PermissionDeniedError = exports.ALREADY_UPGRADED_CODE = exports.UNINSTALLATION_EVENT_POLL_INTERVAL = void 0;
4
- const cs_ari_1 = require("@forge/util/packages/cs-ari");
3
+ exports.InstallationsGraphqlClient = exports.InvalidAtlassianSiteError = exports.UnknownSiteWithoutCloudIdError = exports.InstallationNotFoundError = exports.MissingAppUninstallTask = exports.MissingAppError = exports.InstallationRequestFailedError = exports.MissingTaskIdError = exports.EnvironmentNotFoundError = exports.UpgradeError = exports.InstallationError = exports.AlreadyInstalledError = exports.PermissionDeniedError = exports.ALREADY_UPGRADED_CODE = exports.UNINSTALLATION_EVENT_POLL_INTERVAL = void 0;
5
4
  const cli_shared_1 = require("@forge/cli-shared");
6
5
  const cli_shared_2 = require("@forge/cli-shared");
7
6
  const cli_shared_3 = require("@forge/cli-shared");
@@ -36,9 +35,12 @@ exports.UpgradeError = UpgradeError;
36
35
  class EnvironmentNotFoundError extends Error {
37
36
  }
38
37
  exports.EnvironmentNotFoundError = EnvironmentNotFoundError;
39
- class MissingInstallationDetailsError extends Error {
38
+ class MissingTaskIdError extends Error {
40
39
  }
41
- exports.MissingInstallationDetailsError = MissingInstallationDetailsError;
40
+ exports.MissingTaskIdError = MissingTaskIdError;
41
+ class InstallationRequestFailedError extends Error {
42
+ }
43
+ exports.InstallationRequestFailedError = InstallationRequestFailedError;
42
44
  class MissingAppError extends Error {
43
45
  }
44
46
  exports.MissingAppError = MissingAppError;
@@ -60,12 +62,6 @@ class InvalidAtlassianSiteError extends Error {
60
62
  }
61
63
  }
62
64
  exports.InvalidAtlassianSiteError = InvalidAtlassianSiteError;
63
- const tenantToHostname = (tenantInfo) => {
64
- if (!tenantInfo) {
65
- return null;
66
- }
67
- return tenantInfo.hostName || null;
68
- };
69
65
  const tenantContextsToCloudId = (url, contexts) => {
70
66
  if (!contexts.length) {
71
67
  throw new InvalidAtlassianSiteError(url);
@@ -82,27 +78,22 @@ class InstallationsGraphqlClient {
82
78
  this.pause = pause;
83
79
  }
84
80
  static buildInstallationContext(product, cloudId) {
85
- const ari = new cs_ari_1.ResourceIdentifier({
86
- resourceOwner: product.toLowerCase(),
87
- resourceType: 'site',
88
- resourceId: cloudId
89
- });
90
- return ari.toString();
81
+ return '';
91
82
  }
92
83
  async installAppIntoSite({ environmentKey, site, product, appId }) {
93
84
  const cloudId = await this.getCloudId(site);
94
85
  const installationContext = InstallationsGraphqlClient.buildInstallationContext(product, cloudId);
95
86
  const query = `
96
- mutation installApp($input: AppInstallationInput!) {
87
+ mutation forge_cli_installApplication($input: AppInstallationInput!) {
97
88
  installApp(input: $input) {
98
89
  success
90
+ taskId
99
91
  errors {
100
92
  message
101
93
  extensions {
102
94
  errorType
103
95
  }
104
96
  }
105
- installationId
106
97
  }
107
98
  }
108
99
  `;
@@ -110,39 +101,40 @@ class InstallationsGraphqlClient {
110
101
  input: {
111
102
  installationContext,
112
103
  appId,
113
- environmentKey
104
+ environmentKey,
105
+ async: true
114
106
  }
115
107
  };
116
- const { response: { installApp: { success, installationId, errors } }, requestId } = await this.graphqlClient.mutate(query, variables);
108
+ const { response: { installApp: { success, taskId, errors } }, requestId } = await this.graphqlClient.mutate(query, variables);
117
109
  const error = cli_shared_2.getError(errors);
118
110
  if (!success) {
119
111
  if (error.code === ALREADY_INSTALLED_CODE) {
120
112
  throw new AlreadyInstalledError();
121
113
  }
122
114
  if (error.code === PERMISSION_DENIED) {
123
- throw new PermissionDeniedError(requestId, cs_ari_1.parse(appId).resourceId);
115
+ throw new Error();
124
116
  }
125
117
  throw new InstallationError(`${error.message} (requestId: ${requestId || 'unknown'})`, error.code);
126
118
  }
127
- if (!installationId) {
128
- throw new MissingInstallationDetailsError(error.message);
119
+ if (!taskId) {
120
+ throw new MissingTaskIdError(error.message);
129
121
  }
130
- return { installationId };
122
+ await this.monitorAppInstallOrUpgrade(taskId);
131
123
  }
132
124
  async upgradeInstallation({ site, product, environmentKey, appId }) {
133
125
  const cloudId = await this.getCloudId(site);
134
126
  const installationContext = InstallationsGraphqlClient.buildInstallationContext(product, cloudId);
135
127
  const query = `
136
- mutation upgradeApp($input: AppInstallationUpgradeInput!) {
128
+ mutation forge_cli_upgradeApplication($input: AppInstallationUpgradeInput!) {
137
129
  upgradeApp(input: $input) {
138
130
  success
131
+ taskId
139
132
  errors {
140
133
  message
141
134
  extensions {
142
135
  errorType
143
136
  }
144
137
  }
145
- installationId
146
138
  }
147
139
  }
148
140
  `;
@@ -150,22 +142,35 @@ class InstallationsGraphqlClient {
150
142
  input: {
151
143
  installationContext,
152
144
  appId,
153
- environmentKey
145
+ environmentKey,
146
+ async: true
154
147
  }
155
148
  };
156
- const { response: { upgradeApp: { success, installationId, errors } }, requestId } = await this.graphqlClient.mutate(query, variables);
149
+ const { response: { upgradeApp: { success, errors, taskId } }, requestId } = await this.graphqlClient.mutate(query, variables);
157
150
  const error = cli_shared_2.getError(errors);
158
151
  if (!success) {
159
152
  throw new UpgradeError(`${error.message} (requestId: ${requestId || 'unknown'})`, error.code);
160
153
  }
161
- if (!installationId) {
162
- throw new MissingInstallationDetailsError(error.message);
154
+ if (!taskId) {
155
+ throw new MissingTaskIdError(error.message);
156
+ }
157
+ await this.monitorAppInstallOrUpgrade(taskId);
158
+ }
159
+ async monitorAppInstallOrUpgrade(taskId) {
160
+ let status = cli_shared_1.AppTaskState.Pending;
161
+ while (status !== cli_shared_1.AppTaskState.Complete) {
162
+ const { state, errors } = await this.getAppInstallationTask(taskId);
163
+ status = state;
164
+ if (status === cli_shared_1.AppTaskState.Failed) {
165
+ throw new InstallationRequestFailedError((errors === null || errors === void 0 ? void 0 : errors[0].message) || undefined);
166
+ }
167
+ if (status !== cli_shared_1.AppTaskState.Complete)
168
+ await this.pause(exports.UNINSTALLATION_EVENT_POLL_INTERVAL);
163
169
  }
164
- return { installationId };
165
170
  }
166
171
  async uninstallApp(input) {
167
172
  const query = `
168
- mutation uninstallApp($input: AppUninstallationInput!) {
173
+ mutation forge_cli_uninstallApplication($input: AppUninstallationInput!) {
169
174
  uninstallApp(input: $input) {
170
175
  success
171
176
  taskId
@@ -215,7 +220,7 @@ class InstallationsGraphqlClient {
215
220
  }
216
221
  async getAppInstallationTask(taskId) {
217
222
  const query = `
218
- query appInstallationTask($id: ID!) {
223
+ query forge_cli_getInstallationTask($id: ID!) {
219
224
  appInstallationTask(id: $id) {
220
225
  state
221
226
  errors {
@@ -252,56 +257,12 @@ class InstallationsGraphqlClient {
252
257
  }
253
258
  return true;
254
259
  }
255
- async createCloudIdToHostnameMap(cloudIds) {
256
- const cloudIdToHostname = {};
257
- const query = `
258
- query tenantContexts($cloudIds: [ID!]!) {
259
- tenantContexts(cloudIds: $cloudIds) {
260
- hostName
261
- }
262
- }
263
- `;
264
- const result = await this.graphqlClient.query(query, {
265
- cloudIds
266
- });
267
- const tenantContexts = result.tenantContexts || [];
268
- cloudIds.forEach((cloudId, index) => {
269
- const maybeHostname = tenantToHostname(tenantContexts[index]);
270
- cloudIdToHostname[cloudId] = maybeHostname || cloudId;
271
- });
272
- return cloudIdToHostname;
273
- }
274
260
  async resolveInstallationsHostnames(installations) {
275
- if (!installations.length) {
276
- return [];
277
- }
278
- const installationContexts = installations.map(({ installation }) => {
279
- const context = cs_ari_1.parse(installation.installationContext);
280
- const cloudId = context.resourceId;
281
- if (!cloudId) {
282
- throw new UnknownSiteWithoutCloudIdError();
283
- }
284
- return context;
285
- });
286
- const uniqueCloudIds = [...new Set(installationContexts.map((context) => context.resourceId))];
287
- const cloudIdToHostname = await this.createCloudIdToHostnameMap(uniqueCloudIds);
288
- return installationContexts.map((context, i) => {
289
- const { environment, installation } = installations[i];
290
- const site = cloudIdToHostname[context.resourceId];
291
- return {
292
- id: installation.id,
293
- product: context.resourceOwner,
294
- environmentKey: environment,
295
- site,
296
- version: installation.version || {
297
- isLatest: false
298
- }
299
- };
300
- });
261
+ return [];
301
262
  }
302
263
  async getAllInstallations(appId) {
303
264
  const query = `
304
- query app($id: ID!) {
265
+ query forge_cli_getApplicationInstallations($id: ID!) {
305
266
  app(id: $id) {
306
267
  environments {
307
268
  key
@@ -335,7 +296,7 @@ class InstallationsGraphqlClient {
335
296
  }
336
297
  async getCloudId(site) {
337
298
  const query = `
338
- query tenantContexts($hostNames: [String!]) {
299
+ query forge_cli_getCloudIfForTenantContexts($hostNames: [String!]) {
339
300
  tenantContexts(hostNames: $hostNames) {
340
301
  cloudId
341
302
  }
@@ -347,24 +308,39 @@ class InstallationsGraphqlClient {
347
308
  const tenantContexts = result.tenantContexts || [];
348
309
  return tenantContextsToCloudId(site, tenantContexts);
349
310
  }
350
- async getScopes(appId, environmentKey) {
311
+ async getVersions(appId, environmentKey, firstN = 1) {
351
312
  const query = `
352
- query app($appId: ID!, $environmentKey: String!) {
313
+ query forge_cli_getApplicationEnvironmentLatestVersions($appId: ID!, $environmentKey: String!, $firstN: Int!) {
353
314
  app(id: $appId) {
354
315
  environmentByKey(key: $environmentKey) {
355
- scopes
316
+ versions(first: $firstN) {
317
+ nodes {
318
+ permissions {
319
+ egress {
320
+ addresses
321
+ }
322
+ scopes {
323
+ key
324
+ }
325
+ }
326
+ }
327
+ }
356
328
  }
357
329
  }
358
330
  }
359
331
  `;
360
- const result = await this.graphqlClient.query(query, { appId, environmentKey });
332
+ const result = await this.graphqlClient.query(query, {
333
+ appId,
334
+ environmentKey,
335
+ firstN
336
+ });
361
337
  if (!result.app) {
362
338
  throw new MissingAppError();
363
339
  }
364
340
  if (!result.app.environmentByKey) {
365
341
  throw new EnvironmentNotFoundError();
366
342
  }
367
- return result.app.environmentByKey.scopes;
343
+ return result.app.environmentByKey.versions;
368
344
  }
369
345
  }
370
346
  exports.InstallationsGraphqlClient = InstallationsGraphqlClient;
@@ -9,19 +9,13 @@ export interface TriggerAppSiteInstallDetails {
9
9
  export interface AppInstallSiteDetails extends TriggerAppSiteInstallDetails {
10
10
  appId: string;
11
11
  }
12
- export interface InstallationResult {
13
- installationId: string;
14
- }
15
12
  export interface InstallAppClient {
16
- installAppIntoSite(appInstallDetails: AppInstallSiteDetails): Promise<InstallationResult>;
13
+ installAppIntoSite(appInstallDetails: AppInstallSiteDetails): Promise<void>;
17
14
  }
18
15
  export declare class InstallAppSiteCommand {
19
16
  private readonly getAppConfig;
20
17
  private readonly installAppClient;
21
18
  constructor(getAppConfig: AppConfigProvider, installAppClient: InstallAppClient);
22
- execute({ environmentKey, site, product }: TriggerAppSiteInstallDetails): Promise<{
23
- installationId: string;
24
- appName: string;
25
- }>;
19
+ execute({ environmentKey, site, product }: TriggerAppSiteInstallDetails): Promise<void>;
26
20
  }
27
21
  //# sourceMappingURL=install-app-site.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install-app-site.d.ts","sourceRoot":"","sources":["../../src/installations/install-app-site.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,C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AY,EAAE,iBAAiB,EAAmB,gBAAgB,EAAE,gBAAgB;IAEpG,OAAO,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,4BAA4B;CASrF"}
@@ -7,14 +7,13 @@ class InstallAppSiteCommand {
7
7
  this.installAppClient = installAppClient;
8
8
  }
9
9
  async execute({ environmentKey, site, product }) {
10
- const { id: appId, name: appName } = await this.getAppConfig();
11
- const result = await this.installAppClient.installAppIntoSite({
10
+ const { id: appId } = await this.getAppConfig();
11
+ return await this.installAppClient.installAppIntoSite({
12
12
  appId,
13
13
  environmentKey,
14
14
  site,
15
15
  product
16
16
  });
17
- return Object.assign({ appName }, result);
18
17
  }
19
18
  }
20
19
  exports.InstallAppSiteCommand = InstallAppSiteCommand;
@@ -2,7 +2,6 @@ import { AppConfigProvider } from '@forge/cli-shared';
2
2
  import { AppUninstallationInput } from '@forge/cli-shared';
3
3
  import { Installation } from '../service/installation-service';
4
4
  export interface UninstallAppOutput {
5
- appName: string;
6
5
  product: string;
7
6
  site: string;
8
7
  environmentKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"uninstall-app.d.ts","sourceRoot":"","sources":["../../src/installations/uninstall-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,2BAA4B,SAAQ,sBAAsB;IACzE,KAAK,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,KAAK,EA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AAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,qBAAqB,CAAC,KAAK,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;CACrG;AAED,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAAqB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAxD,YAAY,EAAE,iBAAiB,EAAmB,MAAM,EAAE,kBAAkB;IAE5F,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAY5D,YAAY,CACvB,eAAe,GAAE,MAAM,EAAO,EAC9B,iBAAiB,CAAC,EAAE,YAAY,EAAE,GACjC,OAAO,CAAC,kBAAkB,EAAE,CAAC;CA4BjC"}
@@ -7,11 +7,10 @@ class UninstallAppCommand {
7
7
  this.client = client;
8
8
  }
9
9
  async execute(installationId) {
10
- const { id: appId, name: appName } = await this.getAppConfig();
10
+ const { id: appId } = await this.getAppConfig();
11
11
  const { product, site, environmentKey } = await this.client.getInstallation(appId, installationId);
12
12
  const success = await this.client.uninstallApp({ appId, environmentKey, installationId, async: true });
13
13
  return {
14
- appName,
15
14
  product,
16
15
  site,
17
16
  environmentKey,
@@ -19,7 +18,7 @@ class UninstallAppCommand {
19
18
  };
20
19
  }
21
20
  async batchExecute(installationIds = [], installationInfos) {
22
- const { id: appId, name: appName } = await this.getAppConfig();
21
+ const { id: appId } = await this.getAppConfig();
23
22
  let appsInstallInfo;
24
23
  if (installationInfos && installationInfos.length) {
25
24
  appsInstallInfo = installationInfos;
@@ -34,7 +33,6 @@ class UninstallAppCommand {
34
33
  async: true
35
34
  })));
36
35
  return appsInstallInfo.map(({ product, site, environmentKey }, index) => ({
37
- appName,
38
36
  product,
39
37
  site,
40
38
  environmentKey,
@@ -0,0 +1,8 @@
1
+ import { GraphQLClient } from '@forge/cli-shared';
2
+ import { AppEnvironmentMigrationKeys } from '../service/migration-keys-service';
3
+ export declare class GraphqlClient {
4
+ private readonly graphqlClient;
5
+ constructor(graphqlClient: GraphQLClient);
6
+ getLatestMigrationKeys(appId: string, environmentKey: string): Promise<AppEnvironmentMigrationKeys>;
7
+ }
8
+ //# sourceMappingURL=graphql-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/migration-keys/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+C,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CA+CjH"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphqlClient = void 0;
4
+ const cli_shared_1 = require("@forge/cli-shared");
5
+ class GraphqlClient {
6
+ constructor(graphqlClient) {
7
+ this.graphqlClient = graphqlClient;
8
+ }
9
+ async getLatestMigrationKeys(appId, environmentKey) {
10
+ var _a, _b;
11
+ const query = `
12
+ query forge_cli_getMigrationKeys($id: ID!, $key: String!) {
13
+ app(id: $id) {
14
+ environmentByKey(key: $key) {
15
+ id
16
+ versions(first: 1) {
17
+ edges {
18
+ node {
19
+ isLatest
20
+ migrationKeys {
21
+ jira
22
+ confluence
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ marketplaceApp {
29
+ appKey
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ const result = await this.graphqlClient.query(query, {
35
+ id: appId,
36
+ key: environmentKey
37
+ });
38
+ if (!result.app) {
39
+ throw new cli_shared_1.MissingAppError();
40
+ }
41
+ if (!result.app.environmentByKey) {
42
+ throw new cli_shared_1.MissingAppEnvironmentError();
43
+ }
44
+ const mpacAppKey = (_a = result.app.marketplaceApp) === null || _a === void 0 ? void 0 : _a.appKey;
45
+ const versions = result.app.environmentByKey.versions;
46
+ let migrationKeys;
47
+ for (const edge of (versions === null || versions === void 0 ? void 0 : versions.edges) || []) {
48
+ if (edge) {
49
+ migrationKeys = (_b = edge.node) === null || _b === void 0 ? void 0 : _b.migrationKeys;
50
+ }
51
+ }
52
+ return { migrationKeys, mpacAppKey };
53
+ }
54
+ }
55
+ exports.GraphqlClient = GraphqlClient;
@@ -0,0 +1,19 @@
1
+ import { AppConfigProvider } from '@forge/cli-shared';
2
+ export interface ProviderDetails {
3
+ environment: string;
4
+ providerKey: string;
5
+ clientSecret: string;
6
+ }
7
+ export interface AppProviderDetails extends ProviderDetails {
8
+ appId: string;
9
+ }
10
+ export interface ConfigureProviderClient {
11
+ configureProvider(details: AppProviderDetails): Promise<void>;
12
+ }
13
+ export declare class ConfigureProviderCommand {
14
+ private readonly client;
15
+ private readonly getAppConfig;
16
+ constructor(client: ConfigureProviderClient, getAppConfig: AppConfigProvider);
17
+ execute(details: ProviderDetails): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=configure-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure-provider.d.ts","sourceRoot":"","sources":["../../src/providers/configure-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAED,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAA2B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAA9D,MAAM,EAAE,uBAAuB,EAAmB,YAAY,EAAE,iBAAiB;IAEjG,OAAO,CAAC,OAAO,EAAE,eAAe;CAO9C"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigureProviderCommand = void 0;
4
+ class ConfigureProviderCommand {
5
+ constructor(client, getAppConfig) {
6
+ this.client = client;
7
+ this.getAppConfig = getAppConfig;
8
+ }
9
+ async execute(details) {
10
+ const { id: appId } = await this.getAppConfig();
11
+ await this.client.configureProvider(Object.assign(Object.assign({}, details), { appId }));
12
+ }
13
+ }
14
+ exports.ConfigureProviderCommand = ConfigureProviderCommand;
@@ -0,0 +1,12 @@
1
+ import { GraphQLClient } from '@forge/cli-shared';
2
+ import { AppProviderDetails, ConfigureProviderClient } from './configure-provider';
3
+ export declare class MissingAppError extends Error {
4
+ }
5
+ export declare class MissingAppEnvironmentError extends Error {
6
+ }
7
+ export declare class GraphqlClient implements ConfigureProviderClient {
8
+ private readonly graphqlClient;
9
+ constructor(graphqlClient: GraphQLClient);
10
+ configureProvider(details: AppProviderDetails): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=graphql-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/providers/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAC7C,qBAAa,0BAA2B,SAAQ,KAAK;CAAG;AAExD,qBAAa,aAAc,YAAW,uBAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,iBAAiB,CAAC,OAAO,EAAE,kBAAkB;CA0C3D"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphqlClient = exports.MissingAppEnvironmentError = exports.MissingAppError = void 0;
4
+ const cli_shared_1 = require("@forge/cli-shared");
5
+ class MissingAppError extends Error {
6
+ }
7
+ exports.MissingAppError = MissingAppError;
8
+ class MissingAppEnvironmentError extends Error {
9
+ }
10
+ exports.MissingAppEnvironmentError = MissingAppEnvironmentError;
11
+ class GraphqlClient {
12
+ constructor(graphqlClient) {
13
+ this.graphqlClient = graphqlClient;
14
+ }
15
+ async configureProvider(details) {
16
+ const mutation = `
17
+ mutation forge_cli_setExternalAuthCredentials($input: SetExternalAuthCredentialsInput!) {
18
+ setExternalAuthCredentials(input: $input) {
19
+ success
20
+ errors {
21
+ message
22
+ extensions {
23
+ errorType
24
+ }
25
+ }
26
+ }
27
+ }
28
+ `;
29
+ const { response: { setExternalAuthCredentials: { success, errors } }, requestId } = await this.graphqlClient.mutate(mutation, {
30
+ input: {
31
+ environment: {
32
+ appId: details.appId,
33
+ key: details.environment
34
+ },
35
+ serviceKey: details.providerKey,
36
+ credentials: {
37
+ clientSecret: details.clientSecret
38
+ }
39
+ }
40
+ });
41
+ const error = cli_shared_1.getError(errors);
42
+ if (!success) {
43
+ throw new cli_shared_1.GraphQlMutationError(`${error.message} (requestId: ${requestId || 'unknown'})`, error.code);
44
+ }
45
+ }
46
+ }
47
+ exports.GraphqlClient = GraphqlClient;
@@ -1,25 +1,26 @@
1
1
  /// <reference types="node" />
2
2
  import { AppConfigProvider, AppEnvironment } from '@forge/cli-shared';
3
- import { AppInstallSiteDetails } from '../installations/install-app-site';
4
3
  import { URL } from 'url';
4
+ import { AppInstallSiteDetails } from '../installations/install-app-site';
5
5
  export interface Installation {
6
6
  id: string;
7
7
  product: string;
8
8
  site: string;
9
9
  environmentKey: string;
10
+ context: string;
10
11
  version: {
11
12
  isLatest: boolean;
12
13
  };
13
14
  }
14
15
  export interface AppInstallation {
15
- name: string;
16
16
  installations: Installation[];
17
17
  }
18
- export interface AppUpgradeResult {
19
- installationId: string;
18
+ export interface AppEnvironmentVersionPermissions {
19
+ scopes: string[];
20
+ egressAddresses: string[];
20
21
  }
21
- export interface AlreadyUpgradedResult {
22
- alreadyUpdated: true;
22
+ export interface AppEnvironmentPermissions extends AppEnvironmentVersionPermissions {
23
+ addedScopes: string[];
23
24
  }
24
25
  interface InstallationFilterOptions {
25
26
  site?: string;
@@ -28,10 +29,10 @@ interface InstallationFilterOptions {
28
29
  }
29
30
  export interface ListAppInstallationsClient {
30
31
  listInstallations(appId: string): Promise<Installation[]>;
31
- getScopes(appId: string, environmentKey: string): Promise<AppEnvironment['scopes']>;
32
+ getVersions(appId: string, environmentKey: string, firstN: number): Promise<AppEnvironment['versions']>;
32
33
  }
33
34
  export interface UpgradeAppInstallationsClient {
34
- upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<AppUpgradeResult>;
35
+ upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<void>;
35
36
  }
36
37
  export declare class InstallationService {
37
38
  private readonly getAppConfig;
@@ -40,10 +41,11 @@ export declare class InstallationService {
40
41
  constructor(getAppConfig: AppConfigProvider, listInstallationsClient: ListAppInstallationsClient, upgradeAppInstallationsClient: UpgradeAppInstallationsClient);
41
42
  private filterInstallations;
42
43
  listAppInstallations(filter?: InstallationFilterOptions): Promise<AppInstallation>;
43
- listNonIdentityAppInstallations(filter?: InstallationFilterOptions): Promise<AppInstallation>;
44
+ listNonTechnicalAppInstallations(filter?: InstallationFilterOptions): Promise<AppInstallation>;
44
45
  hasOutdatedProductInstallation(environment: string): Promise<boolean>;
45
- upgradeInstallation(site: URL, product: string, environmentKey: string, appId: string): Promise<AppUpgradeResult | AlreadyUpgradedResult>;
46
- getScopes(appId: string, environmentKey: string): Promise<string[] | null | undefined>;
46
+ upgradeInstallation(site: URL, product: string, environmentKey: string, appId: string): Promise<boolean>;
47
+ private getPermissionsFromAppEnvironmentVersion;
48
+ getAppEnvironmentPermissions(appId: string, environmentKey: string): Promise<AppEnvironmentPermissions | undefined>;
47
49
  }
48
50
  export {};
49
51
  //# sourceMappingURL=installation-service.d.ts.map