@smplkit/sdk 1.3.15 → 1.3.17

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/index.cjs CHANGED
@@ -255,13 +255,18 @@ var Config = class {
255
255
  }
256
256
  /**
257
257
  * Walk the parent chain and return config data objects, child-to-root.
258
+ *
259
+ * @param configs - Optional pre-fetched list of configs to look up parents
260
+ * by ID, avoiding extra network calls and the key-vs-UUID mismatch with
261
+ * {@link ConfigClient.get}.
258
262
  * @internal
259
263
  */
260
- async _buildChain() {
264
+ async _buildChain(configs) {
261
265
  const chain = [{ id: this.id ?? "", items: this.items, environments: this.environments }];
266
+ const configsById = new Map(configs?.map((c) => [c.id, c]) ?? []);
262
267
  let parentId = this.parent;
263
268
  while (parentId !== null) {
264
- const parentConfig = await this._client._getById(parentId);
269
+ const parentConfig = configsById.get(parentId) ?? await this._client._getById(parentId);
265
270
  chain.push({
266
271
  id: parentConfig.id ?? "",
267
272
  items: parentConfig.items,
@@ -692,7 +697,7 @@ var ConfigClient = class {
692
697
  const configs = await this.list();
693
698
  const newCache = {};
694
699
  for (const cfg of configs) {
695
- const chain = await cfg._buildChain();
700
+ const chain = await cfg._buildChain(configs);
696
701
  newCache[cfg.key] = resolveChain(chain, environment);
697
702
  }
698
703
  const oldCache = this._configCache;
@@ -712,7 +717,7 @@ var ConfigClient = class {
712
717
  const configs = await this.list();
713
718
  const cache = {};
714
719
  for (const cfg of configs) {
715
- const chain = await cfg._buildChain();
720
+ const chain = await cfg._buildChain(configs);
716
721
  cache[cfg.key] = resolveChain(chain, environment);
717
722
  }
718
723
  this._configCache = cache;
@@ -728,7 +733,7 @@ var ConfigClient = class {
728
733
  const configs = await this.list();
729
734
  const cache = {};
730
735
  for (const cfg of configs) {
731
- const chain = await cfg._buildChain();
736
+ const chain = await cfg._buildChain(configs);
732
737
  cache[cfg.key] = resolveChain(chain, environment);
733
738
  }
734
739
  this._configCache = cache;