@runeya/runeya 2.0.6 → 2.0.7

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);
@@ -2041,13 +2069,20 @@ var environmentRouter = router({
2041
2069
  for (const serviceId of project.serviceIds) {
2042
2070
  const service = await serviceStore.get(serviceId);
2043
2071
  if (!service) continue;
2072
+ const parentServiceEnvIds = [];
2073
+ for (const parentGlobalId of env2.parentIds) {
2074
+ const parentServiceEnv = await environmentStore.findServiceEnvironment(serviceId, parentGlobalId);
2075
+ if (parentServiceEnv) {
2076
+ parentServiceEnvIds.push(parentServiceEnv.id);
2077
+ }
2078
+ }
2044
2079
  const svcEnv = await environmentStore.create({
2045
2080
  projectId: input.projectId,
2046
2081
  name: `${service.name} (${env2.name})`,
2047
2082
  scope: "service",
2048
2083
  reference: serviceId,
2049
2084
  activateOn: env2.id,
2050
- parentIds: [env2.id],
2085
+ parentIds: [env2.id, ...parentServiceEnvIds],
2051
2086
  variables: {}
2052
2087
  });
2053
2088
  await projectStore.addEnvironment(input.projectId, svcEnv.id);
@@ -11028,4 +11063,4 @@ export {
11028
11063
  createLocalServer,
11029
11064
  pullEnv
11030
11065
  };
11031
- //# sourceMappingURL=dist-RZD3EUA3.js.map
11066
+ //# sourceMappingURL=dist-TZCPKLE5.js.map