@runeya/runeya 2.0.6 → 2.0.8

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.
@@ -778,6 +778,33 @@ var EnvironmentResolver = class {
778
778
  }
779
779
  return { ctx, secretKeys: parentSecretKeys, keySources: parentKeySources };
780
780
  }
781
+ /**
782
+ * For service-scoped envs, compute effective parentIds by also including
783
+ * the service-scoped envs of ancestor global environments.
784
+ *
785
+ * Example: "Server (test)" has parentIds=[test-global]. test-global has
786
+ * parentIds=[Local-global]. This method adds "Server (Local)" to the
787
+ * effective parents so service-specific variables from ancestor envs
788
+ * are inherited correctly.
789
+ */
790
+ async getEffectiveParentIds(environment) {
791
+ if (environment.scope !== "service" || !environment.reference || !environment.activateOn) {
792
+ return environment.parentIds;
793
+ }
794
+ const additionalIds = [];
795
+ for (const parentId of environment.parentIds) {
796
+ const parentEnv = await environmentStore.get(parentId);
797
+ if (!parentEnv || parentEnv.scope !== "global") continue;
798
+ for (const grandparentGlobalId of parentEnv.parentIds) {
799
+ const ancestorServiceEnv = await environmentStore.findServiceEnvironment(environment.reference, grandparentGlobalId);
800
+ if (ancestorServiceEnv && !environment.parentIds.includes(ancestorServiceEnv.id)) {
801
+ additionalIds.push(ancestorServiceEnv.id);
802
+ }
803
+ }
804
+ }
805
+ if (additionalIds.length === 0) return environment.parentIds;
806
+ return [...environment.parentIds, ...additionalIds];
807
+ }
781
808
  async resolveDag(environmentId, visited) {
782
809
  if (visited.has(environmentId)) {
783
810
  throw new Error(`Circular dependency detected in environment inheritance for ${environmentId}`);
@@ -787,8 +814,9 @@ var EnvironmentResolver = class {
787
814
  throw new Error(`Environment "${environmentId}" not found`);
788
815
  }
789
816
  visited.add(environmentId);
817
+ const effectiveParentIds = await this.getEffectiveParentIds(environment);
790
818
  const parentResults = [];
791
- for (const parentId of environment.parentIds) {
819
+ for (const parentId of effectiveParentIds) {
792
820
  const parentVisited = new Set(visited);
793
821
  const parentResult = await this.resolveDag(parentId, parentVisited);
794
822
  parentResults.push(parentResult);
@@ -821,9 +849,12 @@ var EnvironmentResolver = class {
821
849
  parentKeySources[variable.key] = { environmentId: source.environmentId, environmentName: source.environmentName };
822
850
  }
823
851
  }
852
+ const isInterpRef = (v) => /\{\{environment\.[^}]+\}\}/.test(v);
824
853
  for (const result of parentResults) {
825
854
  for (const [key, value] of Object.entries(result.parentEnv)) {
826
- if (!(key in parentEnv)) {
855
+ const existingIsRef = key in parentEnv && isInterpRef(parentEnv[key]);
856
+ const newIsConcrete = !isInterpRef(value);
857
+ if (!(key in parentEnv) || existingIsRef && newIsConcrete) {
827
858
  parentEnv[key] = value;
828
859
  }
829
860
  }
@@ -2041,13 +2072,20 @@ var environmentRouter = router({
2041
2072
  for (const serviceId of project.serviceIds) {
2042
2073
  const service = await serviceStore.get(serviceId);
2043
2074
  if (!service) continue;
2075
+ const parentServiceEnvIds = [];
2076
+ for (const parentGlobalId of env2.parentIds) {
2077
+ const parentServiceEnv = await environmentStore.findServiceEnvironment(serviceId, parentGlobalId);
2078
+ if (parentServiceEnv) {
2079
+ parentServiceEnvIds.push(parentServiceEnv.id);
2080
+ }
2081
+ }
2044
2082
  const svcEnv = await environmentStore.create({
2045
2083
  projectId: input.projectId,
2046
2084
  name: `${service.name} (${env2.name})`,
2047
2085
  scope: "service",
2048
2086
  reference: serviceId,
2049
2087
  activateOn: env2.id,
2050
- parentIds: [env2.id],
2088
+ parentIds: [env2.id, ...parentServiceEnvIds],
2051
2089
  variables: {}
2052
2090
  });
2053
2091
  await projectStore.addEnvironment(input.projectId, svcEnv.id);
@@ -10958,7 +10996,7 @@ async function pullEnv(opts) {
10958
10996
  });
10959
10997
  return Object.entries(env2).map(([key, value]) => `${key}=${value}`).join("\n");
10960
10998
  }
10961
- dotenv.config();
10999
+ dotenv.config({ quiet: true });
10962
11000
  function listenWithRetry(server, port, host, wss, maxRetries = 20, delay = 500) {
10963
11001
  return new Promise((resolve5, reject) => {
10964
11002
  let attempts = 0;
@@ -11028,4 +11066,4 @@ export {
11028
11066
  createLocalServer,
11029
11067
  pullEnv
11030
11068
  };
11031
- //# sourceMappingURL=dist-RZD3EUA3.js.map
11069
+ //# sourceMappingURL=dist-PSPHMTZN.js.map