@safetech/inheriti-cli 0.0.28 → 0.0.29

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/dist/main.js CHANGED
@@ -78763,12 +78763,12 @@ function createAutomationSetupOperations(options) {
78763
78763
  const connections = `${base}/automation-connections`;
78764
78764
  const grants = (planId) => `${base}/plans/${encodeURIComponent(planId)}/automation-grants`;
78765
78765
  const transport = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
78766
- const plansPort = new He4(options.apiUrl, "TEST", async () => await options.getBearerToken() ?? null, transport);
78766
+ const plansPort = new He4(options.apiUrl, options.environment, async () => await options.getBearerToken() ?? null, transport);
78767
78767
  const request = async (url2, method = "GET", body) => {
78768
78768
  const token = await options.getBearerToken();
78769
78769
  if (!token)
78770
78770
  throw new Error("Authentication required");
78771
- const response = await transport(url2, { method, headers: { Authorization: `Bearer ${token}`, "x-organization-id": options.organizationId, "x-elements-environment": "TEST", ...body ? { "Content-Type": "application/json" } : {} }, ...body ? { body: JSON.stringify(body) } : {} });
78771
+ const response = await transport(url2, { method, headers: { Authorization: `Bearer ${token}`, "x-organization-id": options.organizationId, "x-elements-environment": options.environment, ...body ? { "Content-Type": "application/json" } : {} }, ...body ? { body: JSON.stringify(body) } : {} });
78772
78772
  if (!response.ok) {
78773
78773
  const grantAction = method === "POST" && /\/automation-grants(?:\/[^/]+\/activate)?$/u.test(url2);
78774
78774
  const detail = response.status === 400 && grantAction ? await response.json().catch(() => void 0) : void 0;
@@ -126694,7 +126694,7 @@ function createAutomationStatusReader(options) {
126694
126694
  url2.searchParams.set("connectionId", connectionId);
126695
126695
  if (jobId)
126696
126696
  url2.searchParams.set("jobId", jobId);
126697
- const response = await transport(url2, { headers: { Authorization: `Bearer ${token}`, "x-organization-id": options.organizationId, "x-elements-environment": "TEST" }, ...signal ? { signal } : {} });
126697
+ const response = await transport(url2, { headers: { Authorization: `Bearer ${token}`, "x-organization-id": options.organizationId, "x-elements-environment": options.environment }, ...signal ? { signal } : {} });
126698
126698
  if (!response.ok)
126699
126699
  throw new Error(response.status === 401 ? "automation_status_authentication_required" : response.status === 403 || response.status === 404 ? "automation_status_permission_denied" : "automation_status_request_failed");
126700
126700
  const body = await response.json().catch(() => void 0);
@@ -177093,6 +177093,7 @@ async function automationManage(context, configuration, terminal, signal, argv)
177093
177093
  const operations = createAutomationSetupOperations({
177094
177094
  apiUrl: configuration.apiUrl,
177095
177095
  organizationId: context.organization.id,
177096
+ environment: configuration.environment,
177096
177097
  getBearerToken: () => context.core.getAccessToken()
177097
177098
  });
177098
177099
  if (pair) {
@@ -177377,6 +177378,7 @@ async function automationMetadata(context, configuration, terminal, planId, all
177377
177378
  const operations = createAutomationSetupOperations({
177378
177379
  apiUrl: configuration.apiUrl,
177379
177380
  organizationId: context.organization.id,
177381
+ environment: configuration.environment,
177380
177382
  getBearerToken: () => context.core.getAccessToken()
177381
177383
  });
177382
177384
  if (planId) {
@@ -177955,6 +177957,7 @@ async function githubAutomationSetup(context, configuration, terminal, argv, dep
177955
177957
  const operations = dependencies.operations ?? createAutomationSetupOperations({
177956
177958
  apiUrl: configuration.apiUrl,
177957
177959
  organizationId: context.organization.id,
177960
+ environment: configuration.environment,
177958
177961
  getBearerToken: () => context.core.getAccessToken()
177959
177962
  });
177960
177963
  try {
@@ -177969,10 +177972,10 @@ async function githubAutomationSetup(context, configuration, terminal, argv, dep
177969
177972
  if (!field2) throw new Error("Plan field required.");
177970
177973
  if (!resolveAutomationFieldMappings(selectedPlan.assets, { onlyFields: [field2], mappings: [] }).length)
177971
177974
  throw new Error("Selected field is not available in the plan.");
177972
- const connectionId = options.connection ?? await select("Which GitHub connection?", operationalConnections(await operations.listConnections()).filter((item) => item.provider === "GITHUB" && ["PENDING_VERIFICATION", "VERIFIED"].includes(item.status)).map((item) => ({ value: item.id, description: connectionChoice(item).name })));
177975
+ const connectionId = options.connection ?? await select("Which GitHub connection?", operationalConnections(await operations.listConnections()).filter((item) => item.provider === "GITHUB" && item.environment === configuration.environment && ["PENDING_VERIFICATION", "VERIFIED"].includes(item.status)).map((item) => ({ value: item.id, description: connectionChoice(item).name })));
177973
177976
  if (!connectionId) throw new Error("GitHub connection required.");
177974
177977
  const selected = await operations.getConnection(connectionId);
177975
- if (selected.provider !== "GITHUB" || selected.environment !== "TEST" || selected.trust.method !== "GITHUB_ACTIONS_OIDC" || !["PENDING_VERIFICATION", "VERIFIED"].includes(selected.status))
177978
+ if (selected.provider !== "GITHUB" || selected.environment !== configuration.environment || selected.trust.method !== "GITHUB_ACTIONS_OIDC" || !["PENDING_VERIFICATION", "VERIFIED"].includes(selected.status))
177976
177979
  throw new Error("Selected GitHub connection is not pending or verified.");
177977
177980
  const { repository: repositoryName, path: path9, branch } = githubAutomationWorkflowLocation(selected.trust.repositoryName, selected.trust.workflow);
177978
177981
  const environment = selected.trust.environment;
@@ -178127,6 +178130,7 @@ async function githubAutomationCreate(context, configuration, terminal, argv, de
178127
178130
  const operations = dependencies.operations ?? createAutomationSetupOperations({
178128
178131
  apiUrl: configuration.apiUrl,
178129
178132
  organizationId: context.organization.id,
178133
+ environment: configuration.environment,
178130
178134
  getBearerToken: () => context.core.getAccessToken()
178131
178135
  });
178132
178136
  try {
@@ -178153,21 +178157,21 @@ async function githubAutomationCreate(context, configuration, terminal, argv, de
178153
178157
  environment,
178154
178158
  workflow: `${name2}/.github/workflows/${filename}@refs/heads/${branch}`
178155
178159
  };
178156
- const matches = (await operations.listConnections()).filter((item) => item.provider === "GITHUB" && item.environment === "TEST" && item.trust.method === "GITHUB_ACTIONS_OIDC" && item.trust.repositoryName === name2 && item.trust.environment === environment && item.trust.workflow === trust.workflow);
178160
+ const matches = (await operations.listConnections()).filter((item) => item.provider === "GITHUB" && item.environment === configuration.environment && item.trust.method === "GITHUB_ACTIONS_OIDC" && item.trust.repositoryName === name2 && item.trust.environment === environment && item.trust.workflow === trust.workflow);
178157
178161
  const active = matches.filter((item) => ["PENDING_VERIFICATION", "VERIFIED"].includes(item.status));
178158
178162
  if (active.length > 1) throw new Error("Multiple active matching GitHub connections; select one explicitly for setup.");
178159
178163
  const disabledIds = matches.filter((item) => !active.includes(item)).map((item) => item.id).sort();
178160
178164
  const id2 = active[0]?.id ?? connectionIdFor(
178161
178165
  configuration.apiUrl,
178162
178166
  context.organization.id,
178163
- disabledIds.length ? { trust, disabledIds } : trust
178167
+ { trust, environment: configuration.environment, ...disabledIds.length ? { disabledIds } : {} }
178164
178168
  );
178165
178169
  if (!active.length) {
178166
178170
  try {
178167
- await operations.createConnection({ id: id2, name: `${name2} Inheriti`, provider: "GITHUB", environment: "TEST", trust });
178171
+ await operations.createConnection({ id: id2, name: `${name2} Inheriti`, provider: "GITHUB", environment: configuration.environment, trust });
178168
178172
  } catch (error2) {
178169
178173
  const current = await operations.getConnection(id2).catch(() => void 0);
178170
- if (!current || current.provider !== "GITHUB" || current.environment !== "TEST" || current.trust.method !== "GITHUB_ACTIONS_OIDC" || current.trust.repositoryName !== name2 || current.trust.environment !== environment || current.trust.workflow !== trust.workflow || !["PENDING_VERIFICATION", "VERIFIED"].includes(current.status)) throw error2;
178174
+ if (!current || current.provider !== "GITHUB" || current.environment !== configuration.environment || current.trust.method !== "GITHUB_ACTIONS_OIDC" || current.trust.repositoryName !== name2 || current.trust.environment !== environment || current.trust.workflow !== trust.workflow || !["PENDING_VERIFICATION", "VERIFIED"].includes(current.status)) throw error2;
178171
178175
  }
178172
178176
  }
178173
178177
  terminal.write(`${active.length ? "Reused" : "Created"} GitHub connection ${id2} for ${trust.workflow} (environment ${environment}). Use --connection ${id2} for setup.`);
@@ -178300,6 +178304,7 @@ async function automationSetup(context, configuration, terminal, argv) {
178300
178304
  const operations = createAutomationSetupOperations({
178301
178305
  apiUrl: configuration.apiUrl,
178302
178306
  organizationId: context.organization.id,
178307
+ environment: configuration.environment,
178303
178308
  getBearerToken: () => context.core.getAccessToken()
178304
178309
  });
178305
178310
  const grants = await operations.listGrants(options["--plan"]);
@@ -178610,7 +178615,7 @@ async function automationStatus(context, configuration, terminal, argv, signal)
178610
178615
  terminal.writeError("Sign in before checking automation status.");
178611
178616
  return 1;
178612
178617
  }
178613
- const operations = createAutomationSetupOperations({ apiUrl: configuration.apiUrl, organizationId: context.organization.id, getBearerToken: () => context.core.getAccessToken() });
178618
+ const operations = createAutomationSetupOperations({ apiUrl: configuration.apiUrl, organizationId: context.organization.id, environment: configuration.environment, getBearerToken: () => context.core.getAccessToken() });
178614
178619
  const planId = options["--plan"] ?? (terminal.interactive ? await promptSelect("Plan", (await operations.listPlans()).map((item) => ({ value: item.id, description: item.name ?? item.title ?? item.id })), signal) : void 0);
178615
178620
  if (!planId) {
178616
178621
  terminal.writeError("A plan is required. Use --plan ID.");
@@ -178621,7 +178626,7 @@ async function automationStatus(context, configuration, terminal, argv, signal)
178621
178626
  terminal.writeError("A connection is required. Use --connection ID.");
178622
178627
  return 1;
178623
178628
  }
178624
- const read4 = createAutomationStatusReader({ apiUrl: configuration.apiUrl, organizationId: context.organization.id, getBearerToken: () => context.core.getAccessToken() });
178629
+ const read4 = createAutomationStatusReader({ apiUrl: configuration.apiUrl, organizationId: context.organization.id, environment: configuration.environment, getBearerToken: () => context.core.getAccessToken() });
178625
178630
  do {
178626
178631
  let snapshot;
178627
178632
  try {
@@ -178668,6 +178673,7 @@ async function pairAwsAutomationService(context, configuration, terminal, argv,
178668
178673
  const operations = createAutomationSetupOperations({
178669
178674
  apiUrl: configuration.apiUrl,
178670
178675
  organizationId: context.organization.id,
178676
+ environment: configuration.environment,
178671
178677
  getBearerToken: () => context.core.getAccessToken()
178672
178678
  });
178673
178679
  const connection = await operations.getConnection(options["--connection"]);
@@ -178803,6 +178809,7 @@ async function pairEc2AutomationInstance(context, configuration, terminal, argv,
178803
178809
  const operations = createAutomationSetupOperations({
178804
178810
  apiUrl: configuration.apiUrl,
178805
178811
  organizationId: context.organization.id,
178812
+ environment: configuration.environment,
178806
178813
  getBearerToken: () => context.core.getAccessToken()
178807
178814
  });
178808
178815
  const connection = await operations.getConnection(options["--connection"]);
@@ -178866,6 +178873,7 @@ async function pairGoogleAutomationWorkload(context, configuration, terminal, ar
178866
178873
  const operations = createAutomationSetupOperations({
178867
178874
  apiUrl: configuration.apiUrl,
178868
178875
  organizationId: context.organization.id,
178876
+ environment: configuration.environment,
178869
178877
  getBearerToken: () => context.core.getAccessToken()
178870
178878
  });
178871
178879
  const connection = await operations.getConnection(options["--connection"]);