thinkwork-cli 0.12.9 → 0.12.11

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.
@@ -5,7 +5,7 @@ import {
5
5
  readTfVar,
6
6
  resolveApiConfig,
7
7
  resolveTfvarsPath
8
- } from "./chunk-34NMB5AK.js";
8
+ } from "./chunk-JEHV35EU.js";
9
9
  export {
10
10
  apiFetch,
11
11
  apiFetchRaw,
@@ -43,6 +43,11 @@ function saveEnterpriseDeployment(config) {
43
43
  JSON.stringify(config, null, 2) + "\n"
44
44
  );
45
45
  }
46
+ function loadEnterpriseDeployment(customerSlug) {
47
+ const configPath = join(ENTERPRISE_DEPLOYMENTS_DIR, `${customerSlug}.json`);
48
+ if (!existsSync(configPath)) return null;
49
+ return JSON.parse(readFileSync(configPath, "utf-8"));
50
+ }
46
51
  function loadEnvironment(stage) {
47
52
  const configPath = join(ENVIRONMENTS_DIR, stage, "config.json");
48
53
  if (!existsSync(configPath)) return null;
@@ -176,6 +181,30 @@ function getApiEndpoint(stage, region) {
176
181
  );
177
182
  return raw && raw !== "None" ? raw : null;
178
183
  }
184
+ function discoverThinkworkStageUrls(stage, region) {
185
+ const urls = {};
186
+ const apiEndpoint = getApiEndpoint(stage, region);
187
+ if (apiEndpoint) urls.apiEndpoint = apiEndpoint;
188
+ const appSyncUrl = runAws(
189
+ `appsync list-graphql-apis --region ${region} --query "graphqlApis[?name=='thinkwork-${stage}-subscriptions'].uris.GRAPHQL|[0]" --output text`
190
+ );
191
+ if (appSyncUrl && appSyncUrl !== "None") urls.appSyncUrl = appSyncUrl;
192
+ const distributions = runAws(
193
+ `cloudfront list-distributions --query "DistributionList.Items[?contains(Origins.Items[0].DomainName, 'thinkwork-${stage}-')].{Origin:Origins.Items[0].DomainName,Domain:DomainName}" --output json`
194
+ );
195
+ if (distributions) {
196
+ const parsed = JSON.parse(distributions);
197
+ for (const distribution of parsed) {
198
+ if (distribution.Origin.includes(`thinkwork-${stage}-admin`)) {
199
+ urls.adminUrl = `https://${distribution.Domain}`;
200
+ }
201
+ if (distribution.Origin.includes(`thinkwork-${stage}-docs`)) {
202
+ urls.docsUrl = `https://${distribution.Domain}`;
203
+ }
204
+ }
205
+ }
206
+ return urls;
207
+ }
179
208
  function getApiAuthSecretFromLambda(stage, region) {
180
209
  const raw = runAws(
181
210
  `lambda get-function-configuration --function-name thinkwork-${stage}-api-tenants --region ${region} --query "Environment.Variables.API_AUTH_SECRET" --output text`
@@ -345,8 +374,10 @@ export {
345
374
  printSummary,
346
375
  listDeployedStages,
347
376
  getApiEndpoint,
377
+ discoverThinkworkStageUrls,
348
378
  saveEnvironment,
349
379
  saveEnterpriseDeployment,
380
+ loadEnterpriseDeployment,
350
381
  loadEnvironment,
351
382
  listEnvironments,
352
383
  resolveTerraformDir,